Transducer mapping

Hi, I have a problem reading sensor Value display on serial monitor. I used a 3 wire pressure transducer 0-200 psi 0.5-4.5v. My project is a compressor charges the tank then to electronic valve as gate to the pneumatic cylinder. Pressure sensor is attach between valve and cylinder.

My problem is its not reading straight linear and start reading at cylinder psi. It jumps and starts to read at higher psi (spike) when valve opens and when valve close it goes back down to correct reading. I need reading that starts with cylinder psi straight up linear reading when valve is open.

I test it on potentiometer and it works ok. It gives straight linear reading.

Im a newbie on arduino

Any help will do. thank you very much.

const int Cyl = A0;  //Tank Sensor


void setup() {
  Serial.begin(230400);

  pinMode(Cyl, INPUT);

}

void loop() {

  int Cyl = map(analogRead(Cyl), 102 , 1024, 0, 200);
  Cyl = (Cyl);

  Serial.println(" ");
  Serial.print(Cyl);

  delay(50);

}

That is EXACTLY what I would expect to see. The pressure before the piston begins to move is exactly the pressure from the tank. The solenoid valve limits the air flow, so as the piston begins to move, the pressure drops. Get a solenoid valve large enough to not restrict the air flow and you will get your steady reading.

Paul

If 4.5V = 200 PSI then this:int Cyl = map(analogRead(Cyl), 102 , 1024, 0, 200);
Should be:

int Cyl = map(analogRead(Cyl), 102 , 921, 0, 200);

But you gave your PSI variable (Cyl) the same name as your input pin.

Thanks for the reply. yes i think its the high pressure of the tank then when the valve opens and high tank pressure joins the low pressure of the cylinder, it hammers the transducer and returns correct reading when valve closed. Are there any solution like algorithm to cure the spike? What about capacitor on analog pin to absorb spike voltage from transducer? I need a constant linear reading from cylinder pressure.

Even on pressure release of valve, reading will go below the cylinder reading and stops high correct reading when valve close. It fluctuates

JCA34F:
Should be:

int Cyl = map(analogRead(Cyl), 102 , 921, 0, 200);

But you gave your PSI variable (Cyl) the same name as your input pin.

Could be:

float pressure = (analogRead(A0) - 102) * 0.244;
//
Serial.print(pressure, 1); // one decimal place

For five times the resolution.
map only works with integers.

Oversampling could take that (almost) to a real decimal place.
Leo..

Wawa:
Could be:

float pressure = (analogRead(A0) - 102) * 0.244;

//
Serial.print(pressure, 1); // one decimal place



For five times the resolution.
map only works with integers.

Oversampling could take that (almost) to a real decimal place.
Leo..

thanks for the help Leo. I cant make it work. it read wrong using potmeter for test. It gives wrong value not 0 to 200 psi.

const int Cyl = A0;  //Tank Sensor


void setup() {
  Serial.begin(230400);

  pinMode(Cyl, INPUT);

}

void loop() {

  float pressure = (analogRead(A0) - 102) * 0.244;
//
Serial.print(pressure,1); // one decimal place

  delay(50);

}

Redesign your system to include an appropriate sized accumulator to absorb the pressure wave.

Paul

Working code (tested with pot).
Leo..

const byte sensorPin = A0; //Tank Sensor
float pressure;

void setup() {
  Serial.begin(230400);
}

void loop() {
  pressure = (analogRead(sensorPin) - 102) * 0.244;
  Serial.print("Pressure: ");
  Serial.print(pressure, 1);
  Serial.println(" psi");

  delay(250);
}

yes Leo it works with println using potmeter.. I will test it later in sensors.

Im totally blank as of now. I tried pressure snubber and micron filter to control pressure hammering of sensor but still the same. voltage spike from sensor i think is the problem.
I just need a linear reading from cylinder close and open valve because Im building a trigger on and off in pressure reading.

A hardware solution seems to be needed, but you could try averaging multiple readings (smoothing code).
Leo..

const byte sensorPin = A0; // tank sensor
unsigned int sensorValue; // can hold up to 64 A/D values
float pressure;

void setup() {
  Serial.begin(230400);
}

void loop() {
  sensorValue = 0; // reset
  for (int i = 0; i < 64; i++) { // 64 readings
    sensorValue += analogRead(sensorPin); // add readings
    delay(1); // time between readings
  }
  pressure = (sensorValue - 6528.0) * 0.0038125;
  Serial.print("Pressure: ");
  Serial.print(pressure, 1);
  Serial.println(" psi");
  delay(200);
}

White_Lady:
yes Leo it works with println using potmeter.. I will test it later in sensors.

Im totally blank as of now. I tried pressure snubber and micron filter to control pressure hammering of sensor but still the same. voltage spike from sensor i think is the problem.
I just need a linear reading from cylinder close and open valve because Im building a trigger on and off in pressure reading.

Where did you place the pressure sensor when you did this? All snubbers, accumulators, etc, must be BEFORE you pressure sensor.

Paul

Paul_KD7HB:
Where did you place the pressure sensor when you did this? All snubbers, accumulators, etc, must be BEFORE you pressure sensor.

Paul

Hi Paul. yes its before pressure sensor. I tried snubbers only with different porous and adjustable. still the same. I would like to ask if putting a capacitor to absorb the voltage spike from sensor to analog in will do? Kinda voltage buffer to slowly introduce spike voltage to analog input. Or any Ideas how to solve? I will give it a try. Thanks

How about a diagram showing where the sensor is located in relation to compressor, tank, valves and air bags / cylinders.

White_Lady:
Hi Paul. yes its before pressure sensor. I tried snubbers only with different porous and adjustable. still the same. I would like to ask if putting a capacitor to absorb the voltage spike from sensor to analog in will do? Kinda voltage buffer to slowly introduce spike voltage to analog input. Or any Ideas how to solve? I will give it a try. Thanks

In order to reduce the voltage excursion, you need a low pass filter. that would be a resistor followed by a capacitor. That values I do not know, but someone will know. Perhaps a 10k Ohm and a small cap.

Paul

Did you try the averaging code from post#11.
Different way is shown here.
Leo..

Hi, Thanks Leo. I tried your code with averaging but I guess thats what the sensor really behave, spikes value when valve opens and high pressure meets low pressure and returns to correct reading when valve closes. range/jump value is too big to average, I will use your first sample with float. Thanks Paul for the reply. I guess I will try capacitor and resistor. If you have a simple schematic it would be a big help. :slight_smile:

Hi JCA34F. Here is the diagram/setup. sensor output to A0 then +5v and ground.

Kindly jump to 2:10. Its the exact behavior of my display value when valve opens and close. Need Linear reading that starts with cylinder psi up when valve inflates and same with valve deflate. :slight_smile: