Professional Documents
Culture Documents
1 Introduction Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
This application note demonstrates how to
implement a first order Proportional-Integral (PI) 2 Closed Loop Block Diagram . . . . . . . . . . . . . 2
closed loop control algorithm using the MC34929
3-phase Brushless DC (BLDC) Motor Driver IC, and 3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
an 8-bit MCU MC9S08QG8 to process all the
external signals, and provide the correct control to 4 MC9S08QG8 Features. . . . . . . . . . . . . . . . . . . 3
the motor driver. It also gives a guideline to develop
5 PI Control Basic Theory . . . . . . . . . . . . . . . . . 4
the software code implemented on the
KIT34929EPEVME.
6 Software Flowchart Diagram . . . . . . . . . . . . . 5
The PI control specifies the procedure to calculate
the proportional and integrative constants as well 7 MC9S08QG8 Signal Processing . . . . . . . . . . 6
as all the MCU signal processing.
8 Control Process Implementation. . . . . . . . . 11
All of these processes are considered to be
implemented with an MC9S08QG8 8-bit MCU, so 9 Timing Considerations . . . . . . . . . . . . . . . . . 13
calculations and timing processes could change
depending on the selected MCU. 10 Practical Results . . . . . . . . . . . . . . . . . . . . . 14
11 Conclusions. . . . . . . . . . . . . . . . . . . . . . . . . 15
12 References. . . . . . . . . . . . . . . . . . . . . . . . . . 15
Reference Signal
MC9SO8QG8
MCU CONTROL
Explanation:
1. The MCU first receives an external reference signal.
2. This signal is compared with the actual motor speed measured by Hall Effect sensors.
3. The error between these two signals is computed by a First Order PI closed loop control
algorithm.
4. Depending on the error, a new pulse width PWM signal is generated to the BLDC Driver.
5. The BLDC driver automatically interprets the signal and drives a 3-phase BLDC Motor.
6. This process repeats.
3 Features
The MC34929 is a complete BLDC motor driver integrated in one chip. Its main features are:
1. Operation Supply Voltage (8V-28V)
2. 3-Phase Hall Effect sensors interface
3. Two tachometer outputs (TACH and 3XTACH)
4. Adjustable Maximum Current Limit
5. Short Circuit Detection and Protection
6. Overtemperature Detection and Thermal Shutdown
7. Undervoltage Detection and Shutdown
4 MC9S08QG8 Features
The MC9S08QG8 is a member of the low-cost, high-performance HCS08 Family of 8-bit
microcontroller units (MCUs). All MCUs in the family use the enhanced HCS08 core and are
available with a variety of modules, memory sizes, memory types, and package types.
This application note uses the 16 TSSOP packaged MCU, which is contained on the
KIT34929EPEVME EVB.
Kp Kp
C ( s) = K p + , τi =
τi ⋅ s Ki
PI Control
Transfer
Function
To apply the Z Transform to this function, it is necessary to use the following conversions:
Obtaining:
Kp Kp
C ( z) = K p + , τi =
τ i ⋅ (1 − z ) −1
Ki
–1
( Kp + Ki ) – Kp • z
C ( z ) = -------------------------------------------------
–1
-
1–z
Port Initialization
TRIM Adjust
PWM Register
Configuration
MTIM Module
Configuration
Keyboard Register
Configuration
Enable Interrupts
500ms
Set new
PI Control
PWM Calculation
When the pulse width decreases from 1.5ms to 0.9ms, the speed of
the motor increases from STOP to full speed in CCW direction.
2. PWM requirements for the MC34929.
MC34929 BLDC driver can operate with a Maximum input frequency
of 100 kHz. This driver uses the same input frequency to control the
PWM output signal.
It’s important to choose an appropriate frequency, because it can
change the power consumption of the IC. (For more information
regarding this point please refer to the Hardware design application
note AN3319)
3. How to generate the PWM signal.
For the purposes of this application, the PWM signal is generated by
the TPM (Time/Pulse Width Modulator) registers of MC9S08QG8
MCU.
The following TPM registers are used to generate the PWM signal to
control the Speed of the Motor:
This register contains the channel interrupt status flag and control
bits that are used to configure the interrupt enable, channel
configuration, and pin function.
For this application, channel 1 is used to generate the PWM signal,
and TPMCnSC becomes TPMC1SC with a value of 0x24. With this
value, the PWM generates as Edge-aligned.
The PWM duty cycle depends on the 16-bit value charged into this
register.
This value must be between 0x0000, and the Period value set on
TPMMOD (0x0190).
This value has to be updated for every reference signal or PI control
value.
4. Interpreting the Feedback signal.
The TACH feedback is a square signal which indicates the position
of the motor, one cycle of this square signal indicates one turn of the
motor.
In this application, the feedback signal TACH is polled by the MCU
every 50ms (Frequency 20kHz) by reading bit 2 of the MCU’s parallel
port A. This bit detects every change of state of the pin.
System
Transfer
Function
This system has the following transfer function in the continuous time
domain.
Taking the Z transform, and considering the zero order hold of the
PWM module, the system’s transfer function becomes:
–T ⁄ τ –1
(1 – e )⋅z
G ( z ) = -------------------------------------------
–T ⁄ τ –1
1–e ⋅z
As it was shown in section 5, the PI control’s function is:
If we join the C(z) and G(z) to have just one block that shows the
closed loop system we obtain:
C ( z) ⋅ G( z)
R(z) U(z)
1 + C ( z) ⋅ G( z)
Gd(z)
Where:
– T ⁄ τd –1
(1 – e )⋅z
G d ( z ) = -----------------------------------------------
– T ⁄ τd – 1
1–e ⋅z
Gd ( z )
C ( z ) = ----------------------------------------------
G ( z ) ⋅ [ 1 – Gd ( z ) ]
– T ⁄ τd –T ⁄ τ –1 –1
1–e 1–e ⋅z ( Kp + Ki ) – Kp ⋅ z
C ( z ) = ---------------------------- ⋅ --------------------------------------- = ----------------------------------------------------
–T ⁄ τ –1 –1
1–e 1–z 1–z
Solving for Ki and KP:
– T ⁄ τd
Ki = 1 – e
–T ⁄ τ
Ki • e
K p = ----------------------------
–T ⁄ τ
1–e
Where:
T : Controller Period
τ : Time constant of motor speed in open loop.
τd : Desired time constant of motor speed in closed loop.
KP : Proportional Gain of the controller.
Ki : Integral Gain of the controller.
9 Timing Considerations
Graphic 1 Graphic 2
In Graphic 1 and Graphic 2 the following signals are shown (Graphic
2 represents a zoom in of a single yellow/green pulse event):
a) Reference Signal (Yellow) - top signals
b) MTIM Signal (Green) - middle signals
c) PWM (Pink) - bottom signals
The MTIM Timer is configured with a frequency of 40 KHz, counting
the time of the reference design pulse width.
The MTIM is activated when the Keyboard detects a reference
design rising edge and turns off when the Keyboard detects a falling
edge.
During all this time the TPM produces a PWM signal.
All closed loop calculations are processed once the MTIM is turned
off. The time you have available to make this calculation is the result
of the difference between the 20ms of reference period and the lost
time to execute the MTIM counter (reference signal pulse width).
The maximum and the minimum time to execute this calculation are:
10 Practical Results
The implementation of the PI controller using parallel programming
are shown in the following graphics:
Ki
+
E(z) M(z)
Ki +
1 − z −1
– T ⁄ τd
Ki = 1 – e
–T ⁄ τ
Ki • e
K p = ----------------------------
–T ⁄ τ
1–e
For this application, the values used to calculate Ki and Kp were the
following:
T = 500ms
τ = 5.44ms
τd = 1s.
–T ⁄ τ
Ki • e – 38
K p = ---------------------------- = 1.22 × 10
–T ⁄ τ
1–e
– T ⁄ τd
Ki = 1 – e = 0.393
11 Conclusions
The MC34929 is not only a 3-phase BLDC motor control IC, but also it can interpret Hall Sensor
inputs and provide TACH signal outputs required to support a PI closed loop control algorithm.
Together with an MCU, the MC34929 provides a complete and intelligent 3-phase BLDC Motor
Control Driver solution.
12 References
1. Katsuhiko Ogata, MODERN CONTROL ENGINEERING, Third Edition, Prentice- Hall,
1998.
2. W. Bolton, Control Engineering, 2nd Edition, Alfaomega, 2001.
3. Katsuhiko Ogata, DISCRETE TIME CONTROL SYSTEMS, Second Edition, Prentice-
Hall, 1996.
4. MC34929 Data Sheet
5. AN3319 - Hardware Design Using the MC34929
6. KIT34929 Software Programming Quickstart User Guide - MC34929EPUG
E-mail:
support@freescale.com For information on Freescale’s Environmental Products program, go to
http://www.freescale.com/epp.
USA/Europe or Locations Not Listed:
Freescale Semiconductor
Technical Information Center, CH370
1300 N. Alma School Road
Chandler, Arizona 85224
+1-800-521-6274 or +1-480-768-2130
support@freescale.com
Information in this document is provided solely to enable system and software
Europe, Middle East, and Africa: implementers to use Freescale Semiconductor products. There are no express or
Freescale Halbleiter Deutschland GmbH implied copyright licenses granted hereunder to design or fabricate any integrated
Technical Information Center circuits or integrated circuits based on the information in this document.
Schatzbogen 7
81829 Muenchen, Germany
+44 1296 380 456 (English) Freescale Semiconductor reserves the right to make changes without further notice to
+46 8 52200080 (English) any products herein. Freescale Semiconductor makes no warranty, representation or
+49 89 92103 559 (German) guarantee regarding the suitability of its products for any particular purpose, nor does
+33 1 69 35 48 48 (French) Freescale Semiconductor assume any liability arising out of the application or use of any
support@freescale.com
product or circuit, and specifically disclaims any and all liability, including without
Japan: limitation consequential or incidental damages. “Typical” parameters that may be
Freescale Semiconductor Japan Ltd. provided in Freescale Semiconductor data sheets and/or specifications can and do vary
Headquarters in different applications and actual performance may vary over time. All operating
ARCO Tower 15F parameters, including “Typicals”, must be validated for each customer application by
1-8-1, Shimo-Meguro, Meguro-ku, customer’s technical experts. Freescale Semiconductor does not convey any license
Tokyo 153-0064 under its patent rights nor the rights of others. Freescale Semiconductor products are
Japan not designed, intended, or authorized for use as components in systems intended for
0120 191014 or +81 3 5437 9125
support.japan@freescale.com surgical implant into the body, or other applications intended to support or sustain life,
or for any other application in which the failure of the Freescale Semiconductor product
Asia/Pacific: could create a situation where personal injury or death may occur. Should Buyer
Freescale Semiconductor Hong Kong Ltd. purchase or use Freescale Semiconductor products for any such unintended or
Technical Information Center unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and
2 Dai King Street its officers, employees, subsidiaries, affiliates, and distributors harmless against all
Tai Po Industrial Estate claims, costs, damages, and expenses, and reasonable attorney fees arising out of,
Tai Po, N.T., Hong Kong directly or indirectly, any claim of personal injury or death associated with such
+800 2666 8080
support.asia@freescale.com unintended or unauthorized use, even if such claim alleges that Freescale
Semiconductor was negligent regarding the design or manufacture of the part.
For Literature Requests Only:
Freescale Semiconductor Literature Distribution Center Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
P.O. Box 5405
Denver, Colorado 80217 All other product or service names are the property of their respective owners.
1-800-441-2447 or 303-675-2140 © Freescale Semiconductor, Inc., 2006. All rights reserved.
Fax: 303-675-2150
LDCForFreescaleSemiconductor@hibbertgroup.com
AN3318
Rev. 1.0
9/2006