Complex math on 16F series?
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2013

    Default Complex math on 16F series?

    d = 1 / ((x1 - x2) * (x1 - x3) * (x2 - x3));
    a = d * (x1 * (y3 - y2) + x2 * (y1 - y3) + x3 * (y2 - y1));
    b = d * (x1 * x1 * (y2 - y3) + x2 * x2 * (y3 - y1) + x3 * x3 * (y1 - y2));
    c = d * (x1 * x2 * y3 * (x1 - x2) + x1 * x3 * y2 * (x3 - x1) + x2 * x3 * y1 * (x2 - x3));
    y(x) = a*x*x + b*x + c
    Hello, there is some math to be done to calculate polynomial smoothing points. Fragment of code is shown above. X and Y will be in range of 100-900.
    If I understand correctly, there is no way to calculate that on 16F core and need to go for 18F core, right?

  2. #2
    Join Date
    Jan 2006

    Default Re: Complex math on 16F series?

    Check this one first:

    and then check this one second:

    or reverse the order.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Feb 2013

    Default Re: Complex math on 16F series?

    Thanks, I will consider it (though I have not yet understood how to use it). I'm also considering moving to 18F core or pre-calculating these data and storing them in external EPROM.

  4. #4
    Join Date
    Aug 2003

    Default Re: Complex math on 16F series?

    You can do just about any math you have the RAM for, and display a result, but the real question is what you want to do with the result.
    You’ll probably still need a result value that fits into a PBP variable to get PBP to do anything further.
    Aside from that, variable types are just arbitrary allocations of RAM, that also tell the compiler how to treat it.

    For the problem you posted it looks as though the result would overflow a 16 bit word.
    I don’t understand the desire to push shit uphill though, unless it was just for a challenge.
    For XC16 free compiler, that problem would drop straight in to the compiler and be valid (with the forgotten semicolon on the last line).

    If you’re going to say C is hard, it’s not harder that what you’re about to try, if you are going to make your own arbitrary variable types.

  5. #5
    Join Date
    Feb 2013

    Default Re: Complex math on 16F series?

    This is polynomial interpolation, designed to smooth out camera slider movements. User enters 3 sets of X and Y data and then slider moves along these points. As long as input variables are in 100-900 range, so will be the output ones, which perfectly fit into WORD variable I guess.

Similar Threads

  1. Replies: 12
    Last Post: - 29th May 2019, 11:00
  2. Replies: 2
    Last Post: - 31st October 2017, 17:04
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 26th January 2010, 12:56
  4. how large and complex firmware you design using pbp?
    By chrdcv in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 22nd December 2008, 00:30
  5. Upgrading 16F to 18F
    By Ron Marcus in forum General
    Replies: 1
    Last Post: - 29th March 2006, 09:44

Members who have read this thread : 17

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