View Full Version : conversion factor rctime

Tobias

12-07-2006, 12:46 AM

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?

·

Chris Savage

12-07-2006, 01:03 AM

Tobias,

·

·· 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

Tobias

12-07-2006, 03:55 AM

I am using a 1-5 volt output pressure transducer 0-150 psi

I would like to have an example of a lookup conversion table thank you

-Tobias

AIman

12-07-2006, 04:30 AM

You can figure out that 95 PSI * 2.347 will give 223.

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

Chris Savage

12-07-2006, 11:32 AM

Tobias,

·

·· 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

TechnoRobbo

12-07-2006, 12:08 PM

I'm confused. How are you using a 1 to 5 volt transducer with rctime? Are you charging the cap with it? is it a 3-wire or 2 wire device? Shouldn't you be using an ADC?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Have Fun

TR

Tobias

12-07-2006, 03:12 PM

Yes I am inputing the voltage to the cap therefore it increases my rctime value, as the psi drops the voltage drops and so does the rctime value. It is three wires thata I am using pos, neg and output wire.

-Tobias

Sarten-X

12-07-2006, 05:00 PM

Close to accurate is ((PSI * 3 / 4) - 53). This is what I got by entering your test data into http://www.wessa.net/esteq.wasp, and approximating the resulting equation, PSI[t] = +0.74217240046386 RC[t] -52.47197526092. Using the approximated equation:

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.

TechnoRobbo

12-07-2006, 08:10 PM

Ok - I get it you change the zero crossing point (1.4V) on the curve therefore the lower the transducer voltage the higher the RCtime.

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

TechnoRobbo

12-11-2006, 05:27 AM

I did a logarithmic regression on the numbers you posted and I came out with this formula

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:overflow=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:overflow=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

rmnsc1v16

12-12-2006, 12:44 AM

I'm not sure what your application is, but if you do not need to display pressure anywhere, I would do conversions outside of the Basic Stamp.· The equation above should give you fairly accurate values.· I've been working on a project that needed to covert RCTIME to temperature.· The integer limitations of the stamp didn't give suitable values for temp so I just read off an RCTIME and calculated Temp in my calculator (or in excel).· If you need to do some type of cutoff, I would set the cutoffs based on RCTIME instead of a coverted value.· just a thought

TechnoRobbo

12-12-2006, 11:41 AM

Actually there's a give and take between program size and program speed.

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