Altitude Estimation with Pressure Sensors (STM32, Firmware + Hardware) - Phil's Lab #68

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 มิ.ย. 2024
  • Estimating altitude (relative) with pressure measurements via a barometric pressure sensor. All the way from theory with equations, to implementation on custom hardware and custom firmware written for an STM32 microcontroller. Utilising an I2C/SPI-based absolute pressure sensor (SPL06-001), showing how the driver code was written. Including basics on simple digital IIR low-pass filters.
    Mixed-signal hardware design course: phils-lab-shop.fedevel.education
    [SUPPORT]
    Free trial of Altium Designer: www.altium.com/yt/philslab
    PCBA from $0 (Free Setup, Free Stencil): jlcpcb.com/RHS
    Tag-Connect: www.tag-connect.com/product/t...
    Patreon: / phils94
    [LINKS]
    GitHub: github.com/pms67
    [TIMESTAMPS]
    00:00 Introduction
    00:11 Altium Designer Free Trial
    00:34 JLCPCB & Design Files
    01:06 Altitude from Pressure
    02:10 Measuring Pressure
    03:16 Calculations
    04:15 Hydrostatic Method
    05:17 Filtering Measurements
    06:39 1st Order IIR Filter
    08:05 Hardware Overview
    09:11 Tag-Connect Debug Header/Probe
    09:51 Pressure Sensor Datasheet (SPL06-001)
    10:54 STM32CubeIDE Set-Up
    12:04 Implementation (main.c)
    16:31 Sensor Driver (SPL06.c/SPL06.h)
    17:36 Initial Interrupt/Firmware Test
    19:50 Pressure (Raw and Filtered) Measurement Test
    23:30 Altitude Estimation Test
    ID: QIBvbJtYjWuHiTG0uCoK
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 43

  • @islammohamed3954
    @islammohamed3954 ปีที่แล้ว +11

    Such joy when I get notified Phill’s lab has released a new video!
    Thanks alot for the remarkable content.

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +2

      Thank you very much!

  • @notDacian
    @notDacian ปีที่แล้ว +13

    Well done! I usually watch a lot of electronics/programming videos here on TH-cam, your videos are by far the most well documented/explained ones. In high-school i was pretty good at math, bun now after years of not using almost any math, i kinda get frustrated when i see math formulas, since i dont remember much of it... What i want to say is that i really appreciate they way you explain the theory and then implement it in code, something that usually other channels dont explain!
    I made a PID controller for a hot plate and i remember that i watched and read like 30 videos and articles but i was unable to create a good PID algo, then i stumbled upon your channel and in one hour i got it working imho perfectly.
    Thank you, please keep making excellent content like this

    • @damny0utoobe
      @damny0utoobe ปีที่แล้ว +3

      Yes. Phils videos are in depth, deeply educational and practical. Most other channels are too click baity. They are after the views. I hope Phil keeps the in depth and design theme of his channel.

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +1

      Thank you, Dacian! I'm glad to hear you found the videos useful. I had the same experience at university - a lot of theory with next to no coverage of actual implementation. Goal with this channel is to help with that :

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +1

      Thank you - definitely will try to keep the channel running along that theme :)

  • @damny0utoobe
    @damny0utoobe ปีที่แล้ว +1

    I spend a lot of money on Altium each year.
    Your videos are helping me make the most of it

  • @youtube.really.stole.my.handle
    @youtube.really.stole.my.handle ปีที่แล้ว

    I was REALLY hoping you might cover this, and Im so excited to be able to spend the time watching this. Just had to comment already, Thanks for always making great content Phil! I really appreciate all the work youve done leading up to this

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว

      Thank you very much, Anthony!

  • @yacineyaker7485
    @yacineyaker7485 ปีที่แล้ว

    that is a very great video i always love how you present them, well structured and documented

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว

      Thank you, Yacine!

  • @wiicchooo
    @wiicchooo ปีที่แล้ว

    Awesome content thanks for diving into the software side as well!

  • @tevereAR
    @tevereAR ปีที่แล้ว

    Your tutorials are always very useful, thank you for the effort you put in making them! I've been able to design and test very simple boards mainly thanks to your channel.
    I think I've seen external memory chips in some of your designs, will you ever make a tutorial on them? Especially the software side of things with the FileSystem and what not

  • @TinyHouseHomestead
    @TinyHouseHomestead ปีที่แล้ว +6

    Phil, .... you da MAN! 😁👍✌🎯

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +2

      Thank you, Terry!

    • @TinyHouseHomestead
      @TinyHouseHomestead ปีที่แล้ว +1

      @@PhilsLab nooooo, .... TankU! 😁👍✌

    • @PattysLab
      @PattysLab ปีที่แล้ว

      Exactly this 👌

  • @biswajit681
    @biswajit681 ปีที่แล้ว

    Phill I am eagerly waiting for your new course... please please publish it as soon as possible

  • @antonmadto
    @antonmadto ปีที่แล้ว +1

    As mechanical engineering I benefit a lot from your channel and your mixed signal course. My PCB design improving a lot.
    If I may request please make how to design a PCB with Ethernet protocol such as STM32F407.

  • @madrigo
    @madrigo ปีที่แล้ว +1

    Man I just love to receive a notification from your channel. Great video as always. Just wanted to ask you a question regarding the fluctuations on your differential pressure measurement by the end of the video: Aren't the oscillations natural? I mean, while you're moving and talking wouldn't that add to the "pressure noise" in your environment? Maybe putting a soda cap o top of the sensor to protect it from the very delicate and natural wind of your room would show some smoother results. I got curious because I'm developing a altimeter by pressure as well :) cheers!

  • @sarbog1
    @sarbog1 ปีที่แล้ว

    After a few changes to the software it is now woking, very cool!

    • @sarbog1
      @sarbog1 ปีที่แล้ว

      An interrupt request is provided by the generated software when the sensor has some data ready, one must satisfy this request by inserting the callback function into the interrupt request function ..... If any one is interested I will put my code up on Github.... let me know . I am no expert on C programming language but my code works. Improvement suggestions are welcome. Like Phil said, the sensor drifts....... Very cool to play with filter implementations and explore...... Thank you Phil.

  • @7alfatech860
    @7alfatech860 ปีที่แล้ว

    Nice walkthrough of the whole process. I believe the BMP280 has an IIR filter built in that can be activated if needed. I imagine one would not want to do another 1st order filter in software if using the built in filter?

  • @dankodnevic3222
    @dankodnevic3222 ปีที่แล้ว

    On the scale of few Pa, it is normal to get random wandering, even in the closed room (even smallest draft is caused by pressure diff.). For more reliable test, sensor should be placed in the hermetically closed jar (without touching for some 10 minutes).

  • @EmbeddedEnigma
    @EmbeddedEnigma ปีที่แล้ว

    just recently made drivers for BMP180 and I was thinking about how one can calculate altitude using this sensor. This video really helped.
    And can u make a video on, how one can reset i2c when it lockups in stm32

  • @aitorsierra
    @aitorsierra ปีที่แล้ว

    @Phil_Lab: In your constant PRESSURE_SEA_LEVEL_PA = 101325.0f is not Pa, is hPA (mBar) so if you are going to use the datasheet formula for altitude you have to divide by 100 because P0 is indicated in hPA.

    • @aitorsierra
      @aitorsierra ปีที่แล้ว

      Sorry, mistake. Your constant is Ok but the datasheet expression is in hPa.

  • @Quantum_Dots
    @Quantum_Dots ปีที่แล้ว

    Can you continue ESC design

  • @danielliden6829
    @danielliden6829 ปีที่แล้ว +1

    Could you do a STM32 with MPU6050 (or something similar with a gyroscope). Great video!

    • @antonmadto
      @antonmadto ปีที่แล้ว +1

      You could check his video STM32 using gyro (IMU) from Bosch. Check his video with title "STM32 Programming Tutorial for Custom Hardware | SWD, PWM, USB, SPI - Phil's Lab #13"

  • @falin9557
    @falin9557 ปีที่แล้ว

    I come from arduino and I would really like to enter STM uC. Could you make a tutorial for beginners?

  • @essentiallynoah
    @essentiallynoah ปีที่แล้ว +2

    What are your thoughts on using Rust for embedded development? Would love to see a video where you step through the bring-up process on one of your boards using Rust / give your reaction to the workflow.
    P.S. Amazing video as always!

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว +7

      Thanks, Noah! I never really considered using Rust nor seen a reason to use anything but C/C++ for embedded purposes. I'm also far more hardware-focused and can do everything I need to do with C (as I usually just write drivers, simple code to test boards, and some DSP/control algos). Since I just use CubeIDE, that also just ties in nicely with C. Happy to be convinced otherwise though!

    • @damny0utoobe
      @damny0utoobe ปีที่แล้ว +3

      @@PhilsLab exactly. C/C++ does everything I need and it's not assembly so for now, why introduce more work

    • @essentiallynoah
      @essentiallynoah ปีที่แล้ว

      If you've got some time/are interested, it might be a rabbit hole worth exploring. The tooling is still in quite early stages (you're not going to have the ease of configuration that CubeIDE allows for) but already it's quite an ergonomic development experience. Also Rust has nice things like guaranteed memory safety (segfaults and race conditions are compiler errors). Pair that with a package manager, automatic documentation for all published packages, and a robust open source community, it becomes a great option for quick firmware prototyping and improved security.
      TLDR: Shameless pitch for giving Rust a shot

  • @lohikarhu734
    @lohikarhu734 ปีที่แล้ว

    Funny that you mix terms 'height' and 'altitude', because they are different entities...altitude is, indeed, the correct term for measuring with barometric pressure, unless one is using barometric pressure to measure the height of a building, or a person, but, otherwise, 'Elevation' for topographical features, and 'altitude' for measurements not related to a 'thing', only the distance above MSL (typically)... I got laid into by a German civil engineer, one day, so I remembered. Picky, but you seem to be a person who might care ;-)

  • @MartinWolker
    @MartinWolker ปีที่แล้ว

    Useful for my personal project of variometer

    • @PhilsLab
      @PhilsLab  ปีที่แล้ว

      Glad to hear that, Martin!

  • @xpressivemusic4578
    @xpressivemusic4578 ปีที่แล้ว

    hi Phil could we have your other course on udemy?

  • @ivanarakistain3885
    @ivanarakistain3885 ปีที่แล้ว

    Hi! Can I buy you one unit of this PCB?

  • @rallymax2
    @rallymax2 ปีที่แล้ว

    10cm drift for a device that does almost 10km is way better than I thought it would do. That’s 0.001% error.

  • @enis1678
    @enis1678 ปีที่แล้ว

    pls share code 🙏

  • @mth469
    @mth469 ปีที่แล้ว +1

    A lot of base (or is it bass?)
    in this guy's
    voice.