Shop OBEX P1 Docs P2 Docs Learn Events
Object MS5534.spin in OBEX - how to set reference point for current barometric — Parallax Forums

Object MS5534.spin in OBEX - how to set reference point for current barometric

LarryGLarryG Posts: 50
edited 2013-02-17 03:31 in Propeller 1
I have given up on the idea of using GPS for altitude. Enough people have told me the values are useless and I need to use a barometric means to get altitude. I found an object in the OBEX that looks close to what I want. But from all of my reading this week it seams you need to somehow set a baseline barometric value before each use since that changes with the weather. I don't understand where that value comes from, and if it is practical to do a calibration of some sort before each use of the device. Has anyone actually ever used the MS5534 to measure altitude, and can offer advice on this?

Thanks

Larry G.

Comments

  • TimmooreTimmoore Posts: 1,031
    edited 2010-07-25 16:49
    I haven't used the MS5534 but I have used the bmp085, scp1000 and hp03 and I found they all need a reference. Its not really the sensor but the equations to translate from pressure to altitude needs a reference.

    So it depends on what you want to do. If you are looking for difference altitude from a time e.g. altitude from takeoff for a copter then you can use that for the reference, if you dont have that then you need to input a reference probably pressure at sea level at a location near to you which you can get from weather info sites.
  • LarryGLarryG Posts: 50
    edited 2010-07-25 23:07
    Thanks Tim.

    I am wanting to use the altimeter on my bicycle. So it will be moving, and change in altitude for any given day can be as much as 5,000 feet. I want the altimiter to be accurate because I will also use the reading to calculate grade of road.

    Here is what I don't get: Right now where I live the reported barometric pressure is 30.03 inches according to the weather guys. Do I enter that as a one time reference into an equation and forget about it? Or do I somehow have to check the current reported pressure from the weather guys every day and enter it in to get an accurate reading?
  • TimmooreTimmoore Posts: 1,031
    edited 2010-07-25 23:38
    The pressure changes due to weather e.g. low/high pressure zones, a barometer gives the weather by changes of pressure. The problem is so a short period of time the pressure is unlikely to change due to weather though in some places it can change quickly. For me for a copter I only need it stable for 10/15minutes but for a bike you need it stable for much longer periods of time I assume.
    You probably need to think about combining multiple sensors perhaps gps and pressure. Pressure changes over a short period of time use as altitude change, with gps uses to stablization drift of the pressure over long periods of time. Maybe use sometime like a kalman filter to combine gps and pressure, there some discussion on this here http://diydrones.com/profiles/blogs/barometric-altitude-sensor-1
  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-07-26 20:49
    Do you care about absolute altitude or just about calculating grade? Do you want data while you ride or can you post process after you get home?

    Altitude is calculated from sensor reading + a correction for weather pressure changes. Or A = S + C. If you are only calculating grade, you need A1-A2 or S1 + C - (S2 + C) = S1 - S2. This is assuming your time between measurements is small enough that C has not changed. For a day long ride, C may change due to changes in weather and/or changes in location. For altitude during a ride, set it before leaving and hope it doesn't change too much. If you record data by time/location it could be post processed with recorded data pressure data. Remembering way back to my flying days, we set our altimeter before takeoff, sometimes during flight (I cannot remember when), and before landing.

    John Abshier
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2010-07-27 07:55
    Here are reference equations for altitude vs pressure, pressure vs altitude, and rate of change of altitude vs pressure (1st derivative). Also the 2nd derivative. Base (sea level) pressure and temperature are parameters, as is the standard lapse rate, which is the nominal 6.5 Kelvin decrease for each kilometer of altitude.
    attachment.php?attachmentid=72027

    The easiest thing to do is to use your known starting altitude and measured starting pressure as your reference, and then calculate change in elevation from subsequent changes in pressure. For example, if you start at at elevation of 643 feet, your station pressure will be somewhere near 990 millbar. But whatever it is, make note of it and record its value as "P1". At that elevation, the rate of change with pressure will be close to +28 feet per millibar decrease in pressure. You find that from the equations by plugging in the parameters to the equation for the first derivative. You don't know sea level pressure and temperature? Look them up online for a nearby source or take a good guess. Subsequently, as you ride, calculate
    elevation = 643 + (P1 - P) * 28
    where P is the real time pressure measurement in millibar. That will be sort of okay. However, the multiplier is not constant. If you ride up to 1200 feet, the multiplier will be closer to 28.5 feet per millibar. To lessen the error, add a second order correction.
    elevation = 643 + (P1 - P) * (28 - 0.025 * (P1 - P))
    The factor 0.025 is in units of feet per millibar per millibar and comes from the second derivative. That accounts for the changing density of the atmosphere with altitude and should cover a bike ride pretty well. Whenever you come to a waypoint with a known elevation, recalibrate.

    Recalibration at waypoints is essential and especially so on an extended trip. There are lots of approximations involved in using a barometer for altitude. If during your trip a low pressure front moves in, so the sea level pressure drops from 1013.25 to 1000 millibar, then the slope constant at 1200 feet will increase from 28.5 to 28.7 feet per millibar.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com

    Post Edited (Tracy Allen) : 7/28/2010 4:03:20 PM GMT
    591 x 403 - 26K
  • simonlsimonl Posts: 866
    edited 2010-07-27 21:53
    @LarryG: I can't answer your question, but I can tell you for certain that GPS altitude is not to be trusted. It so happens that I've just hooked-up my EM406 GPS and have it sitting on my table showing various readings, including altitude. As I've been watching; it's been showing altitudes from 34.6m to 79.4m! It also rekons that it's been moving about - as much as 30m in any direction! (I guess it could be my hardware, or even bad signals due to it being indoors near the window, but I was expecting better!).

    <edit>
    Ouch! Just moved the GPS and I'm apparently now at 763.3m!
    </edit>

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.

    Post Edited (simonl) : 7/27/2010 9:58:42 PM GMT
  • TimmooreTimmoore Posts: 1,031
    edited 2010-07-27 22:30
    Simonl, Try it outside, it needs several satellites and indoors limits that and causes other affects such as multipath. It is calculating time delays from the satellites, speed of light changes dependent on the material, it assumes atmosphere and in your case its not, or its reflecting off something to come in the window in which case the distance is not correct. GPS isn't good at altitude anyway due to the angles to the satellites but trying indoors will make it worse.
  • LarryGLarryG Posts: 50
    edited 2010-07-28 02:32
    Thanks for all the info Tracy. Now I am learning that the barometric method is not too accurate either. But I think it will work for me. I placed an order for a few sensors to play with. I will give it a try. Hey, its all about playing and learning new stuff anyway.
  • TimmooreTimmoore Posts: 1,031
    edited 2010-07-28 02:56
    I have used 2 methods for pressure to altitude, these are code versions of Tracys equations.
    1. h = 44330 * (1 - (Pressure/GroundPressure)^0.19) - in mm
    2. h = ln(GroundPressure/Pressure) * 292.712 * (100*T + 27315) - in mm, T is temp in C
          value := f.FFloat(AverageP)
          value := f.FDiv(value,101325.0)                   '1013.25 * 100 since Pressure is * 100
          value := f.Pow(value, 0.190263)
          value := f.FSub(1.0, value)
          value := f.FMul(value,44330.32172096)             'Altitude is m
          uarts.str(0,fp.FloatToFormat(value,7,3))
          uarts.str(0, string("m, "))
    

    This is a float version of 1, with GroundPressure fixed at 1013.25hPa
        SenData[noparse][[/noparse]SENSALTPRESSUREOFFSET] := trig.Qmul(trig.Qmul(trig.QLn(trig.Qdiv(GroundPressure<<14,SenData[noparse][[/noparse]SENSPRESSUREOFFSET]<<14)), {
    }     constant((trunc(292.71267)<<16)| round((292.71267 - float(trunc(292.71267))) * 65536.0))), ((GroundTemp*10) + 27315)<<16)
    
    

    This is a fixed point version of 2 with GroundPressure the measured pressure when the system starts so it measures altitude difference from system start. The temp I used was system start temp I didnt change it based on current temp.
    If you are getting one of the sensors I have used I2C SCP1000, bmp085 or hp03 let me know if you want to driver code.
    The other thing I found is all the sensors are noisy so I feed them all through a low pass filter before using the pressure value.
  • LarryGLarryG Posts: 50
    edited 2010-07-28 11:03
    Cool, thanks for all the info Tim. I have a better understanding of how this works now.

    After reading your prior post a few days ago, I did order 3 of the HP03D modules (have not received them yet). If you have anything specific to share about that sensor, I would appreciate it.

    Larry G
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2010-07-28 16:15
    I updated the chart in my previous post. The print came out kind of small, and I added the second derivative of altitude vs pressure (the curvature).

    The correction for weather changes can be substantial. Suppose you you sit home without taking the ride, and a low pressure front moves in with a sea level pressure drop from 1013.25 to 1000 millibar. The instrument would (without the correction for base pressure) erroneously indicate that you climbed from 600 ft to about 1000 ft elevation without breaking a sweat!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • TimmooreTimmoore Posts: 1,031
    edited 2010-07-28 17:16
    hp03object.spin is a driver for the hp03. fsensor.spin is the object that calls it. fsensor does a lot of other stuff and will not build using propellor tool but it should show how to call the driver.
    Some things to note with the hp03
    While it is a i2c device it has the same address as the eeprom so you need to attach it to the prop using different pins that the eeprom.
    It also needs a clock, the driver uses a prop counter to generate the clock.
    There are some delays from requesting the pressure to being able to read the pressure ~40ms. The driver call GetPressure can either be called and it will return immediately returning true if a pressure value is returned and false if not or it can wait until the pressure is ready and always return a pressure value. To calculate pressure it needs temperature which takes another 40ms - calling getpressure gets both and does all the necessary caculations to get pressure.
  • LarryGLarryG Posts: 50
    edited 2010-07-28 19:17
    @Tracy- Great info. Thanks for taking the time to update the chart. It is going to really come in handy soon.

    @Timmore- Thanks for the objects. I missed the part in the datasheet that the sensor has the same address as the eeprom. Too bad it cannot be changed.
  • Ezz_zzAEzz_zzA Posts: 1
    edited 2013-02-17 03:31
    Timmoore wrote: »
    I haven't used the MS5534 but I have used the bmp085, scp1000 and hp03 and I found they all need a reference. Its not really the sensor but the equations to translate from pressure to altitude needs a reference.

    So it depends on what you want to do. If you are looking for difference altitude from a time e.g. altitude from takeoff for a copter then you can use that for the reference, if you dont have that then you need to input a reference probably pressure at sea level at a location near to you which you can get from weather info sites.
    I'm sorry if my english is bad
    but can you tell me how to use hp03 with basic stamp?
    thank
Sign In or Register to comment.