Post Reply 
AriCalculator is a home made pocket calculator.
03-05-2017, 11:20 PM (This post was last modified: 03-05-2017 11:21 PM by hotwolf.)
Post: #21
RE: AriCalculator is a home made pocket calculator.
This weekend I've built a black version of the AriCalculator:

[Image: AriCalculatorBlack.jpg]

Now there is a little more contrast to the laser engravings.
Visit this user's website Find all posts by this user
Quote this message in a reply
03-06-2017, 02:02 AM (This post was last modified: 03-06-2017 02:02 AM by EugeneNine.)
Post: #22
RE: AriCalculator is a home made pocket calculator.
(03-04-2017 06:29 PM)hotwolf Wrote:  What does the back side look like?

It was old skool, wire wrapped

[Image: IMG_20170305_2051098.jpg]

The breadboard at the top of the pic I'm starting over from scratch, its currently just wired to run NOP. I'm going to do a PCB in KiCAD and probably upload the final to OSHPark or something similar.

The DAC was so I could control the contrast like my 48sx, the serial port since my 48sx has a serial port. So it was influenced by my 48SX a good bit.
Find all posts by this user
Quote this message in a reply
03-06-2017, 09:19 PM (This post was last modified: 03-06-2017 11:18 PM by hotwolf.)
Post: #23
RE: AriCalculator is a home made pocket calculator.
That wire wrapping is quite a piece of art.

Good luck with the rebuild, I hope all of your components are still intact.
Visit this user's website Find all posts by this user
Quote this message in a reply
03-06-2017, 11:06 PM
Post: #24
RE: AriCalculator is a home made pocket calculator.
Thats why I'm hunting down new parts. Bought a couple 8085's and 8155's and the 373 for the latch.
Find all posts by this user
Quote this message in a reply
03-07-2017, 12:16 PM
Post: #25
RE: AriCalculator is a home made pocket calculator.
I like it in black too !
Find all posts by this user
Quote this message in a reply
03-07-2017, 10:08 PM
Post: #26
RE: AriCalculator is a home made pocket calculator.
Can you sidelight that acrylic and make the key legends glow?
Find all posts by this user
Quote this message in a reply
03-07-2017, 10:33 PM
Post: #27
RE: AriCalculator is a home made pocket calculator.
(03-07-2017 10:08 PM)EugeneNine Wrote:  Can you sidelight that acrylic and make the key legends glow?

The calculator can be equipped with a back lit display. This circuit could be used to side light the front panel as well. The current PCB/panel hasn't been designed with provisions for these extra LEDs, but that could be hacked.

Front panel illumination is definitely something I will consider for the next revision of the calculator.
Visit this user's website Find all posts by this user
Quote this message in a reply
03-08-2017, 06:46 AM
Post: #28
RE: AriCalculator is a home made pocket calculator.
Amazing looking machine. Well done on a fantastic job Dirk.

Daniel
Find all posts by this user
Quote this message in a reply
05-13-2017, 03:53 PM
Post: #29
RE: AriCalculator is a home made pocket calculator.
updates

http://hotwolf.github.io/AriCalculator/2...lator.html


Visit this user's website Find all posts by this user
Quote this message in a reply
05-14-2017, 02:44 PM
Post: #30
RE: AriCalculator is a home made pocket calculator.
Daniel's four-function firmware is running on the real handheld device now:

http://hotwolf.github.io/AriCalculator/2...mware.html


Visit this user's website Find all posts by this user
Quote this message in a reply
05-24-2017, 11:46 AM (This post was last modified: 06-26-2017 06:41 AM by Dan.)
Post: #31
RE: AriCalculator is a home made pocket calculator.
We are now adding factorial, square, 1/x and sqrt(x), and will use an 8-byte mantissa instead of 5 to improve accuracy. The following shows what has been implemented (in black), and what remains to be done (in red).

[Image: ACKP_v1.3_zpshjc9933n.png]
Find all posts by this user
Quote this message in a reply
06-13-2017, 03:20 AM
Post: #32
RE: AriCalculator is a home made pocket calculator.
I'm thinking of implementing e^x next. Maclaurin series converges rapidly for x near 0, but what about for other values of x?

One option is to factorise the index, e.g. e^32 = (e^3.2)^10, calculating e^3.2 using the Maclaurin series and then raising the result to the power of 10.

