Dave,
Thanks for your help. That makes a huge difference. Few questions for you though. Since this sensor will never hit it's maximum pressure reading at any point, is there a way to cut the max pressure to a tenth of what it is? i.e. the MPX5500DP has a Pmax of 500 kpa, if I cut that down to 50 kpa (500 / 10), would that make any major difference in my calculations?
So, from the copying from the other thread and plugging in my numbers.
"Using the old formula of
y = mx-b
y = output 'Volts
m = slope
x = input units
b = offset
wanting to read form 0 to 500kpa.
Output is 10 to 14 volts.
Start off by looking at the output in volts. I have a 4 volt span. Giving a span of 500 / 4 = 125
m = 125
The offset. Starting at 10 volts. 10 volts = 0 kpa. The offset is 10 * 125 = 1250
1250
Plug all this into the formula and lets say the input is 14 volts.(full scale)
y = (125 * 14) - 1250
y = 500
Now convert this to an 10 bit PIC resolution.
10 bits ADC = 0 to 1023, 1024 steps.
At 14 volts one volt of input will will read 73.
Spanning 4 volts or 292 steps (4 * 73).
New value for m. 500 / 292 = 1.7123
m = 1.7123
The new offset starting at 730, (10 * 73).
730 * 1.7123 = 1250
b = 1250
y = (ADC * 1.7123) - 1250
ADC = 1023
y = 500kpa
ADC is from the sensor."
Correct?
But, then in the code you multiple m by 10,000 and b by 100, what does this do for the values? Is that simple to prevent truncation in the program?
"Code:
' m = 0.00479
' b = 0.98
' y = (ADC * 0.00479) - 0.98
' ADC = 1023
' y = 3.92kpa
M CON 479 'm = 0.00479 * 10,000
B CON 98 'b = 0.98 * 100
ADC VAR WORD 'INPUT FROM SENSOR
Y VAR WORD 'KPA
Z VAR WORD 'DUMMY VAR
Z1 VAR WORD 'DUMMY VAR
'V = SQRT((2 * (Y/1000)) / 1.225)
V VAR WORD 'METERS/SECOND
D CON 122 'AIR DENSITY
START:
ADC = 1023 'FULL SCALE HARD CODED, NO SENSOR
Z = ADC * M
Z1 = DIV32 1000
Y = Z1 - B
Z = (2 * Y * 10000)
Z1 = DIV32 1000
V = SQR(Z1 / D *100)
LCDOUT $FE,1,"KPA= ",DEC Y/100,".",DEC Y//100
LCDOUT $FE,$C0,"M/S= ",DEC V
PAUSE 250
GOTO START"
I really appreciate the help.
-Marcus
Bookmarks