NXC: Mindsensors PPS35 - ADC values to bar?

Discussion specific to the intelligent brick, sensors, motors, and more.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

NXC: Mindsensors PPS35 - ADC values to bar?

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

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

Post 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.
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:...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.
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 »

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
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, 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).
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 »

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

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

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

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

Post 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.
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 »

:D
do you know the story why a Mars orbiter exploded before landing?
:D
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests