Page 2 of 5
Re: NXC: Mindsensors PPS35 - ADC values to bar?
Posted: 13 Nov 2011, 21:10
by mattallen37
So, to convert RAW into kPa, use this:
kPa = ((0.043 * RAW) - 38) * 6.89475729;
or for Bar use this:
Bar = (((0.043 * RAW) - 38) * 6.89475729) / 100;
Re: NXC: Mindsensors PPS35 - ADC values to bar?
Posted: 13 Nov 2011, 21:11
by mattallen37
doc-helmut wrote:
do you know the story why a Mars orbiter exploded before landing?
Because someone preferred imperial over metric, and there was a mis-conversion.
Re: NXC: Mindsensors PPS35 - ADC values to bar?
Posted: 13 Nov 2011, 21:14
by mattallen37
And no, I don't give preference to imperial. However, pressure and heavy measure are still a bit of a challenge to my way of thinking (just because I have only used imperial up until a couple months ago).
Re: NXC: Mindsensors PPS35 - ADC values to bar?
Posted: 13 Nov 2011, 21:35
by HaWe
thx again, I googled the conversion meanwhile, too.
And you're right of course:
kPa or hPa are the correct values, not bar or mbar any longer :)
(I had quite a lot of issues when I once made my pilot licence many years ago: all instruments of all Cessnas and Pipers show mph or knots and feet or feet/min instead of km/h and and m or m/s :roll:
And do you know why we call a quarter-pounder with cheese "Royal mit Käse"? :)
But that's another topic... )
Re: NXC: Mindsensors PPS35 - ADC values to bar?
Posted: 15 Nov 2011, 19:07
by HaWe
PSI = 0.043 * RAW ADC - 38
or
float PSI = 0.043 * SensorMSPressureRaw(S1) - 38;
matt, with this formula I get negative values (PSI=-40 when the ADC SensorValue=300), there must be something wrong.
I tried SensorValue instead of SensorMSPressureRaw, but it's the same.
(what a mess, those NXC "read ADC Sensor value" commands are really more than weird! They all do anything but either all the same or something completely unexpected!)
Code: Select all
#define printf1( _x, _y, _format1, _value1) { \
string sval1 = FormatNum(_format1, _value1); \
TextOut(_x, _y, sval1); \
}
task main()
{
string msg;
int v;
float PSI;
SetSensorType(S1, SENSOR_TYPE_LIGHT);
while (true) {
//***************************************************************
v = SensorValue(S1);
PSI = (0.043 * SensorMSPressureRaw(S1)) - 38;
OnFwd(OUT_A,100);
//***************************************************************
printf1(0,40, "ADC=%5d", v);
printf1(0,32, "PSI=%5.1f", PSI);
Wait (200);
}
}
ps:
can't attach NXT screenshot to this post:
Information
The image file you tried to attach is invalid.
(but it's a legal jpeg file!)
Re: NXC: Mindsensors PPS35 - ADC values to bar?
Posted: 15 Nov 2011, 19:41
by HaWe
hmhh..
if I use
Code: Select all
int v, w, hPa;
float PSI;
v = SensorValue(S1);
w = SensorMSPressure(S1);
hPa = w * 68.95;
PSI = (0.043 * SensorMSPressureRaw(S1)) - 38;
OnFwd(OUT_A,100); // air pressure pump
//***************************************************************
printf1(0,40, "RAW=%5d", v);
printf1(0,32, "MSP=%5d", w);
printf1(0,24, "PSI=%5.1f", PSI);
printf1(0,16, "hPa=%5d", hPa);
I get
Code: Select all
RAW= 289
MSP= 9
PSI=-39.7
hPa= 620
That migth mean, that SensorMSPressure (MSP) might possibly give a more or less correct PSI value (although undocumented),
while the mindsensors formula for PSI is completely wrong...
Re: NXC: Mindsensors PPS35 - ADC values to bar?
Posted: 15 Nov 2011, 23:01
by mattallen37
Okay, what ADC value do you get with no pressure? What about with moderate pressure? What about with max (like 30 PSI) pressure?
Re: NXC: Mindsensors PPS35 - ADC values to bar?
Posted: 16 Nov 2011, 12:58
by HaWe
It's weired - it seems there is a big difference between SensorValue(S1) and SensorMSPressureRaw(S1)...
(but neither the first one nor the second one works with the MS PSI formula)
Code: Select all
SensorValue SensorMSPressure SensorMSPressureRaw
0 1 995
0 3 943
65 6 869
260 9 790
423 12 723
610 15 646
800 18 568
_1000 (limit) 21 482 (limit)
if I increase the pressure even further, now the pump gets broken or hoses burst from ports.
SensorMSPressure might be pressure by PSI - but then the resolution of SensorMSPressure is too low (1/21 ≈ 5%) , we should better have float then instead!
Re: NXC: Mindsensors PPS35 - ADC values to bar?
Posted: 16 Nov 2011, 17:01
by mattallen37
What about using SensorRaw(S1)? SensorRaw is supposed to be the absolute raw 10-bit ADC value, with no modifications.
Re: NXC: Mindsensors PPS35 - ADC values to bar?
Posted: 16 Nov 2011, 18:40
by HaWe
Code: Select all
SensorValue SensorMSPressure SensorMSPressureRaw SensorRaw PSI=(0.043*SensorRaw(S1))-38;
0 1 995 994 4.8 ...nonsense!
0 3 943 943 2.6 ...???...
65 6 869 868 -0.5 ...nonsense!
260 9 790 789 -4.1 ...nonsense!
423 12 723 <- ...nonsense!
610 15 646 <- ...nonsense!
800 18 568 <- ...nonsense!
_1000 (limit) 21 482 <- ...nonsense!
again, a mess...!
So SensorMSPressureRaw is nothing else than SensorRaw, but for THAT evaluation we won't need an extra keyword, and the rest stays weird!
I wonder why those manufacturers don't manage to provide correctly working drivers with readings and values and units you can start something ...
All what anybody would need os ONE correct and definite ADC reading (and not twenty) and ONE correct formula for calculated pressure units (psi or hPa).