How to use servos with Pico - C/C++

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024

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

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

    Leave any questions you have in the comments. I hope the code helps!

    • @Mark-ut3ml
      @Mark-ut3ml 3 года назад

      can i see your wire diagram sir ?

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

      @@Mark-ut3ml It's very simple. The orange wire on the servo gets connected to the pin defined in code. The brown wire goes to ground and the red wire goes to an external 5 volt power supply.

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

      can you demonstrate a continuous rotation servo please?

    • @Max_Bio
      @Max_Bio 3 месяца назад

      Can it be done with Voice Control over Bluetooth?

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

    Can you suggest me a method to drive a esc for a bldc motor. That how can i set the 1000ms and 2000ms value like in the real Servo.h function servo.attach(2,1000,2000)

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

    Thank you very much. You saved my day. These days everybody is working with python on Raspberry Pi Pico and it is hard to find people developing C libraries. Not only that but I started again to learn the VSCODE environment. I use Arduino , Raspberry Pico (mainly), STM32 and some more. I like everything in one place. Since I am using Ubuntu is was difficult in the beginning in setting it up but I am not coming back (but still I like the work done in Atom).
    Thanks again for the clean and informative video. Keep on the nice work.
    Vasilis

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

      I definitely love the vscode environment. Its gotten to the point that I'm even taking notes in class on vscode.

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

    I have a problem. My servo doesn't change direction.
    if (currentMillis >= 2200) direction = false;
    if (currentMillis

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

      I defined currentmillis correctly: int currentMillis = 800;

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

      It may be one of two things. Last night I updated the code because I realized I had made a mistake that made the library useless. If you downloaded the code before then, you should download the new code.
      The other thing is that the AR-3606HB is a continuous rotation servo. This means that if you set it to 800 micros, it will spin in one direction at max speed until you set it to the dead point, unlike the servos I showed in the video that go to a set position based on a potentiometer reading. But it should still change direction.
      The first thing I would try is redownloading the code.

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

      @@kleistrobotics thanks! New code works very well :)

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

      Awesome, glad it works!

  • @FarhanAli-xd5oe
    @FarhanAli-xd5oe 2 года назад

    Newby question, where did you get the value 64.f and 39062.f from?

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

    how did you manage to get all of the libraries such as hardware/pwm.h to be found and not to have red lines?

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

    It will be a great helpful in my collage project

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

    I compiled and uploaded the sweep.uf2 to my raspberry pico pico w but the motor does not move

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

    can you demonstrate a continuous rotation servo please?

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

      The code works the same, however the pwm value correlates to a speed instead of a position.

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

      @@kleistrobotics
      thanks i have played and managed to make it work

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

    Great video! Clarified my doubts.. Thanks!

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

    I was looking into servo.c and I don’t understand the need for line 27 “while (clockspeed/clockDiv/50 > 65535 && clockDiv < 256) clockDiv += 64;” to me it looks like it never runs (125,000,000)/(64)/50 = 39062.5 which is not greater than 65535 so it never runs. Could you explain the use of this while loop and the need to increment clockDiv by 64 for the wrap?

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

      I think I found the answer to my question. In pwm.h the function pwm_set_wrap requires inputs of (uint slice_num, uint16_t wrap) and uint16_t has the range 0-65535. You are just preventing overflow.

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

      Yeah, it's to prevent overflow. In most cases, it will never run and the variable "clockDiv" will stay at 64. However, if someone was to run this code on an overclocked pico, the clock speed could be much greater.
      To compensate for this, the pwm wrap variable would need to be higher, but as you mentioned wrap must be in the range 0-65535. If it overflows, the "clockDiv must be increased, essentially slowing down the pico clock in the eyes of the pwm module.

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

    What does millis stand for? Did you mean microseconds?

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

      It's microseconds. Not entirely sure where I got the shortening from.

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

      @@kleistrobotics from arduino but there it means milliseconds