Vector Control 3phase Ac
Vector Control 3phase Ac
AN024702-1006
ZiLOG is a registered trademark of ZiLOG Inc. in the United States and in other countries. All other
products and/or service names mentioned herein may be trademarks of the companies with which they are
associated.
Information Integrity
The information contained within this document has been verified according to the general principles of
electrical and mechanical engineering. Any applicable source code illustrated in the document was either
written by an authorized ZiLOG employee or licensed consultant. Permission to use these codes in any
form, besides the intended application, must be approved through a license agreement between both
parties. ZiLOG will not be responsible for any code(s) used beyond the intended application. Contact the
local ZiLOG Sales Office to obtain necessary license agreements.
Document Disclaimer
©2006 by ZiLOG, Inc. All rights reserved. Information in this publication concerning the devices,
applications, or technology described is intended to suggest possible uses and may be superseded.
ZiLOG, INC. DOES NOT ASSUME LIABILITY FOR OR PROVIDE A REPRESENTATION OF ACCURACY
OF THE INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED IN THIS DOCUMENT. ZiLOG
ALSO DOES NOT ASSUME LIABILITY FOR INTELLECTUAL PROPERTY INFRINGEMENT RELATED
IN ANY MANNER TO USE OF INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED HEREIN OR
OTHERWISE. Except with the express written approval ZiLOG, use of information, devices, or technology
as critical components of life support systems is not authorized. No licenses or other rights are conveyed,
implicitly or otherwise, by this document under any intellectual property rights.
Version Disclaimer
Application Notes are tested with the version of ZDS II available at the time of release. Subsequent
releases of ZDS II may require you to modify Application Note code to restore its function.
AN024702-1006
Application Note
Vector Control of a 3-Phase AC Induction Motor Using FMC16100 MCU
iii
Revision History
Each instance in the Revision History reflects a change to this document from its
previous revision. For more details, refer to the corresponding pages or appropri-
ate links given in the table below.
iv
Table of Contents
List of Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
List of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi
Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Z8 Encore!® MC Flash Microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Theory of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Description of Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Application Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Software Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Variables and Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Main Event Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Subfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Software Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Appendix A—References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Appendix B—Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Appendix C—Schematic Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Appendix D—Flowcharts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
List of Figures
Figure 1. Washing Machine Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Figure 2. Washing Machine Motor with Tachogenerator . . . . . . . . . . . . . . . . . . . 5
Figure 3. Modular Controller and XP Command Module . . . . . . . . . . . . . . . . . . 5
Figure 4. Hardware Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 5. Current Sense Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 6. Overcurrent Sense Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 7. Functional Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 8. Sampling Space Vector PWM Current (State = 3) . . . . . . . . . . . . . . . 15
Figure 9. Space Vector PWM States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Figure 10. Phase Current Reconstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Figure 11. Park Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Figure 12. Inverse Park Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Figure 13. Inverse Clarke Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Figure 14. PWM Space Vector Modulation (Ground Reference) . . . . . . . . . . . 23
Figure 15. PWM Space Vector Modulation (Neutral Reference) . . . . . . . . . . . . 24
Figure 16. High-Voltage Main Board Schematic . . . . . . . . . . . . . . . . . . . . . . . . 31
Figure 17. FMC16 Control Module Schematic . . . . . . . . . . . . . . . . . . . . . . . . . 32
Figure 18. HV Gate Drive Module Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Figure 19. HV Power Module Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Figure 20. Washing Machine Interface Module Schematic . . . . . . . . . . . . . . . . 35
Figure 21. DAC Module Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Figure 22. XP Command Module Schematic (Connects to Washing
Machine Module) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Figure 23. Flowchart for the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Figure 24. Flowchart for the PWM ISR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
vi
List of Tables
Table 1. Sample Interpretation by PWM State . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 2. PWM Duty Cycle by State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Table 3. Initialization Execution Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Table 4. Main Loop (ISR) Execution Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Table 5. Subfunction Execution Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Table 6. List of References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Table 7. Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Abstract
The 3-phase alternating current (AC) induction motors are mechanically simple,
rugged, highly reliable, lower in cost per horsepower than DC motors, and
capable of more torque and efficiency than single-phase AC motors. A 3-phase
AC induction motor can be controlled by varying its inputs according to a
mathematical model of the rotor flux field in a complex vector space (Vector
Control). Vector Control provides efficient and accurate control of the motor’s
speed and torque.
Until now, Vector Control has been the domain of digital signal processors
(DSPs), digital signal controllers (DSCs), and a few 32-bit and 16-bit
microcontrollers. Constant cost pressure and increased consumer expectations
have driven design engineers to seek minimal hardware solutions that extract
maximum performance from motors used in consumer goods.
This application note demonstrates how ZiLOG's Z8 Encore!® MC 8-bit
microcontroller is used to implement Vector Control of an AC induction motor.
Discussion
An electric motor consists of a stationary frame (stator) in which a rotating
component (rotor) is mounted on a shaft and bearings. In a 3-phase AC induction
motor, the stator is laced with three sets of inductor windings energized by three
AC voltage inputs that are phase-offset 120° from each other, producing a rotating
field of magnetic flux inside the motor. This field creates an induced magnetic flux
in short passive windings on the rotor. The stator field exerts magnetic force on
the rotor flux field, resulting in torque on the output shaft.
AN024702-1006 Abstract
Application Note
Vector Control of a 3-Phase AC Induction Motor Using FMC16100 MCU
Theory of Operation
In this application, the FMC16100 microcontroller’s PWM module is configured as
three complementary output pairs. Each output pair controls one complementary
source/drain transistor pair in the inverter bridge. The PWM module is configured
to insert a 0.6 µS deadband between ON states to prevent leakage that might
occur if one transistor in a pair turns on before the other is fully off.
Each PWM output pair produces a stream of complementary on/off pulses to
activate the corresponding source or drain transistor in the inverter bridge. The
voltage of each bridge output varies with the source/drain pulse duty cycle.
The period of each PWM cycle is configured to be 50 µS and the PWM module
generates an interrupt request at the end of each cycle. The PWM interrupt
service routine (ISR) leaves the PWM interrupt disabled while it executes, and is
tuned to execute within 200 µS to 250 µS. Therefore, the PWM ISR is executed
every five PWM cycles or 250 µS.
The PWM ISR controls all of the ongoing application program functions after
initialization. The primary goal of the ISR is to update the duty cycle value for each
PWM channel as needed to produce the appropriate AC waveforms at the inverter
bridge outputs.
The PWM duty cycle values are derived from a feedback loop based on rotor
speed and rotor flux position. The stator current waveform is determined by
sampling two phases of the inverter output current and reconstructing the third
phase.
The rotor speed is sampled by a counter/timer configured to measure the period
of a magnetic position sensor on the motor. The measured speed is periodically
compared to the requested speed received through UART from an external
controller. The resulting speed command value is used to create a rotation
reference frame expressed as a two-phase direct/quadrature (DQ) vector.
AN024702-1006 Discussion
Application Note
Vector Control of a 3-Phase AC Induction Motor Using FMC16100 MCU
The resulting vector is regulated to produce the necessary flux and torque
amplitude in the output vector.
An inverse Park transform is used to rotate the reference frame relative to the
rotor position. Then an inverse Clarke transform is used to convert the rotated
two-phase reference frame back into a 3-phase expression. At the same time, the
vector’s position is classified into one of six states, each corresponding to one
sixth of the vector circle.
When the ISR calculates duty cycles for the three PWM channels, one phase is
left unmodulated (ON or OFF for the whole PWM cycle), and the flux vector is
encoded by modulating the other two phases. This reduces switching losses by
one third. The two phases to be modulated depend on the flux vector’s state
position. After the PWM space vector calculation is complete, the corresponding
PWM registers are updated. For more details on the software implementation, see
Software Implementation on page 11.
Description of Components
In addition to the Z8 Encore!® MC microcontroller, this design uses the following
major components:
• Z8 Encore! XP® microcontroller
• Insulated-gate bipolar transistors (IGBTs)
• I2C interfaced 8-bit digital-to-analog converter (DAC)
• Washing Machine Motor
AN024702-1006 Discussion
Application Note
Vector Control of a 3-Phase AC Induction Motor Using FMC16100 MCU
Three IR21064S high-side and low-side gate drivers are used to convert the
Z8 Encore!® MC microcontroller’s CMOS PWM outputs into signals with the
voltage needed to drive the IGBT gate inputs.
Digital-to-Analog Converter
The Z8 Encore!® MC microcontroller’s I2C interface is used with a DAC5574
digital-to-analog-converter to generate up to 4 analog test outputs based on
internal program values. This allows the internal values to be directly compared to
the motor controller’s output waveform on an oscilloscope.
Motor
The motor is a 3-phase AC Induction motor used in washing machine applications
as illustrated in Figure 1.
The application motor is illustrated in Figure 2 on page 5. The motor has the
following specifications:
• Rated Power: 500 W
• RPM max: 15,000 rpm
• Max current: 2.8 Arms
• Continuous current: 1.5 Arms
• DC Bus Voltage: 350 Vdc
The motor windings are connected in the Wye configuration for this application.
The back side of the motor has an integrated Tachogenerator, which consists of
an 16-pole magnet mounted on the shaft and a single-phase winding mounted on
the housing. This produces a sine wave signal whose voltage and frequency are
proportional to the motor speed. The interface to the Z8FMC16100 is a simple
transistor circuit that squares off the sine wave into 3.3 V digital pulses going to
Timer 0 in Capture Restart mode. This gives 8 pulses per revolution.
AN024702-1006 Discussion
Application Note
Vector Control of a 3-Phase AC Induction Motor Using FMC16100 MCU
Application Hardware
The application electronic components and circuitry are divided among several
printed circuit modules that attach to a main board mounted on a heat sink and a
separate user command module, as illustrated in Figure 3.
HV Main Board
AC 3 Phase AC
Power Stage Induction
Power
Motor
HV HV
Power Drive
Module Module
FMC16
Control
Module
User Interface
XP Washing
Command Machine DAC
Module Interface Module
Module
The following sections briefly describe each module of the application hardware.
The schematics are shown in Appendix C—Schematic Diagrams on page 31.
The power stage section rectifies and filters the single-phase AC supply to provide
a high-voltage DC bus supply. This section also contains the six IGBTs used
under PWM control to generate the 3-phase AC motor drive current.
The MPU is powered after the AC supply is connected, but a normally-open relay
withholds DC power from the IGBTs until the MPU has started and the application
software has completed its necessary startup functions. The application then uses
an I/O port output to enable a simple transistor driver that closes the relay,
powering the IGBTs.
Figure 5 illustrates the overall current sense circuit, including some power stage
components and components internal to the MPU. Vref is the internal reference
voltage of the MPU analog-to-digital converter and the full scale input range. At
zero current (zero voltage across Rsense) the output of the Op Amp is at 1/2Vref,
this centers the current waveform at one half of the full input range of the ADC.
R1 = 10 KΩ
R2 = 100 KΩ
Gain = 10
Vref = 2 V
C1 = unused
C2 = 120 pF
Vref 2V
Rsense = = 10 kΩ × = 0.0125 Ω (0.020 used)
2 × Gain × I_max 2 × 10 × 8A
The Resistive Divider also forms a Low Pass Filter (LPF) to take out the diode
reverse recovery current spike in the current sense signal. Since this is usually in
the MHz frequency range a single pole LPF is sufficient set at a couple of hundred
kHz. As the Operational Amplifier circuit already has a LPF this is more important
for the following comparator circuit.
1 1
ƒc = = = 256 kHz
2π × R1 || R2 × C2 2π × 5 kΩ × 120 pF
Figure 6 illustrates the overall schematic for the overcurrent sense circuit, likewise
including some power stage components and components internal to the MPU.
R3 and R4 set the overcurrent trip threshold. Since this is a DC value, a bypass
capacitor (C3) of 0.1 μF is used.
For R4 = 10, R3 is selected as:
10
11
Software Implementation
Figure 7 illustrates the functional block diagram of the Vector Control application.
12
The program uses a 128-value sine lookup table, Sine_Table[128]. This table
represents sine values from 0 to 90 Degrees, or approximately 0.7 Degree steps.
Stepping through the table in the forward direction gives sine values from 0 to 90
Degrees and stepping through the table in the reverse direction gives cosine val-
ues from 0 to 90 Degrees. This along with knowledge of the quadrant of the angle
of interest (Theta) allows full reconstruction of sine and cosine values for any
angle between 0 and 360 Degrees.
The polarity table, Polarity_table[8], contains bit masks used to set the polar-
ity bits in the PWMCTL1 register. A 1 bit causes the corresponding channel to
start the next PWM cycle in the ON state. A 0 bit causes the channel to start in the
OFF state.
The ripple compensation table, ripple_table[256], contains pre-calculated bus
voltage ripple compensation factors. See Bus Ripple Compensation on page 20.
Initialization
The following initializations are performed when main() is executed:
Option Bits
The options bits set the PWM Polarity and the WDT default mode.
Oscillator
Oscillator initialization consists of sending an unlock sequence to the oscillator
control register then enabling the external oscillator circuit. After allowing a setting
time of 50 ms the oscillator control register is unlocked again 20 MHz External
Ceramic Resonator
Digital Output
PB7 is used as a digital test pin for code development. This allows testing of the
speed of routines and to check out conditional branching of routines.
Comparator
Used for Overcurrent shutdown.
Op Amp
For current sensing using a single current sense resistor. The op Amp is used to
offset the ground referenced current sense signal to 1 V (half of the 2 V reference)
and the voltage is gained up by a factor of 10. For a sense resistor value of
20 mOhms and a current of +/-4A gained up by 10 this represents a 1 V signal
that can swing +/- 0.8 V.
13
ADC
Used for sampling current and DC Bus Voltage.
Relay
The main relay is normally open so the high-voltage power supply is disabled
while the microcontroller starts up. The relay initialization pauses for three
seconds before closing the relay to make sure the high-voltage bus capacitors can
precharge through a resistor. After closing the relay, the program waits another
second to allow the relay contacts to settle.
Current Calibration
Once the peripherals are enabled and have settled out 8 samples of the current
sense channel are taken with zero current. The average of these samples are
used to zero out any offsets in the circuit.
UART
The UART is configured for 9600 baud, 1 start bit, 8 data bits, and 1 stop bit.
UART transmit and receive are tied together for single wire communication. The
3 wires are ground, data, and 5 V. The UART service routine updates every 2 ms.
The service routine is set up for just receiving data in this application. A more
elaborate communication link could be implemented with this hardware.
I2C
I2C is used for an external EEPROM for logging product data. For testing
purposes the I2C interface is used to send data to a 4 Channel DAC. In this
implementation a single channel of the DAC is updated every 250 μs so that one
parameter can be monitored in real time. This provides a method for
troubleshooting and code development, and field orientation tuning using an
oscilloscope. To control the DAC the Z8FMC16100 is set up as the I2C Master at
384 kbps, 2.6 μs per bit. All data is sent to DAC channel A.
Timer0
Timer 0 is used in Capture Restart Mode, the encoder input rising edge is used to
trigger the Capture. If the timer rolls over then the maximum timer count of
0xFFFF is used setting it to the minimum speed.
PWM Module
The 3-phase PWM module is set up in Edge Aligned PWM and the PWM polarity
is controlled to Allow Space Vector Modulation and current sampling and
reconstruction. Each PWM pair is set up in complementary mode with 12 clock
14
cycles of deadband (0.6 μs). The PWM reload event triggers an ADC conversion.
This is used for current reconstruction.
PWM Interrupt
The PWM reload interrupt is enabled. The PWM ISR constitutes the program
control loop. PWM interrupts are disabled during the ISR until the ISR is complete.
Current Sample
The PWM interrupt is configured to automatically start an ADC conversion that
samples the high-voltage current, so the PWM ISR begins with an ADC
conversion already in progress. The PWM interrupt is edge-aligned, and the
sample takes place before the PWM state change propagates to the inverter
bridge gates. Thus, this first sample captures the current at the end of the just-
completed PWM cycle.
After reading the first sample, the ISR immediately begins another ADC
conversion. This second sample captures the current at the beginning of the new
PWM cycle. This is illustrated in Figure 8 on page 15. Phase currents are then
reconstructed from these samples.
15
16
180°
STATE 2 STATE 1
STATE 4 STATE 5
360°
Using Kirchoff’s current Law and assuming no zero sequence currents (zero
sequence currents are only possible in an imbalanced Delta wound motor not in a
17
Wye winding), the sum of three phase currents equals zero. The third current can
be derived from the other two samples using the following equation:
I_a + I_b + I_c = 0
The oscillograph in Figure 10 compares a reconstructed waveform as output to
the DAC at 1 A/330 mV (top trace) to the original waveform as read by a current
probe at 1 A/10 mV.
18
Clarke Transform
A Clarke transform produces a 2-phase (direct and quadrature) representation of
the reconstructed 3-phase stator flux vector. Then a quadrant test is applied to the
reference currents I_ds and I_qs to determine which quadrant the currents are
in. This result is used later in the Park Transform to rotate the 2-phase vector. The
equation for the Clarke Transform is:
1
I_ds = I_a – 2 (I_b + I_c)
2
I_qs = √3 (I_b + I_c)
Angle Update
The angle Theta is updated through the following equation:
Theta = Theta + Speed + Slip
Where:
Theta = rotor flux angle relative to the stator phase A winding
Speed = speed (frequency) of the rotor in terms of the update rate of the control
loop
Slip = slip speed (frequency) required to produce the proper rotor flux
19
I_qs
I_qr
I_dr
Theta
I_ds
I_d Regulator
Regulator that controls the direct component of the current vector. This is
regulated by a simple PI regulator.
I_q Regulator
Regulator that controls the quadrature component of the current vector. This is
regulated by a simple PI regulator.
20
Quadrant Test
A quadrant test is applied to the reference currents I_dr and I_qr to determine
which quadrant the currents are in. This result is used later in the Inverse Park
Transform to rotate the 2-phase vector. Reference currents I_dr and I_qr are
calculated in the Speed_reg() subroutine.
ADC_vbus_nom
pwm_correction = × 255
ADC_vbus
21
V_qs
V_qr
V_dr
Theta
V_ds
V_a = V_ds
1 2
V_b = 2 (V_ds) + √3 (V_qs)
1 2
V_c = 2 (V_ds) – √3 (V_qs)
22
I_q
I_b
I_a=I_d
I_c
23
24
Subfunctions
Tachometer Update
The Tachometer update routine looks at the latest Capture Value from Timer 0.
The routine checks for a roll-over, if it detects a roll-over then the maximum
counter value of 0xFFFF is used to calculate speed. Also a rate limit is put on the
variable Speed_step to make sure noise doesn’t cause erratic speed readings. In
case of an optical encoder you can have the phenomena of edge jitter, when and
encoder line is on the edge of the optical pick-up and the motor is at stand still,
and movement in the motor can cause fast edges that can be interpreted as
25
sensing high speed. This is filtered out by not allowing a jump in speed. The
Tachometer update function is divided into three subfunction calls to limit the
execution time for each call.
Field Weakening
Currently not developed for this application.
Speed Regulator
The speed regulator is a standard Proportional Integral (PI) regulator. The
command comes from the UART and the speed feedback comes from the
Tachometer.
UART Communication
The UART communicates with the Z8 Encore! XP® module that simulates a
washing machine control panel. The control module has a potentiometer and two
momentary switches. The potentiometer setting determines the transmitted speed
command. Switch 1 stops/starts communication (stopping the communication
stops motor).
The control module sends a single command byte that is read at each UART
update. Bits 7:1 of the command byte are the speed command (MSB of the
control module’s ADC sample). Bit 0 reflects the controller module Switch 2
status, which is used to control the motor direction.
Acknowledge byte from motor controller: AAh
The UART baud rate is 9600 Baud.
Software Metrics
Table 3 illustrates the execution time for each program initialization routine,
executed once at startup.
Routine Time
init_osc 50 ms
init_out 1 µs
init_comp 1 µs
init_amp 2 µs
26
Routine Time
init_adc 2 µs
init_relay 4s
init_current 32 µs
init_uart 2 µs
init_i2c 3 µs
init_timer0 3 µs
init_pwm 5 µs
init_pwmint 1 µs
Table 4 illustrates the execution time for each routine in the PWM ISR, executed
every 250 μs (4 kHz loop).
27
Subtotal 224
End of PWM Period Test Variable
Total 250
28
Summary
The purpose of this application is to demonstrate how a Z8 Encore!® MC
microcontroller is used for efficient rotor flux field oriented vector control of a
3-phase AC induction motor. The following microcontroller features make this part
particularly suited to motor control applications:
• The eZ8 processor core runs at up to 10 MIPS with a 20 MHz clock.
• The integrated PWM interface module provides the necessary timing and logic
outputs for synthesizing 3-phase voltage in motor control applications.
• The 2.5 μs successive approximation register (SAR) ADC can be triggered by
PWM events for sampling and reconstructing phase currents. The integrated
Op Amp amplifies and provides offset adjustment of a single ground-
referenced sense resistor, centered to one-half of the built-in ADC reference.
The integrated comparator provides for fast overcurrent shutdown.
• The integrated communication peripherals (UART, I2C, and SPI) provide for
system level communication. For example, the UART in this application
provides a highly capable user command interface, yet simple enough to be
optically coupled for electrical isolation.
In addition to the Z8 Encore!® MC microcontroller’s native advantages, the
software design uses the following techniques to manage the processing task:
• To make time for the waveform calculations, the main loop operates at one
fifth of the 20 kHz PWM chop rate (five 50 μs cycles, 250 μs per loop). This
preserves most of the advantages of a high-frequency PWM rate, while still
producing a good approximation of the appropriate output waveform.
• To free up additional time for main loop calculations, low-priority subfunctions
are called in a 10-position round-robin schedule, so that each subfunction is
executed only once every 2.5 ms. The lengthy tachometer update operation is
further divided into three subfunction calls to limit execution time per call.
• Converting current measurements to a 2-phase vector for the rotation
transform reduces calculation time compared to rotating a 3-phase vector.
• All signed values are expressed as pairs of unsigned variables. This requires
extra code to perform an if-then-else for each calculation, but the eZ8
processor’s short-range branch instructions are efficient enough so the
unsigned calculations can execute faster than the equivalent library routines,
which are written for general-case signed arithmetic.
The example application and techniques described in this document should prove
helpful for anyone who intend to develop motor control applications based on the
Z8 Encore!® MC family of microcontrollers.
AN024702-1006 Summary
Application Note
Vector Control of a 3-Phase AC Induction Motor Using FMC16100 MCU
29
Appendix A—References
Further details on this topic and the eZ80® family of products is available in the
references listed in Table 6.
30
Appendix B—Glossary
Definitions for terms and abbreviations used in this application note that are not
commonly known are listed in Table 7.
Table 7. Glossary
Term/Abbreviation Definition
ADC Analog-to-Digital Converter
DAC Digital-to-Analog Converter
IGBT Insulated-gate bipolar transistor
ISR Interrupt Service Routine
PI Proportional plus Integral
PWM Pulse Width Modulation
Rotor Rotating cage and windings of AC motor
Stator Stationary windings of AC motor
1 2 3 4 5 6
MTHOLE1
HIGH VOLTAGE POWER STAGE HEATSINK
M_FGND
M_4_DC_IN M_R4 MTHOLE
M_5_VBUS TEMP SENSOR
4
CL-140
M_TEMP MTHOLE2
MTHOLE
M_R7 M_Q1 M_Q3 M_Q5
1
1.00M M_6_AH SGS5N60RUFD M_7_BH SGS5N60RUFD M_8_CH SGS5N60RUFD
M_R17 MTHOLE3
D + M_C2 10k NTC MTHOLE D
3 M_3_DIV 2322 640 66103
M_1_AC 2 M_6_PH_A A M_7_PH_B B M_8_PH_C C
1000uF 200V MTHOLE4
ESMQ201VSN102MR30S M_R6 M_C3 M_C4 MTHOLE
2 5 1.00M 22nF 400V 22nF 400V M_GND
Rectifier B32529B6223J B32529B6223J M_12V
GBU6J M_K1 M_Q2 M_Q4 M_Q6
RELAY_JS1A-12V
3
M_D1 M_GATE_AL SGS5N60RUFD M_GATE_BL SGS5N60RUFD M_GATE_CL SGS5N60RUFD
M_3_CENTER_TAP M_V+
M_RELAY
M_12V
2 M_D2
BAS16
M_2_AC 3
1
+
M_C1 M_R5 M_RELAY
1000uF 200V 10.0k M_R1 M_RSENSE M_R2 10.0k M_CS+
ESMQ201VSN102MR30S 0.020 OHM
ERJ-M1WSF20MU M_R18
M_GND M_R3 10.0k M_CS- M_ENABLE M_BASE
2K
M_Q7
MMBT2N2222A
M_GATE_AL
M_GATE_BL
M_GATE_CL
1
M_6_PH_A
M_7_PH_B
M_8_PH_C
M_6_AH
M_7_BH
M_8_CH
M_GND
M_GND
M_GND
M_GND
C C
BEMF DIVIDERS
AC POWER
1
2
1
2
1
2
1
2
1
2
1
2
M_6_PH_A M_7_PH_B M_8_PH_C
pad 2 pad 2 pad 2 pad 2 pad 2 pad 2 M_P1
MG_J5 MG_J4 MG_J9 MG_J8 MG_J13 MG_J12 M_1_AC
1
M_R10 M_R13 M_R16 M_2_AC
2
UNUSED UNUSED UNUSED M_12V HV GATE DRIVE MODULE M_3_CENTER_TAP
1 3
M_GND MG_J1 M_FGND
2 4
pad 2
EDGE 4 HV
M_9_DIV M_10_DIV M_11_DIV MG_J2 MG_J3 MG_J6 MG_J7 MG_J10 MG_J11
pad 2 pad 2 pad 2 pad 2 pad 2 pad 2
1
2
1
2
1
2
1
2
1
2
1
2
M_R9 M_R12 M_R15
UNUSED UNUSED UNUSED ME_J1
DAC MODULE MOTOR
M_GND
M_GND
M_GND
M_GND
M_GND
M_GND
M_AH
M_AL
M_BH
M_BL
M_CH
M_CL
M_P2
M_VA M_VB M_VC
1
4
3
2
1
M_6_PH_A
1
2
1
2
1
2
1
2
1
2
1
2
2
B MW_J1 M_7_PH_B B
3
pad 2 pad 2 pad 2 pad 2 pad 2 pad 2 M_3_3V MW_J4 M_8_PH_C
1 4
M_R8 M_R11 M_R14 M_3_3V MC_J3 MC_J4 MC_J5 MC_J6 MC_J7 MC_J8 M_GND
1 2 1 5
UNUSED UNUSED UNUSED M_SCL M_T2
2 WASHING 2 6
M_SDA MC_J17 Pad2 M_T1
3
M_GND pad 4 pad 2 HV EDGE 6 HV
4 MACHINE
MW_J2
M_GND M_VC
1 INTERFACE
M_GND
2
M_ENABLE FMC16 CONTROL MODULE
1 MODULE
M_GND MC_J2 Pad2 OPTO UART
2
pad 2
M_4_DC_IN
1 1 1 1
M_3_3V M_TXD M_ISO_DATA
1 2 2 2 2
M_GND MC_J1 M_GND M_ISO_GND
2 3 3 3 3
M_5_VBUS pad 2
MC_J16 MC_J15 MC_J14 MC_J13 MC_J12 MC_11 Pad3 Pad3 pad 3 EDGE3
pad 2 pad 2 pad 2 pad 2 pad 2 pad 2
M_GND AUX POWER
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
M_P4
M_C5 M_C6 pad 2 HV pad 2 pad 2 M_12V
1
4700pF 4700pF MP_J1 MP_J2 MP_J3 M_GND
2
M_TEMP
A EDGE2 A
M_GND
M_GND
M_GND
M_GND
M_GND
M_CS+
M_CS-
M_V+
M_VA
M_VB
M_VC
C_P8
C_VREF
1
C_GND
2
con 2
C_R1 C_R3 C_R4 C_P16
C_P7 10.0K 10.0K 10.0K C_V+
1
C_GND
1 2
D C_GND D
2
con 2
con 2
C_P15
C_P6 C_C1 C_3_3V C_R15 C_VA
1
C_C2 UNUSED
1 2
C_GND 0.1uF C_R2 C_GND
2
12.4K 100pF con 2
con 2
C_P14
C_P5 C_3_3V C_R14 C_VB
C_NRESET
C_GND
1
C_ENABLE
UNUSED
C_CINP
1 2
C_DBG
C_GND C_GND
C_CH
C_BL
2
C_CL
con 2
con 2
C_U1 C_P13
C_P4 Z8FMC16_32LQFP C_3_3V C_R13 C_VC
16
15
14
13
12
11
10
1
9
1 10K 2
C_GND C_GND
2
con 2
PA7/FAULT1/T0OUT/COUT
PA2/CINP
DBG
RESET/FAULT0
PC0/T0OUT
PWM2H
PWM1L
PWM2L
con 2
C_P12
C_P3 C_VREF C_R10 C_TEMP
1
C 1 10.0K 2 C
C_GND C_GND
2
con 2
con 2
C_BH 17 8 C_CS+ C_P11
PWM1H PA1/OPINP/CINN
C_AL 18 7 C_CS- C_CS+
PWM0L PA0/OPINN 1
C_AH 19 6 C_VREF C_CS-
PWM0H VREF 2
C_GND 20 5 C_GND
GND AGND
C_XOUT 21 4 C_3_3V con 2
XOUT AVDD
C_XIN 22 3 C_VA
XIN PB0/ANA0/T0IN0
C_3_3V 23 2 C_VB
VDD PB1/ANA1/T0IN1
C_SCL 24 1 C_VC
PA3/TXDE/SCK/SCL PB2/ANA2/T0IN0
C_Y1
PB3/ANA3/OPOUT
C_C5 C_C6 C_C12 C_C13
PA6/CTS/SS/SDA
PB4/ANA4/CINN
PA4/RXD/MISO
1 3
PA5/TXD/MOSI
20MHz C_GND
2
C_GND
25
26
27
28
29
30
31
32
C_C14
C_CURRENT
B B
C_P2
C_ENABLE
C_TEMP
1 TP1
C_GND UNUSED
C_CMD
2 CURRENT
C_V+
CON2 C_R9
C_P1 49.9K
C_3_3V
1
C_GND C_3_3V
2
DBG
con 2 INTERFACE
C_R11 C_P18
C_P17 10.0K C_R12
1 2
C_3_3V 10.0K
1 3 4
C_SCL
2 5 6
C_SDA
3 C_GND C_NRESET HEADER 3X2
4 TP2
C_DBG
con 4 TEMP C_C19
C_GND
C_C18 2200pF
A A
CP10 C_C17 UNUSED
C_RXD Title
1 FMC16 CONTROL MODULE
C_TXD UNUSED
2
C_GND C_GND
3
Size Number Revision
CON3
B
96C1020-001 A
Date: 12-Jul-2006 Sheet of
File: C:\Program Files\Design Explorer 99 SE\PROJECTS\APPLICATIONS\Rex\HiVoltRefDes\
Drawn By:
1 2 3 4 5 6
G_P2
G_AH
1
G_GND G_U1 G_R1 49.9 G_P5
2
1 G_6_AH G_C3 + G_C4
VCC 1
+ G_C1 G_C2 con 2
D 2 D
2 13 0.1uF 10uF 16V
HIN VB
10uF 16V 0.1uF G_P3 con 2
UWX1C100MCL2GB 3 12 UWX1C100MCL2GB
G_AL G_6_HO
1 LIN HO
G_GND
2
11 G_6_PH_A
VS
con 2
G_GND 5
VSS
6
COM
7
LO
IR21064S
G_R2 49.9 G_P4
G_LO_A G_GATE_AL
1
2
con 2
C G_12V
G_12V G_D2
2 US1J1 G_7_VB C
G_P6
G_BH
1
G_GND G_U2 G_R3 49.9 G_P9
2
G_P1 1 G_7_BH G_C7 + G_C8
VCC 1
G_12V + G_C5 G_C6 con 2
1 2
G_GND 2 13 0.1uF 10uF 16V
2 HIN VB
10uF 16V 0.1uF G_P7 con 2
UWX1C100MCL2GB 3 12 UWX1C100MCL2GB
con 2 1 G_BL
LIN HO
G_7_HO
G_GND
2
11 G_7_PH_B
VS
con 2
G_GND 5
VSS
6
COM
7
LO
IR21064S
G_R4 49.9 G_P8
G_LO_B G_GATE_BL
1
2
con 2
B B
G_12V
G_12V G_D3
2 US1J1 G_8_VB
G_P10
G_CH
1
G_GND G_U3 G_R5 49.9 G_P13
2
1 G_8_CH G_C11 + G_C12
VCC 1
+ G_C9 G_C10 con 2 2
2 13 0.1uF 10uF 16V
HIN VB
10uF 16V 0.1uF G_P11 con 2
UWX1C100MCL2GB 3 12 UWX1C100MCL2GB
G_CL G_8_HO
1 LIN HO
G_GND
2
11 G_8_PH_C
VS
con 2
G_GND 5
VSS
6
COM
7
LO
A IR21064S A
G_R6 49.9 G_P12
G_LO_C G_GATE_CL Title
1
2 HV GATE DRIVE MODULE
con 2 Size Number Revision
Orcad B 96C1017-001 A
Date: 26-Jun-2006 Sheet of
File: C:\Program Files\Design Explorer 99 SE\PROJECTS\APPLICATIONS\Rex\HiVoltRefDes
Drawn By:
1 2 3 4 5 6
D D
P_R2 16.5k
P_2_FB P_2_OUT
1
P_U1 P_R1 UWX1C100MCL2GB P_D2
P_2_BP 3.3V POWER SUPPLY
P_1_VBUS 5 4 P_C1 2.00k + P_C2
D FB US1J
C 3 C
BP
0.01uF 10uF P_L1 UA78M33CSCYR
2
P_P1 7 2 P_12V 1 3 P_3_3V
S7 S2 VI VO
GND
1
8 1 1mH P_C4
2 S8 S1 B82477G4105M
P_D1 + P_C3 P_P2 P_C5 + P_C6 P_P3
con 2 HV LNK304G 0.1uF P_U2
0.2" Spacing 1 1
US1J 100uF 16V 0.1uF 100uF 16V
2
UWX1C101MCL1GB 2 UWX1C101MCL1GB 2
P_2_S
con 2 con 2
2
P_GND
REFERENCE DESIGNATORS AND NET NAMES: "P_" FOR POWER SUPPLY MODULE
B B
A A
Title
HV POWER MODULE
Size Number Revision
Orcad B 96C1016-001 A
Date: 26-Jun-2006 Sheet of
File: C:\Program Files\Design Explorer 99 SE\PROJECTS\APPLICATIONS\Rex\HiVoltRefDes
Drawn By:
1 2 3 4 5 6
D D
TACH/TURN SENSOR
W_C3 W_P1
W_GND W_3_3V
1
W_GND
0.1uF 2
CON2
W_R5
OPTOISOLATED UART 10.0K
C W_P4 W_P2 C
W_C1 200mil spacing from rest of circuitry W_T1 W_VC
1 1
W_GND W_3_3V W_T2 W_GND
2 2
0.1uF con 2 CON2
3
W_R1 W_Q1
220 W_C2 W_BASE 1 MMBT2N2222A
W_R3
0.1uF W_R2 390 W_3_3V W_R6 10.0K
3
4.99K
2
W_U1 W_U2 C_EMITTER
W_C4 2 W_C5
1 8 1 8 2
W_R4 0.1uF W_D1 W_D2 0.1uF W_R7
W_ANODE 2 7 W_ISO_ANODE2 7 4.99K BAS16 BAS16 100
W_P3
1
3 6 3 6 W_RXD
1
W_TXD W_GND
2
4 5 4 5 W_GND
3
CON3
6N137 6N137
B B
W_P5
W_ISO_5V
1
W_ISO_DATA
2
W_ISO_GND
3
con 3
A A
Title
Washing Machine Interface Module
Size Number Revision
B 96C1021-001 A
Date: 26-Jun-2006 Sheet of
File: C:\Program Files\Design Explorer 99 SE\PROJECTS\APPLICATIONS\Rex\HiVoltRefDes\
Drawn By:
1 2 3 4 5 6
1 2 3 4
D D
J1 J2 J3 J4 J5 J6
CON1 CON1 CON1 CON1 CON1 CON1
1
3.3V
C C
R1 R2
U1 10K 10K
1 10
VOUTA A1
2 9
VOUTB A0
3 8
GND VDD
4 7
VOUTC SDA
5 6 C1
VOUTD SCL
.1uF
DAC5574IDGS
1
2
3
4
B B
J7
CON4
Title
A DAC MODULE A
12V U1 5V
VREG_LM78M05CDT
1 3
D V_IN V_OUT D
GND
C1 C2
.1uF .1uF
2
J1 J2
CON2 CON3
1
2
1
2
3
12V 3.3V 12V 5V
U2
2 1
IN V_OUT
C3 GND C4
.1uF VREG_LM3480 .1uF
3.3V
3
DATA
C 3.3V R3 C
220
R1 R2
10K 10K LED1
3.3V U3 GRN
1 8
VCC GND
2 7
PA0/DBG PA5/TXD0
3 6
PA1/VREF PA4/RXD0
4 5
PA2/RESET PA3/CTS0
Z8F04XP_8PIN
S2
DEBUG R4 R5
2.49K 2.49K C5
.1uF
B 3.3V B
JP1 S1
1 2
3 4
RESET
5 6 R6
HEADER 3X2 5K
Title
A A
XP COMMAND MODULE
Size Number Revision
A 96C1023-001 A
Date: 26-Jun-2006 Sheet of
File: C:\Program Files\Design Explorer 99 SE\PROJECTS\APPLICATIONS\Rex\HiVoltRefDes
Drawn By:
1 2 3 4
38
Appendix D—Flowcharts
Figure 23 illustrates the overall program flow. After main() initializes the
application, it drops into an infinite loop. Meanwhile, the PWM timer generates an
event every 50 μs. The PWM ISR is timed to execute on every fifth PWM event,
once every 250 μs. The ISR calls one of ten low-priority subfunctions on every
loop cycle, so each subfunction is called once every 2.5 ms.
main()
Initialization
PWM Timer
Events (50 μs)
Infinite Loop
PWM Interrupt
Service Routine
Tach Update 1
Calculate/Update
PWM Values Tach Update 2
Tach Update 3
Refresh
WDT Timer Field Weakening
Slip Update
Unused
Return
39
PWM Interrupt
Service Routine
Return