Raspberry Pi Pico Servo Motors via PWM

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ก.พ. 2021
  • In this video we take a look at a common micro servo motor and figure out how to drive it with a Raspberry Pi Pico and a PWM signal. The demo code is available on github at github.com/tinkertechtrove/pi...
    Comments and feedback always welcome.
    Copyright free music from Stream Beats www.streambeats.com/
  • วิทยาศาสตร์และเทคโนโลยี

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

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

    Tim these pico tutorials are gold!! Thank you!

  • @4ur3n
    @4ur3n 2 ปีที่แล้ว +1

    HUGE LIKE, I tested another code and I thought my little servo was broken, but your code worked like a charm.

  • @jayk806
    @jayk806 2 ปีที่แล้ว

    What a great video. I learned so much about servos and the pico. Thanks for sharing this info!!! 😁

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

    *Helpful information:* The reason you had to use expanded duty cycle values is that the sg90 servos are actually 120-degree servos. Most Chinese documentation is wrong. They do have a max rotation of 200 degrees but it requires a bigger range of duty cycles than what the documentation states. If you run the servos at 900us -2100us duty cycle you will get the 120 degrees. To measure this you can use the shell in Thonny to set the duty cycle to duty_ns(900000) and mark the location and then set the duty cycle to duty_ns(2100000). This will result in the 120degree rotation that the servo is actually meant for. I have found that for most of these servos a duty cycle of 600us and 2500us will result in the 180 degrees that we want.

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

    Hi Tim, Great video, working through my arduino kit with my new Pico. This and your stepper video have been really useful!

  • @eternaldoorman5228
    @eternaldoorman5228 11 หลายเดือนก่อน

    It's a Pi co-processor, so you were right the first time, I reckon!

  • @SoggyCashew
    @SoggyCashew 2 ปีที่แล้ว

    Learned a lot thank you

  • @rahula3944
    @rahula3944 2 ปีที่แล้ว

    really good explanation...

  • @MicrobyteAlan
    @MicrobyteAlan 3 ปีที่แล้ว

    Interesting and well presented, thanks. I sub’d 👍🏽

  • @qcasares
    @qcasares 3 ปีที่แล้ว

    Really clear and simple explanation. EXCELLENT!

  • @mohamedfarid7499
    @mohamedfarid7499 2 ปีที่แล้ว

    thank you Mr.Tim , i use adafruit keypad hid library to stop and start the video using macro push bottom

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

    Hi Tim, Your videos are so good. They're still relevant. Won't you be making more? It's been a year!

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

    why did you use for _ in instead of: for i in range ? Also, why did you limit to 1024? Also would of been nice to see the code running the servo!

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

    Tinker...a very interesting coding. How can I modify the code so that, at switch on, the Horn moves to Zero Position, then requests the user to tell it (via a text message in the shell area) to what angle it should move, and at what speed.. I am a newbie at MicroPython so having to just play with the various variables. At the moment the code just makes the horn thrash back and to.

  • @JarleTeigland
    @JarleTeigland 2 ปีที่แล้ว

    Great Video- n00b question - HOW do you interpret datasheets from the servos (into duty cycle etc) ??? Having Trouble with a servo/robot arm

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

    SHOW 😁 🇧🇷

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

    I really need to make a catalogue or something to figure out all the random parts I have in my electronics kits. Would be nice to have the part numbers or store links in the description (^_^)

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

      Thanks for the feedback, that's not a bad idea :-)

  • @naomisunga4799
    @naomisunga4799 2 ปีที่แล้ว

    Hello, can I ask if we can code a pid control in the servo motor using raspberry pi pico? (sadly, without the use of arduino)

  • @chrisl2656
    @chrisl2656 3 ปีที่แล้ว

    It’s normal for a servo to want a pulse of between 1ms (0 degrees) and 2ms (180 degrees), which would equate to PWM duty cycles corresponding to what your data sheet recommended. 50Hz = 20ms. 1/20 = 5%, 2/20 = 10%.
    I think the fact that you had to significantly expand this range is because your sweep is much faster than the servo can physically track. Try an alternating 5% for 5 seconds, 10% for 5 seconds and I expect you’ll see the range of motion is very close to the full 180 degrees.

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

      Oh that's very interesting, it would explain things. I'll give that a go, thanks for the suggestion!

  • @bosqueblanco3744
    @bosqueblanco3744 2 ปีที่แล้ว

    this is one of the first videos i watched to get an understanding of using servos with my micro controller -
    revisiting it now as i have upgraded to mg90s servos for a robot project and mainly i wanted a clarification to the importance of that last line of code:
    "pwm.duty_u16(duty)"
    i thought it corresponded to what pin was in use but i see this is incorrect - can someone explain?

  • @manwithgutz
    @manwithgutz 2 ปีที่แล้ว

    Hi, Possible to do one for a drone brushed motor?

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

    Duty_u16 has a range of 0-65534, doesn’t it? Maybe that’s why you had to jiggle your calculated values for full range movement as you were using 65025?

  • @guillermosuperboy2001
    @guillermosuperboy2001 3 ปีที่แล้ว

    hi could you explain me why " direction = -direction " in the if and elif, what does it mean and how does it work? thanks you very much

    • @tinkertechtrove2910
      @tinkertechtrove2910  3 ปีที่แล้ว

      Sure, if direction is 1 then -direction sets it to -1. If direction is -1 then -direction sets it to -(-1) which it 1. So its just a quicker way to say "if direction == 1: direction = -1; elif direction == -1: direction = 1". This value, 1 or -1, is then added to the servo position control to make it 1 bigger or 1 smaller as needed. Hope that helps

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

      @@tinkertechtrove2910Thanks a lot I hadn't understood that part

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

    how many volts is your supply?

  • @elfenmagix8173
    @elfenmagix8173 2 ปีที่แล้ว

    Great video BUT...
    1) The SG90 (and the MG90) has a swing of about 210 and not 180. But 0 to 180 is used so that the arm is not pulled back when it goes past 180 degrees.
    2) "High Torque?" It is called the SG90 because 90grams of the max allowed force the servo should run on. Anything more the plastic gears start to get chewed up. Now, the MG90 is a metal gear version of the SG90. Though the gears are metal in the MG90, does not mean one can go past 90grams though it can handle 4x the force, you can still break it.
    The SG90 and the MG90 are the same shape and size though the SG90 uses plastic gears and the MG90 uses metal gears.
    Otherwise great video!

  • @timwalt9190
    @timwalt9190 3 ปีที่แล้ว

    since now the pico is supported on the arduino ide, can you do a tutorial how how to program the pico and servos with pwm using arduino ide

  • @rizacelik
    @rizacelik 3 ปีที่แล้ว

    How can we read PWM from an RC receiver, can you make a simple example. Can you take a video.

  • @Mark-ut3ml
    @Mark-ut3ml 3 ปีที่แล้ว

    sir how can i turn 1 time 360degrees

    • @tinkertechtrove2910
      @tinkertechtrove2910  3 ปีที่แล้ว

      The sg90 can only turn through 180degrees.

    • @Mark-ut3ml
      @Mark-ut3ml 3 ปีที่แล้ว

      If mg996r sir you tried ?

    • @MrBeiger
      @MrBeiger 3 ปีที่แล้ว

      I got the Micro Servo 9g SG90 and it can definitely spin around and not just 180 degrees.

  • @johntyler4222
    @johntyler4222 4 หลายเดือนก่อน

    Every single video on this subject ends up making the servo run backwards and forwards but nobody takes it any further and shows how to move to a certain point if some input occurs and another point if something else happens. It’s only half a story.

  • @projo2
    @projo2 3 ปีที่แล้ว

    I did a Google search and the definition audio pronounced it Peye-Co.

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

    Sorry OldMan but if you had Zoomed_In on the CodeScreen I'd have given you a Thumb'sUp instead of a Thumb'sDown.
    You need to BrushUp on your YT_VideoSkills.....

    • @TheUnofficialMaker
      @TheUnofficialMaker 2 ปีที่แล้ว

      yeah, I had to look at the code on his github page.Contrast sucks too.