Close
0%
0%

Scientific Calculator

An ARM based scientific calculator

Similar projects worth following
This is a basic open source scientific calculator. I started this project more than a year ago when I was looking to buy a graphing calculator. But since I did not need one (There are better options, like Desmos), I decided to invest that money into this project because I wanted to put into practice what I had been learning.

The main challenge of this project is building a calculator that can be reliable and compete directly with other professional calculators.
The first version of the calculator (see the first Log) used an ATMega328p, big components and home-made PCBs. The result of this was a bulky calculator, a high power consumption and a low precision for the calculations (8-bit microcontroller).
To achieve what I had in mind, I've used an ARM Cotex-M0+, which has a small power consumption, SMD components (except the LCD) and a custom PCB to achieve a small form factor.

I hope this will be seen as an open alternative to most common scientific calculators when I finis

What the calculator can do at the moment:

  • Add, subtract, multiply, divide.
  • Square root, nth root, exponentiation.
  • Trigonometry: sin, cos, tan with their respective inverse functions (working with degrees, radians and gradians).
  • log10 and log.
  • Factorial
  • x10^

To do:

  • Low power (need to change PCB layout, maybe in future design?)
  • Constants menu
  • Splash screen intro
  • Graphing mode (basic explicit functions)

Known bugs:

  • Syntax error when two or more unary operators are put together.
  • Cursor may not be in correct position after making a line leap
  • Crashes when result is bigger than 16 digits

SciCalc-KiCAD.zip

The schematic and PCB layout

Zip Archive - 958.67 kB - 02/22/2017 at 14:46

Download

  • 1 × MKL25Z128VLK4 ARM Cortex-M0+ (80-pin LQFP) Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 1 × Electronic Assembly DOGL-128 128x64 low power LCD
  • 10 × 1uF Capacitor
  • 2 × 22pF Capacitor
  • 1 × 8 MHz Crystal

View all 8 components

  • How to program the calculator using a KL25Z board

    Ramón Calvo10/15/2017 at 17:45 1 comment

    Once the calculator is mounted, we no longer can program the MCU from a USB interface. To solve that inconvenience, we need to prepare the KL25Z so it can act as an SWD programmer. The theory is simple, disconnect the internal SWD to the KL25Z's MCU and connect it directly to the calculator's.

    To isolate the MCU from the SWD interface, we need to cut J11, according to the manual.

    KL25Z SWD
    Credit to mcuoneclipse.com

    And now we need to solder the male 1.27mm 2x5 pin headers so we can use a cable to connect the programmer and the calculator.

    To program the calculator, since we are still using mbed's firmware, we can just drag and drop the files over USB, or as I do, use PlatformIO to automatically upload it.

  • Migrating project to PlatformIO

    Ramón Calvo10/12/2017 at 20:31 0 comments

    I haven't been updating this project for a while. One of the reasons was the messy mbed online IDE. The larger the code, the slower the response of the browser. But lately I've been tinkering with Atom and discovered the plugin PlatformIO. PlatformIO has lots of development boards already configured and it worked almost out-of-the-box. The good thing about this is that now I can edit the code and compile anywhere with no need of the Internet. Also, from now on I will publish the source code on GitHub.

    The migration was done 'by hand'. I couldn't find any export option in the mbed IDE that matched the configuration PlatformIO used. However this was not difficult and was done in under 5 min.

    Also, if you want PlatoformIO to flash the KL25Z directly, change the upload_port in platformio.ini to this (make sure the board is mounted):

    upload_port = /run/media/"user"/FRDM-KL25Z/ 
    

  • Releasing schematic and source code

    Ramón Calvo02/22/2017 at 15:45 0 comments

    About the circuit:

    • A day after I ordered the PCBs I realized I had forgotten to put a power switch on the board. I thought maybe using sleep modes and wake-ups by interrupts I could solve that problem but to my disappointment the MKL25Z only has interrupts in ports A and D, and I connected the keypad to B and C. Because of this the calculator powers on and off putting in and taking the battery out (sighs).
    • I also forgot to design a reverse voltage protection circuit, which combined with the previous problem becomes a great danger.
    • If you want to replicate the PCB please make sure that the silkscreen doesn't overlap the SWD programming interface (very important)

    About the code:

    The library used to drive the LCD was made by [imachooon]. Thank you for your library [imachooon].

    The code is not finished at the time of writing (and probably won't be for a long time) and can present some bugs, but it works.

  • A summary of almost a year

    Ramón Calvo02/17/2017 at 22:49 2 comments

    I started this project in February of 2016, but it hasn't been a continuous work, here is a summary:

    The first problem I encountered making the calculator was obviously the parsing. Being unable to come up with a solution, a quick Google search led me to something called Reverse Polish Notation and a sweet algorithm invented by Edsger Dijkstra called shunting-yard algorithm. Explaining all of this in detail is beyond the scope of this text, but to understand it, RPN gets rid of every parenthesis and makes it easy to make the calculation (with the shunting-yard algorithm). More about that here: Shunting-yard algorithm and RPN.

    The above, combined with the keypad, were the 'funny' thing to program. The rest was a bit tedious. I also have to say that originally this was an Arduino project, but I didn't quite liked the result, it needed a 9V battery, wasn't low power at all and was bigger than my hand. And also didn't have much precision (32-bit float).

    That's why I decided to move to mbed, specifically to the Freescale's Freedom KL25Z development board. So I ported the code I had and made a working prototype. Everything went fine but when I tried to get the voltage doubler of the st7920 LCD driver to work I couldn't (that meant I couldn't get the needed voltage for contrast out of a 3V coin cell). That was in July of last year and I gave up. The project had remained in a shoe box for six months until I decided to bring it to an end.

    I bought a new LCD and designed the PCB using KiCAD. I got the PCBs manufactured by Elecrow. It was the first time I ordered any PCB but I can say they are very good quality. The bad part was the delivery time (about 25 days).

    Although I don't own a soldering station I managed to solder the microcontroller with a cheap soldering iron and a thin tip pin by pin (with the help of a magnifier, of course). SMD was something I had a lot of respect before that day. I finally understand those who say it is even easier than through hole (I mean it's not easier but also you don't need that much experience).

    I may have skipped some important steps but that's it. This is a big summary of my year-long (and not yet finished) journey.

