Post Reply 
RPN-duino
10-16-2015, 03:55 PM (This post was last modified: 11-15-2015 08:43 AM by Chasfield.)
Post: #1
RPN-duino
I have been busy with a home brew RPN calculator project based on the Arduino Nano mini board. The impulse to get going with it came from finding an Arduino starter kit that had been sitting unused since last Christmas, linked to the discovery that Rockwell once turned out four banger calculators with an easily detachable modular keyboard. I cannibalised a 20 key unit from a model 18R. These keyboards have a nice, almost HP48-like action and are perfect for adding custom key labels to. These old calcs are cheap on auction sites.

As the pictures show, I finished up with a fairly chunky device in a custom case. It features varnished pine trim, which I believe is a first for calculators!

The back-lit display is the ubiquitous and ridiculously cheap 2x16 character 1602 unit. And power comes from a PP3 battery, which should be good for about 20 hours use at 30 mA current draw. That isn't bad, given that the calculator has a real on/off switch. A reflective type LCD would double the battery life but I quite like the blue and white glow of the one used - easy on middle aged eyes as it is.

Calculating accuracy surpasses the Sinclair Scientific by a couple of decimal places but floating point maths is not a strong feature of regular low cost Arduino boards. At the moment, standard form number handling isn't programmed - big/small numbers with exponents display as 0. Digging the bits of them out of Arduino "float" type variables and doing something useful with them is a project in progress.


Attached File(s) Thumbnail(s)
           
Find all posts by this user
Quote this message in a reply
10-16-2015, 07:03 PM
Post: #2
RE: RPN-duino
HAHHA! so cool!

Which code are you using for the arduino? Custom code?

My website: erwin.ried.cl
Visit this user's website Find all posts by this user
Quote this message in a reply
10-16-2015, 07:22 PM
Post: #3
RE: RPN-duino
Excellent! Nice job.
Find all posts by this user
Quote this message in a reply
10-16-2015, 07:23 PM (This post was last modified: 10-16-2015 07:32 PM by Chasfield.)
Post: #4
RE: RPN-duino
Re: coding approach

I am working in version 1.0 of the Arduino IDE under Lubuntu and my sketch calls in these libraries:

#include <Keypad.h>
#include <LiquidCrystal.h>
#include <math.h>

So others have done much of the hard work. The keypad.getKey() method does the donkey work, with no need to worry about rows and columns.
Find all posts by this user
Quote this message in a reply
10-16-2015, 08:50 PM
Post: #5
RE: RPN-duino
Yeah, keypad.h is so useful, I was thinking you had some advanced in the RPN routines itself.

My website: erwin.ried.cl
Visit this user's website Find all posts by this user
Quote this message in a reply
10-16-2015, 09:23 PM
Post: #6
RE: RPN-duino
(10-16-2015 03:55 PM)Chasfield Wrote:  I have been busy with a home brew RPN calculator project based on the Arduino Nano mini board.

As the pictures show, I finished up with a fairly chunky device in a custom case. It features varnished pine trim, which I believe is a first for calculators!

Very cool, thanks for sharing. I like the pine trim. The only other thing that comes to mind of course are the WOODstocks, but that's a whole different topic...

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
10-16-2015, 11:40 PM
Post: #7
RE: RPN-duino
(10-16-2015 07:23 PM)Chasfield Wrote:  Re: coding approach

I am working in version 1.0 of the Arduino IDE under Lubuntu and my sketch calls in these libraries:

#include <Keypad.h>
#include <LiquidCrystal.h>
#include <math.h>

So others have done much of the hard work. The keypad.getKey() method does the donkey work, with no need to worry about rows and columns.

Why reinvent the wheel? Think of the code written by others as libraries.

Are you thinking of bringing the finished product to work or school for everyday use?
Find all posts by this user
Quote this message in a reply
10-17-2015, 04:38 AM
Post: #8
RE: RPN-duino
I am, more a collector/tinkerer of calculators and have no need for one at work - particularly if it splits my shirt pocket open! However, I will keep it to hand at home for everyday calculations as its ergonomics suit me well - and it won't have a flat battery if I pick it up to use in a month's time.
Find all posts by this user
Quote this message in a reply
10-17-2015, 07:48 AM
Post: #9
RE: RPN-duino
(10-16-2015 11:40 PM)Dwight Sturrock Wrote:  Why reinvent the wheel?

