Hello folks, I am using G1/4 Pressure Transmitter Sensor 0-1.2 MPa sensor can you guide for programming part.The conversion from bar to pascal or bar to Mpa or pascal to psi.Though I am new to it. Plz guide me .
2 Answers
I'm assuming you mean that you want to pull a voltage number off of an input pin and convert it to a meaningful number.
To do this find the range of the incoming voltage.
Find the range of the sensor.
After that you need to split the voltage up to show what parts of the range convert to how much psi.
Here is an example of a temperature gauge that has the same principle.
-
I done by this way it is right to do this? int rawReading = analogRead(A0); // Range : 0..1023 float millivolt=(rawReading*4.882); float rawVoltage = (rawReading * (4.5 / 1023.0)) + 0.5; byte psi = (rawReading-102)/8; float bar = psi*0.07; float MPa = psi*0.006894759086775369; Commented Nov 27, 2015 at 5:07
-
Looks good to me. Do you think those numbers are accurate after testing done readings? Commented Nov 27, 2015 at 6:37
-
I dont know i search on it and find this values.It shows the output but dont know it is right or wrong Commented Nov 27, 2015 at 7:49
-
Logically what you did sounds right. I don't have your sensor in front of me so I can't help you as far as that goes. Commented Nov 27, 2015 at 7:51
One thing that I would add to this is that if you need good accuracy you may want to apply a voltage equal to your full scale output to the AREF pin. The value on AREF does not have to be equal to the full range of the sensor – just to the maximum value you will get – if you will never see readings at the extremes of the sensor's range you can set your AREF below the maximum value and get higher resolution.
Tronixstuff has a good tutorial on the AREF pin that goes into considerable detail about how to configure the pin and use the analogReference()
function.