Re: Arduino HP-25 Simulator - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: Not HP Calculators (/forum-7.html) +--- Forum: Not quite HP Calculators - but related (/forum-8.html) +--- Thread: Re: Arduino HP-25 Simulator (/thread-18163.html) |
Re: Arduino HP-25 Simulator - teenix - 03-23-2022 08:00 AM 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 RE: Re: Arduino HP-25 Simulator - TellyS - 03-23-2022 03:28 PM (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. 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 RE: Re: Arduino HP-25 Simulator - Maximilian Hohmann - 03-23-2022 03:57 PM 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. RE: Re: Arduino HP-25 Simulator - TellyS - 04-01-2022 07:44 PM (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. RE: Re: Arduino HP-25 Simulator - Paul Dale - 04-02-2022 03:12 AM 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] RE: Re: Arduino HP-25 Simulator - Maximilian Hohmann - 04-02-2022 10:06 AM 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 RE: Re: Arduino HP-25 Simulator - TellyS - 04-02-2022 03:29 PM (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. 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: Due: PS: I, of course, have a 34S. I will look into that library you mention. RE: Re: Arduino HP-25 Simulator - TellyS - 04-02-2022 03:33 PM (04-02-2022 10:06 AM)Maximilian Hohmann Wrote: Hello! 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. RE: Re: Arduino HP-25 Simulator - Paul Dale - 04-03-2022 12:23 AM Looks like the mega is using 32 bit floats while the Due is using 64 bit ones. Interesting. Pauli |