Airspeed from MPX5500DP differential pressure sensor using a PIC16F88


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    I am glad your code works. But in case you will need one decimal place precision in your calculation, then you can re-work your formula in this way:

    Code:
    Vu  var byte ' unit
    Vd var byte  ' decimal
    
    P = 6000 * ad_word / 614
    V = SQR(P)
    Vu = V DIG 1
    Vd = V DIG 0
    
    LCDOUT $FE, 1, Vu,".",Vd
    Cheers

    Al.
    Last edited by aratti; - 11th November 2010 at 14:59.
    All progress began with an idea

  2. #2
    Join Date
    Oct 2010
    Location
    Northern Colorado
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Fellas,

    I am having a problem with my LCD display that I can't seem to figure out what the deal is. I have a 16 x 2 LCD that has a Hitachi 44780 driver. I am having problems with the value it is reading being displayed in a useable number.

    Sitting at "idle" the LCD outputs 00008, which is fine. But then when the values increase it gets up to 00010 and then roles back around to 00001 and can do that for several cycles up and down. What is it doing? It should be outputting a velocity in relation to the pressure.

    My basic LCDOUT command is as follows

    Code:
    LCDOUT $FE, 1,"Begin Program"
    
    Pause 2000
    
    'main loop
    main:
    	ADCIN 4, ad_word				'read value from voltage input on AN4 (pin 3) and then store as ad_word
    
    	Pauseus	200						'check sampling time for that of the sensor and the pic to see if this value is correct
    
    	P = maxp * ad_word / 1023	'equation to calculate pressure using the variables and constants defined earlier
    									'Also contains 10 bit results
    									'Hopefully will output whole value without truncation, if it does find value to multiple by
    	Pauseus 200
    
    	X = 20 * P / 12
    
    	Pauseus 200
    
    	V = SQR X					'calculating velocity with the sqaure root of 2 times pressure (p) divide by density (1.2)
    
    	Pauseus 200
    
    	LCDOUT $FE, 1
    
    	LCDOUT $FE, $80 + 4, dec5 V			'Output Velocity to LCD, should be in m/s
    
    	Pauseus 200				
    
    Goto main
    
    End
    Any thoughts?

    You are all great and I am so thankful for all the help you guys are giving me!

    -Marcus

  3. #3
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Insert the following snippet to stabilaze the ADC reading averaging it.

    Code:
    A0 var Byte
    Ad_Average Var Word
    
    Ad_Average = 0
    For A0  = 0 TO 7
    ADCIN 4, ad_word				
    Ad_Average = Ad_Average + ad_word
    Pauseus	200
    Next A0
    
    ad_word = Ad_Average >> 3

    Al.
    All progress began with an idea

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi, Marcus

    One thing hurts me :

    you use a 500 kPa sensor ...

    but @ reasonnable ( flying ) speeds ... say @ 90m/s = 324 km/h ...

    the diff pressure only is 6k Pa ...

    1/100 of your sensor full scale !!! - or 10 units of the ADC.

    Adding the noise produced by the sensor ( see Freescale ANs about it ) - even if amplified - you do not measure anything real ...

    a 50 kPa range sensor would allow you to measure close to speed of sound !!!

    No need to calculate average value ... it's noise average value you measure ...

    In short words ... you can't succeed in this way ...

    first choose a sensor to match your measured speed range.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Alain since the OP is is using a 1.2 factor for fluid density, it means that he is not working with air, but the gas he is using is more dense than the air.

    Cheers

    Al.
    Last edited by aratti; - 12th November 2010 at 23:49.
    All progress began with an idea

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    As an example, using the ISA standard sea level conditions of P = 101325 Pa and T = 15 deg C, the air density at sea level, may be calculated as:

    D = (101325) / (287.05 * (15 + 273.15)) = 1.2250 kg/m3
    Above is from
    http://wahiduddin.net/calc/density_altitude.htm
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    D = (101325) / (287.05 * (15 + 273.15)) = 1.2250 kg/m3
    Dave you are correct, fluid density is temperature dipendent. I made a wrong assumption, Alain forget my previous post.

    Al.
    All progress began with an idea

  8. #8
    Join Date
    Oct 2010
    Location
    Northern Colorado
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Thank you all for the help.

    I'll explain to all of you what this is all for. What I am have been building this semester is a open circuit wind tunnel for a mechatronics class. We have several criteria that it has to meet, which I will spare you the details of. But, the basic set up I have at the moment is that I have a DC motor spinning an RC plane prop to create the wind with a PWM function off of a PIC16F88. We are using a keypad to control the different speed settings and LED's to display the speed setting for the keys pressed. Then we have another PIC16F88 running a pitot tube set up which consist of a differential pressure sensor, op amp, voltage regulators, PIC16F88, and then an LCD for outputting displays and for helping as a "heart beat" monitor. We had a deadline coming up this Tuesday for an extra %10 on the project if we had everything function. I got it all locked down tonight and should be set for the deadline.

    Alain - I realized when I started the programming for the sensor last week that I had one that was WAY over sized for what I was using it for. I got it as a sample and am happy it has gotten me to where it has, but I am planning on ordering a more realistic one next week for the final presentation. Realistically I only need one that hits 1 psi because I am only planning on hitting 60 mph wind speeds. Its a matter of finding one that can give me what I want without the high cost.

    Al - We are indeed working with air and yes 1.2 is the density of air. That is even straight from my fluid dynamics text book.

    Again, thank you all for the help! I have most of the stuff completely ironed out except for calibrating of the pitot tube (probably need a better pressure sensor ). But now with the month left in the project it leaves me the chance to add in safety features such as a open door sensor, tachometer, refine the pitot tube setup and possibly a data acquisition set up.


    I doubt I can help many people on here with any programming, but I do have a lab book that has examples for PWM and other simple functions to fun things. Let me know if there is ever anything I can help with.

    -Marcus

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts