Hardware Reference
In-Depth Information
SN754410
PWM (PP3)
A
When A = B, torque
applied to motor = 0
A
When A
B, motor runs
Motor
B
Off
Off
Port Pin (PP7)
B
Clockwise
Counterclockwise
Figure 8.56 The TI SN754410 motor drive
motor rotation is illustrated in Figure 8.56. By applying appropriate voltages on PP7 and PP3
(PWM3), the motor can rotate clockwise, counterclockwise, or even stop. Input-capture channel
0 is used to capture the feedback from the Hall-effect transistor.
When a motor is first turned on, it cannot reach a steady speed immediately. A certain
amount of startup time should be allowed for the motor to get to speed. A smaller motor can
reach steady speed faster than a larger one. It is desirable for the motor speed to be constant for
many applications. However, when a load is applied to the motor, it will be slowed down. To
keep the speed constant, the duty cycle of the voltage applied to the motor should be increased.
When the load gets lighter, the motor will accelerate and run faster than desired. To slow down
the motor, the duty cycle of the applied voltage should be reduced.
The response time will be slow if the change to the duty cycle is small. However, a large varia-
tion in duty cycle tends to cause the motor to overreact and oscillate. There are control algorithms
for motors that you can find in textbooks on control. A DC motor cannot respond to the change of
duty cycle instantaneously because of its inertia. A certain amount of time should be allowed for
the motor to speed up or slow down before the effect of the change of duty cycle is measured.
Example 8.25
Write a C function to measure the motor speed (in rpm) assuming that the HCS12 is run-
ning with a 16-MHz E-clock.
Solution: To measure the motor speed, one needs to capture two consecutive rising edges. Let
the difference of two consecutive edges be diff and the period of the timer be set to 1
μ
s; then
the motor speed (rpm) is
Speed 5 60 3 10 6 4 (2 3 diff )
The C function that measures the motor speed is as follows:
#include “c:\cwHCS12\include\hcs12.h”
unsigned int motor_speed (void)
{
unsigned int edge1, diff, rpm;
long int temp;
TSCR1 5 0x90;
/* enable TCNT and fast flag clear */
TIOS
& 5 IOS0;
/* select IC0 function */
TSCR2 5 4;
/* set TCNT prescale factor to 16 */
 
Search WWH ::




Custom Search