Go Down

### Topic: Transducer mapping (Read 491 times)previous topic - next topic

##### Jul 22, 2019, 12:01 am
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.

Code: [Select]
`const int Cyl = A0;  //Tank Sensorvoid 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);}`

#### Paul_KD7HB

#1
##### Jul 22, 2019, 04:32 am
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

#### JCA34F

#2
##### Jul 22, 2019, 05:15 am
If 4.5V = 200 PSI then this:
Code: [Select]
`int Cyl = map(analogRead(Cyl), 102 , 1024, 0, 200);`
Should be:
Code: [Select]
`int Cyl = map(analogRead(Cyl), 102 , 921, 0, 200);`
But you gave your PSI variable (Cyl) the same name as your input pin.

#3
##### Jul 22, 2019, 07:22 am
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.

#4
##### Jul 22, 2019, 07:28 am
Even on pressure release of valve, reading will go below the cylinder reading and stops high  correct reading when valve close. It fluctuates

#### Wawa

#5
##### Jul 22, 2019, 08:20 am
Should be:
Code: [Select]
`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:
Code: [Select]
`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..

#6
##### Jul 23, 2019, 01:11 am
Could be:
Code: [Select]
`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.

#7
##### Jul 23, 2019, 01:16 am
Code: [Select]
`const int Cyl = A0;  //Tank Sensorvoid 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);}`

#### Paul_KD7HB

#8
##### Jul 23, 2019, 01:19 am
Redesign your system to include an appropriate sized accumulator to absorb the pressure wave.

Paul

#### Wawa

#9
##### Jul 23, 2019, 01:26 am
Working code (tested with pot).
Leo..
Code: [Select]
`const byte sensorPin = A0; //Tank Sensorfloat 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);}`

#10
##### Jul 23, 2019, 01:30 am
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.

#### Wawa

#11
##### Jul 23, 2019, 02:14 am
A hardware solution seems to be needed, but you could try averaging multiple readings (smoothing code).
Leo..
Code: [Select]
`const byte sensorPin = A0; // tank sensorunsigned int sensorValue; // can hold up to 64 A/D valuesfloat 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);}`

#### Paul_KD7HB

#12
##### Jul 23, 2019, 05:15 am
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

#13
##### Jul 24, 2019, 01:14 am
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

#### JCA34F

#14
##### Jul 24, 2019, 03:54 am
How about a diagram showing where the sensor is located in relation to  compressor, tank, valves and air bags / cylinders.

Go Up