Post Reply 
Re: Arduino HP-25 Simulator
03-23-2022, 08:00 AM (This post was last modified: 03-23-2022 08:01 AM by teenix.)
Post: #1
Re: Arduino HP-25 Simulator
TellyS wrote:

> What is not even close to the HP-25, however, is the accuracy of calculations and even
> the number representations. I relied on Arduino's built-in math library and number
> handling that is apparently not sufficient. Arduino float/double has a range of
> 3.4028235E+38 to -3.4028235E+38 and 6-7 decimal digits of precision. The 25
> can handle much larger numbers and with greater accuracy. Any suggestions would
> be appreciated, if there is a solution.

Seeing this post cannot be answered in the [Articles Forum] that it was posted in, I'll try an answer here.

The only real way to address this problem is to add the ACT simulation code for the Woodstock calculators. In this way, the original intent of the HP microcode can be realized and it will work as expected. This will require big changes to your software but will be a great and interesting challenge to add to what you have achieved so far.

Check out any web information you can find for "Eric Smith" to see how the HP code was used in modern emulators. There are plenty of HP code listings available for this model of calculator including my emulator at teenix.org

I'm happy to help out if you want to try this approach and get stuck along the way.

cheers

Tony
Find all posts by this user
Quote this message in a reply
03-23-2022, 03:28 PM
Post: #2
RE: Re: Arduino HP-25 Simulator
(03-23-2022 08:00 AM)teenix Wrote:  Seeing this post cannot be answered in the [Articles Forum] that it was posted in, I'll try an answer here.

The only real way to address this problem is to add the ACT simulation code for the Woodstock calculators. In this way, the original intent of the HP microcode can be realized and it will work as expected. This will require big changes to your software but will be a great and interesting challenge to add to what you have achieved so far.

Check out any web information you can find for "Eric Smith" to see how the HP code was used in modern emulators. There are plenty of HP code listings available for this model of calculator including my emulator at teenix.org

I'm happy to help out if you want to try this approach and get stuck along the way.

cheers

Tony

Tony,
Someone replied to me and told me that they cannot post replies. I was not aware of it. I reposted it in this forum instead.

Thank for your reply. Let me review what you are suggesting and I will get back to you.

Nigel, from the forum, suggested this library: Big Numbers on Arduino, that seems to provide more accuracy than I could ever imagine.

Telly
Visit this user's website Find all posts by this user
Quote this message in a reply
03-23-2022, 03:57 PM
Post: #3
RE: Re: Arduino HP-25 Simulator
Hello!

(03-23-2022 03:28 PM)TellyS Wrote:  Nigel, from the forum, suggested this library: Big Numbers on Arduino, that seems to provide more accuracy than I could ever imagine.

Yes, but... the BigNumber library does not come with transcendental functions (I know this because I used it some time ago for a project). You will have to add them yourself. In the examples section they only provide code for the sine function, and this is probably very slow.
Maybe Teenix's approach will be less tediuos in the end and will certainly result in something more similar to the original HP-25.

Otherwise an interesting project and you really made the best of the display concerning the graphic rendering of the calculator.

Regards
Max

NB: They have been out of production for some time, but some years ago the company "Micromega" sold a 64bit FPU for use with microcontrollers such as the Arduino, called "uM-FPU64". It could be accessed using the I2C bus, thus requiring very few connections. I don't know if they can still be found somewhere, but this may also solve your accuracy problem.
Find all posts by this user
Quote this message in a reply
04-01-2022, 07:44 PM
Post: #4
RE: Re: Arduino HP-25 Simulator
(03-23-2022 03:57 PM)Maximilian Hohmann Wrote:  ... but some years ago the company "Micromega" sold a 64bit FPU for use with microcontrollers such as the Arduino, called "uM-FPU64". It could be accessed using the I2C bus, thus requiring very few connections. I don't know if they can still be found somewhere, but this may also solve your accuracy problem.

Thank you for your comment.

