NXC: Mindsensors PPS35 - ADC values to bar?

Discussion specific to the intelligent brick, sensors, motors, and more.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC: Mindsensors PPS35 - ADC values to bar?

Post 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;
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC: Mindsensors PPS35 - ADC values to bar?

Post by mattallen37 »

doc-helmut wrote::D
do you know the story why a Mars orbiter exploded before landing?
:D
Because someone preferred imperial over metric, and there was a mis-conversion.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC: Mindsensors PPS35 - ADC values to bar?

Post 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).
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: Mindsensors PPS35 - ADC values to bar?

Post 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... )
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: Mindsensors PPS35 - ADC values to bar?

Post 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!)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: Mindsensors PPS35 - ADC values to bar?

Post 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... :roll:
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC: Mindsensors PPS35 - ADC values to bar?

Post 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?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: Mindsensors PPS35 - ADC values to bar?

Post 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!
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC: Mindsensors PPS35 - ADC values to bar?

Post by mattallen37 »

What about using SensorRaw(S1)? SensorRaw is supposed to be the absolute raw 10-bit ADC value, with no modifications.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: Mindsensors PPS35 - ADC values to bar?

Post 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).
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests