Post Reply 
RPN scientific calculator firmware for $13 calculator kit
10-22-2019, 09:33 AM
Post: #21
RE: RPN scientific calculator firmware for $13 calculator kit
(10-21-2019 04:43 AM)jklsadf Wrote:  The only thing I can think of that could cause LCD issues is either a connection issue or a low battery.

You nailed it! The problem was a low battery. That's the last time I buy a Sosumi (So Sue Me?) product. Smile

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-22-2019, 09:40 AM
Post: #22
RE: RPN scientific calculator firmware for $13 calculator kit
(10-22-2019 05:46 AM)jklsadf Wrote:  
(10-22-2019 04:59 AM)toml_12953 Wrote:  I'm trying to compile the new firmware with STO, RCL, etc. I use 64-bit Ubuntu with 8GB RAM. When I type make, I get this:

?ASlink-Error-Insufficient ROM/EPROM/FLASH memory.
make: *** [Makefile:19: main] Error 1

What version of Ubuntu/SDCC are you using to build? On Ubuntu 18.04LTS with SDCC 3.5.0 doing "make clean" and then "make" gives a binary 12,212 bytes in size, which is a bit tight (but still 1K free). I think newer versions of SDCC might be less efficient at code generation. If you do want to build it, SDCC has few dependencies, so I think it is possible to install older versions of the package. Other compilers (e.g. Keil) are probably even more efficient, but I don't have a license for the 8051, and also it's not free.

I'm using Ubuntu 19.10 with SDCC 3.8.0. Code size is 13312.

I'll look for an older SDCC. I wonder why it's getting less efficient!

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-22-2019, 11:04 AM (This post was last modified: 10-22-2019 11:05 AM by toml_12953.)
Post: #23
RE: RPN scientific calculator firmware for $13 calculator kit
(10-22-2019 05:46 AM)jklsadf Wrote:  What version of Ubuntu/SDCC are you using to build? On Ubuntu 18.04LTS with SDCC 3.5.0 doing "make clean" and then "make" gives a binary 12,212 bytes in size, which is a bit tight (but still 1K free). I think newer versions of SDCC might be less efficient at code generation. If you do want to build it, SDCC has few dependencies, so I think it is possible to install older versions of the package. Other compilers (e.g. Keil) are probably even more efficient, but I don't have a license for the 8051, and also it's not free.

I found sdcc 3.5.0 and now make works but I get the following:

PHP Code:
Name                 Start    End      Size     Max     
   
---------------- -------- -------- -------- --------
   
ROM/EPROM/FLASH  0x0000   0x2fb7   12216    13312 

I guess you won't have room for any trigonometric functions like sine, cosine, etc., eh?

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-22-2019, 11:59 AM
Post: #24
RE: RPN scientific calculator firmware for $13 calculator kit
Success! I was able to compile v1.07 and upload it to the calculator. Now that I have all the software in place, future updates will be easier!

One user suggested the universal symbol for roll down (Rv) rather than the loop you have above the 4 now. I'm going to make a similar change to my personal template but with a down arrow instead of the "v". I'd suggest you use that as well but I won't update my public template unless you say OK.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-22-2019, 04:03 PM (This post was last modified: 10-22-2019 04:07 PM by jklsadf.)
Post: #25
RE: RPN scientific calculator firmware for $13 calculator kit
SDCC is indeed getting less efficient for the 8051, since it's no longer the focus of development. See for example this thread: https://sourceforge.net/p/sdcc/discussio...589cc8d57/

It is kind of sad, since I think SDCC was originally written for the 8051, but to be fair the 8051 is a pretty horrible architecture for programming in anything but assembly (in my opinion). The architectures Philipp says the situation is even worse for (the ds390, pic14, and pic16) are similarly fairly horrible for programming in anything but assembly (again in my opinion), so it's no surprise the compiler developers have moved on to "greener pastures".

I think fitting the CORDIC trig functions from the HP 35 is probably not easily doable with SDCC 3.5.0, without first freeing up space some other way. I was thinking of using some of Valentin Albillo's algorithms for the trig functions: http://www.hpcc.org/datafile/hp12/12c_Tr...ctions.pdf

Those functions use the taylor series expansion after range reduction/various trig identities, and the series expansion is fairly repetitive/should be less code space. The downside is it's probably slower.

Feel free to change the roll-down symbol on the template. It's one of the symbols from Elektronika calculators I personally like (the other being an up arrow for Enter). After you get used to it, it's a pretty good representation of what the stack does, although maybe a bit sacrilegious on an HP calculator forum. Rv is definitely more standard on HP calculators.
Find all posts by this user
Quote this message in a reply
10-22-2019, 08:42 PM (This post was last modified: 10-22-2019 08:44 PM by toml_12953.)
Post: #26
RE: RPN scientific calculator firmware for $13 calculator kit
OK, now I KNOW the HP 42S doesn't do this!

Press 8
Press Enter
Press 3
Press +
Display shows
0
11
Press Shift CLx
Display shows
0
0
Press -
Display shows
0
-11

Huh?
The HP 42S shows 0 as it should. The X and Y registers should have 0 in them after the CLx and 0 - 0 = 0 (AFAIK)

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-22-2019, 10:56 PM (This post was last modified: 10-23-2019 12:20 AM by jklsadf.)
Post: #27
RE: RPN scientific calculator firmware for $13 calculator kit
That is indeed a bug. ClearX only clears the number entry, but doesn't actually clear the X register (which is separate from digit entry to make processing digit entry easier). I think it should be just a one line fix, but need to test a little.

EDIT: just released a new bugfix version 1.08
Find all posts by this user
Quote this message in a reply
10-23-2019, 01:47 PM
Post: #28
RE: RPN scientific calculator firmware for $13 calculator kit
Is there a way to enter an exponent during number entry? I'd like to be able to enter scientific notation numbers. The only way I see to do it now is this

Example: Enter 1.67e14

1.67
Enter
14
Shift 6 (10^x)
*

That wouldn't be too bad if the base 10 antilog returned integers when given an integer argument but it doesn't always (as in the example above)

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-23-2019, 03:59 PM
Post: #29
RE: RPN scientific calculator firmware for $13 calculator kit
Yes, the . key also serves as the enter exponent key. The first press enters a decimal point, the second press begins exponent entry, and the third press negates the exponent. This is copied from old Sinclair scientific calculators (which also had a limited number of keys).
Find all posts by this user
Quote this message in a reply
10-28-2019, 10:50 AM
Post: #30
RE: RPN scientific calculator firmware for $13 calculator kit
I was trying to reflash one of my chips and got an error partway through. Now I can't power cycle the calculator to reflash it properly. Is there any hope for the chip? If so, how can I get the flash process to continue? It's not a big deal since $12.00 or so for a whole new kit isn't a big strain on my budget but still if there's a way to save the chip, I'd like to know how.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-28-2019, 07:35 PM (This post was last modified: 10-28-2019 07:38 PM by jklsadf.)
Post: #31
RE: RPN scientific calculator firmware for $13 calculator kit
These chips are very hard to completely "brick" since the bootloader is permanently burned into ROM, and isn't overwritable as far as I know. Even with no code loaded (or corrupted code loaded) you should be able to start the stcgal programmer software, turn off the calculator by removing the batteries, and then turn on the calculator by reinserting the batteries and pressing the ON button.

