core independent brushless dc fan control using...

21
AN2522 AVR42778: Core Independent Brushless DC Fan Control Using CCL on tinyAVR® 1-series Features Base setup for performing core independent brushless DC motor (BLDC) commutation and dead time insertion using Configurable Custom Logic (CCL) 100% CPU available after initialization for additional tasks like control, monitoring, and communication Motor commutation based on Hall sensor signal using Analog Comparator (AC) and Configurable Custom Logic (CCL) Dead time insertion based on Hall sensor signal using Analog Comparator (AC), Event System (EVSYS), and 16-bit Timer/Counter Type B (TCB) Pulse Width Modulated (PWM) signal generation using 16-bit Timer/Counter Type A (TCA) Example setup for Microchip ATtiny817 Xplained Mini is provided Introduction As package dimensions reduces and power consumption figures increases thermal management becomes an increasingly important factor in modern-day electronics design. Perhaps the simplest form of thermal management is forced convection, i.e. increasing the dissipation of heat by moving the air inside and around the heat source. This is most conveniently done using fans, which are powered by BLDC motors. BLDC motors are commutated electronically, eliminating problems such as mechanical wear of brushes, but also reducing EMI (Electro-Magnetic Interference). The most straightforward fan designs simply spin the fan rotor at full speed, but as the number of fans tends to increase so does the noise and power consumption. In many cases, it would be desirable to keep noise and power consumption at a minimum. This, in turn, could create a demand for adjusting the speed of the fan according to environmental conditions and/or other external factors. This application note describes a core-independent method of using an AVR ® device to control a simple BLDC fan. Many peripherals are configured to work together, enabling the Configurable Custom Logic (CCL) module to achieve BLDC motor commutation and dead time insertion while feeding a PWM signal to a dual driver BLDC motor circuit, independent of CPU operation. After initialization, no CPU cycles are needed to operate the motor at the set PWM duty cycle, achieving minimal process delay compared to an interrupt based configuration. The device configuration described in this application note could serve as starting point for an intelligent BLDC motor control application with features like automatic speed control and external monitoring. A typical application could be monitoring and control of a cooling fan. © 2018 Microchip Technology Inc. Application Note DS00002522B-page 1

Upload: phungdiep