I just ordered an Arduino Due to see if a 64-bit processor would make a difference in accuracy. The Uno (and the likes) are just useless when it comes to basic math.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-02-2022, 03:12 AM
Post: #5
RE: Re: Arduino HP-25 Simulator
Changing the processor is unlikely to make a difference. The C types float and double don't change -- they are generally IEEE 754 binary reals. The performance will vary but not the accuracy.

Calculators use decimal arithmetic, you need a decimal big number library or an arbitrary precision floating point library. Or, as Tony mentioned, a emulation of HP's firmware.

If you want some code to lift, try the WP 34S project which has a pretty reasonable decimal floating point library. It is also quite accurate and requires little RAM but it isn't fast.


Pauli

[disclaimer: I authored most of the WP 34S mathematical code, so I might be slightly biassed]
Find all posts by this user
Quote this message in a reply
04-02-2022, 10:06 AM (This post was last modified: 04-02-2022 10:07 AM by Maximilian Hohmann.)
Post: #6
RE: Re: Arduino HP-25 Simulator
Hello!

(04-02-2022 03:12 AM)Paul Dale Wrote:  Changing the processor is unlikely to make a difference.

Yes, but an Arduino Due will at least provide plenty of memory to install an arbitrary precision math library which is hard (or even impossible) to fit into the memory of an Arduino Uno.

Be aware that the Arduino Due has 3.3V pins as opposed to the 5V of the Uno. Make sure that your LCD touchscreen complies with that. Some Arduino shields can be set to either 3,3V or 5V by a jumper or solder bridge. The Due board has no protection against overvoltage, if the display shield has 5V on any of it's pins it will destroy the Arduino (I learnt that the hard way...).
If the screen is not compatible, an Arduino Mega board might be an alternative to the Due. It has 5V pins and a lot more memory than the Uno, so fitting a math library like this one https://bellard.org/libbf/ should be no problem.

Regards
Max
Find all posts by this user
Quote this message in a reply
04-02-2022, 03:29 PM (This post was last modified: 04-02-2022 03:30 PM by TellyS.)
Post: #7
RE: Re: Arduino HP-25 Simulator
(04-02-2022 03:12 AM)Paul Dale Wrote:  Changing the processor is unlikely to make a difference. The C types float and double don't change -- they are generally IEEE 754 binary reals. The performance will vary but not the accuracy.

Pauli

Paul,
I ran a short program that prints pi * power(10,i) and I see a major difference in precision. Perhaps not accuracy, but number of digits supported are much higher. for b]Double[/b].

Mega:
[Image: Mega.jpg]

Due:
[Image: Due.jpg]

PS: I, of course, have a 34S. I will look into that library you mention.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-02-2022, 03:33 PM (This post was last modified: 04-02-2022 08:23 PM by TellyS.)
Post: #8
RE: Re: Arduino HP-25 Simulator
(04-02-2022 10:06 AM)Maximilian Hohmann Wrote:  Hello!

Be aware that the Arduino Due has 3.3V pins as opposed to the 5V of the Uno. Make sure that your LCD touchscreen complies with that. Some Arduino shields can be set to either 3,3V or 5V by a jumper or solder bridge. The Due board has no protection against overvoltage, if the display shield has 5V on any of it's pins it will destroy the Arduino (I learnt that the hard way...).
If the screen is not compatible, an Arduino Mega board might be an alternative to the Due.
Regards
Max

Max,
thanks for the warning. The screen is voltage-wise compatible, but the libraries are not. I suspect there is no definition for Due, so it may be easy to fix that issue.

Edit: I switched library to MCUFRIEND and everything works, although I need to change the procedures that do the rendering. Should be interesting to see how accurate Due's Double is.

I have been using Mega. Should not have mentioned Uno. My code does not fit on an Uno.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-03-2022, 12:23 AM
Post: #9
RE: Re: Arduino HP-25 Simulator
Looks like the mega is using 32 bit floats while the Due is using 64 bit ones. Interesting.


Pauli
Find all posts by this user
Quote this message in a reply
Post Reply 




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