@@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.
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)
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
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.
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?
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.
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.
Leave any questions you have in the comments. I hope the code helps!
can i see your wire diagram sir ?
@@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.
can you demonstrate a continuous rotation servo please?
Can it be done with Voice Control over Bluetooth?
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)
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
I definitely love the vscode environment. Its gotten to the point that I'm even taking notes in class on vscode.
I have a problem. My servo doesn't change direction.
if (currentMillis >= 2200) direction = false;
if (currentMillis
I defined currentmillis correctly: int currentMillis = 800;
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.
@@kleistrobotics thanks! New code works very well :)
Awesome, glad it works!
Newby question, where did you get the value 64.f and 39062.f from?
how did you manage to get all of the libraries such as hardware/pwm.h to be found and not to have red lines?
It will be a great helpful in my collage project
I compiled and uploaded the sweep.uf2 to my raspberry pico pico w but the motor does not move
can you demonstrate a continuous rotation servo please?
The code works the same, however the pwm value correlates to a speed instead of a position.
@@kleistrobotics
thanks i have played and managed to make it work
Great video! Clarified my doubts.. Thanks!
Glad to hear it!
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?
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.
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.
What does millis stand for? Did you mean microseconds?
It's microseconds. Not entirely sure where I got the shortening from.
@@kleistrobotics from arduino but there it means milliseconds