Post on 26-Sep-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • AN2522 AVR42778: Core Independent Brushless DC Fan Control

    Using CCL on tinyAVR 1-series

    Features

    Base setup for performing core independent brushless DC motor (BLDC) commutation and deadtime insertion using Configurable Custom Logic (CCL)

    100% CPU available after initialization for additional tasks like control, monitoring, andcommunication

    Motor commutation based on Hall sensor signal using Analog Comparator (AC) and ConfigurableCustom Logic (CCL)

    Dead time insertion based on Hall sensor signal using Analog Comparator (AC), Event System(EVSYS), and 16-bit Timer/Counter Type B (TCB)

    Pulse Width Modulated (PWM) signal generation using 16-bit Timer/Counter Type A (TCA) Example setup for Microchip ATtiny817 Xplained Mini is provided

    Introduction

    As package dimensions reduces and power consumption figures increases thermal managementbecomes an increasingly important factor in modern-day electronics design. Perhaps the simplest form ofthermal management is forced convection, i.e. increasing the dissipation of heat by moving the air insideand around the heat source. This is most conveniently done using fans, which are powered by BLDCmotors. BLDC motors are commutated electronically, eliminating problems such as mechanical wear ofbrushes, but also reducing EMI (Electro-Magnetic Interference). The most straightforward fan designssimply spin the fan rotor at full speed, but as the number of fans tends to increase so does the noise andpower consumption. In many cases, it would be desirable to keep noise and power consumption at aminimum. This, in turn, could create a demand for adjusting the speed of the fan according toenvironmental conditions and/or other external factors.

    This application note describes a core-independent method of using an AVR device to control a simpleBLDC fan. Many peripherals are configured to work together, enabling the Configurable Custom Logic(CCL) module to achieve BLDC motor commutation and dead time insertion while feeding a PWM signalto a dual driver BLDC motor circuit, independent of CPU operation. After initialization, no CPU cycles areneeded to operate the motor at the set PWM duty cycle, achieving minimal process delay compared to aninterrupt based configuration.

    The device configuration described in this application note could serve as starting point for an intelligentBLDC motor control application with features like automatic speed control and external monitoring. Atypical application could be monitoring and control of a cooling fan.

    2018 Microchip Technology Inc. Application Note DS00002522B-page 1

  • Table of Contents

    Features.......................................................................................................................... 1

    Introduction......................................................................................................................1

    1. Relevant Devices.......................................................................................................31.1. tinyAVR 0-Series.........................................................................................................................31.2. tinyAVR 1-Series.........................................................................................................................31.3. megaAVR 0-Series..................................................................................................................... 4

    2. Device Specific Implementation Details.................................................................... 5

    3. Theory of Operation...................................................................................................63.1. Common BLDC Fan Construction................................................................................................63.2. Hall Effect Sensors in BLDC Motors............................................................................................ 63.3. BLDC PWM Operation................................................................................................................. 73.4. Dead Time Insertion..................................................................................................................... 7

    4. CCL BLDC Fan Controller Implementation............................................................... 8

    5. CCL BLDC Fan Hardware Suggestions.................................................................. 12

    6. CCL BLDC Fan Further Development.....................................................................14

    7. Get Source Code from Atmel | START.................................................................... 15

    8. Terms and Abbreviations......................................................................................... 16

    9. Revision History.......................................................................................................17

    The Microchip Web Site................................................................................................ 18

    Customer Change Notification Service..........................................................................18

    Customer Support......................................................................................................... 18

    Microchip Devices Code Protection Feature................................................................. 18

    Legal Notice...................................................................................................................19

    Trademarks................................................................................................................... 19

    Quality Management System Certified by DNV.............................................................20

    Worldwide Sales and Service........................................................................................21

    AN2522

    2018 Microchip Technology Inc. Application Note DS00002522B-page 2

  • 1. Relevant DevicesThis chapter lists the relevant devices for this document.

    1.1 tinyAVR 0-SeriesThe figure below shows the tinyAVR 0-series, laying out pin count variants and memory sizes:

    Vertical migration is possible without code modification, as these devices are fully pin- and featurecompatible.

    Horizontal migration to the left reduces the pin count and therefore the available features.

    Figure 1-1.tinyAVR 0-Series Overview

    8 14 20 24Pins

    Flash

    16 KB

    8 KB

    4 KB

    2 KB

    ATtiny1607

    ATtiny807

    ATtiny1606

    ATtiny806

    ATtiny1604

    ATtiny804

    ATtiny402

    ATtiny202

    ATtiny404

    ATtiny204

    ATtiny406

    Devices with different Flash memory size typically also have different SRAM and EEPROM.

    1.2 tinyAVR 1-SeriesThe figure below shows the tinyAVR 1-series devices, illustrating pin count variants and memory sizes.

    Vertical migration upwards is possible without code modification, as these devices are pincompatible and provide the same or more features. Downward migration may require codemodification due to fewer available instances of some peripherals.

    Horizontal migration to the left reduces the pin count and therefore the available features.

    AN2522Relevant Devices

    2018 Microchip Technology Inc. Application Note DS00002522B-page 3

  • Figure 1-2.tinyAVR 1-Series Device Overview

    32KB

    16KB

    8KB

    4KB

    2KB

    8 14 20 24Pins

    Flash

    ATtiny816 ATtiny817ATtiny814

    ATtiny417

    ATtiny1616 ATtiny1617

    ATtiny414 ATtiny416ATtiny412

    ATtiny214ATtiny212

    ATtiny1614

    Devices with different Flash memory size typically also have different SRAM and EEPROM.

    1.3 megaAVR 0-SeriesFigure 1-3 shows the feature compatible devices in the megaAVR device family, including pinout variantsand memory variants.

    Vertical migration is possible without code modification, as these devices are fully pin and featurecompatible.

    Horizontal migration to the left reduces the pin count and therefore the available features.

    Figure 1-3.Device Family Overview

    48KB

    32KB

    16KB

    8KB

    4KB

    28/32 48Pins

    Flash

    ATmega3208

    ATmega4808

    ATmega3209

    ATmega4809

    Devices with different Flash memory size typically also have different SRAM and EEPROM.

    AN2522Relevant Devices

    2018 Microchip Technology Inc. Application Note DS00002522B-page 4

  • 2. Device Specific Implementation DetailsSome details are specific for the device or device group for which the accompanying code was written,thus they may or may not be applicable for other devices. The details described below applies to, but arenot necessarily limited to, tinyAVR 1-series.

    Configurable Custom Logic (CCL)On the tinyAVR 1-series the Configurable Custom Logic (CCL) module contains two Look-up Tables(LUTs), taking up to six inputs and generating up to two different outputs.

    I/O Pin Controller (PORT) and Port Multiplexer (PORTMUX)For the tinyAVR 1-series the pin used for Hall sensor input in this application is shared with the defaultoutput pin of LUT1. The alternate pin for LUT1-OUT is therefore used by writing to the CTRLA register ofthe Port Multiplexer (PORTMUX) module. The specific pins used are listed in the table below.

    Table 2-1.Pins Used

    Pin Description Signal Module

    PA7 Hall sensor input P0 Analog Comparator (AC)

    PA4 PWM output A LUT0-OUT Configurable CustomLogic (CCL)

    PC1 PWM output B LUT1-OUT Configurable CustomLogic (CCL)

    16-bit Timer/Counter Type A (TCA)The accompanying code for this application note uses the default clock settings on tinyAVR 1-series,which from the 20 MHz CLK_MAIN and a division factor of 6, gives a CLK_PER of 3.33 MHz. The defaultPWM period is set to 100 timer counts and the default PWM duty cycle is set to 20 timer counts. As 16-bitTimer/Counter Type A (TCA) is set up with a clock division factor of 1, this corresponds to 30 s and 6 s,respectively.

    16-bit Timer/Counter Type B (TCB)The accompanying code for this application note uses the default clock settings on tinyAVR 1-series,which from the 20 MHz CLK_MAIN and a division factor of 6, gives a CLK_PER of 3.33 MHz. The defaultdead time is set up to 500 timer counts. As 16-bit Timer/Counter Type B (TCB) is set up with a clockdivision factor of 1, this corresponds to 150 s.

    AN2522Device Specific Implementation Details

    2018 Microchip Technology Inc. Application Note DS00002522B-page 5

  • 3. Theory of OperationThe design presented in this application note could be applied to a range of systems using a simpleBLDC motor with Hall sensor feedback. Since a very common application would be that of a cooling fan,the application note focuses mainly on that particular usage.

    3.1 Common BLDC Fan ConstructionBasic brushless DC motors can be broken into two main components; the rotor and the stator. As impliedby its name, the rotor is the rotating part while the stator is the static construct around which the rotorrotates. The rotor houses permanent magnets, and in the case of a fan motor, the fan blades areattached to it. See the figure below.

    Figure 3-1.Common BLDC Fan Rotor

    The motor coils are housed in the stator, which when energized correctly will make the motor turn. Incommon two-phase BLDC motors, there are typically four coils. See the figure below.

    Figure 3-2.Common BLDC Fan Stator

    Torque to turn the motor is produced by the interaction between the magnetic fields created by theenergized motor coils and those of the permanent magnets in the rotor. What motor coils should beenergized at what time is given by the angular position of the rotor relative to the stator. The act ofapplying current to the correct coils as the motor turns is called commutation. Information about theorientation of the rotor is most commonly fed back to the motor controller by a Hall effect sensor mountedon the stator.

    3.2 Hall Effect Sensors in BLDC MotorsA digital Hall effect sensor (also called buffered Hall effect sensor) detects the strength of the currentlypresent magnetic field, and has a single output wire with two possible output states; high and low. BLDCmotors are typically equipped with Hall effect sensors to provide information about the orientation of therotor relative to the stator. When the rotor and its permanent magnets move, the magnetic flux detectedby the Hall sensor changes. This can be used for commutation by a motor controller, as it can tell thecontroller when to activate which coil in the motor in order for it to turn.

    AN2522Theory of Operation

    2018 Microchip Technology Inc. Application Note DS00002522B-page 6

  • For a simple BLDC motor with one Hall sensor, the frequency of the sensor signal will be twice therotation frequency of the motor, toggling the level four times per motor rotation. This is illustrated in thefigure below.

    Figure 3-3.Fan Rotor and Hall Sensor Signal

    3.3 BLDC PWM OperationA basic way of turning a fan motor would be to constantly apply the supply voltage directly to the motorcoils in accordance with the Hall sensor signal. This would make the fan rotate at its maximum achievablespeed for the given supply voltage.

    In many applications, it would be desirable to control the fan speed. As the steady-state fan speed isclosely coupled to the average applied voltage, open loop speed control can be achieved by toggling theapplied voltage between supply level and ground at high frequency using transistors and PWM drivesignals. The average applied voltage will then be proportional to the duty cycle of the PWM signal, whichcan be set and adjusted by a motor controller to manipulate the fan speed.

    3.4 Dead Time InsertionIn order to avoid short-circuiting the supply voltage side to ground, also called shoot-through, for a briefmoment when toggling a PWM signal from driving one motor driver to another, the drivers should be heldin an inactive state for a number of PWM cycles. This is called dead time insertion.

    Since a BLDC motor controller typically uses a Hall sensor signal to determine which of the stator coils topower, this signal should also be used to trigger the insertion of a dead time period.

    AN2522Theory of Operation

    2018 Microchip Technology Inc. Application Note DS00002522B-page 7

  • 4. CCL BLDC Fan Controller ImplementationSome basic elements and features that are often needed for operating a BLDC motor with a micro-controller are PWM control signals, a Hall sensor input signal, motor commutation, and PWM dead timeinsertion. For a simple BLDC fan motor with two drive signal inputs and a Hall sensor output, the resultingwaveforms when the motor is rotating should look similar as illustrated in the figure below. The names ofthe waveforms in the figure are the names of the specific module signals selected for design andimplementation of the application described in this document.

    By making the device produce the outlined waveforms based on the provided Hall sensor signal it will actas a simple BLDC Fan Controller. As the name of the application note suggests, the Configurable CustomLogic (CCL) plays the main role in accomplishing this.Figure 4-1.Sketch of Relevant Waveforms for the CCL BLDC Fan Controller

    Hall sensor (ACOUT)

    Base PWM (TCA0 WO)

    Dead time (TCB0 WO)

    PWM A (CCL LUT0-OUT)

    PWM B (CCL LUT1-OUT)

    The Configurable Custom Logic (CCL) moduleThe Configurable Custom Logic (CCL) module is a programmable logic peripheral, which can beconnected to the device pins, events, or peripherals. This allows the user to eliminate external logic gatesfor simple glue logic functions on the PCB, reducing bill-of-materials (BOM) cost. Each LUT consists ofthree inputs, a truth table, and a filter/edge detector. Each LUT can generate an output as a userprogrammable logic expression with three inputs.

    Implementation OverviewFrom examining the waveforms in the figure above it can be seen that the logical value of the signalsPWM A and PWM B are each given by a combination of the logical values of the three other signals. Thisrepresents a typical use-case for the CCL module, which can generate the two desired signals by usingthe Hall sensor signal, base PWM signal, and dead time signal as inputs.

    The Hall sensor signal waveform can be generated by connecting the physical Hall sensor to the AnalogComparator (AC) module, while the 16-bit Timer/Counter Type A (TCA) is suited for generating the basePWM signal, also called "pulse train". By combining two additional device modules it is also possible tocreate the dead time signal. The signal from the Analog Comparator (AC) can be routed through theEvent System (EVSYS) to 16-bit Timer/Counter Type B (TCB). In 16-bit Timer/Counter Type B (TCB) itcan be used to trigger a square wave which will represent the dead time signal in the ConfigurableCustom Logic (CCL) module.

    An overview of the involved modules is presented below. By configuring these correctly, a controller for asimple BLDC fan that performs motor commutation and dead time insertion without using the CPU can berealized. A more specific description of how the different modules are set up is presented in the followingsections.

    AN2522CCL BLDC Fan Controller Implementation

    2018 Microchip Technology Inc. Application Note DS00002522B-page 8

  • Figure 4-2.Overview of Utilized Device Modules and Signals

    AnalogComparator

    (AC)

    16-bit Timer/Counter

    Type A(TCA)

    16-bit Timer/Counter

    Type B(TCB)

    Event System(EVSYS)

    VoltageReference

    (VREF)Hallsensor

    I/O PinController

    (PORT)

    PortMultiplexer(PORTMUX)

    Configurable Custom Logic

    (CCL)Fan

    I/O PinController

    (PORT)

    AVRmodule

    Externalhardware

    Hall sensorsignal

    (ACOUT)

    Dead timesignal

    (TCB0 W0)

    Base PWMsignal

    (TCA0 W0)

    PWM A(CCLLUT0-OUT)

    PWM B(CCLLUT1-OUT)

    Digital to Analog

    Converter(DAC)

    Configurable Custom Logic (CCL) SetupTwo programmable Look-up Tables, also referred to as LUTs or Truth tables, are needed to output twoseparate PWM signals. Enabling of the LUTs and sending the outputs to pads is done by writing to theCTRLA register of each LUT. Since the value of both output signals is given by a combination of the Hallsensor signal, the dead time signal, and the base PWM signal, both LUTs are set up to take these threeinputs by writing to their respective CTRLB and CTRLC registers.

    The behavior of each LUT is determined by its truth table, which is set up by writing to its respectiveTRUTH register. The hexadecimal value to be written to the TRUTH registers for this application isdetermined from TRUTHn[0:7] to be 0x02 for LUT0 and 0x08 for LUT1 as shown in the table below. Thetwo figures following the table illustrate the two LUT setups using logic gates. Which signal is routed towhat LUT input can be seen from the table and figures below.

    Table 4-1.Truth Table for LUT0 and LUT1 with Identical Input Selection

    IN[2], TCB W0 IN[1], ACOUT IN[0], TCA W0 CCL LUT0 OUT CCL LUT1 OUT

    0 0 0 0 (TRUTH0[0]) 0 (TRUTH1[0])

    0 0 1 1 (TRUTH0[1]) 0 (TRUTH1[1])

    0 1 0 0 (TRUTH0[2]) 0 (TRUTH1[2])

    0 1 1 0 (TRUTH0[3]) 1 (TRUTH1[3])

    1 0 0 0 (TRUTH0[4]) 0 (TRUTH1[4])

    1 0 1 0 (TRUTH0[5]) 0 (TRUTH1[5])

    1 1 0 0 (TRUTH0[6]) 0 (TRUTH1[6])

    1 1 1 0 (TRUTH0[7]) 0 (TRUTH1[7])

    AN2522CCL BLDC Fan Controller Implementation

    2018 Microchip Technology Inc. Application Note DS00002522B-page 9

  • Figure 4-3.LUT0 LogicIN[2], TCB W0

    IN[0], TCA W0

    IN[1], ACOUT

    CCL LUT0 OUT

    Figure 4-4.LUT1 logicIN[2], TCB W0

    IN[0], TCA W0

    IN[1], ACOUT

    CCL LUT1 OUT

    The values of the two TRUTH registers implement the desired behavior for the LUTs according to theillustrated waveform in the introduction of this chapter. The output of LUT0 will follow the base PWMsignal as long as the dead time signal is low and the Hall sensor signal is low, while the LUT1 output willfollow the base PWM signal as long as the dead time signal is low and the Hall sensor signal is high.

    Analog Comparator (AC), Voltage Reference (VREF), and Digital to Analog Converter (DAC) SetupTo provide the status of the connected Hall sensor, which indicates the position of the fan rotor, theAnalog Comparator (AC) is set up to take the physical Hall sensor signal on its positive input pin and theDigital to Analog Converter (DAC) output as its negative input. This is set up via the MUXCTRLA registerof the Analog Comparator (AC) module.

    The output of the Digital to Analog Converter (DAC) is set to a fixed level by setting an initial input valueand selecting the voltage reference. This is done by writing to the DATA register of the module, and theCTRLA register of the Voltage Reference (VREF) module, respectively.

    The Analog Comparator (AC) output signal, ACOUT, will be high when the physical sensor signal isabove the Digital to Analog Converter (DAC) output and low when it is below. This aligns with theillustrated waveform in the introduction of this chapter.

    Note: The Voltage Reference (VREF) and Digital to Analog Converter (DAC) modules need to be set upsuch that the Digital to Analog Converter (DAC) output lies between the upper and lower steady statevoltage output levels of the physical Hall sensor.

    AN2522CCL BLDC Fan Controller Implementation

    2018 Microchip Technology Inc. Application Note DS00002522B-page 10

  • 16-bit Timer/Counter Type B (TCB) and Event System (EVSYS) SetupInserting PWM dead time using the CCL as outlined in this application note requires a signal indicatingwhen the PWM outputs should be held inactive during the specified dead time period. Since the deadtime should be inserted when the PWM output is to be switched from one driver signal to the other, whichis indicated by the Hall sensor signal toggling its level, the insertion should be triggered by the edges ofthe ACOUT signal as these will coincide with the edges of the Hall sensor output.

    The 16-bit Timer/Counter Type B (TCB) module has a "Single-Shot" mode that starts a single countingsession upon detecting an edge on its Event input signal. It will then count until it reaches its TOP valueand stops. The timer output signal TCB W0 will be high during counting and low otherwise, making it verysuitable as a dead time signal by using the ACOUT signal as Event input.

    The ACOUT signal is routed to the 16-bit Timer/Counter Type B (TCB) via the Event System (EVSYS) byselecting ACOUT as input to an event channel and assigning the 16-bit Timer/Counter Type B (TCB) tobe a user of the same event channel. In this application, this is set up by writing to the ASYNCCH0 andASYNCUSER0 registers of the Event System (EVSYS), respectively. Furthermore, the 16-bit Timer/Counter Type B (TCB) is configured to asynchronous single-shot mode with dual Event edge detection bywriting to the CTRLB and EVCTRL registers of the timer. The dead time duration is set up through theCCMP register.

    16-bit Timer/Counter Type A (TCA) SetupThe base PWM signal represents the PWM signal that will be output to either PWM A or PWM Bdepending on the Hall sensor signal input. 16-bit Timer/Counter Type A (TCA) is used for this purpose inthis application, implicating that the period and duty cycle of the PWM outputs must be set up in thismodule.

    The timer is configured to use basic Single-Slope PWM Generation mode by writing to its CTRLB register,while the PWM period and duty cycle is set up by writing the desired values to the PER and CMP0registers, respectively. The TCA W0 is used directly as an input to the Configurable Custom Logic (CCL)module. Open loop speed control of the connected BLDC motor can then be accomplished by adjustingthe duty cycle between 0 and 100% of the timer period.

    I/O Pin Controller (PORT) and Port Multiplexer (PORTMUX) SetupInputs and outputs are directed to and from the external pins of the device by setting up the I/O PinController (PORT) module. Several signals in the device can be connected to an alternate pin instead ofits default pin. This is configured in the Port Multiplexer (PORTMUX) module. The pins that need to be setup for this application are the positive input pin for the Analog Comparator (AC), which should beconnected to the Hall sensor, and the two output pins from the Configurable Custom Logic (CCL), whichshould be connected to the two control inputs.

    AN2522CCL BLDC Fan Controller Implementation

    2018 Microchip Technology Inc. Application Note DS00002522B-page 11

  • 5. CCL BLDC Fan Hardware SuggestionsThe accompanying code includes support for adjusting the PWM duty cycle with the on-board button ofthe ATtiny817 Xplained Mini. Other than this there is no specific hardware provided or described for thisapplication note. For this reason, and the fact that BLDC motors and their control circuits come in manydifferent varieties, two specific fan hardware layouts that will fit the described device setup are outlinedbelow.

    Two-Phase BLDC Fan with Dual Control InputAs the setup described in this application note is designed to take one Hall sensor input and output twoPWM control signals, a simple approach would be to use a two-phase BLDC fan motor with a single Hallsensor output and one driver element connected to each phase as illustrated in the figure below. Thedrivers and Hall sensor should be connected to the device as indicated.

    Figure 5-1.Outline of a Two-Phase BLDC Fan Motor with Drivers

    Two Phase BLDC

    PWM A

    PWM B

    Hall

    AVR

    Hall sensorinput

    For this configuration no shoot-through will occur if both drivers are activated, thus the dead time can infact be reduced to zero or removed.

    One-Phase BLDC Fan with Full H-Bridge ControlIn addition to the more basic configuration illustrated above, the described application is also suited forcontrolling a single-phase BLDC fan motor with a full H-bridge driver circuit by connecting the device as

    AN2522CCL BLDC Fan Hardware Suggestions

    2018 Microchip Technology Inc. Application Note DS00002522B-page 12

  • outlined in the figure below. For this configuration shoot-through will occur if both PWM signals are active,thus dead time is needed when switching between what output the PWM pulses are sent to.

    Figure 5-2.Outline of a One-Phase BLDC Fan Motor and a Full H-Bridge

    One Phase BLDC

    PWM A

    PWM B

    PWM B

    PWM A

    Hall

    AVR

    Hall sensorinput

    AN2522CCL BLDC Fan Hardware Suggestions

    2018 Microchip Technology Inc. Application Note DS00002522B-page 13

  • 6. CCL BLDC Fan Further DevelopmentThis application note presents a basic setup for core independent BLDC fan operation that can act as astarting point for adding more advanced features and/or control. Some examples could be:

    Temperature based fan speed control: This could be implemented by connecting a temperaturesensor via the ADC and set the PWM duty cycle based on the measured value. The duty cyclecould, for instance, be set from a predefined look-up table or by a control algorithm.

    Closed loop speed control: This could be implemented by estimating the fan speed from the Hallsensor signal switching rate and using the value as input to a control algorithm.

    Stall detection: This could be implemented by detecting lack of Hall sensor signal switching. Analog reference input: This could be implemented by connecting a potentiometer to an ADC

    input and use the output value as the set point for a speed or temperature controller, or to simplyset the PWM duty cycle directly.

    Serial communication: By using the SPI module, remote monitoring and control can be added.This could be very useful if the fan is to be integrated in a larger system with some higher levelcontrol scheme.

    AN2522CCL BLDC Fan Further Development

    2018 Microchip Technology Inc. Application Note DS00002522B-page 14

  • 7. Get Source Code from Atmel | STARTThe example code is available through Atmel | START, which is a web-based tool that enablesconfiguration of application code through a Graphical User Interface (GUI). The code can be downloadedfor both Atmel Studio 7.0 and IAR Embedded Workbench via the direct example code-link(s) below orthe BROWSE EXAMPLES button on the Atmel | START front page.

    Atmel | START web page: http://microchip.com/start

    Example Code

    AVR42778 BLDC Fan Control http://start.atmel.com/#example/Atmel%3Aavr42778_bldc_fan_control%3A1.0.0%3A

    %3AApplication%3AAVR42778_BLDC_Fan_Control%3A

    Press User guide in Atmel | START for details and information about example projects. The User guidebutton can be found in the example browser, and by clicking the project name in the dashboard viewwithin the Atmel | START project configurator.

    Atmel Studio

    Download the code as an .atzip file for Atmel Studio from the example browser in Atmel | START, byclicking DOWNLOAD SELECTED EXAMPLE. To download the file from within Atmel | START, clickEXPORT PROJECT followed by DOWNLOAD PACK.

    Double-click the downloaded .atzip file and the project will be imported to Atmel Studio 7.0.

    IAR Embedded Workbench

    For information on how to import the project in IAR Embedded Workbench, open the Atmel | START userguide, select Using Atmel Start Output in External Tools, and IAR Embedded Workbench. A link to theAtmel | START user guide can be found by clicking About from the Atmel | START front page or Help AndSupport within the project configurator, both located in the upper right corner of the page.

    AN2522Get Source Code from Atmel | START

    2018 Microchip Technology Inc. Application Note DS00002522B-page 15

    http://www.microchip.com/starthttp://start.atmel.com/#example/Atmel%3Aavr42778_bldc_fan_control%3A1.0.0%3A%3AApplication%3AAVR42778_BLDC_Fan_Control%3Ahttp://start.atmel.com/#example/Atmel%3Aavr42778_bldc_fan_control%3A1.0.0%3A%3AApplication%3AAVR42778_BLDC_Fan_Control%3A

  • 8. Terms and AbbreviationsTable 8-1.Dictionary

    Phrase/Abbreviation Explanation

    BLDC Brushless Direct Current

    PWM Pulse Width Modulation

    Dead time Buffer time between enabling transistors connected to different voltages to avoidshort circuiting the two voltage levels

    EMI Electromagnetic Interference

    Duty cycle Used to describe the duration of the on-period of a pulse width modulated signal

    Hall effect sensor Magnetic sensor commonly used for indicating the angular position of the rotorin a brushless DC motor in order to correctly apply current to the motor coils

    Commutation The act of applying current to the correct coils of an electrical motor in order tomake it turn

    Steady-state The condition of a dynamic system when its states (like speed, current, etc.)have stabilized

    Open loop control Term used about a control scheme where information about the system state orstates that is to be controlled is not fed back to the controller to create a closedcontrol loop that adjusts the controller output automatically based on thefeedback

    PCB Printed Circuit Board

    I/O Input/Output. Used as collective term for input and output signals to/from thedevice.

    Shoot-through Term commonly used about short circuiting a transistor between supply voltageand ground, potentially damaging the transistor

    AN2522Terms and Abbreviations

    2018 Microchip Technology Inc. Application Note DS00002522B-page 16

  • 9. Revision HistoryDoc. Rev. Date Comments

    B 02/2018 Chapter "Relevant Devices" has been updated to include tinyAVR 0-series andmegaAVR 0-series

    A 08/2017 Converted to Microchip format and replaced the Atmel document number42778

    Added "Relevant Devices" and "Get Source Code from Atmel | START" Changed tiny817 references to tinyAVR 1-series where relevant Added direct example project link to Start in Publication variables

    42778B 11/2016 Minor correction in chapter "Device Specific Implementation Details"

    42778A 10/2016 Initial document release

    AN2522Revision History

    2018 Microchip Technology Inc. Application Note DS00002522B-page 17

  • The Microchip Web Site

    Microchip provides online support via our web site at http://www.microchip.com/. This web site is used asa means to make files and information easily available to customers. Accessible by using your favoriteInternet browser, the web site contains the following information:

    Product Support Data sheets and errata, application notes and sample programs, designresources, users guides and hardware support documents, latest software releases and archivedsoftware

    General Technical Support Frequently Asked Questions (FAQ), technical support requests,online discussion groups, Microchip consultant program member listing

    Business of Microchip Product selector and ordering guides, latest Microchip press releases,listing of seminars and events, listings of Microchip sales offices, distributors and factoryrepresentatives

    Customer Change Notification Service

    Microchips customer notification service helps keep customers current on Microchip products.Subscribers will receive e-mail notification whenever there are changes, updates, revisions or erratarelated to a specified product family or development tool of interest.

    To register, access the Microchip web site at http://www.microchip.com/. Under Support, click onCustomer Change Notification and follow the registration instructions.

    Customer Support

    Users of Microchip products can receive assistance through several channels:

    Distributor or Representative Local Sales Office Field Application Engineer (FAE) Technical Support

    Customers should contact their distributor, representative or Field Application Engineer (FAE) for support.Local sales offices are also available to help customers. A listing of sales offices and locations is includedin the back of this document.

    Technical support is available through the web site at: http://www.microchip.com/support

    Microchip Devices Code Protection Feature

    Note the following details of the code protection feature on Microchip devices:

    Microchip products meet the specification contained in their particular Microchip Data Sheet. Microchip believes that its family of products is one of the most secure families of its kind on the

    market today, when used in the intended manner and under normal conditions. There are dishonest and possibly illegal methods used to breach the code protection feature. All of

    these methods, to our knowledge, require using the Microchip products in a manner outside theoperating specifications contained in Microchips Data Sheets. Most likely, the person doing so isengaged in theft of intellectual property.

    Microchip is willing to work with the customer who is concerned about the integrity of their code.

    AN2522

    2018 Microchip Technology Inc. Application Note DS00002522B-page 18

    http://www.microchip.com/http://www.microchip.com/http://www.microchip.com/support

  • Neither Microchip nor any other semiconductor manufacturer can guarantee the security of theircode. Code protection does not mean that we are guaranteeing the product as unbreakable.

    Code protection is constantly evolving. We at Microchip are committed to continuously improving thecode protection features of our products. Attempts to break Microchips code protection feature may be aviolation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your softwareor other copyrighted work, you may have a right to sue for relief under that Act.

    Legal Notice

    Information contained in this publication regarding device applications and the like is provided only foryour convenience and may be superseded by updates. It is your responsibility to ensure that yourapplication meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS ORWARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORYOR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITSCONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE.Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in lifesupport and/or safety applications is entirely at the buyers risk, and the buyer agrees to defend,indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resultingfrom such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectualproperty rights unless otherwise stated.

    Trademarks

    The Microchip name and logo, the Microchip logo, AnyRate, AVR, AVR logo, AVR Freaks, BeaconThings,BitCloud, CryptoMemory, CryptoRF, dsPIC, FlashFlex, flexPWR, Heldo, JukeBlox, KeeLoq, KeeLoq logo,Kleer, LANCheck, LINK MD, maXStylus, maXTouch, MediaLB, megaAVR, MOST, MOST logo, MPLAB,OptoLyzer, PIC, picoPower, PICSTART, PIC32 logo, Prochip Designer, QTouch, RightTouch, SAM-BA,SpyNIC, SST, SST Logo, SuperFlash, tinyAVR, UNI/O, and XMEGA are registered trademarks ofMicrochip Technology Incorporated in the U.S.A. and other countries.

    ClockWorks, The Embedded Control Solutions Company, EtherSynch, Hyper Speed Control, HyperLightLoad, IntelliMOS, mTouch, Precision Edge, and Quiet-Wire are registered trademarks of MicrochipTechnology Incorporated in the U.S.A.

    Adjacent Key Suppression, AKS, Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, BodyCom,chipKIT, chipKIT logo, CodeGuard, CryptoAuthentication, CryptoCompanion, CryptoController,dsPICDEM, dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, EtherGREEN, In-Circuit SerialProgramming, ICSP, Inter-Chip Connectivity, JitterBlocker, KleerNet, KleerNet logo, Mindi, MiWi,motorBench, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, OmniscientCode Generation, PICDEM, PICDEM.net, PICkit, PICtail, PureSilicon, QMatrix, RightTouch logo, REALICE, Ripple Blocker, SAM-ICE, Serial Quad I/O, SMART-I.S., SQI, SuperSwitcher, SuperSwitcher II, TotalEndurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, and ZENA aretrademarks of Microchip Technology Incorporated in the U.S.A. and other countries.

    SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.

    Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.

    GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary ofMicrochip Technology Inc., in other countries.

    All other trademarks mentioned herein are property of their respective companies.

    AN2522

    2018 Microchip Technology Inc. Application Note DS00002522B-page 19

  • 2018, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.

    ISBN: 978-1-5224-2542-7

    Quality Management System Certified by DNV

    ISO/TS 16949Microchip received ISO/TS-16949:2009 certification for its worldwide headquarters, design and waferfabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in Californiaand India. The Companys quality system processes and procedures are for its PIC MCUs and dsPIC

    DSCs, KEELOQ code hopping devices, Serial EEPROMs, microperipherals, nonvolatile memory andanalog products. In addition, Microchips quality system for the design and manufacture of developmentsystems is ISO 9001:2000 certified.

    AN2522

    2018 Microchip Technology Inc. Application Note DS00002522B-page 20

  • AMERICAS ASIA/PACIFIC ASIA/PACIFIC EUROPECorporate Office2355 West Chandler Blvd.Chandler, AZ 85224-6199Tel: 480-792-7200Fax: 480-792-7277Technical Support:http://www.microchip.com/supportWeb Address:www.microchip.comAtlantaDuluth, GATel: 678-957-9614Fax: 678-957-1455Austin, TXTel: 512-257-3370BostonWestborough, MATel: 774-760-0087Fax: 774-760-0088ChicagoItasca, ILTel: 630-285-0071Fax: 630-285-0075DallasAddison, TXTel: 972-818-7423Fax: 972-818-2924DetroitNovi, MITel: 248-848-4000Houston, TXTel: 281-894-5983IndianapolisNoblesville, INTel: 317-773-8323Fax: 317-773-5453Tel: 317-536-2380Los AngelesMission Viejo, CATel: 949-462-9523Fax: 949-462-9608Tel: 951-273-7800Raleigh, NCTel: 919-844-7510New York, NYTel: 631-435-6000San Jose, CATel: 408-735-9110Tel: 408-436-4270Canada - TorontoTel: 905-695-1980Fax: 905-695-2078

    Australia - SydneyTel: 61-2-9868-6733China - BeijingTel: 86-10-8569-7000China - ChengduTel: 86-28-8665-5511China - ChongqingTel: 86-23-8980-9588China - DongguanTel: 86-769-8702-9880China - GuangzhouTel: 86-20-8755-8029China - HangzhouTel: 86-571-8792-8115China - Hong Kong SARTel: 852-2943-5100China - NanjingTel: 86-25-8473-2460China - QingdaoTel: 86-532-8502-7355China - ShanghaiTel: 86-21-3326-8000China - ShenyangTel: 86-24-2334-2829China - ShenzhenTel: 86-755-8864-2200China - SuzhouTel: 86-186-6233-1526China - WuhanTel: 86-27-5980-5300China - XianTel: 86-29-8833-7252China - XiamenTel: 86-592-2388138China - ZhuhaiTel: 86-756-3210040

    India - BangaloreTel: 91-80-3090-4444India - New DelhiTel: 91-11-4160-8631India - PuneTel: 91-20-4121-0141Japan - OsakaTel: 81-6-6152-7160Japan - TokyoTel: 81-3-6880- 3770Korea - DaeguTel: 82-53-744-4301Korea - SeoulTel: 82-2-554-7200Malaysia - Kuala LumpurTel: 60-3-7651-7906Malaysia - PenangTel: 60-4-227-8870Philippines - ManilaTel: 63-2-634-9065SingaporeTel: 65-6334-8870Taiwan - Hsin ChuTel: 886-3-577-8366Taiwan - KaohsiungTel: 886-7-213-7830Taiwan - TaipeiTel: 886-2-2508-8600Thailand - BangkokTel: 66-2-694-1351Vietnam - Ho Chi MinhTel: 84-28-5448-2100

    Austria - WelsTel: 43-7242-2244-39Fax: 43-7242-2244-393Denmark - CopenhagenTel: 45-4450-2828Fax: 45-4485-2829Finland - EspooTel: 358-9-4520-820France - ParisTel: 33-1-69-53-63-20Fax: 33-1-69-30-90-79Germany - GarchingTel: 49-8931-9700Germany - HaanTel: 49-2129-3766400Germany - HeilbronnTel: 49-7131-67-3636Germany - KarlsruheTel: 49-721-625370Germany - MunichTel: 49-89-627-144-0Fax: 49-89-627-144-44Germany - RosenheimTel: 49-8031-354-560Israel - RaananaTel: 972-9-744-7705Italy - MilanTel: 39-0331-742611Fax: 39-0331-466781Italy - PadovaTel: 39-049-7625286Netherlands - DrunenTel: 31-416-690399Fax: 31-416-690340Norway - TrondheimTel: 47-7289-7561Poland - WarsawTel: 48-22-3325737Romania - BucharestTel: 40-21-407-87-50Spain - MadridTel: 34-91-708-08-90Fax: 34-91-708-08-91Sweden - GothenbergTel: 46-31-704-60-40Sweden - StockholmTel: 46-8-5090-4654UK - WokinghamTel: 44-118-921-5800Fax: 44-118-921-5820

    Worldwide Sales and Service

    2018 Microchip Technology Inc. Application Note DS00002522B-page 21

    FeaturesIntroductionTable of Contents1.Relevant Devices1.1.tinyAVR 0-Series1.2.tinyAVR 1-Series1.3.megaAVR 0-Series

    2.Device Specific Implementation Details3.Theory of Operation3.1.Common BLDC Fan Construction3.2.Hall Effect Sensors in BLDC Motors3.3.BLDC PWM Operation3.4.Dead Time Insertion

    4.CCL BLDC Fan Controller Implementation5.CCL BLDC Fan Hardware Suggestions6.CCL BLDC Fan Further Development7.Get Source Code from Atmel | START8.Terms and Abbreviations9.Revision HistoryThe Microchip Web SiteCustomer Change Notification ServiceCustomer SupportMicrochip Devices Code Protection FeatureLegal NoticeTrademarksQuality Management System Certified by DNVWorldwide Sales and Service