Overview

This is an improved version of the first RPN Scientific Calculator (https://hackaday.io/project/6468-rpn-scientific-calculator ) I made. It uses an LPC1114 microcontroller and adds keystroke programming. It is smaller, faster, and uses less parts. Features:
- BCD number format with 1-120 places
- Internal accuracy configurable from 6 to 32 decimal places
- Single 200 level stack
- Optional scientific notation
- Functions: (a)sin, (a)cos, (a)tan, y^x, x root y, e^x, ln, 10^x, log, mod
- Keystroke programming with 10 user defined functions
- 18x4 character LCD
- 30 buttons

Software

The interface shows 4 levels of the stack, similar to some HP calculators. The stack is stored on an external SPI SRAM but all calculations are done using the internal RAM of the microcontroller. This is much faster than the original RPN Scientific Calculator which used external RAM for buffers during calculations. The size of numbers had to be shrunk to 120 places down from the original 255 so that all the buffers would fit in the microcontroller's 4k of RAM.

The trig and log functions are computed using CORDIC routines. This is a very efficient way to compute these functions for processors that cannot multiply or divide quickly. Instead, a lookup table is used with adds and shifts, which are much faster. I was able to speed the shifting up even more by using another lookup table that let me right shift 4 digits at a time. One way to measure the accuracy of calculations is with the calculator forensic found here: http://www.rskey.org...j/forensics.htm. After setting accuracy to 24 places arcsin(arccos(arctan(tan(cos(sin(9)))))) evaluates to 9.0000000000000003.

The settings page allows the accuracy to be set from 6 to 32 decimal places. With 32 decimal places calculations take less than a second, which is at least 5 times faster than the original calculator. After setting the accuracy, the program finds the largest element in the CORDIC table that is still significant, so that no time is wasted on elements that have no effect on the answer.

Keystroke Programming

This is the main new feature added to this version. There are 10 functions keys that can be programmed with an onscreen editor. So far the functions only repeat the commands entered into the editor. In the future I plan to add more robust programming features like looping, conditionals, and labels.

Hardware

The LPC1114 has 32k of flash and is easily able to hold the entire firmware, while the original project needed two MSP430s. The microcontroller is connected to a 128k SRAM chip that it communicates with over SPI. The 30 buttons of the keypad are multiplexed on 11 pins. The display is a very nice 128x32 VFD made by Noritake which allows four lines of 18 characters. The displays runs on 5v so I used a 74HC245 for level translation. The displays requires its ready pin to be read before sending more data so I connected it to one of the 5v tolerant pins on the LPC1114. Using just three chips is much more compact than the original.

Power is provided by two 18650 batteries rated for 2000mAh. The SRAM and microcontroller should draw less than 100mA together but the VFD can draw as much as 400mA. Voltage regulation is done by a small switching supply that steps the batteries down to 5v. Hopefully the batteries will last at least 6 hours with this set up.

The whole body of the calculator is made from protoboard. Male headers are used to give the pieces more stability. One of the last things left for the hardware is to build or print some kind of case to go around everything. Hopefully I can do this in SolidWorks and have it cut on a 3D printer. I will also need some kind of keypad which I might also have done on the laser cutter.