RPN Scientific Firmware for the Spikenzielabs Calculator Kit
02-24-2016, 08:48 PM
Post: #1
 securd Junior Member Posts: 8 Joined: Feb 2016
RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Hi All,

I have always had a fascination with early scientific calculators, and I'm impressed by how the engineers in the 1970's did so much with so little. So earlier this month I decided to take a stab at putting some scientific calculator firmware together -- and what better hardware base than the excellent Ardunio-based Spikenzielabs Calculator kit! I started the project focused on just the visible 6 digits of precision and native CORDIC routines for the transcendentals, but quickly learned that we needed more guard digits for it to be truly useful as a "daily driver." Plus, the Spikenzie guys may eventually build a model with more display digits... So I pivoted to an Arduino port of the BigNumber arbitrary precision library, coded up high precision Taylor series approximations for the transcendental functions, and voila! SciCalc was born. The attached defines internal precision to 12 digits (defined by INTDIGITS); feel free to dial this up or down depending on the precision / time tradeoff you are happy with. If you are familiar with well-known Calculator Forensics calculation, the SciCalc returns 9.000076557818 -- not too bad for a lowly Atmel processor!

A few notes before you download the attached sketch:

0. Hardware-wise you'll need to solder a 6 pin header to the edge of the board, extending out of the top of the calculator. By leaving out the small plastic cross-piece which sits UNDER the top edge of the circuit board, there is room for the connector to protrude. I programmed with a SiLABS USB-Serial programmer, but use whatever you have (see photo). If you provide power through the programmer, be sure to remove the battery first!!!

1. The = key is now the Enter key

2. With only 17 keys, I needed a function key. So by pressing and holding the decimal (.) key, each key has an alternate shifted function as below (I have also attached a photo of my labeled keyboard):
. 7 = sin
. 8 = cos
. 9 = tan
. / = square root
. 4 = arcsin
. 5 = arccos
. 6 = arctan
. x = e^x
. 1 = deg / rad toggle
. 2 = x/y exchange
. 3 = stack roll down
. - = chs

3. I modeled stack behavior after the HP-15c, with x (bottom), y, z, t (top) registers. I also track Last x in the software, but ran out of buttons to recall it. With #define DEBUG uncommented, serial logging includes the entire stack with every keypress, so you can sort out what is happening.

4. By holding the Clear key for 3+ seconds, the calculator goes into self-test mode. The string 'testkeys' is looped forever, until you hit the Clear key again. This stops the looping, and shows the number of iterations completed on the display (left in the x register).

5. Internal precision is set to 12 digits; although x is rounded to 6 digits prior to displaying. The rounding occurs at display time, and does not affect the internal precision.

6. As provided, the sin / arcsin, cos / arccos and arctan functions are accurate to +/- 0.00000002. tan begins to become less accurate as cos(x) approaches zero. (I can provide an error chart in Excel format if you are interested, with results from the trig functions on one degree increments, from -360 to +360 degrees). If you do any fine tuning with the algorithms, comment out #define DEBUG and uncomment #define TRIGTEST. At the next restart, the calculator will automatically compute and print a table of the sin, asin, cos, acos, tan, atan for every degree, +/- 360 degrees (serial logging port)

7. I carried power management to the max, and even disabled the brownout detector in the Atmel chip. As a result, when the calculator goes to sleep, the power draw is barely measurable (a microamp or less). I'm guessing the battery life will be several months, or longer? Of course, depending on use.

Have fun, and let me know if you find any bugs!

So attached please find:

- photos of programming connector installed and the labeled keys
- scicalc sketch (unzip and move this and open it in the Arduino IDE)
- BigNumber library (unzip and move this to your Arduino library location)
- as a bonus, I also included the Excel spreadsheet of trig errors for every degree +/- 360 deg, as generated by SciCalc with #define TRIGTEST uncommented

Attached File(s)
BigNumber.zip (Size: 88.51 KB / Downloads: 55)
Spikenzie_SciCalc_1.2.ino.zip (Size: 12.03 KB / Downloads: 55)
SciCalc Pics.zip (Size: 745.55 KB / Downloads: 121)
trigerrors.xls (Size: 450 KB / Downloads: 31)
 « Next Oldest | Next Newest »

 Messages In This Thread RPN Scientific Firmware for the Spikenzielabs Calculator Kit - securd - 02-24-2016 08:48 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - striegel - 02-24-2016, 09:37 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - securd - 02-24-2016, 10:31 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - quantalume - 02-25-2016, 04:26 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - securd - 02-26-2016, 07:09 AM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - Chasfield - 02-26-2016, 07:41 AM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - securd - 02-26-2016, 10:29 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - quantalume - 02-27-2016, 04:17 AM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - Maximilian Hohmann - 03-01-2016, 10:19 AM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - securd - 03-01-2016, 12:53 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - Luigi Vampa - 10-29-2016, 11:09 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - securd - 03-01-2016, 12:55 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - Dave Britten - 04-02-2016, 01:57 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - securd - 04-02-2016, 04:23 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - Dave Britten - 04-02-2016, 05:17 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - securd - 04-02-2016, 06:24 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - Dave Britten - 04-02-2016, 08:23 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - Luigi Vampa - 01-04-2017, 12:43 AM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - Maximilian Hohmann - 09-25-2017, 12:14 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - Alejandro Paz(Germany) - 09-28-2017, 06:46 AM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - Maximilian Hohmann - 09-28-2017, 05:45 PM RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit - pier4r - 09-28-2017, 08:07 PM

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