Help with A/D math!


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Jul 2010
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Alain,

    Wow, works like a charm... now can you tell me how you got to those numbers? <grin>
    I'm sure when I install this in the field I will have different numbers, so I will need to know how to recalculate.

    You are a lifesaver!

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dbodenheimer View Post
    Alain,

    Wow, works like a charm... now can you tell me how you got to those numbers? <GRIN>
    I'm sure when I install this in the field I will have different numbers, so I will need to know how to recalculate.

    You are a lifesaver!

    Dave
    Very simple, Dave ... no miracle !

    just need to check what is PBP compatible , as an operation, and avoiding any overflow when calculating ...

    Have a look here ...
    http://curveexpert.webhop.net/

    really a very handy tool

    Alain
    Last edited by Acetronics2; - 20th August 2010 at 18:43.
    ************************************************** ***********************
    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
    Jul 2010
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Got the tool. Yes it looks very handy!
    Can you tell me the setup you used to calculate the data i sent?

    I want to make sure i understand how to set things up

    Thanks!

  4. #4
    Join Date
    Jul 2010
    Posts
    1


    Did you find this post helpful? Yes | No

    Lightbulb

    Enter data into “CurveExpert” chart:

    X is distance, Y is A/D data

    Select ‘Apply Fit”, select ‘Linear” from drop down menu.

    A graph will pop up, press the ‘info’ button and you’ll get your equation and the coefficients to use.


    I will never admit how long that took me to figure out.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lavenatti View Post
    I will never admit how long that took me to figure out.
    Hi, Lavenatti

    Quite Easy to believe...

    Didn't you just swap here input and output values ???

    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 " !!!
    *****************************************

  6. #6
    Join Date
    Mar 2011
    Location
    Bangkok Thailand
    Posts
    16


    Did you find this post helpful? Yes | No

    Default Re: Help with A/D math!

    Hello
    This was very interesting. I have a little bit of the same problem.
    I have A/D input 0-5V (0-255)

    I want a puls out 0V=1mS and 5V=2mS.

    If i take your example with the Laser and run it in CurveExpert i got the formula a-bx.

    Where did you get 8573 and 41 from, and what is + ( AdResult / 2 ) means?
    distance = 8573 + 41*AdResult + ( AdResult / 2 )

    Any help will help.

    Name:  bild2.gif
Views: 960
Size:  52.2 KB

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Help with A/D math!

    Hi,
    How about:
    Code:
    ADResult = ADResult * 10
    DelayInMicroSeconds = 1000 + (ADResult */ 100)
    PortB.0 = 1
    PauseUs DelayInMicroSeconds
    PortB.0 = 0
    When ADResult is 0 DelayInMicroSeconds is 1000 (1ms), when ADResult is 128 you'll get 1000 + (1280 * 100 / 256) = 1500 and when ADresult is 255 DelayInMicroSeconds is 1000 + (2550 * 100 / 256) = 1996.

    It's not perfect but hopefully good enough.

    /Henrik.

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