Hardware Reference
In-Depth Information
PWME
| 5 0x01;
// enable PWM0 channel
// reduce duty cycle 1% per 100 ms in the first second
for (dim_cnt 5 0; dim_cnt < 10 ; dim_cnt 11 ) {
delayby100ms(1);
PWMDTY0 22 ;
}
// reduce duty cycle 2% per 100 ms in the next 4 s
for (dim_cnt 5 0; dim_cnt , 40; dim_cnt 11 ) {
delayby100ms(1);
PWMDTY0 25 2;
}
while(1);
}
8.11 DC Motor Control
DC motors are used extensively in control systems as positional devices because their
speeds and torques can be precisely controlled over a wide range. The DC motor has a perma-
nent magnetic field and its armature is a coil. When a voltage and a subsequent current flow are
applied to the armature, the motor begins to spin. The voltage level applied across the armature
determines the speed of rotation.
The microcontroller can digitally control the angular velocity of a DC motor by monitoring
the feedback lines and driving the output lines. Almost every application that uses a DC motor
requires it to reverse its direction of rotation or vary its speed. Reversing the direction is done
by changing the polarity of the voltage applied to the motor. Changing the speed requires vary-
ing the voltage level of the input to the motor, and that means changing the input level to the
motor driver. In a digitally controlled system, the analog signal to the driver must come from
some form of D/A converter. However, adding a D/A converter to the circuit increases the chip
count, which means increasing the system cost and power consumption. The other alternative
is to vary the pulse width of a digital signal input to the motor. By varying the pulse width, the
average voltage delivered to the motor changes and so does the speed of the motor. The HCS12
PWM subsystem can be used to control the DC motor.
The HCS12 can interface with a DC motor through a driver, as shown in Figure 8.52. This
circuit takes up only three I/O pins. The pin that controls the direction can be an ordinary I/O pin,
HCS12
Direction
PP7
Speed
On/off
Driver
PP3
DC motor
PT0
Feedback
Figure 8.52 Simplified circuit for DC motor control
 
Search WWH ::




Custom Search