12 bit A2D on 18F46K80, need a bit of help for figuring TAD and getting correct value


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,622


    Did you find this post helpful? Yes | No

    Default Re: 12 bit A2D on 18F46K80, need a bit of help for figuring TAD and getting correct v

    Hi Steve,

    On paper, Result = X * 3 is the same as Result = X+X+X, right?
    If the above is correct then Result = X * 1.5 is the same as Result = X + (X/2), right?
    And if we agree that the above is correct then I think we'll agree that Result = X + (X*0.5) is the same as Result = X * 1.5 too?

    Same thing with the formula in the previous message but the number is 1.5464 instead of 1.5.

    Again, ideally, we would want to do Result = ADValue ** 101345 (where 101345 is 65536*1.5464) but that will result in a compile time error if LONGs aren't enabled (because 101345 is larger than 65536 so there's a risk of overflowing the 32bit intermediate result thus returning the wrong value) so we resort to first calculating what 0.5464 is and then add that to the original value, exactly as we did in the example above.

    Don't worry, I'm sure you'll get it!

    /Henrik.
    Last edited by HenrikOlsson; - 22nd May 2014 at 20:47.

  2. #2
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default Re: 12 bit A2D on 18F46K80, need a bit of help for figuring TAD and getting correct v

    Henrik-
    Its probably a good thing you are not in Texas cuz your ears would be ringing over the loud 'Aha!' that I just said - Now I need to check my bathwater -(bad reference to Archimedes <grin>).
    I think I can now see the light, just needed help with the switch......
    Thanks Bud,
    Steve
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

Similar Threads

  1. How do I use 10 bit A/D on 8 bit Pic? 12F675
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 1st April 2020, 21:10
  2. Replies: 1
    Last Post: - 13th March 2012, 00:34
  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, 23:18
  4. LCDOUT 4-bit data on 8-bit setting
    By breesy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 26th June 2006, 19:39
  5. Help 14-bit and 16-bit Core
    By jetpr in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th September 2005, 04:29

Members who have read this thread : 0

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