Post Reply 
AriCalculator is a home made pocket calculator.
10-30-2018, 06:43 AM
Post: #81
RE: AriCalculator is a home made pocket calculator.
I've read a document somewhere that explains how CORDIC can be used to do pretty much everything except hang the washing out. Regardless, I used straightforward long multiplication and long division and a nifty algorithm that gets you a digit of precision for each iteration to calculate sqrt(x).

CORDIC got me sin/cos and I just divide one by the other to get tan. I have a good algorithm that uses 1+10^(-i) constants for exp(x) and ln(x) but have found a way to get sinh/cosh & co. using CORDIC so will no doubt use that.

Results are encouraging. I'm using a DM42 to calculate the constants I need and to check my results. I'd be stuffed if I didn't have that starting point Smile

For now I'm just using the standard gcc toolchain in 64-bit Linux and producing a static library that I'm linking to a test program to obtain/test results. When the time comes to start testing on LPC1115 hardware, I'll be using the ARM-embedded toolchain. It's the same one as for the DM42.
Find all posts by this user
Quote this message in a reply
10-31-2018, 07:53 AM
Post: #82
RE: AriCalculator is a home made pocket calculator.
That's great, sounds like a really cool project. I use the microcontroller's timer to compare algorithms, so if you ever document the ones you are using I would be interested in trying them out.
Find all posts by this user
Quote this message in a reply
10-31-2018, 08:06 AM (This post was last modified: 10-31-2018 09:45 AM by grsbanks.)
Post: #83
RE: AriCalculator is a home made pocket calculator.
The library will be fully open source once I'm satisfied that it's working properly. I'm writing it in C that's as portable as I can make it so it should work on pretty much any 32- or 64-bit system.

As far as usage is concerned, this small test program in C is linked to the library:

Code:
#include <stdlib.h>
#include <stdio.h>

#include "decfp.h"

void prt(_NUM*);

int main(int argc, char** argv) {
    
    _NUM x, sn, cs, tn;

    RealToNum(&CONST_PI_2,&x);
    prt(&x);
    NumSinCos(&x,&sn,&cs);
    NumScaleTrigVector(&sn,&cs);
    prt(&sn);
    prt(&cs);
    
    Setting_ErrorOnOverflow = TRUE;
    /* NumTan does this anyway */
    DECFP_ERR res = NumDivide(&sn,&cs,&tn);
    if (res)
        printf("ERROR: %s\n",ErrorMessage(res));
    else
        prt(&tn);
    
    Setting_ErrorOnOverflow = FALSE;
    res = NumDivide(&sn,&cs,&tn);
    if (res)
        printf("ERROR: %s\n",ErrorMessage(res));
    else
        prt(&tn);

    NumNegate(&x,&x);
    
    NumSinCos(&x,&sn,&cs);
    NumScaleTrigVector(&sn,&cs);
    prt(&sn);
    prt(&cs);
    
    Setting_ErrorOnOverflow = TRUE;
    res = NumDivide(&sn,&cs,&tn);
    if (res)
        printf("ERROR: %s\n",ErrorMessage(res));
    else
        prt(&tn);
    
    Setting_ErrorOnOverflow = FALSE;
    res = NumDivide(&sn,&cs,&tn);
    if (res)
        printf("ERROR: %s\n",ErrorMessage(res));
    else
        prt(&tn);
    
    return 0;
}

void prt(_NUM* x) {
    char* bfr = NumOutFullPrecision(x);
    printf("%s\n",bfr);
    free(bfr);
}

Gives this output:

Code:
$ bin/decfp
+1.57079632679489661923132e+0000
+1.00000000000000000000000e+0000
+0.00000000000000000000000e+0000
ERROR: Divide by zero
+9.99999999999999999999999e+9999
-1.00000000000000000000000e+0000
+0.00000000000000000000000e+0000
ERROR: Divide by zero
-9.99999999999999999999999e+9999
Find all posts by this user
Quote this message in a reply
11-01-2018, 04:11 AM
Post: #84
RE: AriCalculator is a home made pocket calculator.
(10-31-2018 08:06 AM)grsbanks Wrote:  The library will be fully open source once I'm satisfied that it's working properly.

Way to go, same here.
Find all posts by this user
Quote this message in a reply
02-20-2019, 06:39 AM
Post: #85
RE: AriCalculator is a home made pocket calculator.
I have finished porting the firmware to the S12XEP100. I made several changes to the keypad, including adding an extra row of 6 buttons:

[Image: AC-IIKPJP_zps8vhpzuou.jpg]
Find all posts by this user
Quote this message in a reply
03-13-2019, 05:58 AM (This post was last modified: 03-13-2019 06:18 AM by Dan.)
Post: #86
RE: AriCalculator is a home made pocket calculator.
And here it is, two years in the making, the absolute assembly file for a scientific, keystroke programmable RPN calculator (click on "View Raw").

I've started rewriting the code in C++ for the TI Tiva-C LaunchPad, which features a 32-bit ARM Cortex-M4F CPU.

It can be programmed using TI's free Code Composer Studio, which is available for Windows, Mac OS and Linux.

[Image: Tiva_zpsfjmp8taw.jpg]
Find all posts by this user
Quote this message in a reply
03-13-2019, 08:30 PM
Post: #87
RE: AriCalculator is a home made pocket calculator.
If you have a Mac, do not be in too much of a rush to get CCS. Version 9, which will be fully 64-bit on the Mac, will be out in a few weeks to a month.

Commercial:
CCS and the TI launchpads are a great way to get into Arduino-like embedded hobbying. The SimpleLink boards incorporate a radio transceiver and an MCU for low cost wireless applications.
Find all posts by this user
Quote this message in a reply
Post Reply 




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