Generating PWM Signals Using the Raspberry Pi Pico | STOP BIT BANGING on the RP2040!

Поделиться
HTML-код
  • Опубликовано: 6 июл 2024
  • In this video, learn how pulse width modulation works and how you can do it on the Raspberry Pi Pico. Learn about this and more on my channel, check it out! Please like and subscribe!
    0:00 Intro
    0:10 What is PWM?
    1:59 Some Math
    2:20 PWM on the RP2040
    3:39 Lets Code!
    4:45 Demo
    4:55 Outro
    Join us on Discord!: / discord

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

  • @lorenzo.c
    @lorenzo.c 3 года назад +17

    Good video.
    A note: in serial communications "Manchester encoding" refers to associating the logic value of a bit to the direction of the transition of the signal (so binary "1" corresponds to "high-to-low" and binary "0" corresponds to "low-to-high" or the other way round) rather than the level ("VCC" voltage and "GND" voltage). This means that, whatever the actual values of the information being transmitted, the serial stream will have one transition in each of the bit-periods.

    • @LowLevelLearning
      @LowLevelLearning  3 года назад +2

      Ah, yeah you're right good catch. I had the names mixed up

  • @weench
    @weench 2 года назад +6

    Thank you for the detailed explanation of the PWM before revealing the code

  • @MrVipulLal
    @MrVipulLal 2 года назад +1

    Exactly what I was looking for. Thanks!

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

    The best explanation I've seen about PWM on the Pi Pico. Would be perfect if you included an explanation of the PWM clock divider so you can produce much lower PWM frequencies... 👌

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

    great video, i have a question tho could this be used as a clock signal for data transmission?i haven't found any documentation about being able to get the clock signal from the pico and what this offers seems like it would be what i need but not sure.

  • @junaidpv
    @junaidpv 3 года назад +2

    Thanks! Especially for explaining the code.

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

    your the man ,this was really useful

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

    Mate the information from 2:21 onwards was exactly the answer to my question: Are all PWM channels using a common clock. Answer: YES. And I learned something. Thanks.

  • @brendanowen7563
    @brendanowen7563 3 года назад +1

    Well explained video. Had a working example in minutes.

  • @sonnentaugnu2184
    @sonnentaugnu2184 2 года назад

    Loved the video! Thank you very much.

  • @monsterhunter445
    @monsterhunter445 11 месяцев назад

    Can these be used to generate an analog tv signal? I am assuming not i am trying to get way to generate an analog output that is capable of driving a crt .

  • @HighfireX
    @HighfireX 3 года назад +2

    c examples are always appreciated. Was just thinking about learning how to use pwm

    • @LowLevelLearning
      @LowLevelLearning  3 года назад +1

      I found the PWM interface kind of confusing at first, I hope this clears it up!

    • @tinker7722
      @tinker7722 3 года назад

      PWM is often used to dimm an LED or also to control a servo.

  • @la6mp
    @la6mp 3 года назад

    How about making a stopwatch with microsec resolution?

  • @aka12176
    @aka12176 3 года назад

    Thanks so much. Clears alot

  • @yahmk3978
    @yahmk3978 2 года назад

    Thank you very much!

  • @davidkender4660
    @davidkender4660 2 года назад

    Thanks,
    Dave Kender

  • @DavisidMatius
    @DavisidMatius Год назад +2

    Cool video, thank you!
    I have a question for you, how can I set a PWM with 50Hz frequency.
    50Hz would require 2.500.000 as wrap point using the Pico's inner clock (125MHz)
    The thing is that according to the C header of the pwm_wrap_number void function, the wrap point number must be a uint16_t variable and 2.500.000 exceeds the variable maximum number (2**16).
    Thank you!

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

      If you wonder, 50Hz is because I want to control a servo using your method

  • @jeyaprakashrajaiah32
    @jeyaprakashrajaiah32 5 месяцев назад

    i m using rp2040 pwm with dso 100mhz i want create freq 100mhz but the square wave isn't coming it has much noice can you tell me please whats the reason and is it possible to create high freq with pico

  • @vipullal7689
    @vipullal7689 2 года назад +1

    Great, but you might have discussed the fractional dividers.

  • @flethacker
    @flethacker 2 года назад

    Is it posssible to use this to control a dc motor to turn on off and maybe even speed purely in sofware on pico?

    • @monsterhunter445
      @monsterhunter445 11 месяцев назад

      Yes PWM is used for that and buzzers. Encoding digital information as well.

  • @tareqshahriar2587
    @tareqshahriar2587 2 года назад

    That's good

  • @ananduajayan8829
    @ananduajayan8829 2 года назад

    What's the maximum frequency of the PWM signal that we can produce using Raspberry pi pico?

    • @sonnentaugnu2184
      @sonnentaugnu2184 2 года назад

      I can only assume, but I would say 125/2 MHz (62,5 Mhz), if you let the counter count to one as wrapping point. but there could be more limitations due to delay in the timer mechanics.

  • @nin1ten1do
    @nin1ten1do 2 года назад

    can i have wish?? For example of 2 chanel with 180degree phase shift ( not flip flop) with seting of frequency and also duty cycle?? coz at time 0 we shut have one pin HIGH and second pin LOW output.. let se for example for H-BRIDGE i can deal with that code somehow.. still pain for me to use arduino.. ijust try miniaturized my dual chanell function generator and IR2153 or etc was not abble go up to 1MHz per chanell with dudy drive + freq set + phase shift they in the best scenation end at 466kHz.. and ton of EMI problems..

    • @julianbinder2371
      @julianbinder2371 2 года назад

      I don't think you can use PWM like that, you could use PIO for that thou, which the pi pico also has

    • @nin1ten1do
      @nin1ten1do 2 года назад

      @@julianbinder2371 i do and i will share code kid.. dont say you cant.. it is only lack of efford..

    • @abdullahahmed7781
      @abdullahahmed7781 2 года назад +2

      @@nin1ten1do sooooo.... 3 months have passed. Im also a naive kid, can you share the code now? With your dedication and eFfoRT Im sure you have coded the most optimal and beautiful solution 😂

  • @Arthur60
    @Arthur60 2 года назад

    03:20 : On the diagram count 500 should be the same as, not followed by, count 0.

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

    haha duty cycle