Professional Documents
Culture Documents
41233a PDF
41233a PDF
DC Motor Control
Tips n Tricks
Tips n Tricks
Table of Contents
DS41233A-page i
Tips n Tricks
DS41233A-page ii
Tips n Tricks
TIPS N TRICKS INTRODUCTION
Every motor control circuit can be divided into the
drive electronics and the controlling software.
These two pieces can be fairly simple or extremely
complicated depending upon the motor type, the
system requirements and the hardware/software
complexity trade-off. Generally, higher
performance systems require more complicated
hardware. This booklet describes many basic
circuits and software building blocks commonly
used to control motors. The booklet also provides
references to Microchip application notes that
describe many motor control concepts in more
detail.
DS41233A-page 1
Tips n Tricks
TIP #1
V+
PICmicro
Microcontroller
Digital
output
MOSFET
Driver
DS41233A-page 2
Tips n Tricks
FIGURE 1-2:
V+
PICmicro
Microcontroller
Digital
Output
MOSFET
Driver
DS41233A-page 3
Tips n Tricks
FIGURE 1-3:
H-BRIDGE DRIVE
V+
V+
DS41233A-page 4
Tips n Tricks
TIP #2
DS41233A-page 5
Tips n Tricks
Sensorless motors are simpler to build due to the
lack of the sensors, but they are more complicated
to drive. A sensorless motor performs very well in
applications that don't require the motor to start
and stop. A sensor motor would be a better choice
in applications that must periodically stop the
motor.
FIGURE 2-1:
OA
OC
OE
OB
OD
OF
Motor
C
OA-OF are digital outputs from a PICmicro MCU.
DS41233A-page 6
Tips n Tricks
FIGURE 2-2:
PICmicro Microcontroller
A
B
ADC
Low Pass
Filter
FIGURE 2-3:
C
Analog
MUX
PICmicro Microcontroller
Digital
Outputs
Digital
Inputs
Drive
Circuit
A
Motor
C
Hall
Effect
Motor
Position
Sensor
Sensor
Outputs
DS41233A-page 7
Tips n Tricks
Application notes describing Brushless DC Motor
Control:
AN857 Brushless DC Motor Control Made
Easy (DS00857)
AN885 Brushless DC Motor Fundamentals
(DS00885)
AN899 Brushless DC Motor Control Using
PIC18FXX31 (DS00899)
AN901 Using the dsPIC30F for Sensorless
BLDC Control (DS00901)
DS41233A-page 8
Tips n Tricks
TIP #3
DS41233A-page 9
Tips n Tricks
There are many ways to control the winding
current, but the most popular is a chopper system
that turns off current when it reaches an upper limit
and enables the current flow a short time later.
Current sensor systems are discussed in TIP #6.
Some systems are built with a current chopper, but
they do not detect the current, rather the system is
designed to begin a fixed period chopping cycle
after the motor has stepped to the next position.
These are simpler systems to build, as they only
require a change in the software.
FIGURE 3-1:
Unipolar 5 Wire
FIGURE 3-2:
Bipolar 4 Wire
Short for
Unipolar
Individual coils
wire anyway
appropriate
8 Wire
Unipolar and Bipolar
6 Wire
DS41233A-page 10
Tips n Tricks
FIGURE 3-3:
Motor
01
02
03
04
01-04 are outputs from a PICmicro MCU.
DS41233A-page 11
Tips n Tricks
FIGURE 3-4:
V
A
Motor
E
DS41233A-page 12
Tips n Tricks
TIP #4
Drive Software
DS41233A-page 13
Tips n Tricks
EXAMPLE 4-1:
MOVLW A
MOVWF pwm
endm
update_PWM macro
MOVF pwm_counter,w
SUBWF pwm, w
;if the output
;is on bit 0
RLF
PORTC,f ;replace PORTC with
;the correct port if
;the output is on bit
;7 of the port
;replace the rlf with
;rrf incf
;pwm_counter,f
DS41233A-page 14
Tips n Tricks
EXAMPLE 4-2:
MOVF
SUBWF
RLF
MOVF
SUBWF
RLF
MOVF
SUBWF
RLF
;peforms one
;update of all 8
;PWM siganls
;all PWM signals
;must be on the
;same port
pwm_counter,w
pwm0,w
output,f
pwm_counter,w
pwm1,w
output,f
pwm_counter,w
pwm2,w
output,f
DS41233A-page 15
Tips n Tricks
EXAMPLE 4-3:
MOVF
SUBWF
RLF
MOVF
SUBWF
RLF
MOVF
SUBWF
RLF
MOVF
SUBWF
RLF
MOVF
SUBWF
RLF
MOVWF
INCF
endm
DS41233A-page 16
pwm_counter,w
pwm3,w
output,f
pwm_counter,w
pwm4,w
output,f
pwm_counter,w
pwm5,w
output,f
pwm_counter,w
pwm6,w
output,f
pwm_counter,w
pwm7,w
output,w
PORTC
pwm_counter,f
Tips n Tricks
TIP #5
pwm_tmp
DS41233A-page 17
Tips n Tricks
EXAMPLE 5-2:
pwm_tmp
8-BIT MACRO
pwm_tmp
DS41233A-page 18
Tips n Tricks
TIP #6
Current Sensing
DS41233A-page 19
Tips n Tricks
FIGURE 6-1:
VSUPPLY
RS+
V+
PICmicro
MCU
ADC
RS-
MAX4172
High Side
Current
Sensor
Amplifier
1k
CCP
MOSFET
Driver
DS41233A-page 20
Tips n Tricks
FIGURE 6-2:
PICmicro
MCU CCP
MOSFET
Driver
MCP601
Op Amp
ADC
Current
Sensor
Resistor
+
-
Current Sensor
Amplifier
DS41233A-page 21
Tips n Tricks
Current measurement can also be accomplished
using a Hall Effect Sensor to measure the
magnetic field surrounding a current carrying wire.
Naturally, this Hall Effect Sensor can be located on
the high side or the low side of the load. The actual
location of the sensor does not matter because the
sensor does not rely upon the voltage on the wire.
FIGURE 6-3:
PICmicro
MCU
ADC
Hall
Effect
Sensor
M
CCP
DS41233A-page 22
Tips n Tricks
TIP #7
Position/Speed Sensing
Motor Supply
VDD
PICmicro
MCU
CCP
ADC
Note 1:
Q1
DS41233A-page 23
Tips n Tricks
Rotary Encoder Sensing
Rotary encoders are typically used to provide
direct physical feedback of motor position, and/or
speed. A rotary encoder consists of a rotary
element attached to the motor that has a physical
feature, measured by a stationary component. The
measurements can yield motor speed and
sometimes they can provide a motor position.
Rotary encoders are built using many different
technologies. The most common type is an optical
rotary encoder. The optical rotary encoder is used
in the computer mice that have a ball. It is built with
an encoder disc that is attached to the motor. The
encoder disc has many radial slots cut into the disc
at a specific interval. An LED and a photo detector
are used to count the slots as they go by. By timing
the rate that the slots go by, the speed of rotation
can be determined.
Motor position requires a second LED and photo
detector. The second sensor pair is mounted so
the output pulses are 90 degrees out of phase
from the first pair. The two outputs represent the
motion of the encoder disc as a quadrature
modulated pulse train. By adding a third index
signal, that pulses once for each revolution, the
exact position of the motor can be known at all
times.
DS41233A-page 24
Tips n Tricks
FIGURE 7-2:
OPTICAL SPEED/DIRECTION/POSITION
SENSING
VDD
A
VDD
Drive
Encoder Wheel
on Motor Shaft
LED
PICmicro
MCU
Photo
Transistor
A
B
Encoder Wheel
A
B forward
B reverse
Note: Frequency of one signal provides RPM of motor.
Pulse count provides motor position. A-B phase
provides motor direction.
DS41233A-page 25
Tips n Tricks
Quadrature sensing can easily be accomplished in
software, but there is generally an upper limit to
the RPM. By using a few gates, the sensing can be
done partially in hardware and partially in software.
The new PIC18FXX31 and dsPIC 16-bit Digital
Signal Controller families include an encoder
interface that allows MUCH higher RPM motors to
be measured with an excellent degree of accuracy.
Older Methods of Motor Sensing
Resolvers and analog tachometers are two older
technologies for motor position/velocity sensing.
An analog tachometer is simply an electric
generator with a linear output over a specified
range of RPM's. By knowing the output
characteristics, the RPM can be known by simply
measuring the voltage across the tachometer
terminals.
A resolver is a pair of coils that are excited by an
external AC signal. The two coils are at 90 to each
other so they pick up the AC signal at different
strengths, depending on their orientation. The
result is a sine or cosine output related to the angle
of the resolver in reference to the AC signal.
Inverse cosine/sine will produce the angle of the
sensor. This type of sensor can be very accurate
and is still used where absolute position must be
known.
DS41233A-page 26
Tips n Tricks
Application Note References
AN532 Servo Control of a DC Brush Motor
(DS00532)
AN696 PIC18Cxxx/PIC16Cxxx DC Servo
Motor (DS00696)
AN718 Brush-DC Servomotor Implementation using PIC17C56A (DS00718)
AN822 Stepper Motor Micro-stepping with
the PIC18C452 (DS00822)
AN843 Speed Control of 3-Phase Induction
Motor Using PIC18 Microcontrollers
(DS00843)
AN847 RC Model Aircraft Motor Control
(DS00847)
AN857 Brushless DC Motor Control Made
Easy (DS00857)
AN885 Brushless DC (BLDC) Motor
Fundamentals (DS00885)
AN899 Brushless DC Motor Control Using
the PIC18FXX31 (DS00899)
AN893 Low-cost Bidirectional Brushed DC
Motor Control Using the PIC16F684
(DS00893)
AN894 Motor Control Sensor Feedback
Circuits (DS00894)
AN898 Determining MOSFET Driver Needs
for Motor Drive Applications (DS00898)
AN901 Using the dsPIC30F for Sensorless
BLDC Control (DS00901)
DS41233A-page 27
Tips n Tricks
AN905 Brushed DC Motor Fundamentals
(DS00905)
AN906 Stepper Motor Control Using the
PIC16F684 (DS00906)
AN907 Stepper Motor Fundamentals
(DS00907)
DS41233A-page 28
DS41233A-page 29
M
Worldwide Sales and Service
AMERICAS
ASIA/PACIFIC
Taiwan
Corporate Office
Australia
Tel: 480-792-7200
Technical Support:
480-792-7627
Tel: 61-2-9868-6733
Kaohsiung
Tel: 886-7-536-4818
Atlanta
Tel: 770-640-0034
Boston
Tel: 978-692-3848
Chicago
Tel: 630-285-0071
Dallas
Tel: 972-818-7423
Detroit
Tel: 248-538-2250
Kokomo
China-Beijing
Tel:86-10-85282100
China-Chengdu
Taiwan
Tel: 886-2-2717-7175
EUROPE
Tel: 86-28-86766200
Austria
China-Fuzhou
Tel: 43-7242-2244-399
Tel: 86-591-7503506
Denmark
China-Hong
Kong SAR
Tel: 45-4420-9895
Tel: 852-2401-1200
Tel: 33-1-69-53-63-20
China-Shanghai
Germany
Tel: 86-21-6275-5700
Tel: 49-89-627-144-0
China-Shenzhen
Italy
France
Tel: 86-755-82901380
Tel: 765-864-8360
Tel: 39-0331-742611
China-Shunde
Los Angeles
Tel: 86-765-28395507
Netherlands
Tel: 949-263-1888
China-Qingdao
San Jose
Tel: 86-532-5027355
Tel: 650-215-1444
India
Toronto
Tel: 91-80-22290061
Tel: 905-673-0699
Japan
Tel: 31-416-690399
United Kingdom
Tel: 44-118-921-5869
02/17/04
Korea
Tel: 82-2-554-7200
Singapore
Tel: 65-6334-8870
Microchip received ISO/TS-16949:2002 quality
system certification for its worldwide headquarters,
design and wafer fabrication facilities in Chandler
and Tempe, Arizona and Mountain View, California
in October 2003. The Companys quality system
processes and procedures are for its PICmicro
8-bit MCUs, KEELOQ code hopping devices, Serial
EEPROMs, microperipherals, non-volatile memory
and analog products. In addition, Microchips
quality system for the design and manufacture of
development systems is ISO 9001:2000 certified.
*DS41215A*
DS41233A-page 30
*DS41233A*