Eric
- 5th December 2003, 09:16
Hello to everybody
I need to calculate the following formula with PBP from Melabs
P=(1/(10*Cost*C))^(1/expo)
Where P is pressure (mBar)
Cost is a costant (integer i.e.1850)
And expo is another costant (Float 1.065)
C is the indipendent variable (integer from 0.1 to 100000)
Thanks a lot
Eric.
mackrackit
- 7th December 2003, 21:18
Eric,
The method below is what I use to work around the point problem.
This example is for a 0 to 100 psi sensor with 1 to 5 volt out put.
U=SX+Q
"U" is the out put in the units you are using.
"S" is the slope or scale factor.
"X" is the input (millivolts,volts,etc).
"Q" is the offset.
Figure the slope. In the case above...
(100-0) / (5-1) = 25 PSI/Volts
Offset in this case is (-25). Calculated value of offset was 25 PSI/Volts, therefore, 1V=25.
The above will return 0psi for 1volt and 100psi for 5 volts.
Use the same idea when working with an ADC. The input that the PIC sees is 0 to 255, 256 span. Offset would be PSI/BITS. Full span will return 100/256=0.390625
Now, dealing with the decimal.
Two varibles are needed, one for the ADC and one for the out put after calculating.
pressure VAR BYTE 'out put
press VAR BYTE ' ADC return
'ADC routine
pressure = (39 * press - 39) / 100
'Drop "point", in this case 3906 would put the return over the 65535 limit. If more accuracy is needed look at DIV32 in the manual.
Varible "pressure" will now be within 1 psi of the actual pressure at the sensor.
In short, drop the point and then divide by 10,100,1000 etc later.
Hope this helps,
Dave
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.