NXP S08QE Reference guide

Type
Reference guide

This manual is also suitable for

DRM088 Designer Reference Manual
Devices Supported:
M9S08QD4
Document Number: DRM088
Rev. 0
07/2008
DRM088, Rev. 0
Freescale Semiconductor 3
Pulse Width Modulation Controlled Fans Using the
M9S08QD4
Designer Reference Manual
by: Eddie Ng
Freescale Semiconductor, Inc.
Hong Kong
To provide the most up-to-date information, the revision of our documents on the World Wide Web will be
the most current. Your printed copy may be an earlier revision. To verify you have the latest information
available, refer to:
http://www.freescale.com
The following revision history table summarizes changes contained in this document. For your
convenience, the page number designators have been linked to the appropriate location.
Revision History
Date
Revision
Level
Description
Page
Number(s)
Feb, 22 2008 0.B Written by Eddie Ng, Edited by Ping Xu N/A
Revision History
DRM088, Rev. 0
4 Freescale Semiconductor
DRM088, Rev. 0
Freescale Semiconductor 5
Contents
Chapter 1
Introduction
1.1 Introduction ................................................................................................................................... 11
1.2 Freescale’s Low Cost MCU Advantages and Features ................................................................. 11
1.3 BLDC Fan Reference Design Targets ...........................................................................................13
1.4 Bi-Phase BLDC Motor ................................................................................................................... 13
Chapter 2
Motor Control
2.1 Commutation ................................................................................................................................. 15
2.2 Rotor Position Control ................................................................................................................... 15
2.3 Commutation Waveforms .............................................................................................................. 16
2.4 Speed Control Mechanism ............................................................................................................ 16
2.5 Motor Startup ................................................................................................................................ 18
2.6 Fault Detection and Protection ...................................................................................................... 18
2.7 Use of Table Look-Up (TLU) and Closed Loop Speed Control Mechanism .................................. 19
2.8 Input Source Options .................................................................................................................... 19
Chapter 3
Implementation
3.1 Block Diagram ............................................................................................................................... 21
3.2 Hardware Resources .................................................................................................................... 22
3.3 Control Loop .................................................................................................................................. 22
3.4 Fan Speed Response to PWM Control Input Signal ..................................................................... 23
Appendix A
Schematic
Appendix B
Program Listing
DRM088, Rev. 0
6 Freescale Semiconductor
DRM088, Rev. 0
Freescale Semiconductor 7
Tables
Design Targets 13
Measurement of PWM Control Input Signal and Fan Speed (RPM) 26
DRM088, Rev. 0
8 Freescale Semiconductor
DRM088, Rev. 0
Freescale Semiconductor 9
Figures
Bi-Phase BLDC Fan Motor Diagram 13
Bi-Phase BLDC Fan Motor 15
Bi-Phase BLDC Motor Commutation Waveform 16
Commutation Waveform using Phase On/Off Delay Time Control Method 17
Commutation Waveform using PWM Control Method 18
MC9S08QD4 DC Fan Design Block Diagram 21
On Board DAC Block Diagram 22
Firmware Control Loop Flowchart 23
PWM Control Input Signal vs. Fan Speed 24
Measured PWM Control Input Signal vs. Fan Speed 25
DRM088, Rev. 0
10 Freescale Semiconductor
Introduction
DRM088, Rev. 0
Freescale Semiconductor 11
Chapter 1
Introduction
1.1 Introduction
This document describes the implementation of a Brushless DC (BLDC) fan controller using the Freescale
MC9S08QD4 8-bit Microcontroller (MCU). The design reads the standard 4 wire PWM controlled input
signal, which in turn controls the fan speed in a closed-loop feedback system. Complete coding and
schematic are included.
Brushless DC fans are widely used in CPU and graphic display card cooling and system ventilation
applications. The lack of a commutator makes the brushless DC fan more reliable than the conventional
DC fan. Microcontroller (MCU) based, intelligent, variable-speed brushless DC fans are needed to avoid
overheating and fulfill the rapidly changing electronics products requirement. Characteristics of flash
MCU based BLDC such as the MC9S08QD4 include variable speed control, low acoustic noise,
reliability, long lifetime, low power consumption, protection features, easy to maintain/upgrade and
communication interface capability.
There are several advantages of a MCU based closed-loop feedback design over traditional solutions:
A targeted air flow can be achieved by constantly renewed fan speed adjustment based on
environment changes of the target system, such as temperature.
Fan characteristics and behavior can be updated and changed easily for different end users by
modifying the Table Look-Up (TLU) in the flash memory of the MCU.
Fault detection can be easily implemented by the MCU. For example, if the MCU detects a motor
jam or the air flow being blocked, the motor driver can be stopped completely to avoid further
damage. The automatic restart feature is also available.
Digital feedback and output acknowledgment can be generated under a faulty situation.
Sophisticated speed control algorithms can be easily implemented and modified in the flash based
MCU, if needed.
The MCU chosen for this purpose must be low cost and physically small in order to integrate it into the
fan controller Printed Circuit Board (PCB). The MC9S08QD4 is ideal for this application.
1.2 Freescale’s Low Cost MCU Advantages and Features
The Freescale MC9S08QD4 MCU is a low cost, small pin count device well suited for home appliances
and small geometry applications, such as the brushless control DC (BLDC) fan application. This device is
composed of standard on-chip modules, including a small and highly efficient HCS08 8-bit CPU core, 256
bytes RAM, 4 Kilobytes flash, two 16-bit modulo timers, four channels 10-bit ADC and keyboard
interrupt. The device is available in small 8-pin PDIP and SOIC packages.
Introduction
DRM088, Rev. 0
12 Freescale Semiconductor
Features of the MC9S08QD4 include:
8-bit 16 MHz HCS08 CPU (Central Processor Unit)
HC08 instruction set with added BGND instruction
Background debugging system
Breakpoint capability to allow single breakpoint setting during in-circuit debugging
Support for up to 32 interrupt/reset sources
Memory
4096 bytes flash
256 bytes RAM
Internal Clock Source module (ICS)
Containing a frequency-locked-loop (FLL) controlled by internal or external reference
Precision trimming of internal reference allows 0.2% resolution and 2% deviation over
temperature and voltage
System protection
Watchdog Computer Operating Properly (COP) reset with option to run from dedicated 32 kHz
internal clock source or bus clock
Low-voltage detection with reset or interrupt
Illegal opcode detection with reset
Illegal address detection with reset
Flash block protect
ADC
4-channel, 10-bit analog-to-digital converter with automatic compare function, asynchronous
clock source and internal bandgap reference channel
On-chip temperature sensor for ADC temperature compensation, by calibration at 3 points,
-40°C, 25°C and 105°C; the temperature accuracy is up to ±2.5°C
ADC is hardware triggerable using the RTI counter
•TIM1
2-channel timer/pulse-width modulator
Each channel can be used for input capture, output compare, buffered edge-aligned PWM, or
buffered center-aligned PWM
•TIM2
1-channel timer/pulse-width modulator
Each channel can be used for input capture, output compare, buffered edge-aligned PWM, or
buffered center-aligned PWM
•KBI
4-pin keyboard interrupt module with software selectable polarity on edge or edge/level modes
Package Options
—8-pin PDIP
8-pin narrow body small outline integrated circuit (SOIC) package
All package options are RoHS compliant
Introduction
DRM088, Rev. 0
Freescale Semiconductor 13
1.3 BLDC Fan Reference Design Targets
1.4 Bi-Phase BLDC Motor
In the conventional DC fan motor, the stator of the permanent magnet is composed of two or more
permanent magnet pole pieces, and the rotor is composed of windings that are connected to a mechanical
brush (commutator). The opposite polarities of the energized winding and the stator magnet attract the
rotor, and the rotor will rotate until it is aligned with the stator. Just as the rotor reaches alignment, the
brushes move across the commutator contacts and energize the next winding. As a result, the fan rotor is
rotated continuously.
The brushless DC (BLDC) fan motor, however, is a rotating electric machine in which the stator is a classic
two-phase stator and the rotor has surface-mounted permanent magnets. In this respect, the BLDC fan is
equivalent to a reverse-conventional DC fan; the current polarity is altered by the electrical commutator
instead of mechanical brushes. The BLDC has no brushes on the rotor and the commutation is performed
electronically at certain rotor positions. An example of a BLDC fan motor is illustrated in Figure 1-1.
Figure 1-1. Bi-Phase BLDC Fan Motor Diagram
Table 1-1. Design Targets
Item Requirement
Motor Type Bi-Phase BLDC Motor
Fan Dimensions (HxLxW) 80mm x 80mm x 25mm
Operating Voltage 12V
Current Rating 0.17V (max.)
Speed 400 to 2400 RPM
Closed Loop Feedback Yes
Fault Detection Lock Detection
Other Features Automatic Restart
Introduction
DRM088, Rev. 0
14 Freescale Semiconductor
Motor Control
DRM088, Rev. 0
Freescale Semiconductor 15
Chapter 2
Motor Control
2.1 Commutation
The typical bi-phase BLDC has one pole-pair per phase. Each commutation rotates the rotor by 90 degrees
and four commutation steps complete a mechanical revolution. Each pole-pair is implemented by two
coils, with four coils in total for a bi-phase motor. Energizing a pair of coils, either coil A & C or coil B &
D (shown in Figure 2-1) induces magnetic fields that push the equal polarity rotor magnets away from the
energized coils. At the same time the opposite polarity rotor magnets are pulled toward the coils. When
rotation starts, it is called a commutation step. When the rotor magnetic pole is aligned with the energized
coils, the coils are deactivated and the previously un-energized pair of coils are then energized. As the
magnetic field switches to the next motor position or pole, the inertia of the rotor keeps the motor running.
As a result, two commutation steps move the rotor by 180 degrees or one motor phase. One mechanical
revolution is contributed by four commutation steps.
Figure 2-1. Bi-Phase BLDC Fan Motor
2.2 Rotor Position Control
The key idea to prevent a motor lockup involves rotor position detection. The time to switch the
commutation is critical. Energizing coil-pair too long will kill the rotor inertia and the motor stops running.
This is called motor lockup. Switching the commutation too soon will lose control to the rotor and
eventually stall the motor. The rotor position in this design is determined by a hall sensor which will
respond to the change in magnetic field. Hall sensor output toggles when the magnetic field changes its
polarity. Positioned between the coils at 45 degrees to the stator coils, as shown in Figure 2-1, the hall
sensor can effectively detect the rotor position. In this case, the hall sensor outputs toggle when the rotor
magnets are aligned to the coils. Commutation will switch at this time from one coil-pair to the next.
Motor Control
DRM088, Rev. 0
16 Freescale Semiconductor
2.3 Commutation Waveforms
In general, in a bi-phase motor design, alternate coils are tied together and give a single connection to the
driver. In this design, the driver connection for coil A and coil C is called L1 (see Figure 2-1). Similarly,
the driver connection for coil B and coil D is called L2. Driving to either of the connections will energize
a coil-pair. The commutation waveform is shown in Figure 2-2. The coil driving period is aligned with the
hall sensor output. When the sensor outputs toggle, coil driving is stopped, and the coils are de-energized
for a period of time before the next coil-pair is energized.
Figure 2-2. Bi-Phase BLDC Motor Commutation Waveform
2.4 Speed Control Mechanism
Motor speed is normally defined as the mechanical Round Per Minute (rpm). In electrical terms, one
commutation contributes to 90 degrees of a revolution. Four commutation cycles complete one revolution
of the motor. Thus, control of the time taken per commutation can effectively control the overall speed of
the motor.
There are two methods to control the speed of the motor: one is called phase on/off delay time control
method, and the other is called PWM control method.
The phase on/off delay time control method is used to adjust the off time at phase switching. The rotation
speed can be adjusted by the length of the off time. The off time is inversely proportional to the energy
provided to the motor. That is, the longer the off time, the less energy is supplied to the stator coils, which
results in a lower speed of the motor. There is one condition that must be satisfied: it needs to be
synchronized to the feedback signal from the hall sensor (i.e. the commutation). The commutation
waveform is shown in Figure 2-3 to illustrate on the phase on/off delay time control method.
90
o
of rotation
Motor Control
DRM088, Rev. 0
Freescale Semiconductor 17
Figure 2-3. Commutation Waveform using Phase On/Off Delay Time Control Method
Although the implementation of this speed control method is relatively simple, there are some
disadvantages in this method, such as the lower accuracy and higher acoustic noise level. Therefore, it may
not fit for the high-end motor system requirement. The accuracy of this type of the speed control method
is around ±10%, which depends on the maximum speed of BLDC, the maximum bus speed of the MCU,
and the number of bit in the timer. For example, if we drive the higher speed of the BLDC fan with the
lower speed of the MCU with a lower resolution timer, lower accuracy of the speed will occur. The PWM
control method is a better alternative for providing higher accuracy and a lower acoustic noise motor
system.
For the PWM control method, the speed is controlled by changing the duty cycle of the PWM. This drives
the two winding coils in the BLDC fan independently instead of changing the off-time period. The two
winding coils are turned on alternately, but the voltage of the coil is controlled by the duty cycle of the
PWM drive signal. The PWM frequency is a major design consideration. The PWM frequency can be
between 18 kHz to 60 kHz typically.
The PWM frequency range is chosen based on acoustic noise and efficiency. The acoustic noise will occur
if the PWM frequency is falling into the audible range of the human ear. In this method, the PWM
frequency should be set above 18 kHz, which is higher than the audible range of the human ear. This means
that the fan can be operated in a quieter manner. Plus, the use of a higher PWM frequency will also be more
efficient. Because the high speed PWM (18 kHz – 60 kHz) is much higher than the commutation period,
the current ripple is smaller. This is because the averaged DC voltage that is applied in the winding coil is
more stable when compared to the phase on/off time delay method. Figure 2-4 illustrates on the PWM
control method. In this reference design, PWM control method is demonstrated to control the BLDC Fan
speed.
Motor Control
DRM088, Rev. 0
18 Freescale Semiconductor
Figure 2-4. Commutation Waveform using PWM Control Method
2.5 Motor Startup
In this DC fan application, it is desirable to only allow the motor to operate uni-directionally, allowing the
airflow to the target system to always be in one direction. With the bi-phase motor design, it is difficult to
guarantee the direction of rotation. Commutation order or the coil energizing sequence is the same for both
directions of rotation. The rotor position or axis must initially be known in order to guarantee the direction
of rotation.
When the first commutation step is activated where the adjacent coil-pair to the initial axis is energized,
the rotor starts to move. Since the adjacent coil-pairs are connected together and energized at the same
time, there are equal pulling/pushing forces induced on the rotor in both directions. There is a chance for
the rotor to startup in either direction. It is necessary to monitor the initial direction of rotation. If the
direction is not correct, the motor must be locked back to the startup axis again, and the commutation step
must be repeated.
The direction of rotation can be detected by the hall sensor output. If the initial rotor axis is known, the
output edge polarity, rising edge or falling edge, determines the direction of rotation. In the modern
bi-phase motor design, the direction of rotation is normally defined by the manufacturer. The stator design
is not symmetric, so the motor will have a high tendency to rotate in one direction than the other. However,
the direction of rotation cannot be guaranteed without proper monitoring techniques in place.
2.6 Fault Detection and Protection
Motor fault is identified when the rotor is not moving, which is normally the case when the rotor is
jammed, which may be caused by blocked airflow. During each commutation step, the hall sensor output
is monitored. If it is not toggled within a defined duration (which is software configurable), commutation
sequence is terminated and all coils are de-energized. A “rotor locked” signal is then fed back and sent to
the external control system via the PWM 4-wire “Sense” pin.
Given a defined duration (which is also software configurable), the fan system goes through an automatic
restart sequence to re-initialize the whole fan system first and then to re-start the fan.
Motor Control
DRM088, Rev. 0
Freescale Semiconductor 19
2.7 Use of Table Look-Up (TLU) and Closed Loop Speed Control
Mechanism
In this reference design, Table Look-Up (TLU) is implemented so the end user can change their fan speed
profile instantly by reprogramming the TLU inside the built-in MCU flash memory. Based on the same set
of hardware, different behavior of BLDC fans can be tailor made via different TLU stored in the flash
memory in order to meet various end customer requirements.
To implement the TLU, the MCU first reads the DC input voltage via a ADC pin. It then converts the DC
voltage into a digital value. By the TLU, the digital value then points to a pre-defined output fan speed
(stored in the TLU) and the MCU changes the duty cycle of the PWM according to the pre-defined output
fan speed to alter the actual BLDC fan speed.
In order to increase the precision of the BLDC fan speed, a closed loop system is used. First, the actual fan
speed is monitored by the hall signal from time to time. The reading is then fed back and compared to the
pre-defined output fan speed stored in the TLU. If the actual fan speed is faster or slower than the
pre-defined speed, the duty cycle of the PWM will be adjusted according to the result from the comparison.
2.8 Input Source Options
In this reference design, there are four types of speed input options that can be configured by:
A DC voltage source varied by input voltage via voltage divider (Jumper P4, Pin1 connected to
Pin2)
A DC voltage which is varied through thermal sensor depending on temperature (Jumper P4, Pin2
connected to Pin3)
A DC voltage generated through VR circuitry (Jumper P6, Pin1 connected to Pin2)
A PWM signal generated from an external source either goes through a DAC circuitry to convert
the PWM signal into a DC voltage (Jumper P6, Pin2 connected to Pin3) or directly connects to the
MCU KBI pin to measure the PWM signal and then calculate the PWM input duty cycle for fan
speed.
It consumes quite a lot of MCU resources calculated in the PWM input duty cycle. However, it can save
the cost of DAC circuitry on the PCB.
In this reference design, the PWM input source is chosen as it is most commonly used in the BLDC fan
application, and the DAC circuitry is implemented for the PWM input signal.
Motor Control
DRM088, Rev. 0
20 Freescale Semiconductor
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19
  • Page 20 20
  • Page 21 21
  • Page 22 22
  • Page 23 23
  • Page 24 24
  • Page 25 25
  • Page 26 26
  • Page 27 27
  • Page 28 28
  • Page 29 29
  • Page 30 30
  • Page 31 31
  • Page 32 32
  • Page 33 33
  • Page 34 34
  • Page 35 35
  • Page 36 36
  • Page 37 37
  • Page 38 38
  • Page 39 39
  • Page 40 40
  • Page 41 41
  • Page 42 42

NXP S08QE Reference guide

Type
Reference guide
This manual is also suitable for

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI