Sei sulla pagina 1di 8

Application Note

Z8 Encore! XP® Based BLDC Fan Control


Reference Design

AN022802-0708

Abstract Developing the application with


This application note demonstrates the process of Z8 Encore! XP
controlling Brushless DC (BLDC) fans using Figure 1 displays the block diagram of the BLDC
Zilog’s 8-pin Z8 Encore! XP® MCU. The commu- fan controller. The hardware is built and tested
tation is determined by the Hall sensor feedback with commonly available components. The main
signal. The speed of the BLDC fan is controlled by component of the hardware is Z8 Encore! XP 8-pin
varying the potentiometer setting. This is ana- microcontroller. This microcontroller does not
logues to taking an input from an external tempera- require any external crystal or RC network, as it
ture sensor. Therefore, the speed of the motor can uses the internal oscillator. For the schematic dia-
be controlled based on the object temperature. gram of H- bridge BLDC fan controller, see
Appendix B—Schematic Diagram on page 7.
Note: The source code file associated with
this application note (AN0228-
SC01.zip) is available for
download at www.zilog.com.

12V DC
H-bridge BLDC
FAN
GND

Hall Sensor

PWM
Comparator
Generator

Hall Sensor
3.3 V Edge Input
Generator Z8 Encore! XP Detection
Microcontroller

Speed Control Logic Speed/Temp


Stall Detect Logic Input
ADC
Over Current Detect Logic

Figure 1. Block Diagram of BLDC Fan Controller

Copyright ©2008 by Zilog®, Inc. All rights reserved.


www.zilog.com
Z8 Encore! XP® Based BLDC Fan Control Reference Design

Features of BLDC Fan Control Timer


Reference Design The Z8 Encore! XP 4K Series products contain up
to two 16-bit reloadable timers that can be used for
The features of BLDC fan reference
timing, event counting, or generation of pulse
design are:
width modulated (PWM) signals. The timers’
features include:
• Uses Z8 Encore! XP® 8-pin chip.
• In-circuit programming to upgrade the firmware • 16-bit reload counter.
for evaluation purpose.
• Programmable prescaler with prescale values
• Adjusting the fan motor speed by setting the from 1 to 128.
potentiometer.
• PWM output generation.
• Hall effect commutation.
• Capture and compare capability.
• Motor stall detect condition.
• External input pin for timer input, clock gating,
• Over current detection. or capture signal. External input pin signal
• The speed control is achieved by its own ADC frequency is limited to a maximum of one-fourth
and PWM generation. the system clock frequency.

The following Z8 Encore! XP peripherals are used • Timer output pin.


along with the hardware: • Timer interrupt.
On-chip Oscillator
• Analog-to-Digital Converter
The Z8 Encore! XP 4K Series devices uses five
• Timer possible clocking schemes, each of which is user
• On-chip Oscillator selectable. The different clocking schemes are:
Analog-to-Digital Converter
• On-chip precision trimmed RC oscillator.
The Z8 Encore! XP has an on-chip Sigma Delta
ADC that converts an analog input signal to its dig- • On-chip oscillator using off-chip crystal or
ital representation. This ADC can be configured resonator.
either for differential mode or for single-ended • On-chip oscillator using external RC network.
mode.
• External clock drive.
The ADC has 11-bit resolution in differential mode • On-chip low precision Watchdog Timer
and 10-bit resolution in single-ended mode. The Z8 oscillator.
Encore! XP can take up to 8 single-ended analog You have to select any one of the above oscillator.
input sources that are multiplexed with General- The oscillator control register (OSCCTL) enables/
Purpose Input/Output (GPIO) ports. The ninth disables the various oscillator circuits, enables/dis-
analog input is directly obtained from the on-chip ables the failure detection/recovery circuitry and
temperature sensor peripheral. The ADCs can be selects the primary oscillator, which becomes the
configured either for a SINGLE SHOT or for a system clock. The oscillator control register must
CONTINOUS mode. be unlocked before writing. Writing the two-step
sequences E7h followed by 18h to the oscillator
control register unlocks it.

AN022802-0708 Page 2 of 8
Z8 Encore! XP® Based BLDC Fan Control Reference Design

