RPN Scientific Firmware for the Spikenzielabs Calculator Kit
|
02-24-2016, 08:48 PM
Post: #1
|
|||
|
|||
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 |
|||
02-24-2016, 09:37 PM
Post: #2
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
(02-24-2016 08:48 PM)securd Wrote: ... Intriguing! I like that you use a held-down key to act as the shift. When you used all the keys to create shifted functions, did you ever consider using repeated presses of a button to toggle through a sequence of meanings? I understand that TI has done that with several of their (recent?) calculators. |
|||
02-24-2016, 10:31 PM
Post: #3
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Hi striegel,
I thought about that! But when using RPN, multiple presses could very well represent multiple intentional operations. In fact on my old HP's I used to hit "1 enter enter enter enter" to fill the stack, then repeat "+ + + +..." to use the calculator as a simple counter. That said, I did use the Clear key for multiple functions (one press performs CLX, second press performs clear stack). I also experimented with holding the key down until it changes function (sort of like the the HP-41C). I also used this technique on the Clear key: holding it down 3+ seconds causes the calculator to switch into self-test mode. So technically, the Clear key has four functions! Power On, CLX, Clear Stack, and Self-Test. I really wish we had another couple of rows of keys, and a couple more digits on the display -- but otherwise this little calculator is a true gem! Steve. |
|||
02-25-2016, 04:26 PM
Post: #4
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Nice work. Thanks for making the source code available.
What is your opinion of the keyboard? I'm wondering if the WP folks might consider a similar construction technique as an option. It's probably been considered somewhere already... David Brunell Houston, Texas |
|||
02-26-2016, 07:09 AM
Post: #5
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Hi Dave,
The keyboard us certainly useable... the switches are low-cost "clicky" switches, but I haven't experienced any issues with them registering, or bouncing. Compared to actual HP keys they require considerably more force to depress, and the click is harsher. But the unique Spikenzie design is brilliant, in terms of figuring out how to get a key cap over a switch not designed to have a key cap! The punchline is that it is very different from a commercial calculator keyboard, but I have been thoroughly enjoying using it. Steve. |
|||
02-26-2016, 07:41 AM
Post: #6
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Great hardware hack. You have motivated me to attempt to weave the BigNumber library into my RPN-duino project in order to give it the precision the 16x2 display warrants.
|
|||
02-26-2016, 10:29 PM
Post: #7
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Excellent Chasfield!
As you think about this, I actually found the BigNumberMath wrapper is a handy extension of the BigNumber library (http://cerebralmeltdown.com/forum/index.php?topic=342.0) It uses a bit too many resources for this particular calculator, but I am using BigNumberMath on another weekend project -- a 32 DECIMAL DIGIT (not bit) Arduino Due-based scientific calculator. I was inspired by this Scientific American blog relating to precision, and I though it would be cool to code an Arduino to NIST standards! (article here: http://blogs.scientificamerican.com/obse...-you-need/) It turned out to require more resources than I had available on the Spikenzie Calculator, but seems to be working quite well on the ARM-based Due (see photo attached). I'll send more on this later, when I get a chance to get to a useable release! Steve. |
|||
02-27-2016, 04:17 AM
Post: #8
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Oh, boy! You've really whetted our appetite with that 32-digit display!
David Brunell Houston, Texas |
|||
03-01-2016, 10:19 AM
(This post was last modified: 03-01-2016 10:21 AM by Maximilian Hohmann.)
Post: #9
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Hello!
Wonderful projects your micrcontroller/Arduino based calculators! I am also tinkering with these things and have been putting together parts for a calculator for quite some time. Right now, I am waiting for a shipment from China with buttons and transparent keycaps for self-labeling. When it's there I will start soldering... Regarding your projects I have a couple of questions and a suggestion: - Does the housing of the Spikenzie calculator offer enough space for mounting the microcontroller in a socket? I ask because I have already "fried" a couple of them, mostly because loose wires on the breadboard got in contact with the wrong pin. And in-site-programming always comes with a certain risk of connecting the wires in the wrong order... De-soldering the controller from that calculator PCB would be beyond my capabilities. - On one of the pictures I can see a MacBook pro, similar to what I am using. What ISP programmer and which software are you using to flash the controller in-site? And what settings do you use for bringing down the power consumption that low? - As I am a big fan of LED displays I would never build a calculator with anything else (except maybe nixies or other glow-in-the-dark steampunk stuff). After some research I found these displays most useful: eBay item number 121031909296 . Different to every other display I have seen so far, their PCB is exactly the size of the display itself, allowing them to be combined horizontally (for multi-digit displays) and vertically (for full-stack or other multi-line displays) without gaps. They have MAX7219 controllers, therefore only three wires are required to connect any number of them. Unfortunately they are sold as kit only with three SMD components that can be a bit difficult to handle. Looking forward to see more of it coming! Regards Max |
|||
03-01-2016, 12:53 PM
Post: #10
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Hi Maximillian,
Sounds like an excellent project! Please keep us posted. Regarding the displays, those look like they would work just fine. I am using modules with the TM1638 driver (eg. ebay: 351374870047), because they have LED's and pushbuttons which I am utilizing for indicators and additional keys, however the module you chose also has Arduino drivers so it should be a great choice. Regarding the Atmel chip on the SpikenzieLabs calculator enclosure, there is zero room for a socket so the processor is soldered directly to the board (see picture attached). I guess I've been lucky and I haven't yet fried one of these chips, plus they are good for so many programming cycles that I didn't think about socketing it. Probably a good idea though! Regarding the programmer, I am using one based on the CP2102 USB chip with a 6-pin wire connector (see picture 2 attached). I don't remember where I bought mine, but I just searched ebay and there seem to be a large variety. The one pictured here works perfectly -- including resetting the processor when accessing the serial port, etc. Good luck with the project and have fun! Steve. |
|||
03-01-2016, 12:55 PM
Post: #11
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Posting pic of Atmel processor clearance in the SpikenzieLabs calculator kit here for Maximillian:
|
|||
04-02-2016, 01:57 PM
Post: #12
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
I've got one of these kits arriving in the mail later today. Was hoping I could just socket the ATmega, but looks like there isn't enough room to do that, based on the photo. Where can I obtain the necessary right-angle six-pin header for adding I/O pins? I'm not an electronics guy, so I'd be lost digging around Digikey trying to find the right part. I'm sure I could find other neat accessories to add to the order to make the shipping cost-effective, though.
|
|||
04-02-2016, 04:23 PM
Post: #13
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Hi Dave,
I just used a single header strip, and cut off a section of 6 pins with a pair of wire cutters. It is not a right-angle header -- just a straight pin header. I don't know whether a right angle header would fit in the small space. I then laid the header on the back of the board to align with the six pads and tack soldered it in place. Here is the strip I cut a six pin section off of, and the section soldered in place (photos attached). Good luck with the kit! Steve. |
|||
04-02-2016, 05:17 PM
Post: #14
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
(04-02-2016 04:23 PM)securd Wrote: Hi Dave, Cool, that's what I'm going to try doing. I've got a header strip that came with my Arduino kit (not sure what it was intended for), so that'll probably work. Does the ATmega speak plain old RS-232? If so, I should be able to just cut up some IDE cable and stick a D-sub connector on the bare end. |
|||
04-02-2016, 06:24 PM
Post: #15
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Dave,
You will need to find a usb-serial programmer which is recognized by the Arduino IDE. I used one based on the SiLabs CP2102 chip (photo attached here), but any usb to serial adapter which works with Arduino should do the job! |
|||
04-02-2016, 08:23 PM
Post: #16
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Great success. I stuck a straight 6-pin header on there, then carefully bent the pins to a right angle. Then I used the Dremel to remove that portion of the top spacer that blocks the serial pins.
Now I just need to find a small connector that will go on those pins easy enough, and solder a 9-pin serial connector on the other end. Time to dig through my parts boxes. Do you think the CR2032 will supply enough power for flashing the firmware, or do I need to power it through the 5V pin? |
|||
10-29-2016, 11:09 PM
(This post was last modified: 10-30-2016 09:49 PM by Luigi Vampa.)
Post: #17
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
(03-01-2016 12:53 PM)securd Wrote: Regarding the programmer, I am using one based on the CP2102 USB chip with a 6-pin wire connectorI have used a Prolific PL2303 USB chip, that I have for my WP34s, but the lack of DTR signal has made any sketch upload simply impossible. I happened to find this link describing the issue in a quite clear way. BTW, I needed to comment the #include <MemoryFree.h> line, in order to be able to compile the sketch with no errors. I am sure I will enjoy your RPN sketch as soon as I got my proper USB2TTL converter. Thanks Steve for sharing your project. Saludos Saluti Cordialement Cumprimentos MfG BR + + + + + Luigi Vampa + Free42 '<3' I + + |
|||
01-04-2017, 12:43 AM
Post: #18
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
I have found something in the code that I don't understand:
// KeyPad Layout: // // Columns Rows // 3 2 1 0 // // 7 8 9 / 0 // 4 5 6 * 1 // 1 2 3 - 2 // 0 . = + 3 // // Value mapping for decoding // 12 8 4 0 // 13 9 5 1 // 14 10 6 2 // 15 11 7 3 // // ascii values returned // 7 8 9 / // 4 5 6 * // 1 2 3 - // 0 . = + // // shifted ascii values returned (i.e. dp key held down while other key pressed) // A B C D // E F G H // I J K L // na na na na (bottom row not used for shifted keys, since the dp key is in this row) ... so far, so good, but later we can read: case 3: keyvalue = 'P'; // shift '+' break; Does anybody know why this "case 3:" was included in the code? I wish I could use that shift '+' to include the bigln that is left as a comment at the end of the source code. Thanks in advance for any prospect clue. Saludos Saluti Cordialement Cumprimentos MfG BR + + + + + Luigi Vampa + Free42 '<3' I + + |
|||
09-25-2017, 12:14 PM
(This post was last modified: 09-25-2017 01:45 PM by Maximilian Hohmann.)
Post: #19
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
Hello!
Just a little heads-up for would be calculator tinkerers... The original kit was never readily available here in Europe and with shipping and import duties would have cost in excess of 50$/Euros a piece. Now our Chinese friends have come up with a clone of that calculator kit. It includes everything just as the original, but has transparent key caps under which one can place one's own labels - sort of an improvement over the original one form a DIYer's point of view. They cost 11$/Euros a piece, shipping already included (and I ask myself once again: How can it be that shipping alone from the States costs 17$ ? The distance is the same.) I just got 2 of them in the mail (10 days after purchase on eBay). Regards Max NB: This is a picture of the not yet assembled kit. The PCB is more square than the original one and there is no provision for a programming connector. Therefore the processor will require a socket in order to be re-programmable (e.g. on an Arduino board). Other than the original kit the displays are underneath the top acrylic cover so there should be enough space for a socket. |
|||
09-28-2017, 06:46 AM
Post: #20
|
|||
|
|||
RE: RPN Scientific Firmware for the Spikenzielabs Calculator Kit
For like 14 € looks really good !
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)