Академический Документы
Профессиональный Документы
Культура Документы
Pulse-width modulation
NATHANIEL PINCKNEY Often, when controlling an ana-
log device, the ability to drive a
signal with variable power (P = I
× V) is needed. For example, you
may want to adjust the speed of a
dc motor or dim a light-emitting
ANIMATRONICS ARE USED in the diode (LED). This can be a chal-
movie industry to bring aliens, lenge when the signal is generated
dinosaurs, and man-eating sharks by a digital device. Different meth-
to life. Many mechanical devices ods to convert a digital signal to an
are used to impart realism to analog signal exist, one of which is
these puppets. Large motors and a digital-to-analog converter. Using
hydraulics are employed to control a converter will add complexity to
limbs, necks, and other areas a project, so generating a variable
requiring high torque. Small motors power signal with existing circuitry
are used to create facial expres- is desirable to reduce the number
sions, control eyes, and provide of components.
fluidity of movement to add life to An easy method to vary the
these robots. power using a digital signal, when
A common motor used in ani- an analog signal isn’t available, is
matronics is a servo motor. Instead by a method called pulse-width
of providing constant rotation, like modulation (PWM). Instead of con-
most motors, servos are used for trolling the current or voltage of a
precise angular positioning but are signal, a pulse-width-modulated
©ARTVILLE, LLC.
Controlling a servo
PWM, Duty Cycle = 1/4 Average Voltage = 1/4 Vdd Most servos, including the Hitec
High RCD USA, Inc. HS-322HD demonstrated
=> here, have three pins: power, ground,
Low and a control signal. The control signal
Pulse is a pulse-width-modulated input signal
Length whose high pulse width determines the
servo’s angular position, as shown in
Period
Fig. 3. Internally, the servo compares
PWM, Duty Cycle = 3/4 Average Voltage = 3/4 Vdd the PWM control signal to an internally
High generated signal, whose pulse widths
=> are controlled by the potentiometer
Low (which determines the shaft angle) and
Pulse Length matches the pulse widths by rotating
Period the motor shaft. For the HS-322HD,
power can be between 4.8 Vdc (volts
of direct current) and 6 Vdc. Since
Fig. 2 Pulse width modulation and average voltage the control signal (which draws a
28 IEEE POTENTIALS
maximum of about 20 mA) other projects as well.
does not drive the motor Depending on the features
directly, an additional bene- PWM included with the microcon-
High
fit of using a servo is that the troller you are using, a PWM
PIC (whose output pins can => signal can be generated in a
drive up to 25 mA) can Low variety of ways.
0.9 ms
drive the control signal
directly. Most motors draw High Additional resources
more than 25 mA of current => This article was written
for operation and, therefore, Low jointly with the development
must be indirectly connected 1.5 ms of a set of tutorials on how
to the PIC through a current High to use different devices with
amplifying device, like an H- => the Microchip Technology’s
bridge or a transistor. Low PIC 18F452 microcontroller
Typically, servos require 2.1 ms and Xilinx’s Spartan 3 FPGA.
a PWM signal with a 20-ms Five undergraduate students
20 ms
period and a pulse width and two professors under-
between 0.9–2.1 ms (0.9 ms took the development of the
corresponds to the minimum tutorials, appropriately
Fig. 3 Controlling an HS-322HD servo with PWM
angle and 2.1 ms corre- named MicroToys guides.
sponds to the maximum More information about PIC-
angle); therefore, the middle controlled servos, as well as
position is 1.5 ms (the average of the signal is applied. If there is no signal, controlling other devices with a PIC
minimum/maximum pulse widths). The the servo’s motor shaft is not driven by microcontroller, can be found at Harvey
HS-322HD has a maximum angle of any circuitry and, hence, can be rotated Mudd College’s E155 MicroToys Web
180◦ . Servos only move a finite angular freely, even when power is supplied to site at <http://www4. hmc.edu:8001/
amount per cycle of the signal, so mul- the servo. Engineering/microtoys/>.
tiple cycles must be sent before the
servo arrives at the correct angle. The Conclusions About the author
speed/power at which the servo moves Microcontrollers offer a simple and Nathaniel Pinckney is a first-year
to a new position is proportional to the inexpensive solution for controlling undergraduate engineering student cur-
distance it needs to travel. So as the servo motors for robotics and other rently attending Harvey Mudd College.
servo becomes closer to the target electronics projects. Through the use of Before attending Harvey Mudd, he was
angle, it will gradually slow. The servo PWM, the angular position of the servo home schooled since second grade. He
will resist change away from the desig- motor shaft can be conveniently con- has been involved in the development
nated angle as long as a signal is trolled by a microcontroller for a vari- of various GNU/Linux software pro-
applied. Note that the servo’s control ety of projects. PWM is an easy solu- grams and is interested in parallel
mechanism will only engage when a tion for the control of analog devices in embedded architecture design.
JANUARY/FEBRUARY 2006 29