+ Reply to Thread
Results 1 to 12 of 12

Thread: AD - Converter calculations ?

  1. #1
    NetDevil Newbie
    Join Date
    Mar 2009
    Posts
    11

    Default AD - Converter calculations ?

    Hey guys i was wondering if you could help me out with my calculations.

    I'm currently working on a project were we use an ultrasonic sensor to measure distance and later will convert to speed. the output from this is equal to 9.8 mV per inch.

    We are using a 10bit AD-converter and we have chose to only read the 8 MSB. and now comes my problem: how do i calculate the output from the ADC to the actual distance?

    my reference voltage is 2.5V

    I really hope you can help me because i'm stuck(Brain freeze).


  2. #2
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,793

    Default

    You've just said that the sensor provides 9.8mV per inch, so 98mV will be 10 inches, 980mV will be 100 inches and so on.

    I suspect you will need to amplify the sensor output to give the best resolution you want it amplifying to 2.5V at the maximum range you want.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  3. #3
    NetDevil Newbie
    Join Date
    Mar 2009
    Posts
    11

    Default

    Quote Originally Posted by Nigel Goodwin View Post
    You've just said that the sensor provides 9.8mV per inch, so 98mV will be 10 inches, 980mV will be 100 inches and so on.

    I suspect you will need to amplify the sensor output to give the best resolution you want it amplifying to 2.5V at the maximum range you want.
    Yes but i want to use the AD-converter result i.e. 37(decimal) at aprox 82 inches - to later on convert to speed. i guess my problem is that i don't understand the result from the conversion.

  4. #4
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,709
    Blog Entries
    5

    Default

    Which compiler are you using?
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

  5. #5
    NetDevil Newbie
    Join Date
    Mar 2009
    Posts
    11

    Default

    Which compiler are you using?
    Im using hitech and im programming pic16f887
    Last edited by NetDevil; 14th May 2009 at 06:00 PM.

  6. #6
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,793

    Default

    Quote Originally Posted by NetDevil View Post
    Yes but i want to use the AD-converter result i.e. 37(decimal) at aprox 82 inches - to later on convert to speed. i guess my problem is that i don't understand the result from the conversion.
    Have a read of my analogue PIC turopial which explains it a bit.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  7. #7
    NetDevil Newbie
    Join Date
    Mar 2009
    Posts
    11

    Default

    Quote Originally Posted by Nigel Goodwin View Post
    Have a read of my analogue PIC turopial which explains it a bit.
    Thank you but i think i understand the basict with the resulution and such. but its just my result that makes me doubt.

    Can it be because i don't take account the two LSB? i mean when measuring at aprox 1/3 of its range it gave me 37 and i just don't understand why when i have a 10 bits AD-Converter i mean shouldn't it give me 1/3 of 1024?.
    Last edited by NetDevil; 14th May 2009 at 06:18 PM. Reason: Avoid doble post

  8. #8
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,709
    Blog Entries
    5

    Default

    What's the maximum range you'd like to measure? Keep in mind the sensor will have limited range.
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

  9. #9
    NetDevil Newbie
    Join Date
    Mar 2009
    Posts
    11

    Default

    Quote Originally Posted by blueroomelectronics View Post
    What's the maximum range you'd like to measure? Keep in mind the sensor will have limited range.
    The sensors max range is 254 inches or 6,45 meters.

    i'm measuring up to three meters

  10. #10
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,709
    Blog Entries
    5

    Default

    If you can trim your +VREF to 2.602V then your sensor should give you 1" per step at 8bits.

    255 / 0.098 = 2.602
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

  11. #11
    NetDevil Newbie
    Join Date
    Mar 2009
    Posts
    11

    Default

    Quote Originally Posted by blueroomelectronics View Post
    If you can trim your +VREF to 2.602V then your sensor should give you 1" per step at 8bits.

    255 / 0.098 = 2.602
    ah.. thank you that makes it a lot easier !

  12. #12
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,709
    Blog Entries
    5

    Default

    My math was way off and zero counts so

    254" = 2.4892V max

    Adjust your VREF to 9.8mV * 256 = 2.509V
    Last edited by blueroomelectronics; 14th May 2009 at 08:28 PM.
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

+ Reply to Thread

Similar Threads

  1. Capacitor calculations?
    By James1986 in forum Electronic Projects Design/Ideas/Reviews
    Replies: 16
    Latest: 29th January 2009, 11:22 AM
  2. delay calculations
    By AtomSoft in forum Micro Controllers
    Replies: 1
    Latest: 1st October 2008, 01:08 PM
  3. Need help with charging calculations.
    By Nicksan in forum General Electronics Chat
    Replies: 8
    Latest: 29th August 2008, 07:50 PM
  4. calculations in pic
    By eddy123456 in forum Micro Controllers
    Replies: 2
    Latest: 23rd February 2008, 02:39 PM
  5. question about my calculations
    By dak246 in forum General Electronics Chat
    Replies: 5
    Latest: 15th August 2004, 08:50 PM

Tags for this Thread