The register gets locked on successful completion The init_adc function initializes port A pin 4 as
of a register write to the OSCCTL. an ADC channel. The input voltage is applied at
this pin. The speed of the fan is controlled based on
the input voltage applied at this pin.
Software Details
The software offered with this application note is The init_pwm function initializes port A pin 1 to
developed and tested on the hardware as per the generate the PWM output of different duty cycle.
schematic provided in Appendix B—Schematic This sets TIMER0 to work in PWM mode.
Diagram on page 7. This section discusses the
function of different software blocks used to Speed Command Input
control the BLDC fan.
A potentiometer is used to generate different volt-
ages, through a voltage divider network at the
The software provides the following
ADC input channel. The speed_in function peri-
functionalities:
odically reads the ADC data register. These ADC
data register values are scaled and loaded to the
• Initializing the Z8 Encore! XP® Peripheral PWM data register to generate PWM output of dif-
• Speed Command Input ferent duty cycles. This function is called from the
while loop of the main function so as to read the
• Measuring the Speed ADC value and to change the PWM output, which
• Hall Sensor Input Detection and Commutation in turn changes the fan speed.
• Motor Stall Detection
Measuring the Speed
• Over Current Detection
The on-chip ADC of Z8 Encore! XP is used in this
Initializing the Z8 Encore! XP® Peripheral application. An internal reference of 2 V is used as
Port A pin 0 and pin 2 are initialized as GPIO a reference voltage for analog to digital conver-
ports. These pins are used to commutate the two sion. This conversion happens on continuous basis.
different windings of the BLDC fan by driving an The main function calls speed_in routine that
FET. reads the converted data from ADC data register.
The ADC is configured for buffered, single-ended
mode.
The init_com function initializes for port A pin
0 and pin 2 . These port pins are also used for
enabling the high drive feature and as open drain Hall Sensor Input Detection and
outputs. Commutation
Commutation is achieved using two MCU pins:
The init_tach function initializes the port Port A pin2 and pin4 of the Z8 Encore! XP 8-pin
A pin 3 to input mode. The tachometer input from microcontroller. These outputs are either high or
the BLDC fan is fed to this pin and the software low depending on the commutation timings. The
detects the rising and falling edge of the Hall sensor input signal is applied to pin PA3,
tachometer input. which is configured as an input port. The software
detects the rising or falling edge (to detect the state
The init_comp function initializes port A pin 5 changes) of the Hall sensor inputs and accordingly
as input pin to be used as a comparator input. the commutation is done for the fan motor
windings.

AN022802-0708 Page 3 of 8
Z8 Encore! XP® Based BLDC Fan Control Reference Design

The software checks for the rising and falling Equipments Used
edges of the Hall sensor and decides the logical
The following equipments are used for testing:
state of the sensor input. If the Hall sensor input is
logic High, the Commutation state is set to 1 else
the Commutation state is set to 0. The function • H-bridge BLDC fan controller reference design
commutation_a or the function board Zilog PCA:99C0967
commutation_b is activated based on the Hall • Zilog Developer Studio II - Z8 Encore! XP (ZDS
sensor input state. Calling the commutation_a II - IDE)
function commutates one winding of the BLDC fan
• 12 V Vdc 3A power supply
and commutation_b commutates the other
winding of the BLDC fan. • Digital tachometer
Test Procedure
Motor Stall Detection
The H-bridge fan control reference design board is
If no Hall sensor edge is detected for a period of shown in Appendix B—Schematic Diagram on
300 ms, the firmware assumes that the motor is page 7. Supply 12 V DC power to the board and
locked and stops commutating the motor for about observe the speed of the motor by varying the
100 µs. Then after every 300 ms, the firmware tries potentiometer.
to commutate the windings until the locked rotor
comes back to normal or the power is switched off.
Test Results
Over Current Detection You can observe that by changing the position of
the potentiometer settings, the voltage at the ADC
When the motor comes to a stall condition, the input pin changes and accordingly the speed of the
BLDC fan motor draws a very high current. The fan is varied. The graph of fan speed verses the
resultant voltage in the circuit is fed to ISENCE PWM duty cycle is presented below.
input (Port A pin 5). This input voltage is com-
pared with the set voltage (200 mv) using the on-
chip comparator of Z8 Encore! XP® microcontrol-
ler. When the input voltage exceeds the reference
voltage, the comparator generates an interrupt. The
comp_intrp interrupt service routine turns off
the PWM generation from port A pin1 for about
100 us.

