Go Down

### Topic: Help in code for Diffrential pressure Sensor MPXV7002DP (Read 14294 times)previous topic - next topic

#### vin1391

##### Sep 22, 2012, 08:14 pmLast Edit: Sep 22, 2012, 08:26 pm by vin1391 Reason: 1
Hi all...

I wanted to read the pressure values and convert it to Pressure in kPa. We are supposed to use the pressure sensor MPXV7002DP ( data sheet is available here --> www.freescale.com/files/sensors/doc/data_sheet/MPXV7002.pdf )
Ranges are
-2 to 2 kPa (-0.3 to 0.3 psi)
0.5 to 4.5 V Output

We were told to use the transfer function given in the data sheet. This is the transfer function..
Transfer Function:
Vout = VS × (0.2 × P(kPa)+0.5) ± 6.25% VFSS
VS = 5.0 Vdc

Now my confusion is

• what is the need for transfer function?

• can't we use map function to directly map from the bit values to Pressure values?

• and if we are to use the transfer function what value should I tale for Vfss?

By my assumption I thought that

• We get the pressure analog value in bits

• Convert it to voltage using map function

• Use that Voltage value in the transfer function after rearranging the function to Pressure using the Voltage value

To get the correct Vfss value we are trying out random values in the range of 3.5 to 4.5 and getting pressure value for this from a sensor as well as a manometer. By comparing which Vfss value gives the similar Pressure reading from Sensor and manometer we try to get the correct value of vfss.

We tried this but the thing is for whatever air speed we give, the voltage output after bit to voltage conversion remains at 2 volt. Is this how it is supposed to be or?

Don't know if this is what needs to be done. Also we should find the velocity if the air but I did not get to that yet. I am assuming Bernoulli's equation will be enough.

( We are actually doing a project on Propeller Test. We are finding the efficiency of the propeller so we need the speed and hence this code....)

Thankyou...Any help will be much appreciated...

Here is the code I tried out
Code: [Select]
`void setup (){  Serial.begin(9600);}void loop(){  float vfss = 3.5;  int pValue = analogRead(1);  float vOut = map(pValue,0,1023,0,5);  float pressure = (vOut+0.625*vfss)-0.5 ;  Serial.println(pValue);  Serial.println(vOut);  Serial.println(pressure);  delay(1000); }`

#### MarkT

#1
##### Sep 24, 2012, 02:50 am

Hi all...

I wanted to read the pressure values and convert it to Pressure in kPa. We are supposed to use the pressure sensor MPXV7002DP ( data sheet is available here --> www.freescale.com/files/sensors/doc/data_sheet/MPXV7002.pdf )
Ranges are
-2 to 2 kPa (-0.3 to 0.3 psi)
0.5 to 4.5 V Output

We were told to use the transfer function given in the data sheet. This is the transfer function..
Transfer Function:
Vout = VS × (0.2 × P(kPa)+0.5) ± 6.25% VFSS
VS = 5.0 Vdc

Now my confusion is

• what is the need for transfer function?

It tells you how the output voltage depends on the pressure.  Its a linear relation fortunately.
Quote

• can't we use map function to directly map from the bit values to Pressure values?

Because its linear, yes.
Quote

• and if we are to use the transfer function what value should I tale for Vfss?

Vfss is full-scale voltage - its just telling you the error is +/- 6.25% of full-scale, you only need that to calculate the error-bar.
Quote

[/list]

By my assumption I thought that

• We get the pressure analog value in bits

• Convert it to voltage using map function

• Use that Voltage value in the transfer function after rearranging the function to Pressure using the Voltage value

Yup
Quote

To get the correct Vfss value we are trying out random values in the range of 3.5 to 4.5 and getting pressure value for this from a sensor as well as a manometer. By comparing which Vfss value gives the similar Pressure reading from Sensor and manometer we try to get the correct value of vfss.

You only need that for error calculations, not to derive the nominal result value.
Quote

We tried this but the thing is for whatever air speed we give, the voltage output after bit to voltage conversion remains at 2 volt. Is this how it is supposed to be or?

Don't know if this is what needs to be done. Also we should find the velocity if the air but I did not get to that yet. I am assuming Bernoulli's equation will be enough.

First check that the thing is responding to known static pressure differences, then worry about Bernoilli readings.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### elyancorrea

#2
##### Feb 23, 2015, 10:14 pm
Hey,

You was successful getting the air speed?

Thankou!

#### ZachChristoph

#3
##### Jan 17, 2017, 08:03 pm
Hello all. I am making a group project to optimize flap deflaction in flight on airplanes. We are using the Arduino nano and two Sensors. One of the sensors is the MPXV7002DP for the airspeed. now i want to know how this sensor should be written in the Arduino IDE? We want to get the speed. Is the MPXV7002DP only a pressure sensor and we have to use something with the voltage or is it in meter per second.

This is the code i have written so far:

const int FIRST_THRESHOLD = 0.267;
const int SECOND_THRESHOLD = 0.426;
const int THIRD_THRESHOLD = 0.764;
const int FOURTH_THRESHOLD = 0.952;
const int M = 350;
const int P = 1.124;
const double A = 10.5;
const double G = 9.81;

//init pins
int speedSensor = A1;
int accelerationSensor = A4;
//LED pins
int firstLed = 2;
int secondLed = 3;
int thirdLed = 4;
int fourthLed = 5;
int fifthLed = 6;

int WAIT = 500;
double determineLiftCoefficient(int speedValue, int accelerationValue){
double result = 0.0;
result = (2 * M * G * accelerationValue) / (P * speedValue * speedValue * A);
}

void setup() {
// put your setup code here, to run once:
pinMode(speedSensor, INPUT);
pinMode(accelerationSensor, INPUT);
pinMode(firstLed, OUTPUT);
pinMode(secondLed, OUTPUT);
pinMode(thirdLed, OUTPUT);
pinMode(fourthLed, OUTPUT);
pinMode(fifthLed, OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
double liftCoefficient = determineLiftCoefficient(speedValue, accelerationValue);
//Serial.println(speedSensor);
if(liftCoefficient < FIRST_THRESHOLD){
digitalWrite(firstLed, HIGH);
}
else if(liftCoefficient < SECOND_THRESHOLD){
digitalWrite(secondLed, HIGH);
}
else if(liftCoefficient < THIRD_THRESHOLD){
digitalWrite(thirdLed, HIGH);
}
else if(liftCoefficient < FOURTH_THRESHOLD){
digitalWrite(fourthLed, HIGH);
}
else{
digitalWrite(fifthLed, HIGH);
}

delay(WAIT);
}

#### MorganS

#4
##### Jan 18, 2017, 07:25 am
The sensor is only a pressure sensor. To convert that to speed, you need to divide by the density and take a square root.

But your very next formula squares the speed and multiplies by the density.

So don't do that. Just use the dynamic pressure value directly, although you will need to multiply by a calibration constant to turn analogRead() counts into a pressure unit you can use.
"The problem is in the code you didn't post."

Go Up