conversion factor rctime
Tobias
Posts: 95
My time value is 223 which is vertually 95 psi
165 which is 70 psi
118 = 35 psi
111 = 30 psi
what factor could i use to make this work to have a accurate psi reading with the values is presented?
·
165 which is 70 psi
118 = 35 psi
111 = 30 psi
what factor could i use to make this work to have a accurate psi reading with the values is presented?
·
Comments
·
·· The readings don’t appear to be linear.· In this case you may simply need to create a small lookup table with some spaced data points and interpolate to get what’s in between.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
I would like to have an example of a lookup conversion table thank you
-Tobias
70 psi·gives·164.9 but 35 PSI * 2.347 gives 82.145 so you are definatly working a curve.
For a rough table you could study the example·below and list it in a table for·every 5th or 10th number.··· ... Or cheat and run it in Excel...
Example. 223/95 = 2.347368421052631578947368421056
·
·· You’re in luck, Jon Williams has already done this in a Nuts & Volts article…Please see the link below for an example of creating a lookup table using interpolation.
http://www.parallax.com/dl/docs/cols/nv/vol5/col/nv114.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
-Tobias
165 = 70 psi
118 = 35
111 = 30
This is correct for the test data, but you might want to test it for maximum and minimum values.
So the curve should plot like this:
V/E = 1 - e^(-t/RC) with v=capacitor voltage, E=full voltage
t=time and e=2.7182818 (natural log)
Better use a lookup table and interpolation.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 12/9/2006 2:25:20 AM GMT
rctime=80.88187884 * 1.101583319^PSI
I rounded the values to the nearest binary values 1.107421875·(1035/1024) and 81
I wrote a binary fixed point routine and did a comparison loop. It's close but not perfect.
One note: since your using RCTIME and a 1 to 5 volt transducer you will not be able to read the lower end 1 -1.4V which should translate 15 lbs and lower.
' {$STAMP BS2}
' {$PBASIC 2.5}
idx VAR Byte
rct VAR Word 'rctime result
mantissa VAR Word
integer VAR Word
overflow VAR Word
carry1 VAR Word
carry2 VAR Word
Main:
DO
· DEBUGIN DEC3 rct· 'input your rctime / replace with program
· integer=81:mantissa=0[noparse]:o[/noparse]verflow=0:idx=255
· DO
··· idx=idx+1
··· 'multiply by 1035
··· carry1 = mantissa ** $40B
··· mantissa = mantissa * $40B
··· carry2 = integer· ** $40B
··· integer = integer * $40B
··· GOSUB Do_Carry
··· overflow = overflow * $40B
··· overflow = overflow + carry2
··· 'divide by 1024
··· carry1 = mantissa ** $40
··· mantissa = mantissa * $40
··· carry2 = integer ** $40
··· integer = integer * $40
··· GOSUB Do_Carry
··· overflow = overflow * $40
··· overflow = overflow + carry2
··· 'align bits
··· mantissa=integer:integer=overflow[noparse]:o[/noparse]verflow=0
· LOOP UNTIL (integer > rct) AND (idx < 151)
· DEBUG CR,CR,DEC5 idx
LOOP
END
'subroutines
Do_Carry:
··· carry1 = integer.LOWBYTE + carry1
··· integer.LOWBYTE=carry1.LOWBYTE
··· carry1=carry1>>8
··· carry1 = integer.HIGHBYTE + carry1
··· integer.HIGHBYTE=carry1.LOWBYTE
··· carry1=carry1>>8
··· carry2=carry2+carry1
· RETURN
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 12/10/2006 10:55:32 PM GMT
A lookup table would be faster but in this case it would take up atleast 300 bytes not counting the code overhead to operate it. If you use a·smaller table and interpolate·you loose the integrity of the curve. This·may not be desireable, depending on the application.
The binary fixed point algorithm can be cut down to·only 179 bytes max (I expanded it for examination purposes).· Obviously it's much slower and the·developer has to make that call. It may not be suitable for automotive purposes.·On the other hand he may need the room for code.
The accuracy·limitations are in the code more than they are in the Stamp. The algorithm has a 4 "decimal" point accuracy and I can rewrite it for more. The mantissa can easily be formatted and outputted by multiplying by a power of 10.
I also limited the operand, I could have used 9006/8912 giving me an operand 1.01054757630162 which is much closer to the target value of 1.01058331935943. I also didn't use the mantissa to calculate the base but I could have. The numbers I used worked good during the tests so I went with them.
Decimal math is not really more accurate than binary math. It's just easier to relate to.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 12/12/2006 4:07:19 AM GMT