Following labs will deal with input devices, output devices and ntsc signal generation. However, the final section of this lab will deal with motor control.
If you stroll through Active Surplus, you will undoubtedly find simple dc commutator-type motors. These motors simply turn when voltage is applied to two wires. They are contollable, but are generally not used for fine control.
You may find ac motors. These generally are easier to design as they don't need commutators and brushes. There is also the possibilty of seeing three-phase motors which use ac current in which three sinusoidal waves are used to drive the motor. The three phases are 120 degrees apart and are much more efficient than single phase motors you generally see in household appliances.
The next type of motor you may see is a stepper motor. This type of motor offers reasonably fine control. The details of this motor are detailed a small tutorial I've made available here. Though stepper motors may be very reasonably priced (can be $1 or $2 at Active), they need controller ICs. Unfortunately Active and Supremetronics do not have stepper contollers right now. If you really want to use stepper motors for a final project, or just to play around with, check out Electrosonic or order them online at Digikey,com.
The final type of motor you will come across is a servo motor. These motors are used for fine control. They do not rotate like dc or ac motors, they generally only move within 180-260 degrees, but offer fine control. Servo motors are available at Supremetronics for $18 each or two for $35. Supremetronics is located at 330 Queen Street West.
A Servo is a small device that has an output shaft. This shaft can be positioned to specific angular positions by sending the servo a coded signal. As long as the coded signal exists on the input line, the servo will maintain the angular position of the shaft. As the coded signal changes, the angular position of the shaft changes. In practice, servos are used in radio controlled airplanes to position control surfaces like the elevators and rudders. They are also used in radio controlled cars, puppets, and of course, robots.
(Click on picture for larger view)
A Futaba S-148 Servo
Servos are extremely useful in robotics. The motors are small, as you can see by the picture above, have built in control circuitry, and are extremely powerful for thier size. A standard servo such as the Futaba S-148 has 42 oz/inches of torque, which is pretty strong for its size. It also draws power proportional to the mechanical load. A lightly loaded servo, therefore, doesn't consume much energy. The guts of a servo motor are shown in the picture below. You can see the control circuitry, the motor, a set of gears, and the case. You can also see the 3 wires that connect to the outside world. One is for power (+5volts), ground, and the white wire is the control wire.
(Click on picture for larger view)
A servo disassembled.
So, how does a servo work? The servo motor has some control circuits and a potentiometer (a variable resistor, aka pot) that is connected to the output shaft. In the picture above, the pot can be seen on the right side of the circuit board. This pot allows the control circuitry to monitor the current angle of the servo motor. If the shaft is at the correct angle, then the motor shuts off. If the circuit finds that the angle is not correct, it will turn the motor the correct direction until the angle is correct. The output shaft of the servo is capable of travelling somewhere around 180 degrees. Usually, its somewhere in the 210 degree range, but it varies by manufacturer. A normal servo is used to control an angular motion of between 0 and 180 degrees. A normal servo is mechanically not capable of turning any farther due to a mechanical stop built on to the main output gear.
The amount of power applied to the motor is proportional to the distance it needs to travel. So, if the shaft needs to turn a large distance, the motor will run at full speed. If it needs to turn only a small amount, the motor will run at a slower speed. This is called proportional control.
How do you communicate the angle at which the servo should turn? The control wire is used to communicate the angle. The angle is determined by the duration of a pulse that is applied to the control wire. This is called Pulse Coded Modulation. The servo expects to see a pulse every 20 milliseconds (.02 seconds). The length of the pulse will determine how far the motor turns. A 1.5 millisecond pulse, for example, will make the motor turn to the 90 degree position (often called the neutral position). If the pulse is shorter than 1.5 ms, then the motor will turn the shaft to closer to 0 degress. If the pulse is longer than 1.5ms, the shaft turns closer to 180 degress.

As you can see in the picture, the duration of the pulse dictates the angle of the output shaft (shown as the green circle with the arrow). Note that the times here are illustrative, and the actual timings depend on the motor manufacturer. The principle, however, is the same.
Write a simple AVR program which controls a servo in the following manner:
Write a second program in which you are able to control the servo position using the serial port.
If you need more example programs to help out with understanding the AVR check out wearcam.org example programs.
| Activity | Mark |
| Show us that you are able to upload programs to the AVR. This could be as simple as erasing the AVR and uploading the simple mirror program. | |
| Show the sample code working. This includes the interrupt code and the pwm code. | |
| Show that you can send information through UART using the auxillary serial port on the AVR. | |
| Show that you can receive information through UART using the auxillary serial port on the AVR. | |
| Answer some questions about controlling servos using pwm on the AVR. | |
| Show the servo position program working (controlling servo position with switches). | |
| Show the servo position program working which is controlled over serial ports. | |
| Survivability directorate | |
| 2 bonus points may be awarded at the discretion of the TA. |