+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2005
    Location
    Loveland CO USA
    Posts
    83

    Thumbs up PIC18Fxx math 24 & 32 bit

    I am working on a DSP project. I need more speed.
    I converted from PIC16F to PIC18F and that helped!! (8bit * 8 bit)
    I am looking for ASM code for PIC18F math (24 & 32 bit) *,-,+,/, shift
    I have PIC16F math but cannot find 18F libraries.

    MicroChip thinks I should convert to C but I want to stay with PBP for everything but the ‘fast math loop’. PBP has very good IO.

    Thanks

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,532

    Wink

    Hi Ron

    Nothing Here ??? : http://www.melabs.com/resources/fp.htm

    ...

    But µChip is right ... Power, exp and "complex" ( laughs ...) mathematics are easily supported by C ... or other Basic Compilers.
    Basic is a fair language ... but it takes its time ... may be a Swiss or Belgian invention ???

    Alain
    Last edited by Acetronics2; - 30th November 2006 at 15:27.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Feb 2003
    Posts
    428

    Default

    Quote Originally Posted by Acetronics
    Basic is a fair language ... but it takes its time ... may be a Swiss or Belgian invention ???
    So thats what BASIC stands for....

    Belgians And Swiss Invented Code
    Keith

    www.diyha.co.uk
    www.kat5.tv

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    There's no need to switch to C or else language for 24bit maths IF YOU WANT to spend some time in the code development. There's tons of example here and there (most in assembler but anyways).

    Depending what you need to work with trigs (sin cos tan.... ) Biquad eqs? FFT?

    Question is always the same.... do you reallly need to use those maths? They're always slow and code inefficient anyways.
    Last edited by mister_e; - 1st December 2006 at 03:23.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Oct 2005
    Location
    Loveland CO USA
    Posts
    83

    Default RMS math

    I can find “tons of examples” in PIC16 and smaller! I can not find any thing in PIC18F.
    There are many web hits on PIC18F math but it is all PIC16F and smaller.

    I am trying to find the RMS value of 4 audio streams.
    I have it running on a bigger computer.
    Read in ADC(9:0) 10 bits.
    Absolute value(7:0) 8 bits. Loose the sign and drop one bit.
    Square ADC^2(15:0) 16 bits
    Output(23:8)=Output-from last time(23:0)-((Output(23:8)-ADC^2(15:0))/256)
    Convert to db.

    I have the convert to db happening very fast.
    The Square is fast on the PIC18F. very slow in the PIC16
    The average formula finds the e^-t average just like a Resistor Capacitor finds the average. How does it work? Compare input value to the average form last time. We are only concerned with the difference. The difference is divided by some amount (that is the time constant 256) and subtracted from the average. In this type of averaging recent samples greatly effect the output, but averages hundreds of samples ago have only a little effect. (and it takes up very little RAM)
    It takes no code to divide by 256. Actually I want to divide by 1024 but I think there is no time to do the shifting. There is a 24 bit – 16 bit that is hard to do in PBP.
    I coded part of it in PBP and looked at the output. PBP spends a lot of time moving the variables to temp, calling a subroutine, and moving the variables back from temp, then turning around and moving the same variables back into temp for the next call subroutine.

    I am trying some nasty games like:
    AverageUpper= bits 23:8 while AverageLower= bits 15:0 of the same 24 bit number. Using overlapping memory space. That way I can use the 16 bit math in PBP.

    Considering the speed problem I should use assembly. I had it running on a PIC10 in assembler, just for a joke. If a PIC10 running 4mhz with no multiply can do the job s-l-o-w-l-y, then it should run in a PIC18 at 40mhz.

    I want to keep PBP for the LCD and IO functions.

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,532

    Wink reinventing the wheel ....

    Hi, Ron

    There are tons of dedicated circuits, able to do that ... I think to SSM "squad", i.e.

    after, you do what you want as kind of numeric treatment ...

    Why use the Phoenix missile ... for killing a little fly.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695

    Default

    Hi Alain,

    Niklaus E. Wirth a Swiss computer scientist was the chief designer of the
    programming languages Algol W, Pascal, Modula, Modula-2, and Oberon.

    * * *

    Jean Ichbiah (Members of the French Academy of Sciences) was the chief
    designer of the ADA programming language, from 1977–1983. At the time,
    he was a member of the Programming Research division at CII Honeywell
    Bull (CII-HB) in Louveciennes, France.


    Famous code written in ADA:
    http://www.ima.umn.edu/~arnold/disasters/ariane.html

    http://www.rvs.uni-bielefeld.de/publ...riane5rep.html

    Best regards,

    Luciano

  8. #8
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517

    Smile

    Have you seen this? (I am not sure it has what you want)

    http://www.piclist.com/techref/membe...athsdefs_h.htm

    Also, you might want to post your ASM request here

    http://forum.microchip.com/tt.aspx?forumid=7

    Many strong ASM programmers visit this mirochip site.

    Good Luck,
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,532

    Talking Bad Example !!!

    Quote Originally Posted by Luciano
    Famous code written in ADA:
    http://www.ima.umn.edu/~arnold/disasters/ariane.html

    Best regards,

    Luciano
    I' ve seen the word DISASTER somewhere in your link ... didn't I ???

    hi,hi,hi ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. 32 bit math
    By fnovau in forum General
    Replies: 4
    Last Post: - 12th February 2008, 23:55
  2. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  3. Averaging 16 bit values without using 32 bit math
    By sirvo in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th October 2007, 22:18
  4. 32 bit math
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 28th August 2006, 13:34
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts