Position Controlled 360 Degree Servo
by ams03 in Circuits > Arduino
71 Views, 0 Favorites, 0 Comments
Position Controlled 360 Degree Servo

What: Continuous rotation servo with position control via a rotary encoder and PID control program.
Why: I needed this for a project and couldn't find an alternative within a good price range. If they were in a good price range, like the one made by Parallax, it was found to lack reliable control through the full range of motion due to the Hall effect position sensor.
This control is done through an optical encoder, which I have not experienced an error with so far in testing.
Supplies
3D Print
Print 3D files to connect the rotary encoder to the servo.
You can also use a rubber band for testing control
Wiring
Pins are the same for both the Arduino Mega and the Uno. These can be changed.
The servo is attached to pin 10.
The encoder is attached to pins 2 and 3. If the control does not operate as expected, this should be the first thing to troubleshoot. Simply flip these wires around.
Code
I have code for both the Arduino Mega and Arduino Uno. The code should work with no editing necessary.
If you would like to tweak the control, you can edit the kp, ki, and kd variables found in the variable declaration.
Editing the servos operation signal range may also provide some benefit. These variables are "DEAD_LOW" and "DEAD_HIGH"
Improvement
Looking for different possibilities to connect the servo and the rotary encoder. Currently, the gears are a quick fix but leave a bit of slop. Previously, I used a rubber band for testing, but of course this is no good under any sort of load.
Currently looking at timing belts, just not so sure how to size the belt.
Curious to hear or see if anyone has any other ideas!