Arduino with servo

Thread Starter

clark.kent156

Joined Aug 17, 2019
50
Hi. I'm new to arduino, but I'm a quick learner. I have the UNO R3, and the 329RTG servo. I have pulled the stop pin out of the servo to enable continuous rotation. I want the arduino to rotate the servo one full 360 rotation every xxx milleseconds. Is there any pre-written code for this? Where can I go to write the code? (arduino site I'm guessing.) If you guys could point me in the right direction. THX.
 

KeithWalker

Joined Jul 10, 2017
3,063
To modify a pps coded servo to continuous rotation, you need to position the potentiometer wiper to the center of its track and then disengage the mechanical drive to it. Once that is done, pps pulses <1,5 mS will drive it in one direction and pulses >1,5 mS will drive it in the other. The speed of rotation will depend on how much the pulse width deviates in either direction from the 1.5mS center. The minimum width is 1.0mS and the maximum is 2mS.
To drive the servo, you need to generate a negative pulse every 15 to 20 mS.
 

dendad

Joined Feb 20, 2016
4,451
You will not have any real control of the speed so if that is critical, some form of encoder feedback will need to be added.
The speed will vary depending on the load amongst other things.
 

John P

Joined Oct 14, 2008
2,025
If your servo has been modified to allow continuous rotation, you won't be able to use any kind of position sensing, including the kind that would tell you how fast it's going. All you'd have would be a variable-speed (but not closed-loop) gearmotor. You could add an external sensor of some kind, but that would require you to construct a circuit to set up a feedback loop.
 

djsfantasi

Joined Apr 11, 2010
9,156
All of which add up to: you might as well use a DC gear motor, because that is what you have left.

Bob
Or if the torque requirements can be satisfied. A choice better than a continuous servo or a DC motor would be a stepper motor.

There are Arduino shields and libraries available to drive a stepper motor.

Microsecond timing can be achieved in this manner.
 

KeithWalker

Joined Jul 10, 2017
3,063
Using two modified servos, with wheels attached, to drive a small vehicle makes a lot of sense. Using only two channels the vehicle can go forward and in reverse with full speed control and also turn in either direction - on a dime if necessary.
 

Thread Starter

clark.kent156

Joined Aug 17, 2019
50
what if the servo could do 180 then back to home position within a few hundred ms? I'd be happy with that. it need rotate to a degree then turn back quickly is the goal.
 

djsfantasi

Joined Apr 11, 2010
9,156
what if the servo could do 180 then back to home position within a few hundred ms? I'd be happy with that. it need rotate to a degree then turn back quickly is the goal.
That’s a parameter of RC servos. Just do a parametric search for servos that meet your speed criteria.

This servo rotates 60° in 140mS.

Note that the positioning of a servo is not accurate. If you need accurate positioning, you’d need to use a stepper like I suggested.
 
Last edited:

John P

Joined Oct 14, 2008
2,025
Not all servos have 180 degrees of travel, so you'd need to make sure that you can get that much out of it. And it probably wouldn't be very accurate if you don't give it time to settle.
 
Top