[Image: CMyiLuKUwAA6l-V.jpg]
Find all posts by this user
Quote this message in a reply
10-17-2015, 12:56 PM
Post: #10
RE: RPN-duino
(10-17-2015 07:48 AM)Thomas Klemm Wrote:  
(10-16-2015 11:40 PM)Dwight Sturrock Wrote:  Why reinvent the wheel?

[Image: CMyiLuKUwAA6l-V.jpg]

Awesome reply, thank you Thomas. I will keep this image for future use...

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
10-17-2015, 04:41 PM
Post: #11
RE: RPN-duino
(10-17-2015 07:48 AM)Thomas Klemm Wrote:  
(10-16-2015 11:40 PM)Dwight Sturrock Wrote:  Why reinvent the wheel?

[Image: CMyiLuKUwAA6l-V.jpg]

Good point! But isn't that a rotational iterative refinement?
Find all posts by this user
Quote this message in a reply
10-17-2015, 05:02 PM (This post was last modified: 10-17-2015 09:58 PM by Dave Frederickson.)
Post: #12
RE: RPN-duino
(10-17-2015 07:48 AM)Thomas Klemm Wrote:  [Image: CMyiLuKUwAA6l-V.jpg]

Where's the square wheel? Didn't it come prior? And after the square wheel came the triangular wheel, which eliminated one bump. Smile
Find all posts by this user
Quote this message in a reply
10-24-2015, 10:45 AM (This post was last modified: 10-24-2015 11:07 AM by Chasfield.)
Post: #13
RE: RPN-duino
I have implemented the input and display of numbers in standard form on the RPN-DUINO calculator. The problem was that the the 1602 LCD print method only renders plain floating point numbers without exponents, displaying zero if the normal range is exceeded. Following the approach of another coder, I came up with this display formatting procedure that abstracts what is displayed from what is stored. Basically, I throw rocks at the stored "float" variable until it gives up its significand and exponent values, which can then be printed out on the LCD.

I sure ain't pretty but it does the job.

Code:

void lcd_format(float your_reg, int lcd_line){
   float your_significand = 0;
   int your_exp = 0;
   int d_places = 0;
   lcd.setCursor(0, lcd_line); 
   lcd.print("                    ");   
   lcd.setCursor(0, lcd_line); 
   your_exp = trunc(log10(abs(your_reg)));
   if ((abs(your_reg) >10000000) || (abs(your_reg) < 0.001) && (your_reg !=0)){  [i]// range of numbers requiring standard form[/i]
       your_significand =  your_reg/pow_ten(10, your_exp - 1); // reduce the stored float value to a printable significand
       if (abs(your_reg) < 1.0) { // adjust for negative exponents to give something to left of DP
           your_exp = your_exp -1;
           your_significand = your_significand * 10;}
        lcd.print(your_significand, 7);
        lcd.setCursor(11, lcd_line); 
        lcd.print ("E");        
        lcd.print(your_exp);}
    else  // if variable doesn't require display in standard form, suppress fictional significant figures [/i]
        {if (your_reg >= 1)  
                 d_places =  7 - your_exp;
          else 
                 d_places = 7;
         lcd.print(your_reg, d_places);}

Numbers keyed in by users in standard form are scaled by iterative multiplication/division with respect to their exponent. That makes them not directly displayable, but feeding them through the above mangler sorts that out.

I wrote a function "pow_ten", also used above, to do the iterative mult/div. I started out by using the built in math library pow() function but it was squandering precision.
Find all posts by this user
Quote this message in a reply
10-29-2015, 08:26 AM
Post: #14
RE: RPN-duino
Hi,

Super reply with this picture ! Yes sometimes we have to reinvent the wheal !
I keep too this picture for futur use.

GĂ©rard.
Find all posts by this user
Quote this message in a reply
11-14-2015, 05:27 PM (This post was last modified: 11-14-2015 06:39 PM by Chasfield.)
Post: #15
RE: RPN-duino
I have just added another home-made scientific calculator to my RPN-duino stable. This one is completely scratch built, with the keyboard constructed from 30 miniature push switches. It uses a 4 line x 20 character back-lit LCD module and features two wholly visible, 4-line stacks. The left stack works in the usual RPN fashion. The right stack is used for:

carousel storage of pushed X register values
context switching - effectively a two channel calculator
applying arithmetic and slide rule functions simultaneously to multiple stored values

Referring to the top down photo:

Stack control features are implemented on the yellow buttons

Non standard ones are as follows:

CLL - clear left stack, CLR - clear right stack
PSH - push X register to right stack, POP - pop right stack to X register
SAV - image all of left stack to right stack, CPYX - pop right stack to X register with no right stack drop - preserve right stack
FLIP - exchange left and right stack contents - horizontal stack roll
2STK - stack function shift - applies square, square root, reciprocal or arithmetic functions, simultaneously, to all right stack elements

In amongst the blue keys is the 'SUMS' button, which totals the right stack and stores the result in the X register.

The display is split asymmetrically, with 12 characters for the left stack registers and 7 for the right. Column 13 delimits the stacks, with the top row character providing a place for shift annunciator symbols. The 'FLIP' key is convenient for viewing right stack contents in full available precision. Right stack values have an exponent indicator but don't display its value for want of space. Again, a press of the 'FLIP' key reveals the whole picture.

I programmed the display with two custom characters that prefix a number's exponent field and indicate its sign in one column to save space.

The keyboard top plate, bearing the key legends, is retained by magnetic strips and is removable.

The case is 11cm wide and large enough to hold a small packed lunch. It proves Chasfield's law of project enclosures - "an assembly expands to fill the casing available for it". I had hoped to run the whole show from AA batteries but ended up having to work hard to fit a PP3 in there. Current draw is around 30 mA, so that is fine.


Attached File(s) Thumbnail(s)
       
Find all posts by this user
Quote this message in a reply
11-14-2015, 05:48 PM
Post: #16
RE: RPN-duino
(11-14-2015 05:27 PM)Chasfield Wrote:  The right stack is used for:

carousel storage of pushed X register values
context switching - effectively a two channel calculator
applying arithmetic and slide rule functions simultaneously to multiple stored values

This second stack reminds me of the return stack in Forth:
Quote:Forth programmers usually use the return stack for storing data temporarily, if using the data stack alone would be too complex, and factoring and locals are not an option:

: 2swap ( x1 x2 x3 x4 -- x3 x4 x1 x2 )
rot >r rot r> ;
Sometimes I miss that feature in RPL but at least we have local variables.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
11-14-2015, 08:25 PM (This post was last modified: 11-14-2015 08:42 PM by Vtile.)
Post: #17
RE: RPN-duino
(10-17-2015 05:02 PM)Dave Frederickson Wrote:  
(10-17-2015 07:48 AM)Thomas Klemm Wrote:  [Image: CMyiLuKUwAA6l-V.jpg]

Where's the square wheel? Didn't it come prior? And after the square wheel came the triangular wheel, which eliminated one bump. Smile
It is not the bumb count, it is how big they are. In your aproach next update would be "rotating ski", while right aproach is make more bumbs, but smaller ones. Tongue Honestly it doesn't need a genius to invent a wheel, just sit on top of a round log in campfire and you invent one by accident.

With that picture it is actually hard to say which one of those are improvements. Modern car tyre acts more like a stone wheel than spoke wheels which are distributing forces to sphere and push/pull to spokes depending the construction. Tongue
Find all posts by this user
Quote this message in a reply
11-14-2015, 09:11 PM
Post: #18
RE: RPN-duino
(11-14-2015 08:25 PM)Vtile Wrote:  With that picture it is actually hard to say which one of those are improvements. Modern car tyre acts more like a stone wheel than spoke wheels which are distributing forces to sphere and push/pull to spokes depending the construction. Tongue

What's missing in that picture is a bicycle wheel of 1910 at position 5 - optimized for small rolling friction and low moment of inertia. Modern car wheels are a step back - due to the large axial forces they have to withstand since their owners want to slide through curves with a wagon of two tons.

d:-I
Find all posts by this user
Quote this message in a reply
11-15-2015, 10:28 AM
Post: #19
RE: RPN-duino
I shall leave this thread to historians of the wheel.
Find all posts by this user
Quote this message in a reply
11-17-2015, 07:51 PM
Post: #20
RE: RPN-duino
where I find the code and circuit schematic of the project?

I am currently working with a mega arduino
Find all posts by this user
Quote this message in a reply
Post Reply 




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