O'Reilly logo

Microcontroller Programming and Interfacing Texas Instruments MSP430 by Daniel J. Pack, Steven F. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.4. CIRCUIT DIAGRAM 339
motor shaft
old capture
time
new capture
time
one motor
revolution
1 revolution
new_cap - old_cap [clock pulses]
60 seconds
minute
clock pulses
second
X
X
motor speed [RPM]
=
Figure 10.10: Motor speed calculation.
As shown in Figure 10.11, the microcontroller is not directly connected to the motor. The
PWM control signal from P4.0 is fed to the motor through an optical solid state relay (SSR). This
isolates the microcontroller from the noise of the motor. The output signal from the SSR is fed to
the MOSFET, which converts the low-level control signal to voltage and current levels required by
the motor.
Motor speed is monitored via the optical encoder connected to the motor shaft. The index
output signal of the motor encoder provides a pulse for each motor shaft rotation. The signal is
converted to a MSP430 compatible digital signal via the LM324 threshold detector. The output
from this stage is fed back to P8.5 CCR0 to trigger a Timer A input capture interrupt on channel
1. An interrupt service routine captures the time since the last interrupt. This information is used to
speed up or slow down the motor to maintain a constant speed.
10.4.1 REQUIREMENTS
Generate an approximately 2 kHz PWM signal.
Vary the duty cycle from 50% to 100 %, which is set by the external potentiometer i.e., the
50% duty cycle needs to 0 VDC and the 100% duty cycle is equal to 3.3 VDC.
Display the motor RPM and duty cycle on an LCD.
Load the motor and perform compensation to return the RPM to the original value.
10.4.2 STRUCTURE CHART
The structure chart for the motor speed control project is shown in Figure 10.12.
340 10. SYSTEM LEVEL DESIGN
M
DC motor
supply voltage
Solid State Relay
MOSFET
protection
diode
+
-
R
V
DD
I
7404
from
micro
G
D
S
I
LOAD
R
G
0.4V
Index
+5 VDC
optical
encoder
+
-
LM324
threshold
detector
SerLCD V2.5
pin 1
reset
JP4
JP5
LCD
crystal
joystick
accelerometer
5.0
6.7
7.5
7.7
3.4
3.6
4.0
4.2
4.5
4.7
5.5
8.5
5.1
7.4
7.6
Gnd
3.5
3.7
4.1
4.3
4.6
5.4
7.3
8.6
RX to TX: P3.4
Vcc = 3.3 VDC
PWM
Vcc = 3.3 V
motor speed
control
P4.1
CCR1
P7.4
P8.5
Time r A1
CCR0
Figure 10.11: Circuit diagram for a 24 VDC, 1500 RPM motor equipped witha3channel optical
encoder.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required