ZILOG AN031102-0311

Application Note
Sensorless Brushless DC Motor
Control with the Z16FMC MCU
AN031102-0311
Abstract
This application note discusses the closed loop control of a 3-phase brushless direct current (BLDC) motor using the Z16FMC Family of Microcontrollers (MCUs). The
Z16FMC product family is designed specifically for motor control applications, featuring
an on-chip integrated array of application-specific analog and digital modules. The result
is fast and precise fault control, high system efficiency, on-the-fly speed/torque and direction control, as well as ease of firmware development for customized applications.
This document further discusses ways in which to implement a sensorless feedback control system using a Phase Locked Loop along with back EMF sensing. Test results are
based on using the Z16FMC Modular Development System (MDS) module, a 3-phase
motor control (MC) application board and a 3-phase 24 VDC, 30 W, 3200 RPM BLDC
motor with internal Hall sensors.
Note: The source code files associated with this application note, AN0311-SC01 and AN0311SC02, were tested with version 4.12 of ZDS II for ZNEO MCUs. Subsequent releases of
ZDS II may require you to modify the code supplied with this application note.

The sample project included in ZDS II v4.12 and the firmware in the Rev D (or earlier) version of the Z16F28200KITG Development Kit were preprogrammed with AN0311-SC01.
The source code files contained in AN0226-SC02 are enhanced versions of AN0311-SC01
that allow users to easily change parameters to accommodate differing motor types.
Revision History
Each instance in the following table reflects a change to this document from its previous version.
For more details, refer to the corresponding pages or appropriate links provided in the table.
AN031102-0311
Date
Revision
Level
Description
Mar 2011
05
AN0311-SC02 source code added to encompass
multiple motor types; correction to TimerPrescale
data in PLL flow, Figure 17.
Dec 2010
01
Original issue.
Page
Number
1, 22
All
Page 1 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Features
The power-saving features of this Z16FMC application include:
•
Smooth S-curve motor start-up with reduced starting current
•
Sensorless (back-EMF) control using Phase Locked Loop feedback
•
Microcontroller-based overcurrent protection
•
Selectable speed or torque setting
•
Selectable speed or torque control
•
Selectable control of motor direction
•
UART Interface for PC control
•
LED for max speed indication
•
LED for motoring running indication
•
LED for fault indication
Discussion
The Z16FMC Series Flash microcontrollers are based on Zilog’s advanced ZNEO 16-bit
CPU core. The Z16FMC MCU family of devices set a new standard of performance and
efficiency with up to 20 MIPS performance at 20 MHz. It supports 16-bit internal and
external bus widths and provides near-single-cycle instruction execution.
The Z16FMC’s external interface allows seamless connection to external memory and
peripherals. A 24-bit address bus and a selectable 8-bit or 16-bit data bus allows parallel
access up to 16 MB. Up to 128 KB internal Flash memory is accessible by the CPU, 16 bits
at a time, to improve processor throughput. Up to 4 KB of internal RAM provides storage
of data, variables and stack operations.
Figure 1 displays a block diagram of the Z16FMC MCU architecture.
AN031102-0311
Page 2 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
WDT with
RC Oscillator
ADC 10-bit
12-Channel
POR/VBO
& Reset Control
Internal Precision
Oscillator
ZNEO
20 MHz CPU
Multi-Channel
PWM Timers
Comparator
Operational
Amplifier
3 x Timer
DMA
Controller
2
IC
Interrupt
Controller
ESPI
2 x LIN-UART
with IrDA
Flash
Controller
128 KB
RAM
Controller
4 KB
A
B
C
D
E
F
G
H
Ports
8
8
8
8
8
1
1
4
Number of pins available
Figure 1. The Z16FMC MCU Architecture
In each of the Z16FMC products, the novel device architecture allows for realization of a
number of enhanced control features:
•
Time Stamp for Speed Control
•
Integrated Operational Amplifier
•
Multi-Channel PWM Timer
Time Stamp for Speed Control
Most microcontrollers use at least one dedicated comparator to detect the zero crossing of
the input AC voltage signal so that the output driving pulses can be synchronized and
AN031102-0311
Page 3 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
adjusted to properly regulate the motor speed. An alternative approach based on Zilog's
motor control MCU eliminates the need for this comparator by instead employing an analog to digital converter (ADC) in conjunction with a timer. In this case, the ADC samples
the AC line voltage, with the timer running in the background.
When the ADC samples the line voltage's zero crossing, it reads the timer count and writes
the result to a register. As a result, the timers are cued for the output Pulse Width Modulation (PWM) pulses to efficiently regulate the speed of the motor. This time stamp
approach results in a very simple and cost-effective solution for smooth operation of the
motor in steady state.
Integrated Operational Amplifier
Appliance controllers almost invariably monitor motor speed by sensing the current
through the windings, using sensor and sensorless techniques in conjunction with the
ADC. Ordinarily, sampling instances by the ADC are synchronized by the MCU. With
this process, an external operational amplifier is often used to convert the current signal to
a voltage signal; the ADC next samples the voltage signal and outputs the result to the processor. The processor then synthesizes the PWM outputs to control motor speed.
In the case of the Z16FMC Family of Microcontrollers, an on-chip integrated operational
amplifier eliminates the requirement for an external component, thereby reducing overall
system cost.
Multi-Channel PWM Timer
The Z16FMC features a flexible PWM module with three complementary pairs - or six
independent PWM outputs - supporting deadband operation and fault protection trip input.
These features provide multiphase control capability for a variety of motor types and
ensure safe operation of the motor by providing immediate shutdown of the PWM pins
during a fault condition.
Theory of Operation
In a brushless DC motor, the rotor is comprised of permanent magnets while the stator
windings are similar to those in poly-phase motors. For a detailed discussion of BLDC
motor fundamentals, as well as closed-loop control using sensorless techniques, refer to
the Motor Control Electronics Handbook by: Richard Valentine, McGraw-Hill, NY, 1998.
In sensor-based control applications, the Hall elements are integrated and are used to
detect the position of the rotor for drive synchronization. In contrast, sensorless control
employs the detection of Back EMF signals which are generated (induced) by specific
phase windings to synchronize the timing of the control loop.
A block diagram of the BLDC motor control system based on the Z16FMC MCU is
shown in Figure 2. In a 3-phase commutation arrangement, at any given instance, only two
phases are energized. The back EMF voltage is in turn generated in the unenergized phase
winding, and the zero crossing of this induced voltage is detected for synchronization of
the subsequent closed-loop control events. As discussed earlier, the innovative time stamp
feature of the Z16FMC MCU provides for robust, efficient implementation of this critical
sensing function without the requirement for an additional comparator.
AN031102-0311
Page 4 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Figure 2. . A 3-Phase BLDC Motor Control System
The algorithm for Back EMF sensing is based on an implementation of a Phase Locked
Loop (PLL), as shown in Figures 3 and 4 and described in Appendix C, Back EMF Sensing Phase Locked Loop. This algorithm is especially advantageous during startup, resulting in a very smooth increase in the motor speed as well as nearly instantaneous reversal
of direction of rotation on command, as outlined below.
With a conventional approach during the start-up sequence, power is applied to the windings in order to place the rotor in a known starting position, followed by commutation and
start of Back EMF sensing and control. In contrast, the PLL-based approach implemented
herein makes it possible to lock the Back EMF signal from the onset of the start-up phase
without the requirement for initial placement of the rotor in a specific position. Moreover,
this approach significantly reduces any erratic movement of the motor during start-up or a
reversal of direction.
During normal operation following the start-up period, phase torque/current mode control
is achieved via sensing of the voltage generated across a sense resistor in the motor drive
AN031102-0311
Page 5 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
circuit. This voltage is routed to the on-chip integrated ADC, after which data processing
by the CPU, based on a predefined computational algorithm, results in the regulation of
the PWM commutation signal period(s).
As discussed earlier, another key feature of the Z16FMC MCU is the direct coupling of
the on-chip integrated comparator to the PWM module to enable fast, cycle-by-cycle shutdown during an overcurrent fault event. Oscilloscope-generated waveforms representing
this sequence of events are shown in Figure 5.
In conjunction with the integrated on-chip hardware blocks, the 3-phase BLDC motor
control software developed herein allows for ease of programming to achieve the desired
closed-loop control characteristics. The routines that enable the sensing of the motor's
Back EMF and current are all interrupt-driven. It is critical that the highest interrupt priority is assigned to the Back EMF sensing event for subsequent synchronization of the commutation events. In this case, Timer 0 is used for the Time Stamp function as well as for
updating the commutation period, if necessary.
Figure 3. Cycle-By-Cycle Shutdown
AN031102-0311
Page 6 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Testing
This section provides information about how to run the code and demonstrate this application, including the equipment used to build the implementation, its configuration and the
results of its testing.
Equipment Used
The following equipment is used for the setup; the first five items are contained in the
Z16FMC Series Development Kit (Z16FMC28200KITG).
•
Zilog Z16FMC MDS Module (99C1299-001)
•
Zilog 3-Phase Motor Control Application Board (99C0960-001)
•
Opto-Isolated USB Smart Cable to connect the PC to the Z16FMC Series Development
Board
•
LINIX 3 Phase BLDC motor 24VDc, 30W 3200RPM (45ZWN24-30)
•
5 V DC power supply for the Z16FMC MDS Module
•
24 V DC power supply for BLDC motor
•
Digital Oscilloscope or Logic Analyzer
Hardware Setup
Figures 4 and 5 illustrate the application hardware connections.
AN031102-0311
Page 7 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Figure 4. Z16F2800100ZCOG and Motor Control Application Board
Figure 5. 3-Phase BLDC Hardware Setup with Z16FMC MDS Module
AN031102-0311
Page 8 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Figure 6 displays the proper port settings in the HyperTerminal emulation program.
Figure 6. HyperTerminal Display Settings
Procedure
Observe the following steps to test the 3-Phase Sensorless BLDC Motor Control Application demo program to the Z16FMC MDS Module.
1. Install the ZDS II – ZNEO version 4.12 or newer software on your PC.
2. Connect the Opto-Isolated USB Smart Cable to the PC.
– To install the driver of the Opto-Isolated USB Smart Cable, refer to the
installation guide of the Opto-Isolated USB Smart Cable included in the Z16FMC
Series Development Kit.
3. Connect the Hardware Setup as shown in Figure 7.
4. Power up the Z16FMC MDS board using the 5 VDC adapter included in the kit.
5. Open the AN0311-SC01 project in ZDS II for ZNEO.
AN031102-0311
Page 9 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
6. From the main.c source file, choose the following mode for the Motor Control application:
#define LOOP_SELECT_VALUE 1u // 0u = torque loop, 1u = speed loop
7. Compile the application and download the code to the Z16FMC MDS module.
8. Stop the debug mode from the IDE; disconnect the Opto-Isolated USB Smart Cable
and switch off the power supply to the Z16FMC development board.
9. Connect the 24V DC supply source to the MC application board.
10. Ensure that the RUN/STOP switch on the Z16FMC development board is in the STOP
position.
11. First apply power to the Z16FMC development board supply, then apply power via the
24V supply to the MC application board.
12. Set the RUN/STOP switch on the Z16FMC development board to RUN.
13. Additionally, observe the following points:
– If SPEED mode is selected, the speed of the motor can be varied by adjusting the
potentiometer on the Z16FMC development board.
– If TORQUE mode is selected, the motor speed is decreased with application of
force on the shaft of the motor.
– The direction of rotation of the motor is set by changing the position of the
direction switch on the Z16FMC development board.
You can now add your application software to the main program to experiment with additional functions.
Note: While debugging your code, ensure that the Opto-Isolated USB Smart Cable controls the
reset pin of the MCU. After debugging and running your code, detach the Opto-Isolated
USB Smart Cable from P3 of the Z16F28200KITG to free the Reset pin and apply a power
cycle to reset the MCU from debug mode.
Result
This Motor Control application was tested with the Z16FMC MDS board connected to
Zilog’s 3-phase motor control application board.
The BLDC motor specifications are:
•
Manufacturer: Linix
•
Motor type: 3-wire, 3-phase brushless DC motor
•
Voltage rating: 24 V
•
Power rating: 30 W
•
Maximum speed of rotation: 3200 RPM
AN031102-0311
Page 10 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Observations that we noted about speed and torque are indicated in Table 1.
Table 1. Speed and Torque Observations
Function
Description
Observation
• RUN/STOP switch in STOP position
• Motor is in idle mode.
• Yellow LED blinks.
• RUN/STOP switch in RUN position.
• Motor starts rotating.
• Direction switch set to a clockwise rotation. • When the motor is loaded mechanically by
• Potentiometer R10 at minimum value.
holding the shaft, speed initially decreases
then picks up gradually; current increases.
• Green LED blinks.
Speed
• RUN/STOP switch in RUN position.
• Motor starts rotating with no load.
• Direction switch set to a clockwise rotation. • Green LED blinks.
• Potentiometer R10 at maximum value.
• RUN/STOP switch in RUN position.
• Direction switch set to a counterclockwise
rotation.
• Potentiometer R10 at minimum value.
• Motor starts rotating at a speed of 1280
RPM.
• When the motor is loaded mechanically by
holding the shaft, speed initially decreases
then picks up gradually; current increases.
• Green LED blinks.
• RUN/STOP switch in RUN position.
• Direction switch set to a counterclockwise
rotation.
• Potentiometer R10 at maximum value.
• Motor begins rotating at a speed of 3890
RPM with no load.
• Green LED blinks.
• RUN/STOP switch in RUN position.
• Motor begins rotating at a speed of 1250
• Direction switch set to a clockwise direction. RPM at no load.
• Motor stops rotating upon holding the shaft
Constant current consumption of 60mA.
• Green LED blinks.
Torque
• RUN/STOP switch in RUN position.
• Direction switch set to a counterclockwise
direction.
• Motor starts rotating at a speed of 1250
RPM at no load.
• Motor stops rotating upon holding the shaft.
• Constant current consumption of 60mA.
• Green LED blinks.
• RUN/STOP switch in STOP position.
• Motor is in idle mode.
• Yellow LED blinks.
Summary
This Application Note described the closed-loop control of a sensorless BLDC motor
using the advanced on-chip integrated features of the Z16FMC MCU. The Z16FMC product line is ideally suited for such applications, providing for a seamless start-up of the
motor from an idle mode to full operational speed, on-the-fly reversal of the direction of
rotation, an extremely fast fault detection cycle and a lower total solution cost. These features, along with the powerful ZNEO CPU core and some of the best development tools
AN031102-0311
Page 11 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
available in the industry, result in less complex board designs and reduced design cycle
time.
References
The following documents are associated with the Z16FMC Series of Motor Control
MCUs; each is available for download on www.zilog.com.
•
Z16FMC Series Motor Control MCU Product Specification (PS0287)
•
Z16FMC Series Motor Control Development Kit User Manual (UM0234)
•
Z16FMC Series Motor Control Development Kit Quick Start Guide (QS0079)
•
Zilog Developer Studio II – ZNEO User Manual (UM0171)
•
ZNEO CPU Core User Manual (UM0188)
•
Sensorless Brushless DC Motor Control with Z8 Encore! MC Microcontrollers Application Note (AN0226)
AN031102-0311
Page 12 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Appendix A. Schematics
Figures 7 and 8 show basic block and MCU schematics, respectively, for the Z16FMC Motor Control MDS Module.
5
4
3
2
1
D
D
PC0
MCU
POWER&COMMUNICATIONS
MDS INTERFACE
PA[7:0]
PA[7:0]
PA[7:0]
PA[7:0]
PC[7:0]
A1
PF7
PC0
C
-RESET
PG3
-RESET
PC[7:0]
PF7
PG3
PC[7:0]
PF7
PG3
C
-RESET
ANA[11:0]
POWER&COMMUNICATIONS
PWML1
PWMH1
FAB
PWML2
PWMH2
DE1
TXD1
RXD1
nCTS1
VREF
ANA[11:0]
PWML1
PWMH1
PWML2
PWMH2
DE1
TXD1
RXD1
nCTS1
VREF
ANA[11:0]
PWML1
PWMH1
PWML2
PWMH2
-RESET
-RESET
DE1
TXD1
RXD1
nCTS1
VREF
B
B
INTERFACE
MCU
TOP
=LORJ&RQILGHQWLDO$OO5LJKWV5HVHUYHG
=LORJ
A
A
6800 Santa Teresa Blvd
San Jose, CA 95119
408-513-1500
Website: www.zilog.com
Title
Z16FMC MDS BOARD
Page
UNCONTROLLED WHEN PRINTED UNLESS STAMPED 'CONTROLLED COPY' IN RED BY DOCUMENT CONTROL
5
4
3
2
Size
B
Date:
TOP
Document Number
Rev
A
96C1299-001G
Monday, November 08, 2010
Sheet
2
of
5
1
Figure 7. Z16FMC Motor Control MDS Module, #1 of 2
AN031102-0311
Page 13 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
5
4
3
2
1
PB0_ANA0_T0IN0
ANA0
PB1_ANA1_T0IN1
ANA1
PB2_ANA2_T0IN2
ANA2
PB3_ANA3_OPOUT ANA3
PB4_ANA4
ANA4
PB5_ANA5
ANA5
PB6_ANA6_OPINP
ANA6
PB7_ANA7_OPINN
ANA7
PH0_ANA8
ANA8
PH1_ANA9
ANA9
PH2_ANA10
ANA10
PH3_ANA11_CPINP ANA11
VCC_3v3
PA4_RXD0
PA5_TXD0
PA6_SCL
PA1_T0OUT
PA2_DE0
PA3_nCTS0
PF7
PC5_MISO
PD3_DE1
PD4_RXD1
PD5_TXD1
PC4_MOSI
PF7
D
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
-RESET
PE4
PE3
GND
PE2
PE1
PE0
PD1_PWML1
PD0_PWMH1
C
Y1
1
3
C2
22pF
20 MHz
22pF
PA7/SDA
PD6/CTS1
PC3/SCK
PD7/PWM2L
VSS4
PE5
PE6
PE7
VDD3
PG3
VDD2
PC7/T2OUT/PWM0L
PC6/T2IN/T2OUT/PWM0H
DBG
PC1/T1OUT/COMPOUT
PC0/T1IN/T1OUT/CINN
LQFP
ANA[11:0]
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
PA0_T0IN
PA1_T0OUT
PA2_DE0
PA3_nCTS0
PA4_RXD0
PA5_TXD0
PA6_SCL
PA7_SDA
PA7_SDA
PD6_nCTS1
PC3_SCK
PD7_PWML2
GND
PE5
PE6
PE7
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA7
PA[7:0]
VCC_3v3
PG3
PG3
PC[7:0]
PC7_T2OUT_PWML0
PC6_T2IN_PWMH0
DBG
PC1_TOUT
PC0_T1IN
PC0_T1IN
PC1_TOUT
PC2_nSS
PC3_SCK
PC4_MOSI
PC5_MISO
PC6_T2IN_PWMH0
PC7_T2OUT_PWML0
10K R1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
C1
PA1/T0OUT
PA2/DE0/FAULTY
PA3/CTS0/FAULT0
VSS6
VDD5
PF7
PC5/MISO
PD3/DE1
PD4/RXD1
PD5/TXD1
PC4/MOSI
VDD4
VSS5
PA4/RXD0
PA5/TXD0
PA6/SCL
PA0/T0IN/T0OUT
PD2/PWM2H
PC2/SS
RESET
VDD1
PE4
PE3
VSS3
PE2
PE1
PE0
VSS1
PD1/PWM1L
PD0/PWM1H
XOUT
XIN
Z16F2810
VSS2
AVDD
PH0/ANA8
PH1/ANA9
PB0/ANA0/T0IN0
PB1/ANA1/T0IN1
PB4/ANA4
PB5/ANA5
PB6/ANA6/OPINP/CINN
PB7/ANA7/OPINN
PB3/ANA3/OPOUT
PB2/ANA2/T0IN2
PH2/ANA10
PH3/ANA11/CPINP
VREF
AVSS
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
PA0_T0IN
PD2_PWMH2
PC2_nSS
-RESET
D
U1
2
PB6_ANA6_OPINP
VREF
PE0
PE1
PE2
PE3
PE4
PE5
PE6
PE7
1C3
PH0_ANA8
PH1_ANA9
PB0_ANA0_T0IN0
PB1_ANA1_T0IN1
PB4_ANA4
PB5_ANA5
PB6_ANA6_OPINP
PB7_ANA7_OPINN
PB3_ANA3_OPOUT
PB2_ANA2_T0IN2
PH2_ANA10
PH3_ANA11_CPINP
VREF
AGND
VREF
2
12.4K
PH3_ANA11_CPINP
1R2
0.1uF
VCC_3v3
PB3_ANA3_OPOUT
R4
49.9K
2
1
1
3
5
7
9
11
13
15
2
4
6
8
10
12
14
16
HDR/PIN 2x8
C4
2
7.8K
C
J1
1
2
100pF
PC0
PC1
PC2
PC3
PC4
PC5
PC6
PC7
1R3
10K
2
R5
1
B
B
VCC_3v3
C5
P1
1
3
5
1
3
5
10K
2
R8
DBG
INTERFACE
2
4
6
PD0_PWMH1
PD1_PWML1
PD2_PWMH2
PD3_DE1
PD4_RXD1
PD5_TXD1
PD6_nCTS1
PD7_PWML2
PB7_ANA7_OPINN
+
0.01uF
1
C8
3
R6
1
C7
0.01uF
10K
2
C6
2
4
6
1
VCC_3v3
2
10uF
C9
C10
C11
C12
C13
C14
C15
0.01uF
0.01uF
0.01uF
0.01uF
0.01uF
0.01uF
0.01uF 0.01uF
GND
C20
C17
C18
C19
0.01uF
0.01uF
0.01uF
PWMH1
PWML1
PWMH2
DE1
RXD1
TXD1
nCTS1
PWML2
R7
1K
2 2
5K
-RESET
DBG
C16
PWMH1
PWML1
PWMH2
DE1
RXD1
TXD1
nCTS1
PWML2
1
R18
1
12pF
MCU
1000pF
HDR/PIN 2x3
=LORJ&RQILGHQWLDO$OO5LJKWV5HVHUYHG
=LORJ
A
A
6800 Santa Teresa Blvd
San Jose, CA 95119
408-513-1500
Website: www.zilog.com
Title
Z16FMC MDS BOARD
Page
UNCONTROLLED WHEN PRINTED UNLESS STAMPED 'CONTROLLED COPY' IN RED BY DOCUMENT CONTROL
5
4
3
2
Size
B
Date:
MCU
Document Number
Rev
A
96C1299-001G
Monday, November 08, 2010
Sheet
3
of
5
1
Figure 8. Z16FMC Motor Control MDS Module, #2 of 2
AN031102-0311
Page 14 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Figure 9 shows the schematics for the MDS board’s power and serial interfaces.
5
4
3
2
1
P2
2
3
1
VCC_5V
C21
2
C1+
0.1uF
2
0.1uF
U2
C23
4
VO
5
C2+
C27
2
6
VCC_3v3
2
R9
100 OHm
0.1uF
13
PA5_TXD0
GND
2 2
+ C28
10uF
C29
C2-
0.1uF
1
1
1
VI
GND
3
12
PA3_nCTS0
15
PA4_RXD0
10
D1
1
GREEN
0.1uF
V+
3
C1-
VCC_3v3
U3
SPX2815AU-3.3
D
VCC
+ C24
10uF
19
VCC_5V
V-
T1IN
T1OUT
T2IN
T2OUT
R1OUT
R1IN
R2OUT
R2IN
C25
C26
0.1uF
0.1uF
CONSOLE
P3
7
17
TXD0
CTS0
RXD0
8
16
D
1
6
2
7
3
8
4
9
5
USER
9
DB9 Female
3.3 OK
VCC_3v3
1
EN
20
GND
1
5V
C22
CON DC
VCC_3v3
18
SHDN
NC1
NC
14
11
SP3222EBCA
C
C
-RESET
VCC_3v3
R10
D2
1
PA0_T0IN
R11
2 1
2
1
S1
2
1
100
R12
D3
PA1_T0OUT
1
2
PA[7:0]
SW PB NO
RED
10K
2 1
PA0_T0IN
PA1_T0OUT
PA2_DE0
PA3_nCTS0
PA4_RXD0
PA5_TXD0
PA6_SCL
PA7_SDA
-RESET
2
YELL
100
R13
2 1
2
1
GREEN
100
DIRECTION
1
D4
1
PA2_DE0
R14
R15
10K
R16
1
1
2
10K
B
2
S2
2
B
PA7_SDA
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA7
2
3
100
POWER & RS232
EG1218
S3
R17
PC0
PC0_T1IN
1
1
2
2
VCC_3v3
3
100
GND
EG1218
1
2
3
1
2
3
STOP/RUN
GND
A
=LORJ&RQILGHQWLDO$OO5LJKWV5HVHUYHG
VCC 3.3V
TP1
=LORJ
TP2
Page
UNCONTROLLED WHEN PRINTED UNLESS STAMPED 'CONTROLLED COPY' IN RED BY DOCUMENT CONTROL
5
4
A
6800 Santa Teresa Blvd
San Jose, CA 95119
408-513-1500
Website: www.zilog.com
Title
Z16FMC MDS BOARD
3
2
Size
B
Date:
Power and RS232
Document Number
Rev
A
96C1299-001G
Monday, November 08, 2010
Sheet
4
of
5
1
Figure 9. Z16FMC MDS Board Power and RS-232 Connections
AN031102-0311
Page 15 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Figure 10 displays MDS interface schematics.
5
4
3
2
1
JP1
GND
GND
D
JP2
ANA0
ANA2
ANA7
ANA4
VCC_3v3
PC4_MOSI
PWMH2
PC3_SCK
PWMH1
GND
PWML1
PC1_TOUT
PD3
PD5_TXD1
PA0
PA1
PA3_nCTS0
PA4_RXD0
PA[7:0]
PA0
PA1
PA2
PA3
PA4
PA5
PA6
PA7
C
PA0_T0IN
PA1_T0OUT
PA2_DE0
PA3_nCTS0
PA4_RXD0
PA5_TXD0
PA6_SCL
PA7_SDA
PWMH2
PWMH1
PWML1
DE1
TXD1
PC[7:0]
PC0
PC1
PC2
PC3
PC4
PC5
PC6
PC7
PC0_T1IN
PC1_TOUT
PC2_nSS
PC3_SCK
PC4_MOSI
PC5_MISO
PC6_T2IN_PWMH0
PC7_T2OUT_PWML0
GND
PA6_SCL
PA7_SDA
NC
NC
NC
-RESET
VCC_3v3
-RESET
VCC_3v3
NC
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
ANA1
ANA6
ANA3
ANA5
GND
PC5_MISO
PWML2
PC2_nSS
PC6_T2IN_PWMH0
PC7_T2OUT_PWML0
PA2
PD6_nCTS1
PD4_RXD1
PC0_T1IN
GND
PF7
PG3
PA5_TXD0
GND
PWML2
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
VCC_3v3
VCC_33V
D
GND
VCC_33V
GND
HDR/PIN 2x30
C
nCTS1
RXD1
PF7
PG3
NC
NC
NC
NC
GND
PH3_ANA11
GND
NC
NC
HDR/PIN 2x30
B
B
JP3
ANA11
ANA10
ANA2
ANA3
ANA7
ANA6
ANA5
ANA4
ANA1
ANA0
ANA8
ANA9
ANA[11:0]
ANA9
ANA8
ANA0
ANA1
ANA4
ANA5
ANA6
ANA7
ANA3
ANA2
ANA10
ANA11
VREF
C30
C31
C32
C33
C34
C35
C36
C37
C38
C39
C40
C41
0.01uF
0.01uF
0.01uF
0.01uF
0.01uF
0.01uF
0.01uF
0.01uF
0.01uF
0.01uF
0.01uF
0.01uF
PH1_ANA9
PH0_ANA8
PB0_ANA0
PB1_ANA1
PB4_ANA4
PB5_ANA5
PB6_ANA6
PB7_ANA7
PB3_ANA3
PB2_ANA2
PH2_ANA10
PH3_ANA11
VREF
25
23
21
19
17
15
13
11
9
7
5
3
1
25
23
21
19
17
15
13
11
9
7
5
3
1
26
24
22
20
18
16
14
12
10
8
6
4
2
26
24
22
20
18
16
14
12
10
8
6
4
2
HDR/PIN 2x13
A
MDS INTERFACE
=LORJ&RQILGHQWLDO$OO5LJKWV5HVHUYHG
=LORJ
Page
UNCONTROLLED WHEN PRINTED UNLESS STAMPED 'CONTROLLED COPY' IN RED BY DOCUMENT CONTROL
5
4
A
6800 Santa Teresa Blvd
San Jose, CA 95119
408-513-1500
Website: www.zilog.com
Title
Z16FMC MDS BOARD
3
2
Size
B
Date:
MDS INTERFACE
Document Number
Rev
A
96C1299-001G
Monday, November 08, 2010
Sheet
5
of
5
1
Figure 10. MDS Board Interfaces
AN031102-0311
Page 16 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Figures 11 through 13 display the schematics for the 3-Phase Motor Control Application Board.
Figure 11. 3-Phase Motor Control Application Board, #1 of 3
AN031102-0311
Page 17 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Figure 12. 3-Phase Motor Control Application Board, #2 of 3
AN031102-0311
Page 18 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Figure 13. 3-Phase Motor Control Application Board, #3 of 3
AN031102-0311
Page 19 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Appendix B. Flowcharts
This appendix displays flow charts that diagram the Main Function and the Read and
Write APIs.
Figure 14 shows the main control loop.
Start
Peripheral Initialization
Enable Interrupts
Main Loop
(Application Code)
Figure 14. Initialization and Application Code Space
The Back EMF sensing loop is shown in Figure 15.
t0_intrp (Back EMF ISR every Timer0
time out forms Phase Locked Loop
Commutation Update
(every other interrupt)
Back EMF Sensing and PLL Filter
(opposite interrupt from Com Update)
Return
Figure 15. Initialization and Application Code Space
AN031102-0311
Page 20 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
A flow chart of the PWM loop is shown in Figure 16. This PWM loop can also be used for
specific application code, such as communications or additional user interfaces.
pwm_timer_isr
(Main Loop ISR every
PWM reload, 50μs)
Current Loop, PWM duty cycle control
(500μs update)
LED Status (50μs update)
and Blink (0.4 sec update)
Torque (current command from ADC
2ms update, filtered)
Direction Switch
(7.5ms update, filtered)
Return
Figure 16. Current Loop and Timed Housekeeping
AN031102-0311
Page 21 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Appendix C. Back EMF Sensing Phase Locked Loop
The Phase Locked Loop Back EMF algorithm, implemented to provide a smooth start-up
of the motor, is shown in Figures 17 and 18. Additional details about the specific formulas
in these figures are shown in Table 2; a description of these calculations follows.
Back EMF Neutral
Back EMF Divider
ADC
PI Filter
(volts/radian)
(unitless)
(counts/volt)
(unitless)
R1
ADCcounts
1 + ѕτ2
ѕτ2
Θrotor +
Θerror
kc tɐspeed
(radians)
(radians)
π
VΘ
R1 + R2
(volts)
Vcounts
(volts)
(counts)
(counts)
ƒclock
Speed_constant
÷
TimerPrescale
Speed_count
Integrator
Frequency to
Angular Frequency
Conversion
Revolutions
per cycle
Electrical cycles
per Commutation
cycles
Commutation
cycles per
Timer cycles
(sec)
(radians/cycle/sec)
(rev/cycle)
(unitless)
(radians/Hertz)
1
ѕ
ɐmec
h
2π
(rev/sec)
ƒmec
2
ƒelect
1
ƒcom
1
ƒtimer
h
N
(cycles/sec)
6
(cycles/sec)
2
(cycles/sec)
(rev/sec)
Figure 17. Back EMF Sensing Using the Phase Locked Loop Algorithm
Phase Detector
Filter
Θ1(ѕ)
+
Θe(ѕ)
Kd
–
Ud(s) = KdΘe(ѕ)
F(ѕ)
Uƒ(s) = Ud(ѕ)F(ѕ)
Θ2(ѕ)
VCO
Ko
ѕ
Figure 18. Proportional Integral (PI) Filter Representation for Back EMF Sensing
AN031102-0311
Page 22 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Table 2. Back EMF Sensing Phase Locked Loop
We begin with the transfer function of the Proportional Integral (PI) Filter in the s-plane:
AN031102-0311
Page 23 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Next, by using the bilinear transform identity:
where T = the sampling period, yields the following equation.
When multiplying by:
the calculations that follow are:
where:
and:
Collecting terms and dividing by z yields the following result:
AN031102-0311
Page 24 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
When writing this computation as a computer program, it takes the form of a recursive filter, with the coefficients A0 and A1:
where:
•
Y0 = Current output
•
Y1 = Output at the last sample period
•
R0 = Current ADC sample of Back EMF (phase voltage – VBUS / 2)
•
R1 = Most recent sample of Back EMF from ADC
•
A0 = a0
•
A1 = –a1
AN031102-0311
Page 25 of 26
Sensorless Brushless DC Motor Control with the Z16FMC MCU
Application Note
Customer Support
To share comments, get your technical questions answered, or report issues you may be
experiencing with our products, please visit Zilog’s Technical Support page at 
http://support.zilog.com.
To learn more about this product, find additional documentation, or to discover other facets about Zilog product offerings, please visit the Zilog Knowledge Base at http://
zilog.com/kb or consider participating in the Zilog Forum at http://zilog.com/forum.
This publication is subject to replacement by a later edition. To determine whether a later
edition exists, please visit the Zilog website at http://www.zilog.com.
Warning: DO NOT USE THIS PRODUCT IN LIFE SUPPORT SYSTEMS.
LIFE SUPPORT POLICY
ZILOG’S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE
SUPPORT DEVICES OR SYSTEMS WITHOUT THE EXPRESS PRIOR WRITTEN APPROVAL OF
THE PRESIDENT AND GENERAL COUNSEL OF ZILOG CORPORATION.
As used herein
Life support devices or systems are devices which (a) are intended for surgical implant into the body, or (b)
support or sustain life and whose failure to perform when properly used in accordance with instructions for
use provided in the labeling can be reasonably expected to result in a significant injury to the user. A
critical component is any component in a life support device or system whose failure to perform can be
reasonably expected to cause the failure of the life support device or system or to affect its safety or
effectiveness.
Document Disclaimer
©2011 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. The information contained within this document has been verified according
to the general principles of electrical and mechanical engineering.
Z8, Z8 Encore!, Z8 Encore! XP and ZMOTION are trademarks or registered trademarks of Zilog, Inc. All
other product or service names are the property of their respective owners.
AN031102-0311
Page 26 of 26