bldc_motorcontrol
TRANSCRIPT
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc. 1
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 1
Brushless DC (BLDC)Motor Control
using
PIC18Fxx31Microcontrollers
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc. 2
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 2
Agenda� Overview of motor control solutions from Microchip� PIC18Fxx31 peripherals for motor control� BLDC motor control using PIC18Fxx31
� Open loop control� Closed loop control using Hall sensors� Closed loop control using Quadrature encoder� Sensorless control
The agenda for this discussion is:� First we will discuss an overview of motor control solutions from Microchip� PIC18Fxx31 has many peripherals that are useful for motor control application. We
will discuss the major peripherals that are helpful in developing motor controlapplication.
� Then we will discuss the Brushless DC motor control using PIC18Fxx31 devices inopen loop, closed loop with Hall sensors and closed loop with Quadrature Encoderor also known as optical encoder. Finally we will see how a sensorless control ofBLDC motor can be implemented using PIC18Fxx31
� At the end of this discussion, we will show few references that would be helpful foryou to understand BLDC motors and controls using PIC18Fxx31
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc. 3
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 3
Motor Control from Microchip� Complete solutions for Stepper, Brushed DC,
BLDC, ACIM & SR motors utilizing PIC16, PIC18and dsPIC® devices
� Microchip Op Amps and International Rectifierdrivers
� Provide everything a design engineer needs:� Low-risk product development� Lower total system cost� Faster time to market� Outstanding technical support� Dependable delivery & quality
� Visit us at www.microchip.com/motor
Microchip Technology offers a broad product portfolio that provides a completesystem solution for your brushed DC motor, variable speed brushless DC motor,AC induction motor, switched reluctance motor and stepper motor applications.This includes the microcontroller with firmware to drive the motor, analog op ampsand comparators for sensors or feedback and power electronics from Microchip andInternational Rectifier.With our sophisticated development systems and technical documentation,Microchip makes it easy for designers of all experience levels to complete a highperformance electronic motor control design quickly and cost effectively.Microchip provides everything a motor control design engineer needs: low-riskproduct development, lower total system cost, faster time-to-market, outstandingtechnical support and dependable delivery and quality.
For access to Microchip�s complete motor control design resources,visit the Motor Control Design Center at www.microchip.com/motor.
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc. 4
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 4
PIC18Fxx31 overview
PIC18Fxx31 family of microcontrollers have 4 parts, having 28-pin and 40-pinpackages with 8Kbytes and 16Kbytes of program memory. The major peripherals that are usefulin motor control are Power Control PWM or PCPWM, High-speed Analog-to-Digital Converterand Motion Feedback module. These peripherals simplify the motor control algorithm to a greatextent.The main features of PCPWM include:� Up to 8 channels output with independent or 4 pairs complimentary outputs� Up to 14 bits PWM of resolution� Center aligned or edge aligned PWM operation. Also known as symmetrical PWM orasymmetrical PWM operation� Programmable dead band control for complementary outputs� Hardware Fault interface pins for fast PWM shut down in the event of fault.Main features of high-speed ADC include:� Up to 9 channels input, with 2 Sample and Hold circuits� Simultaneous and sequential conversion capabilities with multiple channel selection� 4 word deep FIFO with flexible interrupt settings Main features of Motion Feedback Modules are:�Multiplexed Input Capture and Quadrature Encoder Interface (QEI) modules�In QEI, A, B and Index signals interface for measuring, position velocity and direction ofrotation�3 Input Capture pins with multiple modes for pulse width and frequency measurements -Interrupt on change feature used for Hall sensor interface.
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc. 5
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 5
PIC18Fxx31 peripherals
� Power control PWM� Up to 8 channels with up to 14-bit resolution� Center aligned and edge aligned operations
� High-speed ADC� Up to 9 channels with up to 200 Ksps� 4 word FIFO buffer with flexible interrupts
� Motion feedback module� Quadrature Encoder Interface (QEI) - QEA, QEB, Index
� Position and velocity measurement modes� 3 Input Capture (IC) pins
� Pulse width and frequency measurement modes
PIC18Fxx31 family of microcontrollers have 4 parts, having 28-pin and 40-pin packages with8Kbytes and 16Kbytes of program memory.The major peripheral that are useful in motor control are Power Control PWM or PCPWM, high-speed Analog-to-Digital Converter and Motion Feedback module. These peripherals simplify themotor control algorithm to a great extent.Main features of PCPWM include:� Up to 8 channels output with independent or 4 pairs complimentary outputs� Up to 14 bits PWM of resolution� Center aligned or edge aligned PWM operation. Also known as symmetrical PWM orasymmetrical PWM operation� Programmable dead band control for complementary outputs� Hardware Fault interface pins for fast PWM shut down in the event of fault.Main features of high-speed ADC include:� Up to 9 channels input, with 2 Sample and Hold circuits� Simultaneous and sequential conversion capabilities with multiple channel selection� 4 word deep FIFO with flexible interrupt settings Main features of Motion Feedback Modules are:� Multiplexed Input Capture and Quadrature Encoder Interface modules�In QEI, A, B and Index signals interface for measuring, position velocity and direction ofrotation�3 Input Capture pins with multiple modes for pulse width and frequency measurements -Interrupt on change feature used for Hall sensor interface.
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc.
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 6
Drive topologyVDC+
VDC-
(1)(4)
(5)(2)
(3)(6)
H1
L1
H2
L2
H3
L3
Phase A
Phase B
Phase C
A brushless DC motor is a synchronous motor that finds numerous applications inmotion control. Appliance, automotive, aerospace, industrial automation, automationare few industries to list. These come with different torque and voltage ratings. ABLDC motor has windings on stator and alternate permanent magnets on rotor. BLDCmotors are electronically commutated based on the rotor position with respect to thestator winding. This means, to run a BLDC motor an electronic drive is required.Normally 3 Hall effect sensors mounted on the stator are used to determine the rotorposition. The Hall effect sensors give a combination of high and low signals when theypass next to the rotor poles. With this combination, the commutation sequence isdetermined.A typical control circuit with 3 phase winding connection is shown in the figureH1,H2, H3 and L1, L2,L3 make 3 phase voltage source inverter connected across thepower supply indicated by VDC+ and VDC-. Stator windings A, B and C areconnected in star to the inverter.In coming slide we will see how these stator windings are energized in synchronouswith the Hall sensor inputs.
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc.
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 7
Switching Sequence(1) (2) (3) (4) (5) (6) (1) (2) (3) (4) (5) (6)
Phase A
Phase B
Phase C
H3L2
H1L2
H1L3
H2L3
H2L1
H3L1
H3L2
H1L2
H1L3
H2L3
H2L1
101 001 011 010 110 100 101 001 011 010 110Step
Hall sensorHall A
Hall B
Hall C
HallA
HallB
HallC
PhaseA
PhaseB
PhaseC
1 0 1 NC Vdc- Vdc+1 0 0 Vdc+ Vdc- NC1 1 0 Vdc+ NC Vdc-0 1 0 NC Vdc+ Vdc-0 1 1 Vdc- Vdc+ NC0 0 1 Vdc- NC Vdc+
High switchLow switch
Sequence table example
With 3 Hall sensors on the motor, every 60 degrees of electrical cycle, a Hall sensormakes transition either from low to high or from high to low. With this everyelectrical cycle has 6 steps to complete one full cycle. The energizing sequence willhave 6 combinations of turning ON and Off of the 6 switches that we saw in theprevious slide. A typical switching sequence is shown on the table here.The Hall sensor inputs are at 120 degrees phase shift to each other. Every sequencehas two windings connected across the power supply and third winding left open.Considering the first step where the Hall sensor input is 101, Phase C is connectedto positive DC bus and phase B is connected to negative DC bus and phase A is leftopen. In order to achieve this switch H3 and L2 should be closed and all otherswitches should be open. This will turn the rotor by 60 degree electrical in the givendirection. This will make the Hall sensor to make another transition triggering thenext point on the sequence table and so on.The electrical cycle and shaft rotation have a definite relation. The electrical cyclerepeats with every rotor pole pairs. So to complete one rotation on the shaft, these 6steps should be repeated as many times as rotor pole pairs.If the sequence is followed with rated motor voltage across the motor windings,motor will run at rated speed. Speed can be controlled using PWMs, by PWMingeach switch according to the speed required.The phase current waveform looks trapezoidal in shape with each phase currenthaving 120 degrees phase shift to each other.
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc. 8
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 8
Control using Hall Sensors
/MCLR 1 28
2
3
4
5
6
7
8
9
11
12
13
14
10
27
26
25
24
23
22
21
20
18
17
15
19
16
AN0
AN1/IC1AN2/IC2
AN3/IC3
AN4
AVdd
AVss
OSC1
OSC2
RC0
/FLTA/CCP2
/FLTB/CCP1
RC3/INT0
PWM2
PWM1
PWM0
Vdd
Vss
RC7/RX/DT
RC6/TX/CK
RC5/INT2
RC4/INT1
PWM3
PWM5
RB6/PGC
RB7/PGD
PWM4
R-LowR-High
Y-Low
Y-HighB-High
B-Low
Motor current
Potentiometer
+
Motor current
Reference-
Hall sensors
PIC
18F2
431
BLDCMotor
3 phase Inverter bridge
AC in
+ - DC bus
Hallsensors
Motorcurrent
This slide shows the hardware interface used for controlling a BLDC motor. Hallsensors are used for commutation. Hall sensors can be connected to either Interrupt onchange pins that are on port C or they can be connected to Input capture pins onMotion feedback module.The input capture module has a mode in which the module generates an interrupt ontransition on each pin, making it ideal for Hall sensor interface. Optionally, Timer5 canbe captured on each transition. This Timer5 value can be used for determining thespeed at which motor is running. This gives a low resolution speed measurement.For the applications where high resolution of speed measurement is required,quadrature encoder is used. The QE gives speed, position and direction of rotation.
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc. 9
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 9
OVDCOND v/s PWM output(1) (2) (3) (4) (5) (6)Step
101 001 011 010 110 100Hall sensor
PWM5 - H3
PWM4 - L3
PWM3 - H2
PWM2 - L2
PWM1 - H1
PWM0 - L1
00100100 00000110 00010010 00011000 00001001 00100001OVDCOND
Now let us see how to control the speed using PCPWM module. PCPWM modulehas a feature of over riding the PWM outputs based on the value in OVDCONDregister. When the corresponding value in OVDCOND is set to 1, the PWM outputbecomes active and vise versa. With this we can efficiently allow the required PWMto appear on the pin, when required as per the sequence, and inhibit when notrequired.Speed variation is achieved by varying the duty cycle of each PWM. To increase thespeed, the active part on duty cycle needs to be increased and to reduce the speed,the active time is reduced. By doing this the average voltage supplied across themotor winding varies, thus controlling the motor speed.This slide shows the relationship between the OVDCOND register and the PWMoutput. PWM0 to PWM5 control on and off of 6 switches. The PWMs are passedand inhibited according to the sequence discussed earlier.
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc.
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 10
Control Flow ChartInitialization
Load new step sequence
to the OVDCOND
register from Table
Hall sensorchange?
Yes
No
Key scan/
Other application?
ChangeSpeed?
Calculate new PWM
duty cycle
Yes
No
HallA
HallB
HallC
PhaseA
PhaseB
PhaseC
1 0 1 NC Vdc- Vdc+1 0 0 Vdc+ Vdc- NC1 1 0 Vdc+ NC Vdc-0 1 0 NC Vdc+ Vdc-0 1 1 Vdc- Vdc+ NC0 0 1 Vdc- NC Vdc+
This shows a simplified control flow chart for BLDC motor control. The sequencetable dictates the PWM channels that should be in active or inactive states, based onthe Hall sensor states. On every transition on Hall sensor input, new step from thesequence is loaded to the OVDCOND register.Any change in the speed command is read either using a potentiometer connected toone of the AD channel or a digital value from another controller calculate a newPWM duty cycle and load to the appropriate registers.
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc. 11
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 11
Control using Quadrature Encoder
1 402
34
56
7
9
12
1516
1718
14
39
38
37
36
35
34
3332
3029
26
31
28
INDX
Vss
OSC1
FLTA/CCP2
INT0/RC3
PWM2
PWM1
PWM0VddVssRD7RD6RD5RD4
PWM3
PWM5
PWM4RB6/PGC
RB7/PGD
8
10
13
Vdd
OSC2
1920
RD0RD1
11
27RC7/RX/DT
25 RC6/TX/CK
24 RC5/INT2
23 RC4/INT1
22 RD3
21 RD2
/MCLR
AN0
QEAQEB
AN4
AN5AN6AN7AN8
RC0
FLTB/CCP1 BLDCMotor
3 phase Inverter bridge
R-LowR-High
Y-Low
Y-HighB-High
B-Low
AC in
+ - DC bus
Hallsensors
INT0
QE
QE interface
Motor current
Potentiometer
Temp. sensor
+
Motor current
Reference-
Power factor correction
PIC
18F4
431
Motorcurrent
With QE for speed, position and direction feedback and Hall sensors for commutationcan be interfaced as shown here.Hall sensors connected to INT pins, and QE connected to motion feedback module.
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc. 12
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 12
Sensorless control
1 402
34
56
7
9
12
1516
1718
14
39
38
37
36
35
34
3332
3029
26
31
28
IC1
Vss
OSC1
FLTA/CCP2
INT0/RC3
PWM2
PWM1
PWM0VddVssRD7RD6RD5RD4
PWM3
PWM5
PWM4RB6/PGC
RB7/PGD
8
10
13
Vdd
OSC2
1920
RD0RD1
11
27RC7/RX/DT
25 RC6/TX/CK
24 RC5/INT2
23 RC4/INT1
22 RD3
21 RD2
/MCLR
AN0
IC2IC3
AN4
AN5AN6AN7AN8
RC0
FLTB/CCP1
3 phase Inverter bridge
R-LowR-High
Y-Low
Y-HighB-High
B-Low
AC in
+ - DC bus
Back EMF ZC detect
Motor current
Potentiometer
Temp. sensor
+
Motor current
Reference-
+
-Back EMF ZC detect
BLDCMotor
Power factor correction
PIC
18F4
431
Motorcurrent
Sensorless control of BLDC motor gives many advantages, most importantly loweredsystem cost. Every phase develops a voltage called Back EMF, that opposes the powerapplied to the phase. During the non energized phase of the sequence, this back EMFcrosses from positive voltage to negative voltage. From the the zero cross over point,rotor position can be determined, and used for commutation. This method eliminatesthe requirement of sensors for commutation.However, this may require additional hardware on the drive side and additionalfirmware overhead on the microcontroller.
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc.
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 13
Sensorless control schemes1) Compare with DC bus/2 2) Compare with virtual neutral
3) Using ADC Channels
A
C B
DC+
DC-
DC/2
+_
Back EMF
To IC2BZ_B
+_ To IC1
BZ_A
+_ To IC3
BZ_C A
CB
DC+
DC-
VirtualNeutral
+_
Back EMF
+_ To IC1
BZ_A
+_ To IC3
BZ_C
To IC2BZ_B
A
C B
AN0
AN1
AN2
Back EMF
We will see three different methods of determining the Back EMF zero cross point.1) Comparing WRT center point of DC bus: Every sequence has two windingsconnected across power supply and third winding left open. The BEMF generated inthe non energized winding is compared with respect to the half of DC bus. This gives afairly good result, when the motor terminal voltage is approximately equal to the DCbus voltage. If the DC bus voltage is disproportionately high, the cross over point maydrift away, making it difficult to determine a workable commutation sequence at allspeeds.2) Comparing with a virtual neutral: A virtual neutral point can be generated usingresistor ladders as shown and the BEMF in the non-energized winding can becompared with this neutral point. This makes it comparatively easy to determine thezero cross point at all measurable speeds.3) Using High speed ADCs: The BEMF signals are attenuated and read directly usingan on chip ADC on a PIC18Fxx31 can give a great flexibility in determining the zerocross over point.
However, at low speeds, the BEMF developed is very low in amplitude, which makesit difficult to determine a zero cross over point.
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc. 14
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 14
Summary� Overview of motor control solutions from Microchip� PIC18Fxx31 peripherals for motor control� BLDC motor control using PIC18Fxx31
� Open loop control� Closed loop control using Hall sensors� Closed loop control using Quadrature encoder� Sensorless control
Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers
© 2003 Microchip Technology Inc. 15
© 2003 Microchip Technology Incorporated. All Rights Reserved. Brushless DC Motor Control Using PIC18Fxx31 Microcontrollers 15
Resources� Application notes:
� AN885 : Brushless DC motor fundamentals� AN899 : Brushless DC motor control using PIC18Fxx31� AN857 : Brushless motor control made easy
� Demo and development board� PICDEMTM MC
� Completely isolated, debug tools can be connectedwhen the board is �live�
� Low cost design� Web design center: www.microchip.com/motor
These are additional resources for more information on Microchip�s Motor Control solutions.