Author Topic: Sensor to ADC  (Read 1192 times)

0 Members and 1 Guest are viewing this topic.

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Sensor to ADC
« on: January 26, 2019, 04:24:44 pm »
We have a sensor which measures pressure it's rated between 200 mbar and 2000 mbar. The output of a sensor is between 0 V and 3 V. We connect the sensor's output to the input of an ADC which is 10-bit and it's rated between 0 V and 3 V. How would we convert the pressure into a number which we get in the ADCRESULT register?
 

Offline palpurul

  • Regular Contributor
  • *
  • Posts: 170
  • Country: tr
  • Hey
Re: Sensor to ADC
« Reply #1 on: January 26, 2019, 04:46:11 pm »
I think you should check the datasheet of the sensor you're using. There should be some sort of look up table or equation mapping pressure to voltage output.
 

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: Sensor to ADC
« Reply #2 on: January 26, 2019, 05:19:47 pm »
I am not using any sensor, this is an only theoretical task.

Just explain how would I achieve the conversion thing.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Sensor to ADC
« Reply #3 on: January 26, 2019, 06:56:09 pm »
If the output is linear, you'd just scale the value into whatever units you want. Otherwise you'd generally use a lookup table.
 
The following users thanked this post: nForce

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: Sensor to ADC
« Reply #4 on: January 26, 2019, 07:37:32 pm »
Yes, it's linear. We don't use a lookup table.

Can you solve and explain for this example?
 

Offline palpurul

  • Regular Contributor
  • *
  • Posts: 170
  • Country: tr
  • Hey
Re: Sensor to ADC
« Reply #5 on: January 26, 2019, 07:38:50 pm »
Let's say that an imaginary pressure sensor gives 0V output for 200mbar and 3V for 2000mbar. In that case  ADC code for 200mbar would be 0x000 and for 2000mbar would give you the max. code (0x3FF). Assume that the sensor is linear then you can come with a linear equation using these two set of values.
 
The following users thanked this post: nForce

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: Sensor to ADC
« Reply #6 on: January 26, 2019, 09:57:45 pm »
Thanks :)

I have solved by using units. Can anyone look at this if it's correct? I am not really a math person.

(3V - 0 V)/(2000 mbar - 200 mbar) = 1/600 V/mbar

And...

(2000 mbar - 200 mbar)/ (1024 - 0) = 225/128 mbar/bit

So by units: 1/600 V/mbar * 225/128 mbar/bit, the mbar cancels. And we get 3/1024 V/bit.
 

Offline palpurul

  • Regular Contributor
  • *
  • Posts: 170
  • Country: tr
  • Hey
Re: Sensor to ADC
« Reply #7 on: January 27, 2019, 06:19:53 am »
Thanks :)

I have solved by using units. Can anyone look at this if it's correct? I am not really a math person.

(3V - 0 V)/(2000 mbar - 200 mbar) = 1/600 V/mbar

And...

(2000 mbar - 200 mbar)/ (1024 - 0) = 225/128 mbar/bit

So by units: 1/600 V/mbar * 225/128 mbar/bit, the mbar cancels. And we get 3/1024 V/bit.

It looks incorrect.

Here is the correct equation for mbar/V:
600*V+200 (checking it real quick: for 0V it gives you 200mbar for 3V it gives you 2000mbar)
Converting that to mbar/bits:
(600*(3/1024))*ADC_code+200 (again for 0 it gives you 200mbar and for 1024 it gives you 2000mbar)

I basically construct a linear line with known points.
It is explained here:here
 
The following users thanked this post: nForce


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf