Scaling data from an ADC0831
Turnbull2112
Posts: 65
I need some help here. I am trying to scale the data from three ADC0831's to some pressure readings and a gas concentration (in %) reading. I've looked over the Basic Analog Digital book but I'm getting snagged on converting .86-4.7VDC as 0-101 PSI. The ADC decimal range is 44 to 240. I am trying to play around with y = mx + b but the values arent matching up as I test it on the bench. How do I go about this? My program is attached. The first two ADC's are reading pressure sensors 0-101 PSI and the third is reading an oxygen conc 's/entration sensor 0-100%. The pressure sensors are MPX5700A's from Freescale Semi. Thanks!
Comments
You can adjust this value to get the scale that you need
That is what is used to get your scale value
$139C = 5020 DEC
Here I what I used went I need to change HEX to DEC
http://www.statman.info/conversions/hexadecimal.html
I used this when I wrote the Demo for the MAX186 ADC chip
You could do the same thing in that change the CON value until you get it to read .87 to read 0 and 4.7VDC to read 101
You have to play with the value CON to the scale that you need
What is the scale for this
Range 240 - 44 = 196 will map into a new range, 0 to 101
On a calculator do, 256 * (101 - 0) / (240 - 44) = 132
Note that the fraction 132 / 256 is very close to the fraction 101/196
Now, on the Stamp write,
pressure = (adcResult MIN 44 - 44) */ 132
The business with MIN is to prevent the possibility of a wild reading less than zero.
Looking at your code, in the MAIN section where you are doing the conversion, you are doing the conversion for the slope, but you aren't doing any addition or subtraction for the offset, I think. In other words, in your y = mx + b, you aren't doing the "b". Think of the C to F conversion, and the F to C conversion for temp. If you understand that, do the same for your situation.
Definitely maybe for sure, but I hope that helps. I do a lot of sensor stuff like that and once you get the first one figured out, the rest will be easy.
Then eventually you'll want to use instrument amps and such with offset adjustments so that you can use the full bit capability of the convertors.
Lloyd