View all 4 project logs

Enjoy this project?

Share

Discussions

Garth Wilson wrote 05/13/2017 at 19:12 point

How many digits of precision are you using, and what methods are you using for the trig and log functions, whether CORDIC or the first so many terms of the Taylor series with the coefficients adjusted to make up for the smallish number of terms?  Have you tested the accuracy?  I have yet to see an explanation of CORDIC in English (rather than sterile, theoretical math Ph.D. language) but it looks like you still need an iteration for every bit or digit as you advance toward an answer, using a smallish lookup table at every step.  I would like to understand it.  I have Jack Crenshaw's book, "Math Toolkit for Real-Time Programming," but he never mentions CORDIC.  Real time tends to need the best performance.

  Are you sure? yes | no

Ramón Calvo wrote 10/12/2017 at 20:38 point

Hi Garth. The calculator is able to achieve 16 digits of precision.

For the trig and log functions I'm using C's standard libraries. I thought the trig functions were calculated using Taylor's series, I did not know the existence of CORDIC, I'll look it up.

I'm sorry I replied late and couldn't help you.

  Are you sure? yes | no

EngineerAllen wrote 04/27/2017 at 07:46 point

that capacitor on the back

  Are you sure? yes | no

Max.K wrote 04/20/2017 at 19:14 point

This is an awesome project! I love how the finished pcb with the green display looks like.

  Are you sure? yes | no

Michael Fincham wrote 02/28/2017 at 03:17 point

Hello! Could you please clarify what license the code and design files are available under?

  Are you sure? yes | no

danjovic wrote 02/22/2017 at 20:47 point

Awesome build! 

  Are you sure? yes | no

James Hall wrote 02/22/2017 at 16:54 point

The design of this reminds me of a Pocket Operator. I'm glad to see someone working on an DIY scientific/graphing calculator. 

  Are you sure? yes | no

Ted Yapo wrote 02/22/2017 at 16:02 point

I want to make an RPN version!

  Are you sure? yes | no

zakqwy wrote 02/21/2017 at 16:05 point

Great silkscreen graphics!

  Are you sure? yes | no

Ramón Calvo wrote 02/22/2017 at 15:59 point

Thank you! Fractals rule!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates