Hi Ed,
You may need to change both the offset and the gain value.
Just because the voltage at the low end is off by 37mV doesn't mean the high end is off by the same amount.
Numbers within () are example numbers.
Step 1, Take a bunch of readings at 0 pressure, write down the reported numbers, then calculate the average. (345)
Step 2, Take a bunch of readings at max pressure, write down the reported numbers then calculate the average. (3591)
Step 3, Figure out what you want the final range of values to be. 0-1000, 0-5000, 0-7000 etc? (0-1000)
Step 4, Calculate the "offset" and the "gain":
The "offset" is simply the value calculated in step 1. (345)
The "gain" is [whatever value you want max to be] divided by ( [value at step 2] minus [value at step 1] ) times 256 ie. 1000 / (3591 - 345) * 256 = 79
What's that 79?
Again, it's like multiplying by units of 1/256. So when our value returned by ADC routine is 3591 (max pressure) we first subtract the offset of 345 and then multiplies with 79/256, what's the result?
(3591-345) * 79 / 256 = 1001, not perfect but pretty close.
If you're using the routine I posted earlier, with the 4 times oversampling, then look at the result directly from the ADC (110 in your case), look at the result at the end of the routine. It it might be 438 or 441 and, as long as the sensor isn't super stable and "slient", it'll give you a better over all resolution.
/Henrik.




Bookmarks