The stcgal programmer software continuously sends a special sequence of bytes. On poweron, the STC microcontroller runs the bootloader code (before any other code) to check for this sync sequence, and enters programming mode if found. This should all work even with no code loaded (or corrupted code loaded), since the bootloader is permanently burned into ROM.
Find all posts by this user
Quote this message in a reply
10-28-2019, 07:44 PM (This post was last modified: 10-28-2019 07:54 PM by jklsadf.)
Post: #32
RE: RPN scientific calculator firmware for $13 calculator kit
You might be able to turn off the calculator without removing the battery (or whatever power supply you're using) by shorting the base of Q2 to ground (short the middle pin of Q2 to the left pin of Q2), which should turn off the soft-latching power switch.

Then press the On button to turn on again.
Find all posts by this user
Quote this message in a reply
10-28-2019, 08:17 PM
Post: #33
RE: RPN scientific calculator firmware for $13 calculator kit
One last thing I just thought of...in order to fully turn off the calculator so that it can be turned on again to run the bootloader, it might be necessary to prevent the microcontroller from being parasitically powered through the serial port pins if you have the USB-to-serial adapter connected..

The easiest way to do that is to unplug the USB-to-serial adapter from your computer while turning off the calculator.

For a more permanent setup, you can add a diode/resistor as shown on page 12 in the datasheet (note the pinout of the microcontroller shown is different, but the basic idea is the same: the diode prevents the calculator from being parasitically powered, and I think the 300ohm resistor is just for isolation). The diode used is unimportant, just about any diode will work. The stcgal FAQ has other possible ideas for how to prevent parasitic powering, but the datasheet method works well.
Find all posts by this user
Quote this message in a reply
10-29-2019, 12:05 PM
Post: #34
RE: RPN scientific calculator firmware for $13 calculator kit
(10-28-2019 08:17 PM)jklsadf Wrote:  One last thing I just thought of...in order to fully turn off the calculator so that it can be turned on again to run the bootloader, it might be necessary to prevent the microcontroller from being parasitically powered through the serial port pins if you have the USB-to-serial adapter connected..

The easiest way to do that is to unplug the USB-to-serial adapter from your computer while turning off the calculator.

That was my problem! I had removed the batteries but the USB serial converter was plugged in. When I removed it from the computer and plugged it back in, the download executed. Now I have two RPN calculators and I'll have to buy a third DIY to have one in original shape unless I can get the hex file for the resistor color code calculator.

Thanks for the help. I've uploaded a revised key layout to Dropbox. It has slightly darker numeric keys and the trig functions are on keys 1, 2, 3 and the arc function is on the minus key. I followed your idea for them.

DIY Keyboard Template

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-30-2019, 02:01 AM
Post: #35
RE: RPN scientific calculator firmware for $13 calculator kit
Glad it worked out for you!

I did print out your template in color a while back, and have been meaning to solder up a second kit with better components (FSTN LCD, Omron tactile switches, and shorter screws into 12mm standoffs instead of the super long screw and nut provided). Someday...also the trig functions when I have time. (The log/exponential functions were a lot more motivating, because with those gave calculating arbitrary powers. Trigs I rarely use, and there's usually at least 3 calculators and sometimes a slide rule on my desk with trigs on the rare occasion I do need them.)

I'd be surprised if you could get the original hex file, since it's not on the website, although luckily they at least included the full schematic. There do seem to be multiple sellers on eBay, so maybe the hex file is out there somewhere. They might all be the same seller though, or from the same original source, since most of the sellers do seem to be in Shen Zhen. I would be interested in knowing how much flash space the original firmware used.
Find all posts by this user
Quote this message in a reply
10-31-2019, 06:32 PM
Post: #36
RE: RPN scientific calculator firmware for $13 calculator kit
Could you make it possible to raise a negative number to a positive integer power? Right now numbers like -5 ^ 8 give an error. When raising to a positive integer power, you don't need the log functions. Is there enough room left in firmware memory to test for that?

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-31-2019, 06:49 PM
Post: #37
RE: RPN scientific calculator firmware for $13 calculator kit
(10-31-2019 06:32 PM)toml_12953 Wrote:  Could you make it possible to raise a negative number to a positive integer power? Right now numbers like -5 ^ 8 give an error. When raising to a positive integer power, you don't need the log functions. Is there enough room left in firmware memory to test for that?

The same applies to negative integer exponents. Simply raise to the positive power and then calculate the reciprocal.

There are only 10 types of people in this world. Those who understand binary and those who don't.
Find all posts by this user
Quote this message in a reply
11-01-2019, 01:08 AM
Post: #38
RE: RPN scientific calculator firmware for $13 calculator kit
It would be possible to do, but definitely fairly low priority given the amount of flash space left. I don't think it comes up enough in terms of everyday usage for the amount of flash it would take. (For what it's worth, I think the HP 35 also gives an error: it's one of the examples given in the "The New Accuracy: Making 2 ^ 3 = 8" in HP Journal.) My current priorities to fill the flash are approximately in order: trig, "continuous memory" by storing to flash when turning off (all the flash/eeprom is in-application-programmable on the microcontroller used apparently), auto poweroff, resistor color code decoder, hex/dec converter, and then special cases. Probably possible to free up space elsewhere, but there aren't many easy, major changes I can think of that would magically give a large amount of space back (i.e. similar to switching functions to not be re-entrant and not pass pointers).
Find all posts by this user
Quote this message in a reply
01-16-2020, 10:43 PM
Post: #39
RE: RPN scientific calculator firmware for $13 calculator kit
Any progress on the software front? I have 1.09 but am waiting for further enhancements.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
01-28-2020, 08:20 AM
Post: #40
RE: RPN scientific calculator firmware for $13 calculator kit
I have not made much progress recently, what's on github is fairly up to date. The last change I made was some prototyping work for replacing the existing square root implementation (using logs/antilogs) with a fast-reciprocal square root implementation. I haven't done the implementation for the calculator yet though. The motivation was to reduce the decimal floating point register usage for square root, to use it as part of trig algorithms like those used by valentin albillo for the HP 12C.

I do still use this calculator regularly (it has pretty much a permanent place on my desk at home), but haven't spent much time on it recently. I do want to get trigs done, but probably not much flash left for much else...even for the trigs will probably need to rewrite some other parts to free up some space, so it hasn't been that motivating given how rarely I use trigs.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)