Another is to use e^x = e^a (1 + (x-a) +(1/2)(x-a)^2 + ...), storing e^5, e^10,...,e^30 in memory and choosing the closest value for a, e.g. e^32 = e^30 (1 + (32-30) + (1/2)(32-30)^2+...).

Thoughts?
Find all posts by this user
Quote this message in a reply
06-14-2017, 12:23 PM
Post: #33
RE: AriCalculator is a home made pocket calculator.
(06-13-2017 03:20 AM)Dan Wrote:  I'm thinking of implementing e^x next. Maclaurin series converges rapidly for x near 0, but what about for other values of x?

One option is to factorise the index, e.g. e^32 = (e^3.2)^10, calculating e^3.2 using the Maclaurin series and then raising the result to the power of 10.

Another is to use e^x = e^a (1 + (x-a) +(1/2)(x-a)^2 + ...), storing e^5, e^10,...,e^30 in memory and choosing the closest value for a, e.g. e^32 = e^30 (1 + (32-30) + (1/2)(32-30)^2+...).

Thoughts?

You can use a CORDIC algorithm to calculate the exponential function. This page gives C source code implementing the algorithm for a wide range of different functions. It should be faster than using the power series directly.

Nigel (UK)
Find all posts by this user
Quote this message in a reply
06-15-2017, 02:01 AM
Post: #34
RE: AriCalculator is a home made pocket calculator.
The GNU bc utility uses \( e^{-x} = \frac{1}{e^x} \) and \( e^x = { \left( e^{\frac{x}{2}} \right) }^2 \) to range reduce so that x ≤ 1.

Then it uses the Maclaurin series which will converge very quickly.

- Pauli
Find all posts by this user
Quote this message in a reply
06-15-2017, 04:52 AM
Post: #35
RE: AriCalculator is a home made pocket calculator.
Very nice, thank you Nigel and Pauli.

This gives me quite a bit to work with. I like the idea of using e^x = (e^x/2)^2 to reduce the range to [-1,1] and then squaring the result repeatedly. I wonder why they use e^-x = 1/e^x to change the sign?

I've heard of the CORDIC method but don't know much about it - it would be interesting to compare the two methods using the microcontroller's timer.

The software is 100% assembly and it's been quite a challenge to write the floating-point routines but it's a little easier now that the four basic functions addition, subtraction, multiplication and division are done, e.g factorial was written relatively quickly.