Testing the Application


This section discusses the equipments to use and
procedure to follow for testing the Z8 Encore! XP
based BLDC fan control application note.

AN022802-0708 Page 4 of 8
Z8 Encore! XP® Based BLDC Fan Control Reference Design

5000

4500 44564534
4361
4180
4000 4013
3799
3628
3500 3416
3196
Fan speed in RPM

3000 2998
2775
2500 2555
2290
2000 2031
1782
1500 1527
1245
1000
880

500 574
243
0 0
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 10
0
% PWM Duty Cycle

Figure 2. Fan speed in RPM_PWM percentage duty cycle

Summary
Z8 Encore! XP® 8-pin microcontroller consists of
all the required on-chip peripheral suitable for
speed control application of BLDC motors.

With the availability of in-circuit programming


features, the evaluation can be done effectively by
tuning the software based on the customer require-
ment such as selecting the PWM duty cycle, speed
control etc. The source code associated with this
application can be used directly without modifica-
tion or with few modification by the customer to
design a similar application/product.

AN022802-0708 Page 5 of 8
Z8 Encore! XP® Based BLDC Fan Control Reference Design

Appendix A—H-bridge Fan Control


Figure 3 displays the photograph of the H-bridge Fan Control Reference Design Board.

Figure 3. H-bridge Fan Control Reference Design Board

AN022802-0708 Page 6 of 8
Z8 Encore! XP® Based BLDC Fan Control Reference Design

Appendix B—Schematic Diagram


Power supply to the BLDC fan and MCU
This reference design uses 12 V Vdc regulated power supply for fans. Zener diodes are used to generate the 3.3 V Vdd supply required for microcontroller
unit.
5 4 3 2 1

G ND

J1
2
D1
3
1 12V 2 1
D P WR JACK D
2

B340LA-13 C7 R1 R3 C8
D2

1
3300pF 680 680 3300pF
1N4148

3
DZ1 V DD
1 1
1

SMAJ7.5A C6 Q1 Q2
2
1uF 50V FDD5614P R14
R11 FDD5614P R4 4.99K

2
220 R2 510
510
1

1
DZ2
V CC
SMAJ7.5A

1
2 SPEED_CMD
C5 R22
2

R5 100 Q7 W1 W2 Q8 R6 100 5K
R12 1uF COMA 2 2N7002 2N7002 2 COMB_PWM1 C9
75

3
0.1uF

3
V CC V CC

1
2
PWM0 PWM0
V DD
C C
R16 R17
J2

2
C3 1.0k 1.0k
1

DZ3 1uF R7 100 Q3 Q4 R8 100


COMB_PWM1 1 IRLR024N IRLR024N 1 COMA
BZX84-C3V0
2

3
R9 2.0K
ISENSE
DBG
INTERFACE
C1
R19 J6
0.01uF 0.15 V CC V DD nRST
1 2 D BG
G ND 3 4
R18 5 6
1.0k Header 3x2

PWM0

B B

HALL
V DD
V CC
SENSOR
U2 INTERFACE
R15 V DD 1 8 VSS R25
10k VDD VSS 10k
J5
C4 COMA 2 7 ISENSE
PA0/DBG PA5/CINP TACH 1
D BG 0.1uF 2
PWM0 SPEED_CMD 3
3 PA1/T0OUT PA4/ANA1 6
con_3

COMB_PWM1 4 5 TACH
PA2/RESET PA3/T1IN
R23 0
Z8F04xA
A A

R26 0
nRST

Title
ZiLOG H Bridge Fan Controller

Size Document Number Rev


B <Doc> X0

Date: Monday, March 28, 2005 Sheet 1 of 1


5 4 3 2 1

Figure 4. Schematic Diagram of H-bridge BLDC Fan Controller


AN022802-0708 Page 7 of 8
Z8 Encore! XP® Based BLDC Fan Control Reference Design

Warning: DO NOT USE IN LIFE SUPPORT

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
©2008 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.
Z I L O G A L S O D O E S N O T A S S U M E L I A B I L I T Y F O R I N T E L L E C T U A L P R O P E RT Y
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 Encore! XP is a registered trademark of Zilog, Inc. All other product or service names are the property
of their respective owners.

AN022802-0708 Page 8 of 8
8

Potrebbero piacerti anche