#### neiltechspec

##### Senior Member
Having a bit of trouble getting my head around the calculation need for a Oil Pressure Gauge.

The sensor gives a linear o/p from 0 to 100 PSI.
0 psi = 0.5v
50 psi = 2.5v
100 psi = 4.5v

Normally I would use -

Supply Voltage 5v

Then it would be easy to convert the value w0 to read PSI.

But because 0 psi is not 0v I am somewhat flummoxed at the moment.

Any help appreciated.

Neil

#### goom

##### Senior Member
The equation for the line defining the response is:
psi = 25 x ADC -12.5
To accommodate integer maths:

#### hippy

##### Technical Support
Staff member

psi = ( Vadc - 0.5 ) * 25

psi = ( ( Nadc * 5 / 1023 ) - 0.5 ) * 25

psi = ( ( Nadc * 10 / 1023 ) - 1 ) * 25 / 2

Limiting psi to only positive values ...

Code:
``````Symbol Nadc = w0
Symbol psu  = w1

psi = Nadc * 10 / 1023 Min 1 - 1 * 25 / 2``````

Thanks Hippy,

Neil

#### marks

##### Senior Member
Hi neiltechspec,
at 0 psi our readadc10 value is 0.5v/5v x 1023steps = 102.3
so at 100 psi our value becomes 920.7
so we get w0=w0 - 102.3 / 8.184

a neat trick to convert our adc10 value to 1000 steps is ** 64064

so we can now use w0=w0**64064-100/8

if our supply voltage isn't exactly 5.0v just tweak the high word **

#### srnet

##### Senior Member
But because 0 psi is not 0v I am somewhat flummoxed at the moment.

Any help appreciated.

Neil
If the 0 psi reading is 0.5V, then just subtract the equivalent of 0.5V from the ADC reading.

#### neiltechspec

##### Senior Member
Another option, thanks.
I'll try both (when the sensor arrives).

Neil

#### neiltechspec

##### Senior Member
Temporarily substituted a 5K pot for the sensor.

w0 = w0 * 10 / 1023 Min 1 - 1 * 25 / 2, didn't seem to work quite right, only gave 4 values throughout the range

w0=w0**64064-100/8, works a treat

Neil.

#### hippy

##### Technical Support
Staff member
w0 = w0 * 10 / 1023 Min 1 - 1 * 25 / 2, didn't seem to work quite right, only gave 4 values throughout the range
You could be right. It only determines integer voltage which is probably why there are so few steps.