HC-SR04 Ultrasonic Range Sensor with Raspberry Pi Pico (C++ & PIO)

Поделиться
HTML-код
  • Опубликовано: 4 окт 2024
  • Video Sponsor: PCBWay www.pcbway.com/
    I explore the HC-SR04 Ultrasonic Range Sensor and connecting this to a Raspberry PI Pico. I explore two code strategies for working with the HC-SR04: using Interupts to calculate the echo time and using PIO to do this.
    I got carried away a little with exploring these devices and decided to try to use four of them in parallel. This uses up a lot of the GPIO pads, so I wondered if we could combine the trigger. Watch the video to see if this works.
    All of the source code for this experiment is included in the GitHub Repo: github.com/jon...
    For the PIO integration I also use an excellent library by
    Daniel Garcia-Briseno which can be found here:
    github.com/dan...
    Sponsor: PCBWay: www.pcbway.com/ PCB prototyping, assembly, 3D printing, CNC, sheet metal fabrication and injection moulding.

Комментарии • 16

  • @SamTurmer
    @SamTurmer 10 месяцев назад +1

    Hi Thanks for your comment regarding the some of the pins on a Pico being 5v tolerant. That helped me get my Ultransic sensor running correctly using a 5v without worrying that the echo 5v signal would blow the pin.

    • @DrJonEA
      @DrJonEA  10 месяцев назад

      Glad it helped. Have recently had a few conversations suggesting that 5v in gpio may decrease life of the Pico. Remember ideal is 3.3v.

  • @prashkd7684
    @prashkd7684 Год назад +1

    These modules operation on TTL logic and the proposed voltage divider circuit may not be that reliable. The 5V to 3.3V TTL modules would've been a better option as they're dirt cheap and each module has 4 channels.. perfect for this project.

    • @DrJonEA
      @DrJonEA  Год назад

      Thanks. I've talked about logic level shifter modules in other videos. The best option is to use HC-SR04P and operate it as 3.3Volts. If I had not had a bunch of HC-SR04 already I would have gone that route, as I say in the video.

  • @prashkd7684
    @prashkd7684 Год назад +1

    The ultrasonic wave you showed in the graphics.. does it propogate on one plane only or does it propogate both vertically and horizontally ? I've see them installed vertically on some robots and I always wondered if their orientation maked any difference or not !

    • @DrJonEA
      @DrJonEA  Год назад +1

      It propagates both vertically and horizontally. I think it is 30 degrees on both axis.
      Sorry if my graphics are limited, but yes, you could happily orient these vertically. I've seen that done too.

    • @prashkd7684
      @prashkd7684 Год назад

      @@DrJonEA So is it fair to say the ultrosonic sensor will detect anything that falls within the 30 degree "Cone" under a distance of 10 cms ?
      The robot I am planning to build is slightly larger and I just want to ensure I've sufficient number of these sensors placed to ensure there're no gaps that my let the robot run into an obstical.

    • @DrJonEA
      @DrJonEA  Год назад

      From spec these should cover 34Deg. The signal and echo is though strong towards the centre of the cone. Therefore the range is going to vary depending on where this is in the cone.

  • @bckends_
    @bckends_ Год назад +1

    hello sir, you have mentioned that you experimented with a hexapod robot in the past. would you mind sharing the software for this project?

    • @DrJonEA
      @DrJonEA  Год назад

      I will have a look. That is all Python for ROS1 though.

  • @bulentozgur70
    @bulentozgur70 9 месяцев назад +1

    What is the distance resolution of sensor? mm or micron? Thanks.

    • @DrJonEA
      @DrJonEA  9 месяцев назад

      A few mm. You can improve through some analytical smoothing of the results. Also using accurate temperature sensing as speed of sound changes with temperature in air.

  • @bstanis1237
    @bstanis1237 Год назад +1

    Thank you so much Dr. Jon, I'm so appreciative to you for these great contents;
    I'm new subscribing in your channel, I found it very interesting; please, continue with this amazing efforts;
    Please, I'm beginner, so I'm confused concerning the relationship with Raspberry Pi Pico and programming it with C++,
    as I now; Raspberry Pi Pico is matched to operate with python?
    Please, if you could explain me the intrinsic idea about using C++ for Raspberry Pi?

    • @DrJonEA
      @DrJonEA  Год назад +1

      Thank you for subscribing.
      You can use a number of languages on the Pico. I am aware of Python, Basic, Forth and C/C++ being used. I tend to use C/C++ as it is well supported in terms of toolchain and being compiled language is efficient. So I can get the most power out of the RO2040 processor.
      For some of the stuff I do Python would be fine. But other projects where I have multitasking going on the only real choice is C/C++. Python on a Pico will only support one thread per core. In C/C++ with FreeRTOS I can achieve a lot more.

    • @bstanis1237
      @bstanis1237 Год назад

      I'm so thankful to you, really, I get deeply the idea that you tried to share with me :), So, we can say C++ is the best language to be used for my own projects to get the optimum hardware and their related components usage!!@@DrJonEA

    • @DrJonEA
      @DrJonEA  Год назад +1

      Only you can make that decision.