0

I am measuring pressure in bars from OsiSense™ XMLP pressure sensor (4-20 milliamp) on a arduino uno. When the machine im measuring pressure on is switched off the reading is 0v as expected. When the machine is on (the sensor is on) the reading is 1v as expected.
When the machine is on and hydraulics are active the voltage fluctuates as expected.

The problem I have is I don't know the maths to translate the voltage to bar pressure.

From a previus question i've asked from 0v to 5v the equation is:

// This is for the DEFAULT 5V analog reference.
// v = the voltage at the pin in Volts.
// p = the pressure in bar.
// Note that 'bar' is the pressure relative to the
// normal atmospheric pressure at that moment.
float v = (float) analogRead(A0) / 1024.0 * 5.0;
float p = v / 5.0 * 100.0;"

Is it just a matter of changing the equation to take into account the 1v when the sensor has power and then dividing by 4 instead of 5:

RawVoltage = (float) analogRead(A0) - 1;
float v = RawVoltage / 1024.0 * 4.0;
float p = v / 5.0 * 100.0;"
resolver101
  • 155
  • 2
  • 2
  • 8

1 Answers1

1

If I understand your question correctly, when the sensor is on,

  • 4 mA (1 V on the Arduino) means 0 bar
  • 20 mA (5 V on the Arduino) means 100 bar.

Is that correct?

If that is correct, there you just have to linearly map the voltage range to the pressure range. The equation is

P = (v − 1 V) / 4 V × 100 bar

or, in C++:

float v = analogRead(A0) / 1024.0 * 5.0;  // in volts
float p = (v - 1) / 4 * 100;              // in bars
Edgar Bonet
  • 45,094
  • 4
  • 42
  • 81