When I began this project I wasn't sure how much I could fit into 16kB of firmware space. The settings page also shows the current battery charge. After setting the accuracy, the program finds the largest element in the CORDIC table that is still significant, so that no time is wasted on elements that have no effect on the answer. With 32 decimal places calculations take 3-4 seconds. ![]() With the default of 12, trig functions calculate in about a second. The settings page allows the accuracy to be set from 6 to 32 decimal places. After setting accuracy to 24 places arcsin(arccos(arctan(tan(cos(sin(9)))))) evaluates to this: One way to measure the accuracy of calculations is with the calculator forensic found here. I was able to speed the shifting up even more by using another lookup table that let me right shift 4 digits at a time. Instead, a lookup table is used with adds and shifts, which are much faster. This is a very efficient way to compute these functions for processors that cannot multiply or divide quickly. Before processing void puts ( unsigned char *msg)The trig and log functions are computed using CORDIC routines. These are usually ignored by the compiler if they are not recognized, so they are a convenient way to communicate with the preprocessor. To mark variables as external, #pragma directives are used. External variables are all stored as pointers, so the PC version will work exactly the same with or without the preprocessor. A simple equation like: X+=Y*Z-Q would become something like this (assuming we are passing pointers): RAM_Write(X,RAM_Read(X)+(RAM_Read(Y)*RAM_Read(Z)-RAM_Read(Q)) To simplify things, I wrote a preprocessor program that looks for any variables that need to be stored in external RAM and converts access to them to function calls. I wanted to access this memory using variables but there is no convenient way to do this since every variable requires a function to access it. On Windows:gcc -o rpncalc.exe rpnmain_pc.cOn Linux:gcc -lncurses -o rpncalc rpnmain_pc.cNumbers are stored in unpacked BCD format on an external SRAM chip. You can download it from GitHub if you want to test out the functionality: rpnmain_pc.c It will compile for Windows if #WINDOWS is defined or for Linux with the ncurses library if #LINUX is defined. While I was writing the code for BCD calculations, I used a console program to test the routines. The interface shows 4 levels of the stack, similar to some HP calculators. Functions: (a)sin, (a)cos, (a)tan, y^x, x root y, e^x, ln, 10^x, log, mod. ![]() Internal accuracy configurable from 6 to 32 decimal places.Note: Also available as a Chrome "packaged app" (seamlessly integrates into your ChromeBook or desktop environment and can also be invoked from the desktop menu and/or from a desktop icon (like a standalone app)) - the "packaged app" version will be available as soon as the Chrome Web Store allows.This is a scientific calculator I built that uses RPN notation. This app runs offline i.e., the Chrome browser does not have to be running for the app to run, nor is a connection to the internet required. The screenshot image shows the basic and scientific operators currently available these include plus, minus, multiply, divide, square root, square, y^x, sin, cosine, tangent, natural logarithm and pi. ![]() Thus, there is *NO* equals key ("=") as it is never needed (for more see ). NOTE: For those looking for a regular calculator, this calculator works differently! To use an RPN calculator to add 2 and 3 together, you enter '2' then the 'ENTER' key then '3' and finally '+' to get your answer (whereas in a regular calculator you enter '2' then '+' then '3' then '='). You have the choice of using the keyboard or the UI buttons for input (touch screen capable where supported). RPN Calculator is a simple yet powerful calculator that uses Reverse Polish Notation as the basis of its operation (in RPN, every operator follows all of its operands). A simple RPN calculator application opens in a popup window.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |