Post Reply 
RPN scientific calculator firmware for $13 calculator kit
10-07-2019, 08:07 AM (This post was last modified: 10-07-2019 10:09 PM by jklsadf.)
Post: #1
RPN scientific calculator firmware for $13 calculator kit
I started writing an RPN calculator replacement firmware for the "diyleyuan" calculator here. This is one of the cheapest diy calculator solder kits you can buy (about $13 on ebay) with a full LCD. The original firmware has a fixed point calculator that only operates in chain mode.

My replacement firmware operates in decimal floating point and supports calculating more functions, but doesn't support the original firmware's resistor color code calculator or the hex <=> decimal converter. It does arithmetic with an 18 decimal digit significand, and is reasonably accurate. Eventually, I'd like for it to be able to do all the functions of the original HP 35. The functions supported can be seen in the Qt emulator GUI below:
[Image: calc_small.jpg]
[Image: qt_gui.png]

The diy kit uses an STC microcontroller (which is unfortunate, but likely due to cost). It uses an Intel 8051 compatible architecture instead of a more modern 8-bit architecture like AVR (like in the arduino). But on the bright side, all of these microcontrollers come from the factory with a serial bootloader permanently installed in ROM. All you need to reprogram them is a USB to serial converter dongle thing.
Find all posts by this user
Quote this message in a reply
10-07-2019, 02:00 PM
Post: #2
RE: RPN scientific calculator firmware for $13 calculator kit
Quote:The diy kit uses an STC microcontroller...All you need to reprogram them is a USB to serial converter dongle thing.
I was looking at those this past week for my own DIY project. At least one of the models has a schematic showing how you can directly wire USB to two of the pins and program it with no dongle! They have some other cool stuff, but I passed on them since they don't support external program memory like traditional 8051s. The Atmel AT89LP51 costs about $2 in qty 1, also does single cycle execution, and supports external program and data memory, but it only runs at 20MHz vs 35MHz for some of the STC chips. Dallas has one that runs at 33MHz for $25 if you want all of those features. In any case, it's hard to beat an 8051 if you want to build a DIY calculator with a lot of memory and you're sticking to through hole microcontrollers.

Good luck on your project! I'm gonna buy one of the kits and I'd love to try out your firmware when you're finished.
Find all posts by this user
Quote this message in a reply
10-07-2019, 07:41 PM
Post: #3
RE: RPN scientific calculator firmware for $13 calculator kit
The newer STC microcontrollers have a direct USB interface, instead of serial. The entire industry is moving towards that direction (e.g. arduinos used to have a separate FTDI USB-to-serial converter chip, but the new ones just use a microcontroller with USB built in). The STC microcontrollers aren't bad, and are much faster per clock than the original 8051 (like most modern implementations). I'd consider their main advantage though (other than 8051 compatibility) to be their extremely low cost. The surface-mount version of the chip used in this calculator is less than a dollar in one-off quantities: https://lcsc.com/product-detail/STC_IAP1...08538.html

I would personally probably use an Atmel/Microchip ATxmega for new projects that needed an external memory bus (but still the simplicity of an 8-bit microcontroller), just for the better compiler support for programming in "high-level" languages like C. For anything more powerful, probably an ARM microcontroller. I personally don't mind surface-mount components as long as the pin pitch isn't too fine. Also, there are a lot of really small ARM development boards like the teensy which can be through-hole mounted.

If you're already used to 8051 programming it might not be too bad though. It was my first time though, as I mentioned in the writeup under "Implementation on an STC 8051 Microcontroller". I had originally written the firmware kind of similar to the BigNumber library where functions take pointers to the bignums, but that quickly filled up all available code space, and I had to rewrite large parts of it to just use globals.
Find all posts by this user
Quote this message in a reply
10-11-2019, 01:58 AM
Post: #4
RE: RPN scientific calculator firmware for $13 calculator kit
I bought two of these kits last year and assembled one so far. The fact that the button labels are just paper is a plus. You can break the two-piece buttons apart and relabel at will. The display is impressive in its brightness but I'm pretty sure I've seen the same display in many point of sale terminals.

I'd absolutely be interested in testing an RPN firmware if there is a clear way to reprogram it.
Find all posts by this user
Quote this message in a reply
10-11-2019, 09:06 PM
Post: #5
RE: RPN scientific calculator firmware for $13 calculator kit
I just ordered one of these shipped from an Aliexpress seller for under $11. I'll be waiting a couple of weeks for it though.
I'll absolutely be trying your firmware. Thanks!
I like that it's so easy to relabel the keys.

Georgia, USA
10BII+, 14B AE, 17B, 20B, 30B(WP-34S), 28S, 48G, 82240B
+ sliderules galore, mostly Hemmi/Post & Dietzgen
Find all posts by this user
Quote this message in a reply
10-15-2019, 07:11 PM (This post was last modified: 10-15-2019 09:48 PM by jklsadf.)
Post: #6
RE: RPN scientific calculator firmware for $13 calculator kit
The button labels are a huge plus. I think the transparent button keycap cover for relabeling might be an innovation of the Chinese clones. The original Omron B3F series doesn't have these transparent keycap covers. Not many of the major manufacturers have tactile switches with re-labelable keycaps, or if they do they're either very large or expensive (or both).

Reprogramming is fairly straightforward. There is a prebuilt main.hex file in the binaries folder. You do have to solder at least 3 additional wires (Rx, Tx, and ground), or 4 wires including +5V if you're powering with the USB-to-(logic-level)-serial adapter. You need to purchase (or already have) such an adapter, preferably one that supports 5V operation like this one: https://www.amazon.com/HiLetgo-FT232RL-C...00IJXZQ7C/

I do talk a lot more about other hardware stuff in the writeup (e.g. you need to crossover Rx/Tx), but in the end it's just a matter of soldering and connecting 4 extra wires. Once soldered, run the freely-available programmer program to actually program the chip (see the "Programming with stcgal" section).
Find all posts by this user
Quote this message in a reply
Post Reply 




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