Page 1 of 5

NXC: Mindsensors PPS35 - ADC values to bar?

Posted: 13 Nov 2011, 19:28
by HaWe
hi,
are the Mindsensors PPS35 - ADC values already mbar?
or does anybody know how to convert them to bar / mbar?

Code: Select all

/************************************************************************/
/*                                                                      */
/* Program Name: PPS35-demo.nxc  */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2008 by mindsensors.com                                */
/* Email: info (<at>) mindsensors (<dot>) com                           */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; version 3 of the License.              */
/* Read the license at: http://www.gnu.org/licenses/gpl.txt             */
/*                                                                      */
/************************************************************************/

task main()
{
	string msg;

  int v;
  SetSensorType(S1, SENSOR_TYPE_LIGHT);


	while (true) {
		msg = "Attach PPS35-Nx ";
		TextOut(0, LCD_LINE1, msg, false);
		msg = "Sensor to Port 1";
		TextOut(0, LCD_LINE2, msg, false);
		msg = "and change";
		TextOut(0, LCD_LINE3, msg, false);
		msg = "pressure.";
		TextOut(0, LCD_LINE4, msg, false);
		msg = "Pressure";
		TextOut(0, LCD_LINE6, msg, false);

    //***************************************************************
      v = SensorValue(S1);
		if (v<800) OnFwd(OUT_A,100); // air pressure pump: 800 mbar?
		else Off(OUT_A);
    //***************************************************************
    
		msg = "value: ";
		msg += NumToStr(v);
		msg += "  ";
		TextOut(0, LCD_LINE7, msg, false);
		Wait (200);

  }
}
or what exactly is

Code: Select all

ex_SensorMSPressure.nxc
This is an example of how to use the SensorMSPressure function.

int val = SensorMSPressure(S1);
doing?

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

Posted: 13 Nov 2011, 19:37
by mattallen37
Using SetSensorType(S1, SENSOR_TYPE_LIGHT); probably sets the SensorValue range to % (0-100). I don't think that you would ever see a value above 100, unless you use RAW mode.

In RAW mode, you would get values in the range of 0-1023. The values from the sensor are analog, and due to tolerance and non-linearity of most all sensors, the reading will not be in any specific, common measurement unit. Long story short, you will most likely have to calibrate for it to be in a common unit of measure.

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

Posted: 13 Nov 2011, 19:40
by mattallen37
doc-helmut wrote:...or what exactly is

Code: Select all

ex_SensorMSPressure.nxc
This is an example of how to use the SensorMSPressure function.

int val = SensorMSPressure(S1);
doing?
SensorMSPressure(S1); probably reads the ADC value in % (scaled) mode. I doubt it is doing any calibration, or offsets.

Edited for accuracy.

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

Posted: 13 Nov 2011, 19:55
by HaWe
mattallen37 wrote:Using SetSensorType(S1, SENSOR_TYPE_LIGHT); probably sets the SensorValue range to % (0-100). I don't think that you would ever see a value above 100, unless you use RAW mode.

In RAW mode, you would get values in the range of 0-1023. The values from the sensor are analog, and due to tolerance and non-linearity of most all sensors, the reading will not be in any specific, common measurement unit. Long story short, you will most likely have to calibrate for it to be in a common unit of measure.
the ranges in this MS program go from 0...1020 (manually tested)
with a 3rd party electrical pump they go from 0...330

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

Posted: 13 Nov 2011, 20:02
by mattallen37
Okay, so it's in RAW ADC mode. That means that you need to calibrate it to get common measurement units (or just use RAW ADC values).

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

Posted: 13 Nov 2011, 20:06
by HaWe
I was afraid of that.
But I guess that probably someone did the calibration before because the sensor is already a couple of years on sale... :?
(in future I need values like 0.5...0.8...1,0...1.5 bar for several different applications)

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

Posted: 13 Nov 2011, 20:23
by mattallen37
I went to the PPS35 product page, and immediately found a conversion formula. It is as follows:

PSI = 0.043 * RAW ADC - 38

or

float PSI = 0.043 * SensorMSPressureRaw(S1) - 38;

From PSI you can convert into whatever units you want.

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

Posted: 13 Nov 2011, 21:01
by HaWe
thx matt!
(I think I'll never find my way through this website!)

BTW:
I'm curious why they never use standard physic's SI units... :roll:

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

Posted: 13 Nov 2011, 21:05
by mattallen37
I can see why a US based company would give preference to imperial over metric, but I have no idea why they don't give metric conversion formulas on their site as well.

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

Posted: 13 Nov 2011, 21:08
by HaWe
:D
do you know the story why a Mars orbiter exploded before landing?
:D