Go Down

Topic: SMC PSE530-M5 (Read 1 time) previous topic - next topic

minquist

Hi at all,

i am on that since yesterday and i have huge problems to get my goal.

We use some SMC PSE5530-M5 sensors for pressure measurement. Its connected correctly on an analog pin (A15).

I have to calculate pressure values (in bar or kpa or whatever) from ??the analog values ??(0 .. 1023) i get from analogRead.
My values ??are different from measured values ??significantly.

Can anyone help me out with a formular, a code snippet or other help for that problem?

Thanks!

minquist

marco_c

Can you post your code and a link to the datasheet for the sensor?
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

minquist

Hi!

The datasheet: http://datasheet.octopart.com/PSE530-M5-SMC-datasheet-30258.pdf

From here i cant post my code. If you need it, i will post it tomorrow morning.


marco_c

At least post the formula you are using.
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

marco_c

With 1024 steps for the analog value, the best resolution you are going to get for your 1MPa sensor is 1/1024 or approx 1kPa per step. Is this sufficient for your requirements?
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

minquist

1 kPa per step is very good for us.

I will post my formular tomorrow, it is on my work pc.

How would you calculate the values?

Thanks so far!

michinyon

Well your datasheet claims that for that device,  the range is 0 to 1 MPa   which is approximately 0 to 10 atmospheres.

And it claims to output 0 to 5 V corresponding to that range,    if it has a 12 to 24 V power supply.

So if you are using a 5V arduino,   and you trust the analog voltage not to go over 5V,   then you connect it to the arduino input pin
and read it.   You will get an integer value between 0 and 1023.

The pressure in kilopascals can then be calculated

int analog_value = analogRead(  analog_pin_number ) ;
float pressure = 1000.0 * analog_value / 1023 ;

where the 1000.0  is the value corresponding to 1 MPa,  in  kilopascals,   and the ratio  ( analog_value / 1023 )  is the fraction of the full-scale range
which you read.

The other thing to be aware of,  is in some contexts you measure pressure relative to vacuum,  and in other contexts
relative to one atmosphere.

So if you put 30 psi in your car tires,   that is actually more like 45 psi.


marco_c

A simple linear interpolation where 0 is 0MPa and 1023 is 1MPa (or better 1000kPa).

So the formula is one for a straight line y = mx + b, where b = 0 as you have the 0,0 point as part of the line.  m is the slope of the straight line or the proportionality constant.

Give this is the conversion, you should look at using the built in function map(). Look it up in the reference.
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

minquist

map() was my first intention too. Thats my problem.

Now i know, that the sensors has output as follow:
1V -> 0bar
5V -> 10bar

Any ideas how to calculate it?

marco_c

You still have not posted any code so it is hard to say why map() is a problem if you will not explain it.

Is this an assignment that you are trying to get the forum to do for you?
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

minquist

I tried to map my analog input value (0..1023) to the sensors min and max pressure values with the map() function.

I spent hours of testing with external pressure meter to get a solution. but my calculated values differs from the measured values. the difference first is small and get bigger with every millibar the sensor gets. In that hours i tested many code versions. thats why i didn't post any code.



marco_c

#11
Jan 18, 2013, 09:38 pm Last Edit: Jan 18, 2013, 11:59 pm by marco_c Reason: 1
Again, post your code. It seems to me that you could be getting issues due to the order of you (integer) math operations. What is the percentage error that you get and does that increase with higher pressure? Is the other pressure señor a more accurate sensor? How do you know? The sensor you have has a 2 % error, so the absolute error will increase with the higher pressure.
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

minquist

Higher Pressure = higher difference (up to ~15%), while i get the correct atmosphere pressure.
The other sensor is an external pressure meter (i have done it with 2 different with same values coming out ;-))

Here is my first code. Like i said: I have tested hours and hours with many different functions and code versions. this was my first aproach:

Code: [Select]
return mapfloat(v, 0.0f, 1023.0f,_sensorMin, _sensorMax);
where _sensorMin and _sensorMax are the configured values for the sensor.
Floatmap is this function for floats (equals map for integers):
Code: [Select]
float AnalogSensor::mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}


Today i found out, that the sensor gives
1V => 0bar
5V => 10bar

marco_c

Are the pressure sensors reading from the same reference point (see the post earlier which talked about relative vs absolute).

Have you tried to print intermediate values of the calc to verify it is what you expect?

It should not matter to the arduino, but have you got a stable 5 v voltage? Arduino will return a value referenced thru its own voltage, but if the sensor expects exactly 5 v you may have an issuers it is not accurate.
Arduino libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

michinyon

Your sensor seems to accept a 12-24 supply voltage  and returns a 0-5 V result.    This would
seem to imply that the sensor is generating its own regulated 5V voltage  regardless of its
power supply.  In other words,  it is not relying on a regulated 5V supply being made available
to it, from the arduino.

You should use a voltmeter to check that you are getting a plausible voltage on the signal
wire going to the arduino.

You should then check that you are getting a plausible numerical output form the analogRead().

Then you can worry about the conversion to a value in pressure units.

Go Up