Raspberry Pi Pico W LESSON 9: Getting Analog Output Using PWM (Pulse Width Modulation)

Поділитися
Вставка
  • Опубліковано 15 вер 2024

КОМЕНТАРІ • 110

  • @patrood1557
    @patrood1557 Рік тому +8

    I would like a class on the oscilloscope. Thank you for your classes. I really enjoy them. I appreciate the time that you put into preparing these lessons. I have a Hantec DSO5102P oscilloscope, a DDS Signal Generator/Counter, and a Dr. meter DC Power Supply HY3005F-3 dual power supply.

    • @davidconley9852
      @davidconley9852 3 місяці тому

      I would also be interested in a class on the use of the oscilloscope.

  • @justmc62
    @justmc62 Рік тому +7

    Wow...another great lesson. Would love to see an introduction to oscilloscope's series, count me in . Always been a bit intimidated and need to jump into the deep end 😉 Thank you Paul.

  • @jasonrhoades4122
    @jasonrhoades4122 Рік тому +1

    i would love to have a class on using an oscilloscope. I hope enough other ppl want it too. Love your classes, they are fun & useful. Thanks Paul.

  • @thematthew4246
    @thematthew4246 Рік тому +2

    I think the osciloscop class would be awesome !!!
    thanks for the great lesson on PWM!

  • @edSabio572
    @edSabio572 Рік тому

    Paul, I reworked my homework. I don't have a scope but watching other student's projects gave me a better understanding of the analog world.

  • @cbrombaugh
    @cbrombaugh Рік тому +1

    I am reluctant to claim legendary status for completing this homework. My breadboard still had a red LED connected to the Pico W from the previous homework, so I only had to select the right pin and BOOM it worked. 💡

    • @ctlancearrowlarson8237
      @ctlancearrowlarson8237 Рік тому

      I had the same thought. Connected to GP16 first, but later used GP15. I still have all my components for lessons 1-9 connected to the board. I leave the grounds connected, but remove all pin wires, except for the pins being used on the current lesson. I've only used the first 3 1/2 inches of the 6 1/2 inch breadboard so far. At a point I'll run out of breadboard or components, but it will be a while. It makes reviewing lessons easier.

  • @BertRichard-k6m
    @BertRichard-k6m 19 днів тому

    I generally followed how you did it in the video, but added checks / corrections for values less than 0 or greater than 3.3, to make sure values are controlled and within expected range. Also didn't bother with a sleep statement as I didn't feel it necessary for this exercise.
    Thanks for the awesome videos! Just got my SunFounder kit - I started the lessons with components from previous kits but wanted to make sure I have identical hardware moving forward.
    from machine import PWM, Pin
    outPin = 16
    analogOut = PWM(Pin(outPin))
    analogOut.freq(1000)
    analogOut.duty_u16(0)
    while True:
    myVoltage = float(input('What voltage would you like? '))
    if myVoltage < 0:
    myVoltage = 0
    elif myVoltage > 3.3:
    myVoltage = 3.3
    myPwmVal = int(myVoltage * (65535 / 3.3))
    analogOut.duty_u16(myPwmVal)

  • @MultiNavneeth
    @MultiNavneeth Рік тому +1

    Hello Paul
    I been following you for last one year and being a mechanical engineer, your classes have helped understand basics well.
    a class on using the oscilloscope would be great. waiting for it.
    Thank you!

  • @pralaymajumdar1206
    @pralaymajumdar1206 7 місяців тому

    outstanding lesson👍👍🙏....we are very fortunate to get you sir in UA-cam... Your knowledge surprise me a lot..

  • @Wythaneye
    @Wythaneye Рік тому +6

    Since it keeps coming up, here's a link to Paul's guide to getting started with OBS: ua-cam.com/video/X707dBfCys0/v-deo.html

  • @ericsmith7988
    @ericsmith7988 Рік тому +1

    Would enjoy lessons on an oscilloscope. I have a small one for now but have been looking at 2 channel scoops. Thanks for the Pico lessons.

  • @qzorn4440
    @qzorn4440 Рік тому +1

    wow WW2 Chaga Mushroom ICE Coffee is soo wonderful 🥰 Thanks.

  • @lorisrobots
    @lorisrobots Рік тому

    Excellent Lesson Paul. I would love to take an oscilloscope series from you. Thanks for making these lessons!

  • @JimmeShelter
    @JimmeShelter 10 місяців тому

    An oscilloscope class is a GREAT idea.

  • @scottwait3585
    @scottwait3585 Рік тому

    Thanks Paul! Always like the math aspect. Makes your videos really helpful

  • @PapiJack
    @PapiJack 7 місяців тому

    Love the videos. My OCD flares up when I see no spaces after a comma or an = signs 😅

  • @jeanfrancoisbouchard8400
    @jeanfrancoisbouchard8400 10 місяців тому

    Thanks again for this class. I would like a class on the oscilloscope

  • @rd-tk6js
    @rd-tk6js 9 місяців тому

    super useful, enjoying through the series and learning as well, thanks !

  • @filiepmaes9071
    @filiepmaes9071 Рік тому

    I would love to take an oscilloscope series from you

  • @factoftechandlogic698
    @factoftechandlogic698 7 місяців тому

    Great teacher

  • @oracid
    @oracid Рік тому +1

    Thank you for all !
    Why 65550 instead of 65535 ?

    • @paulmcwhorter
      @paulmcwhorter  Рік тому

      Because I was not paying attention. Also, I was recovering from malaria and pneumonia when I recorded the lesson

    • @oracid
      @oracid Рік тому

      @@paulmcwhorter I'm sorry to read this. I hope you feel better.
      Thanks again for your tutorials.

  • @marinehm
    @marinehm Рік тому

    Interesting... You brought out the oscilloscope. Can you do a video on a real word application for using the oscilloscope? I got a $40. oscilloscope kit just for fun. I soldered it all together. Seems to work ok. But what is it really used for? The only thing I can think of is to see the ripples and experiment with different ceramic capacitors to smooth them out to get a clean signal. I'm sure there are a LOT more uses. Please enlighten me.

  • @masman1st
    @masman1st 2 місяці тому

    In the first graph of Voltage vs time, Voltage was the y axis and time was the x axis, but when you did the math you changed the Voltage to the x axis and time to the y axis. Why?

  • @MorrWorm8
    @MorrWorm8 8 місяців тому

    what program do you use? say when you are switching cameras. be cool to see a bonus video on how you do your UA-cam stuff. you definitely switch from camera to camera very seamlessly. very well done. liked and shared. subbed a long time ago.

    • @paulmcwhorter
      @paulmcwhorter  8 місяців тому +1

      Wirecast. It is a program you have to pay for. That is what I use. OBS is a free program that does most of what Wirecast does.

    • @MorrWorm8
      @MorrWorm8 8 місяців тому

      @@paulmcwhorter oh nice, thanks for the response!!

  • @rickbonari4493
    @rickbonari4493 Рік тому +1

    Hi Paul,
    Great lesson as always. Sixteen bit is actually 0-65535. I noticed you are using 0-65550. This would explain I believe why your voltage is a bit high from what it should be....Rick

    • @rickbonari4493
      @rickbonari4493 Рік тому

      Am I thinking about this correctly? Thanks much

    • @rickbonari4493
      @rickbonari4493 Рік тому

      Hi Paul,
      Am I thinking about this wrong? 16 bit from what I have learned is 2 to the 16th power which is 65536 or 0-65535. Just wondering why you are using 65550 in your calculations? Does this have to do specifically with the pico w analog inputs? Look forward to your reply and thanks much for all you do. Hope and pray you and yours are safe and well....Rick

    • @ctlancearrowlarson8237
      @ctlancearrowlarson8237 Рік тому

      I agree. In lesson 7, Paul uses the value of 65,535. Don't know how you noticed that, very sharp thinking. I think Paul likes baseball, and he through us a curve ball. I think you hit it out of the park! Also lesson 5 at time 20:00-20:50 he calculates 2 to the 16th power-65535. But 15 digits isn't much with a number as large as 65550.

    • @ctlancearrowlarson8237
      @ctlancearrowlarson8237 Рік тому

      Somehow I got confused with the previous lessons. I have no idea who's correct. If I was a better, I'd have to go with Paul. Looking at lesson 9 code, I don't see anything mentioning the potPin, and this is PWM. I believe the previous values were from the potPin. But I'm fine using 65,550. Just wish I made better sense with this comment.

    • @rickbonari4493
      @rickbonari4493 Рік тому

      Yes, I was sruck on the pot pin which is reading the pot pin in a/d. I glossed over the fact that we are talking pwm and not a/d. There is a reason Paul is the best there is on the internet !!!! Thanks for your comment.

  • @TheTechRancher
    @TheTechRancher Рік тому

    I would enjoy a class on the oscilloscope. Count me signed up for it.

  • @zbigniewloboda3393
    @zbigniewloboda3393 Рік тому

    Very good presentation 👍

  • @ke7uia
    @ke7uia Рік тому +3

    I do enjoy doing these problems. They are just the right amount to work on such topics. I started with the board layout with pin 16 and then pin 15 with an Led. I tested the voltage first with pin 16, then showed how to dim the led with pwm. ua-cam.com/video/8J3w2BeQBlI/v-deo.html

  • @kengtecksoh4789
    @kengtecksoh4789 6 місяців тому

    Hi Paul, Any reasons for not using 65535 as the maximum value of u16 (unsigned 16 bit)?

    • @paulmcwhorter
      @paulmcwhorter  6 місяців тому +1

      typo on my part, but practically the error is in the noise. Yet still an error.

  • @masman1st
    @masman1st 2 місяці тому

    Hooked my Fluke 21 Multimeter to PWM outPin. Voltage reads 3.28 when asking for 3.3 volts. All reading are lower then Voltage asking for. Not sure how accurate Pico is or if my Fluke 21 is off, been awhile since it was tested. But voltage readings change as user input changes voltage.

    • @paulmcwhorter
      @paulmcwhorter  2 місяці тому

      Your fluke is correct. Voltages from Pico are not exact.

  • @drdentin3215
    @drdentin3215 Рік тому

    Hello. The Pinout sheet Paul show is different than what came with my Pico W (but the same as the ones shown in previous videos) perhaps I need some nomenclature explained? I don't see PWM on anything, also if I try to suit match the color code that doesn't work either for example physical pin (behind Paul in the video doesn't match anything on pinout card?? Thanks in advance. Bill

    • @paulmcwhorter
      @paulmcwhorter  Рік тому

      THe pins are general purpose pins, so can be used for different things. The new pinout shows specifically which pins are for PWM

  • @charlotteswift
    @charlotteswift Рік тому

    Hi Paul
    I just want to register my interest in classes using an oscilloscope. I have the same make as yours in the touchscreen version. They seem to have the same functionality

  • @gautamarora9448
    @gautamarora9448 11 місяців тому

    Hey Paul, I have a question. Can I set the number of PWM waves to be sent in pico pi? I don't want to change the frequency or control time explicitly, I want to control the number of pulses like we do with frequency and duty cycle.

    • @paulmcwhorter
      @paulmcwhorter  11 місяців тому

      No, you would have to create a custom function for that. Doable, but not with the standard pwm library.

    • @gautamarora9448
      @gautamarora9448 11 місяців тому

      @@paulmcwhorter but can I read the pwm input using pico pi? Like count the number of pulses received.

    • @davidh1187
      @davidh1187 6 місяців тому

      @@gautamarora9448 that would require a frequency counter and none of the Pi Pico inputs offer that (as far as I am aware)

  • @davidh1187
    @davidh1187 6 місяців тому

    _U16 - shouldn't it be 65535 rather than 65550! Interesting that I can only get 3.1v out of the PWM pin when set to 3.3v. In any case here is my version with output on DVM and Oscilloscope - ua-cam.com/video/QXZBtis1Gqw/v-deo.html. Turns out, unloaded, the pins put out the correct voltage. It appears the pi Pico pins can't handle much of a load at all since at 3.3v the LED was only pulling 3.4mA.
    For those wondering about those cheap little scopes - they do work - here's an example with this lesson ua-cam.com/video/u1EW1s58s44/v-deo.html

    • @paulmcwhorter
      @paulmcwhorter  6 місяців тому +1

      It was a typo on my part. Not really going to affect results, but should have been 65535

  • @danielsaenz5570
    @danielsaenz5570 Рік тому

    Hello Paul! Since I don't have an oscilloscope, I can use the analog read function, if I were to do that how would I set up the circuit? Would the output pin (GPIO 16 for me) be hooked up to GND, then I put a wire there and read the voltage?

    • @paulmcwhorter
      @paulmcwhorter  Рік тому

      I am really not sure what would happen if you try and read a PWM signal that way. Interesting question though.

  • @karthick930
    @karthick930 Рік тому

    Hi tutorial is nice. How to use Wifi to send data to Thingspeak or Blynk cloud using this hardware

  • @ctlancearrowlarson8237
    @ctlancearrowlarson8237 Рік тому

    I imputed 3.4 volts into the program and noticed the LED stayed on. I tried to write an if statement to turn off the LED. That should of been easy, but it's not for me. But it's still fun trying. If myVoltage > 3.3:
    myVoltage==0 I'm just a rookie, still learning.

    • @keithlohmeyer
      @keithlohmeyer Рік тому

      Hi maybe try...
      if myVoltage > 3.3:
      myVoltage = 3.3
      The double equals is a comparison. The single equals is an assignment.

    • @peterkarlsson7801
      @peterkarlsson7801 Рік тому

      It should only be one equal sign when setting the voltage to 0, like this
      If myVoltage > 3.3:
      myVoltage=0

  • @jiioannidis7215
    @jiioannidis7215 Рік тому

    I initially assumed that you were using a paper notebook with an overhead camera (which is what I do)... so disappointed when I realized you are using a tablet :) :) :)

    • @paulmcwhorter
      @paulmcwhorter  Рік тому

      I find it hard to use an overhead camera and pen. Seems my hand always blocks a good view of what I am writing.

  • @DKNW62
    @DKNW62 Рік тому

    Hi anyone know where i can buy the sunfounder kit in the uk amazon shows no stock ta

    • @charlotteswift
      @charlotteswift Рік тому

      @DaveNWUK My reply seems to have disappeared😿 I get stuff from US Amazon. The postage isn't too bad and the prices for tech stuff are usually lower.

  • @jameslewellen150
    @jameslewellen150 Рік тому +2

    Here is the link to my homework, ua-cam.com/video/YHZzt5x2idk/v-deo.html. Great explanation of Pulse Width Modulation (PWM), thanks Paul for the videos and get over that malaria and get better.

  • @utube521
    @utube521 5 місяців тому

    how to do this in Arduino? thank you

  • @farshidowrang2762
    @farshidowrang2762 Рік тому

    Takk!

  • @freddyveza
    @freddyveza Рік тому

    This is my homework, no video this time, the most important part is keeping an eye on user interactions and printing graceful messages accordingly
    from machine import PWM, Pin
    from time import sleep
    pwmPin = PWM(Pin(15))
    pwmPin.freq(1000) # 1 millisecond
    pwmPin.duty_u16(0)
    voltage = 0
    dutyValue = 0
    dutyRange = range(0, 65536)
    def main():
    while True:
    try:
    voltage = float(input(f"What voltage would you like? (0, 3.3): "))
    dutyValue = int((65535 / 3.3) * voltage)
    if dutyValue in dutyRange:
    print(f"voltage: {voltage}, dutyValue = {dutyValue}")
    pwmPin.duty_u16(dutyValue)
    sleep(.1)
    else:
    print(f"Voltage out of range (0, 3.3)")
    except ValueError:
    print("Invalid value, please enter numbers only")
    try:
    main()
    except KeyboardInterrupt:
    pwmPin.duty_u16(0)
    print("
    See ya later, RPi Pico!")

  • @TimNudd0525
    @TimNudd0525 Рік тому +1

    I am legend! Beginner based homework video: ua-cam.com/video/d9lf6UqhLlA/v-deo.html went a little longer than planned but kinda went above and beyond this lessons' assignment and incorporated some prior lessons in with this homework.

  • @kev67uk
    @kev67uk Рік тому +1

    Thanks Paul, another great lesson that makes things very easy to follow along. Homework video is here: ua-cam.com/video/pp9uHtKGvXM/v-deo.html 😊

  • @chases9870
    @chases9870 Рік тому

    i am lengend

  • @WilliamBurlingame
    @WilliamBurlingame Рік тому +1

    Link to my lesson 9 homework video ua-cam.com/video/ze3FoLVIa54/v-deo.html

  • @Wythaneye
    @Wythaneye Рік тому +1

    Homework for Lesson 9: ua-cam.com/video/CcKrZY9ePaI/v-deo.html

  • @jimworden9021
    @jimworden9021 7 місяців тому

    Paul, this one seemed to just cry out for a bit of embellishment so I added a few things.
    ua-cam.com/video/B09ALl8W17Y/v-deo.html

  • @danny12345
    @danny12345 Рік тому

    Hello Paul
    Can you make videos connecting arduino mega 256 or uno, to the internet by esp8266
    or in any other form
    Thank you

  • @charlotteswift
    @charlotteswift Рік тому

    Here's my solution to this lesson (and also to what I think the homework will be for lesson 10) - ua-cam.com/video/s8VXOpwp-RY/v-deo.html

  • @daveslack2755
    @daveslack2755 7 місяців тому

    Thank you for your lessons. Here is homework from this lesson - tried some error checking for bad input. ua-cam.com/video/yLQVECjfl68/v-deo.html . In hind sight forgot to test for negative input. Needed another if statement to check for voltage input of minus values.

  • @karliskide2460
    @karliskide2460 Рік тому

    Thank you for the lesson! Would love to see the class on oscilloscope. Here is my homework for today: ua-cam.com/video/ZJBSL_PlCqA/v-deo.html There is some voltage-drop, when LED with resistor is in the closed circuit, that is why multimeter is showing less voltage.

  • @bradjaspers9990
    @bradjaspers9990 Рік тому

    Another fun lesson to keep my mind young! Thank you so much Paul! Homework link- ua-cam.com/video/vcYiCxFqclY/v-deo.html

  • @TheTechRancher
    @TheTechRancher Рік тому

    Homework link: ua-cam.com/video/yUsnZP5dOQY/v-deo.html Thanks Paul.

  • @adammcquade7026
    @adammcquade7026 8 місяців тому

    ua-cam.com/video/QOgGI5Gc11M/v-deo.html I was cheeky and hadn't dismantled my bread board, just seemed simple to swop the green led output from gpio13 to 16 lol

  • @danielsaenz5570
    @danielsaenz5570 11 місяців тому

    Hello Paul! Here is the link to my Homework solution: ua-cam.com/video/HEW-AbTXKqs/v-deo.html

  • @djicedragon855
    @djicedragon855 4 місяці тому

    Homework uploaded. ua-cam.com/video/hm1y0MAHeKo/v-deo.html

  • @aravjain
    @aravjain 8 місяців тому

    Thanks for the great video as always! Here's my homework: ua-cam.com/users/shortsBHIZRWGrnzw

  • @bigbogeyface
    @bigbogeyface Рік тому

    Here's my homework:
    ua-cam.com/video/_uC7n65xZgA/v-deo.html 🙂👍

    • @paulmcwhorter
      @paulmcwhorter  Рік тому +1

      LEGEND!

    • @bigbogeyface
      @bigbogeyface Рік тому

      ​@@paulmcwhorter
      I did a second homework because I didn't like my first one too much.
      Here it is: ua-cam.com/video/wKh2hGMuUY0/v-deo.html ✌️😊