# Converting A/D value to float

Status
Not open for further replies.

#### salman83

##### Newbie level 4
Hi,

I do not know how to convert the A/D value into float.

Remember that A/D converter is 24 bit. Also, I am attaching a text file which contains some logged points.

Any help will be highly appreciated.

Regards.

#### Attachments

• data.txt
1.3 KB · Views: 52

Try this:

Code:
float  result =  ( float ) variable / 2^24

For example, I will take the first A/D value in the attached text file which is 5478960

So, 5478960 / 2^24 = 0.32657146453857421875

This is wrong, the above value is referenced for 200 degree centigrade. I need to map that value around 200 deg C

You did not mention the full scale before.
Ok, so multiply the resulted value with the full scalle that you want:

Code:
result =  ( float ) variable * ( 200/5478960 )

Hello

What sensor ?
What is the scale of this sensor ...and relation chip Degres ..mV
What is YOUR desired scaling ex: 0 to 100°C

What is the scale of ADC 24bits .. How many mV for result 0xFFFFFF result
signed or not signed
0xFFFFFF or +- 8FFFFF

Then we can go further ....

Hello!

Paulfjujo is right, you have to calibrate your thermometer.
You have 2 solutions:
1. The "no factory calibration" method. It means that you know exactly what your sensor
outputs, and at which temperature. Then you can calculate theoretically the ADC output
2. The factory calibration method. Assuming you have some linearity, once your device is build,
measure 2 different temperatures. then you can interpolate between these temperatures, and
extrapolate out of that range.

Now a quick statistic analysis shows that you have a noise of 293 LSBs. As it is close to 256,
we can say that you don't have 24 bit accuracy, but 16 only.

You can improve this value by oversampling, but the problem is that your system will become
less reactive. Remember that if you want to gain 4 bit accuracy, you have to sample 256 times
faster.

Dora.

You did not mention the full scale before.
Ok, so multiply the resulted value with the full scalle that you want:

Code:
result =  ( float ) variable * ( 200/5478960 )

The ratio in the parantheses would evaluate to zero here. You should write them as float:

Code:
result =  ( float ) variable * ( 200.0/5478960.0 )

Status
Not open for further replies.