7 Calibrating the robot

In your previous labs, you used a pan-tilt platform that was moved using standard servo motors. In an inexpensive standard servo motor, you can control the angular position of the motor over some finite range of angles. The Phidget Advanced Servo Motor Controller is designed to control standard servo motors, and its programming interface reflects this design.

The servo motors used in the differential drive robot are continuous rotation servo motors. In a continous rotation servo motor, the controller feedback is modified so that the motor always measures its position as some fixed value (usually the middle value of the controller position range). Commanding the motor to move to a new “position” causes the motor to spin in an attempt to move to the new position (which can never be obtained because the sensed position is always the same fixed value).

To stop a continuous rotation motor, you command the “position” of the motor to be the fixed measured position which we will call the zero-speed position.

The motor speed is proportional to the difference between the commanded position and the zero-speed position. This means that the speed of the motor can be controlled by choosing an appropriate “position”.

Because the zero-speed position is in the middle of the range, the direction of the motor rotation can also be controlled. Commanding the motor to move to a “position” above the zero-speed position causes the motor to spin in one direction, and commanding the motor to move to a “position” below the zero-speed position causes the motor to spin in the opposite direction.

7.0.1 Before you proceed

What you are about to do may cause the robot to move unexpectedly. Before you proceed, have your partner pick up the robot by the frame (not the wheels!) so that the wheels are not in contact with anything. Alternatively, prop the front of the robot up on something so that the wheels are not in contact with anything.

7.1 Using setServoPosition

To change to position of a servo motor, you use the function setServoPosition. In MATLAB, type

help setServoPosition

to view the documentation for the function.

The robot has two servo motors. The index of the motors are 0 and 1. The zero-speed position is approximately 117 and both motors might have a different zero-speed position.

In MATLAB, use setServoPosition to set one servo motor to its approximate zero-speed position:

setServoPosition(0, 117)

Observe that the motor does not turn when you set its position.

7.2 Using setServoEngaged

The servo motors will not move unless they are engaged. To engage and disengage a servo motor, you use the function setServoEngaged. In MATLAB, type

help setServoPosition

to view the documentation for the function.

In MATLAB, use setServoEngaged to engage the servo motor:

setServoEngaged(0, 1)

It is possible that the servo motors of your robot may turn slowly after engaging it. This is because the zero-speed position is not exactly 117 for the motors on your robot.

7.3 Determine what positions correspond to forward and backwards

In MATLAB, use setServoPosition to set the speed of motor 0:

setServoPosition(0, 90)

Note which wheel turns and which direction the wheel turns in. In MATLAB, use setServoPosition to set the speed of motor 0:

setServoPosition(0, 140)

Note which wheel turns and which direction the wheel turns in.

7.4 Find the true zero-speed position of the motor

In MATLAB, use setServoPosition to set the speed of motor 0:

setServoPosition(0, 115)

If the motor turns or hums then 115 is not the true zero-speed position of the motor. Even if the motor does not turn or hum, 115 may not be the true zero-speed position of the motor.

In MATLAB, use setServoPosition to set the speed of motor 0 to the smallest value that just causes the motor to hum or move (the value should be around 115). Then find the largest value that just causes the motor to hum or move (again, the value should be around 115). The true zero-speed position is the average of these two values. Record this value somewhere; you will need it later in the lab.

7.5 Repeat the above process for motor 1

Repeat Steps 7.1-7.4 for motor 1. In Step 7.3, you should observe that the behaviour of motor 1 is opposite to that of motor 0. Make sure to make note of the true zero-speed position for both motors.