I finally got my hands on a smartphone (a friend upgraded and gave me her old one) and I must say I'm impressed by the camera's resolution. I also discovered Windows Movie Maker. This has inspired me to think of creating a series of videos on this project for anyone that would like to build their own calculator - let me know if there is any interest. You can build the prototype version easily using off-the-shelf components (4x4 matrix keypad, breadboard, S12G development board, ST7565 GLCD and 0.1" connectors). You may need to solder pins onto the ST7565 GLCD (like the Adafruit one I am using) but it's easy through-hole soldering. The disadvantage is you don't have that many keys and it's not portable.

Or you can build Dirk's fantastic hand-held version, the AriCalculator (see his website). He kindly built me one so I can't comment on how difficult it is but there is fine-pitch soldering involved (which Dirk assures me is not that hard provided you can see what you are doing). You can program it using the S12 development board and the free CodeWarrior IDE (no time or program size limits for assembly). Dirk also provides plans for a debugger he built and has written his own assembler. Pretty amazing stuff - check out his website for details.

Our goal is to create a completely open source calculator and I'll post the code for software version 1.3 in about a month. This version includes the four basic functions, factorial, square root (using Newton's/Babylonian method) some basic stack operations and the ability to view the contents of the stack memory (8 byte 10's complement BCD mantissa and 1 byte binary exponent).

Clive Maxfield wrote a great book on algorithms for the four basic functions ("How computers do math"), but it only deals with integers and I couldn't find anything that looks at floating-point numbers in similar detail. As we approach the 50th anniversary of the hand-held calculator I'm surprised there isn't more out there. Is this because manufacturers have been secretive in the past about the algorithms they used? Surely this still can't be the case in these changing times. Maybe it's because assembly language varies from one chip to the next, but the difficult part for me wasn't the coding (even though debugging can be a real pain) but developing efficient algorithms. All one needs is pseudo-code.
Find all posts by this user
Quote this message in a reply
06-15-2017, 07:35 AM
Post: #36
RE: AriCalculator is a home made pocket calculator.
(06-15-2017 04:52 AM)Dan Wrote:  I wonder why they use e^-x = 1/e^x to change the sign?

My initial thought would be due to accuracy issues, with x < 0, the series alternates in sign. I've seen the same thing done in other implementations of \( e^x \).

You might want to consider using \( e^x = { \left( e^{\frac{x}{10}} \right) }^{10} \) since you are working in base ten. It would also be possible to reduce the threshold below 1, this will increase the rate of convergence of the series expansion, i.e. reduce x until \( x < \frac{1}{10} = x_{max} \) or even smaller. It becomes a balancing act between the costs of the preprocessing and the series computation. Accuracy loss can also come into play, so verify the algorithm on a desktop computer first.

You'll want to carry more digits than the result and ideally compute the series backwards using Horner's method. This means estimating the number of terms required in advance -- the worst case will be \( x = x_{max} \) and since the first term in the expansion is 1, you'll need an n such that \( 1 + \frac{{x_{max}}^n}{n!} \) stays 1.


Pauli
Find all posts by this user
Quote this message in a reply
06-15-2017, 07:38 AM
Post: #37
RE: AriCalculator is a home made pocket calculator.
(06-15-2017 04:52 AM)Dan Wrote:  This version includes the four basic functions, factorial, square root (using Newton's/Babylonian method) some basic stack operations and the ability to view the contents of the stack memory (8 byte 10's complement BCD mantissa and 1 byte binary exponent).

Once you have the natural logarithm implemented, the gamma function could replace factorial.


Pauli
Find all posts by this user
Quote this message in a reply
06-15-2017, 08:42 AM
Post: #38
RE: AriCalculator is a home made pocket calculator.
(06-15-2017 04:52 AM)Dan Wrote:  Clive Maxfield wrote a great book on algorithms for the four basic functions ("How computers do math"), but it only deals with integers and I couldn't find anything that looks at floating-point numbers in similar detail.

There are quite a few things floating around the internet and in print. The last message on the first page of this thread lists some of the books I've found useful. The link to Kahan's site is invaluable for background. Also add in Knuth's Seminumerical Algorithms.

The WP 34S codebase implements a lot of decimal floating point functions. Other places to look are the source code for the GNU C library, the R statistics package, GNU's bc, the Cephes library -- these are all binary floating point based. The Intel decimal library is good but the algorithms aren't suitable for small processors (table based / using binary floating point functions as estimates).

CASIO's Keisan online calculator is good for checking results as is Wolfram's Alpha (by default it limits floating point accuracy which has caught me out).


- Pauli
Find all posts by this user
Quote this message in a reply
06-21-2017, 03:54 AM
Post: #39
RE: AriCalculator is a home made pocket calculator.
Thanks Pauli, my code for sqrt (A), using x(n+1) = 0.5(xn + A/xn) takes about 3/4 of a second so I'll try to improve the assembly routines for the four functions. The method itself converges quickly - 5 iterations gives me 15 decimal accuracy. The numbers are converted to binary for multiplication/division and then back to BCD for rounding and addition/subtraction, so it's expensive. I'm using the "shift and add" method and may be able to improve things further if I use the assembly multiplication and division instructions.

What you have done with the WP 34S is absolutely awesome.
Find all posts by this user
Quote this message in a reply
07-01-2017, 04:09 AM
Post: #40
RE: AriCalculator is a home made pocket calculator.
I've started to implement keystroke programming for version 1.4. I am inspired by the 1980's Canon F-73P and Elektronika MK-61. I will dedicate 4096 bytes for the program code and 18 memory registers (each 9 bytes in length) for storage of constants and for use in indirect branching. Instructions will be either 1 byte, 2 bytes or 3 bytes in length and stored in RAM with the option to copy to EEPROM or FLASH.

Programs will be entered by pressing the appropriate key on the keypad or by typing in the codes, and can be viewed by scrolling the screen. I am hoping to use keystroke programming to write and test algorithms for the remaining mathematical functions on the actual calculator, which will be a nice break from assembly coding on a laptop and will enable me to reuse code if we move to a different architecture in the future.

I would really like to hear people's thoughts on keystroke programming. I imagine it's best for small programs but perhaps larger programs could be written with it given a rich instruction set and use of subroutines, and the ability to edit programs.
Find all posts by this user
Quote this message in a reply
Post Reply 




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