# AD - Converter calculations ?

Status
Not open for further replies.

#### NetDevil

##### New Member
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).

#### Nigel Goodwin

##### Super Moderator
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.

#### NetDevil

##### New Member
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.

#### blueroomelectronics

##### Well-Known Member
Which compiler are you using?

#### NetDevil

##### New Member
Which compiler are you using?
Im using hitech and im programming pic16f887

Last edited:

#### Nigel Goodwin

##### Super Moderator
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.

#### NetDevil

##### New Member
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:

#### blueroomelectronics

##### Well-Known Member
What's the maximum range you'd like to measure? Keep in mind the sensor will have limited range.

#### NetDevil

##### New Member
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

#### blueroomelectronics

##### Well-Known Member
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

#### NetDevil

##### New Member
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 !

#### blueroomelectronics

##### Well-Known Member
My math was way off and zero counts so

254" = 2.4892V max