Difference between revisions of "Tutorials/Arduino Projects/Mobile Robotics/BoeBot/Zeroing A Continuous Servo"

From ROBOTC API Guide
Jump to: navigation, search
(Zeroing the servo)
(Zeroing the servo)
 
(2 intermediate revisions by one user not shown)
Line 6: Line 6:
  
 
== What is zeroing? ==
 
== What is zeroing? ==
Zeroing a continuous rotation servo is where you adjust the servo such that the servo does not turn when a 1.5ms pulse is revived by the servo. Not all servos can be zeroed. Even among the ones that can be zeroed, it is not always necessary.
+
Unfortunately, not all servos are created equally. Due to slight manufacturing defects, some continuous rotation servos will move or 'drift' even when they are being sent the 1.5 ms 'stop' PWM signal. To compensate for this, most continuous rotation servos contain a small, adjustable resistor (called a potentiometer) that can be used to 'tweak' the servo to account for drift.
  
 
== Zeroing the servo ==
 
== Zeroing the servo ==
First we need to make a program to send a 1.5 ms pulse to the servos. To speed this up, we are going to provide you with the code, and you can learn about how it is setup in the next section.
+
Before we zero the servos we need to ensure that they are drifting in the first place. To do this, we will send a 1.5 ms 'stop' pulse to each servo. If the servos are stationary, they will not need to be zeroed; if they start moving towards one direction or the other, however, they will need to be tweaked.
  
First, we need to create a new source code file, and copy the following code into the file and save it as "Zeroing servos.c"
+
The following code will continually send a 1.5ms pulse to the Arduino's pins 10 and 11. Create a new source code file, and copy the following code into the file and save it as "Zeroing servos.c"
  
 
{|
 
{|
Line 33: Line 33:
 
|}
 
|}
  
Upload the program to the Arduino. Connect the battery back to the Arduino. Flip the power switch on the Boe Shield to position 2. At this point if the servos are not zeroed, you will find that they are turning. This is bad since it would mean that programing the motors to "stop" would not actually stop the motors.
+
Compile and download the program to the Arduino. After ensuring that the battery pack is plugged into the Arduino flip the power switch on the Boe Shield to position 2. If the servos are moving in either direction they will need to be zeroed.
  
Now that we know if they are zeroed, we can use the screwdriver included in the Parallax kit to turn the adjustment potentiometer on the servo. Slowly turn the potentiometer to one direction. If the servo slows down then keep turning in that direction until the servo stops. If the servo starts going faster, then turn the potentiometer the other direction until the servo stops turning. If you turn the potentiometer past the zero point, the servo will start to spin in the opposite direction. If this happens, just turn the potentiometer very slowly in the other direction.
+
You can use the screwdriver included in the Parallax kit to turn the adjustment potentiometer on the servo. Slowly turn the potentiometer to one direction. If the servo slows down, keep turning in that direction until the servo stops. If the servo starts going faster, then turn the potentiometer the opposite direction until the servo stops turning. If you turn the potentiometer past the zero point, the servo will start to spin in the opposite direction. If this happens, just turn the potentiometer very slowly in the other direction; it may take several tries to get it 'just right'.

Latest revision as of 16:18, 11 October 2012

Notepad.gif NOTE: This is a place holder for a video.
Please add the id for the YouTube video with description "Zeroing the Parallax Continuous Rotation Servos"


What is zeroing?

Unfortunately, not all servos are created equally. Due to slight manufacturing defects, some continuous rotation servos will move or 'drift' even when they are being sent the 1.5 ms 'stop' PWM signal. To compensate for this, most continuous rotation servos contain a small, adjustable resistor (called a potentiometer) that can be used to 'tweak' the servo to account for drift.

Zeroing the servo

Before we zero the servos we need to ensure that they are drifting in the first place. To do this, we will send a 1.5 ms 'stop' pulse to each servo. If the servos are stationary, they will not need to be zeroed; if they start moving towards one direction or the other, however, they will need to be tweaked.

The following code will continually send a 1.5ms pulse to the Arduino's pins 10 and 11. Create a new source code file, and copy the following code into the file and save it as "Zeroing servos.c"

#pragma config(CircuitBoardType, typeCktBoardUNO)
#pragma config(PluginCircuitBoard, typeShieldParallaxBoeBot)
#pragma config(UART_Usage, UART0, uartSystemCommPort, baudRate200000, IOPins, dgtl1, dgtl0)
#pragma config(Motor,  servo_10,        leftServo,     tmotorServoContinuousRotation, openLoop, IOPins, dgtl10, None)
#pragma config(Motor,  servo_11,        rightServo,    tmotorServoContinuousRotation, openLoop, reversed, IOPins, dgtl11, None)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
 
task main()
{
  while(true) {//wait indefinitely
    motor[leftServo] = 0;    //Set the left servo stop
    motor[rightServo] = 0;   //Set the right servo stop
  }
}

Compile and download the program to the Arduino. After ensuring that the battery pack is plugged into the Arduino flip the power switch on the Boe Shield to position 2. If the servos are moving in either direction they will need to be zeroed.

You can use the screwdriver included in the Parallax kit to turn the adjustment potentiometer on the servo. Slowly turn the potentiometer to one direction. If the servo slows down, keep turning in that direction until the servo stops. If the servo starts going faster, then turn the potentiometer the opposite direction until the servo stops turning. If you turn the potentiometer past the zero point, the servo will start to spin in the opposite direction. If this happens, just turn the potentiometer very slowly in the other direction; it may take several tries to get it 'just right'.