AVR441: Intelligent BLDC Fan Controller with Temperature Sensor and Serial Interface. 8-bit Microcontrollers. Application Note.



Similar documents
AVR245: Code Lock with 4x4 Keypad and I2C LCD. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit RISC Microcontroller. Application Note. AVR182: Zero Cross Detector

AVR442: PC Fan Control using ATtiny13. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

General Porting Considerations. Memory EEPROM XRAM

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

Quick Start Guide. CAN Microcontrollers. ATADAPCAN01 - STK501 CAN Extension. Requirements

8-bit Microcontroller. Application Note. AVR222: 8-point Moving Average Filter

8-bit Microcontroller. Application Note. AVR400: Low Cost A/D Converter

AT89C5131A Starter Kit... Software User Guide

How to Calculate the Capacitor of the Reset Input of a C51 Microcontroller 80C51. Application Note. Microcontrollers. Introduction

AVR106: C functions for reading and writing to Flash memory. 8-bit Microcontrollers. Application Note. Features. Introduction

8-bit RISC Microcontroller. Application Note. AVR236: CRC Check of Program Memory

AT91 ARM Thumb Microcontrollers. Application Note. Interfacing a PC Card to an AT91RM9200-DK. Introduction. Hardware Interface

8-bit Microcontroller. Application Note. AVR314: DTMF Generator

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit RISC Microcontroller. Application Note. AVR155: Accessing an I 2 C LCD Display using the AVR 2-wire Serial Interface

Tag Tuning/RFID. Application Note. Tag Tuning. Introduction. Antenna Equivalent Circuit

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

AVR32110: Using the AVR32 Timer/Counter. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

8-bit Microcontroller. Application Note. AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory

AT91 ARM Thumb Microcontrollers. AT91SAM CAN Bootloader. AT91SAM CAN Bootloader User Notes. 1. Description. 2. Key Features

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

AVR241: Direct driving of LCD display using general IO. 8-bit Microcontrollers. Application Note. Features. Introduction AVR

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary

AVR32100: Using the AVR32 USART. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR120: Characterization and Calibration of the ADC on an AVR. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR201: Using the AVR Hardware Multiplier

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1922: Xplain Board Controller Firmware. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR034: Mixing C and Assembly Code with IAR Embedded Workbench for AVR. 8-bit Microcontroller. Application Note. Features.

8-bit Microcontroller. Application. Note. AVR204: BCD Arithmetics. Features. Introduction. 16-bit Binary to 5-digit BCD Conversion bin2bcd16

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit RISC Microcontroller. Application Note. AVR910: In-System Programming

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

AN2680 Application note

USER GUIDE EDBG. Description

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

How To Prevent Power Supply Corruption On An 8Bit Microcontroller From Overheating

AVR444: Sensorless control of 3-phase brushless DC motors. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Two-wire Automotive Serial EEPROM AT24C01A AT24C02 AT24C04 AT24C08 (1) AT24C16 (2)

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

How To Use An Atmel Atmel Avr32848 Demo For Android (32Bit) With A Microcontroller (32B) And An Android Accessory (32D) On A Microcontroller (32Gb) On An Android Phone Or

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

Application Note. 8-bit Microcontrollers. AVR091: Replacing AT90S2313 by ATtiny2313. Features. Introduction

Atmel AVR1017: XMEGA - USB Hardware Design Recommendations. 8-bit Atmel Microcontrollers. Application Note. Features.

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

AVR125: ADC of tinyavr in Single Ended Mode. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR461: Quick Start Guide for the Embedded Internet Toolkit. Introduction. System Requirements

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

Table of Contents. Section 1 Introduction Section 2 Getting Started Section 3 Hardware Description

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

Application Note. 8-bit Microcontrollers. AVR280: USB Host CDC Demonstration. 1. Introduction

USB 2.0 Full-Speed Host/Function Processor AT43USB370. Summary. Features. Overview

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

Application Note. 8-bit Microcontrollers. AVR272: USB CDC Demonstration UART to USB Bridge

Two-wire Serial EEPROM AT24C1024 (1)

AVR2006: Design and characterization of the Radio Controller Board's 2.4GHz PCB Antenna. Application Note. Features.

AT91SAM ARM-based Flash MCU. Application Note

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

2-Wire Serial EEPROM AT24C32 AT24C64. 2-Wire, 32K Serial E 2 PROM. Features. Description. Pin Configurations. 32K (4096 x 8) 64K (8192 x 8)

AVR287: USB Host HID and Mass Storage Demonstration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

2-wire Serial EEPROM AT24C1024. Advance Information

Application Note. 8-bit Microcontrollers. AVR307: Half Duplex UART Using the USI Module

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 8-bit Atmel Microcontrollers. Application Note. Features.

APPLICATION NOTE Atmel AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

Atmel AT32UC3A3256 microcontroller 64MBit SDRAM Analog input (to ADC) Temperature sensor RC filter

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

Application Note. Migrating from RS-232 to USB Bridge Specification USB Microcontrollers. Doc Control. References. Abbreviations

Brushless DC Motor Controller Product Specification Assembly 025F0129

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary. Features. Applications. 1. Description

Application Note. USB Mass Storage Device Implementation. USB Microcontrollers. References. Abbreviations. Supported Controllers

AT86RF230 (2450 MHz band) Radio Transceiver... User Guide

8-bit RISC Microcontroller. Application Note. AVR335: Digital Sound Recorder with AVR and DataFlash

Microcontroller for Variable Speed BLDC Fan Control System. T.C. Lun System Engineer, Freescale Semiconductor, Inc.

AT88CK490 Evaluation Kit

STK 500, AVRISP, AVRISP

The Programming Interface

AVR Butterfly Training. Atmel Norway, AVR Applications Group

DIP Top View VCC A16 A15 A12 A7 A6 A5 A4 A3 A2 A1 A0 I/O0 I/O1 I/O2 GND A17 A14 A13 A8 A9 A11 A10 I/O7 I/O6 I/O5 I/O4 I/O3. PLCC Top View VCC A17

APPLICATION NOTE. Atmel AT04389: Connecting SAMD20E to the AT86RF233 Transceiver. Atmel SAMD20. Description. Features

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

APPLICATION NOTE. Atmel LF-RFID Kits Overview. Atmel LF-RFID Kit. LF-RFID Kit Introduction

APPLICATION NOTE. Atmel AT01095: Joystick Game Controller Reference Design. 8-/16-bit Atmel Microcontrollers. Features.

ATF15xx Product Family Conversion. Application Note. ATF15xx Product Family Conversion. Introduction

ET-BASE AVR ATmega64/128

Transcription:

AVR441: Intelligent BLDC Fan Controller with Temperature Sensor and Serial Interface Features Application Example for Controlling Brushless DC Motors - Ideal for Use as an Integrated Fan Controller Automatically Adjusts Fan Speed According to Chip Temperature Automatically Detects Fan Failures Two-Wire Interface for Remote Control and Monitoring 1 Introduction As package dimensions go down and power consumption figures goes up 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 Brushless DC (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. The noise level becomes an annoyance, which creates a demand to adjust the speed of the fan according to environmental conditions. When cooling is not efficient components may overheat and suffer temporary or permanent failures. A modern fan must therefore be able to react to changes in temperature, mechanical wear and even physical obstacles (jamming the fan). As fans are used in computerized environments thermal control can be made more efficient if fans are connected to a master, such as the CPU in a typical PC. This application note describes how to integrate a low-cost, feature-rich AVR microcontroller into the commutator electronics of a BLDC fan. The ATtiny25 used in this application note is a low-cost, low-power, 8-bit microcontroller based on the AVR enhanced RISC architecture. It contains 2 KB Flash program memory, 128 bytes of EEPROM memory and 128 bytes of SRAM. It has an integrated temperature sensor, an analogue comparator, a four-channel ADC and a highspeed timer/counter with PWM outputs. The Universal Serial Interface provides remote control capabilities over a Philips I 2 C -compatible bus. The design is easily migrated to other low pin count tinyavrs. 8-bit Microcontrollers Application Note Figure 1-1. Block Schematic of Fan Controller. Rev.

2 Theory of Operation The basic brushless DC motor, commonly found in most 12-volt fans, can be broken into two main components: the rotor and the stator. As the name implies, the rotor is the part that rotates and the stator is the static construct it rotates around. The rotor houses the permanent magnets, and in the case of a fan motor, the fan blades are also attached to the rotor. See figure below. Figure 2-1. Rotor of BLDC fan. The motor coils are housed in the stator. In a standard two-phase BLDC motor there are typically four coils. See figure below. Figure 2-2. Stator of BLDC fan. As opposed to the typical electrical motor where the rotor is inside the stator, compact fans typically have the rotor on the outside of the stator. 2.1 Position Sensor 2 AVR441 The BLDC motors typically use Hall-effect sensors for commutation information. The sensor tells the controller when to activate the coils. Hall-sensors come in two flavors: non-buffered and buffered. Non-buffered sensors have two output wires, which carry

AVR441 the differential voltage proportional to the currently present magnetic field. The buffered sensor has only one output, and only two possible output states: high and low. The buffered Hall-sensor requires only one wire and allows a more compact design, and is therefore the choice of sensor in this application note. It should be noted that an unbuffered Hall-sensor could readily be connected to the analogue comparator of the AVR, provided that the two input pins are available. In this design, however, the serial interface requires two pins and makes the use of an unbuffered Hall-sensor difficult (but not impossible). A basic design for a fan controller can be very simple, provided that the only requirement is to rotate the fan; basically, two transistors controlled by a Hall-sensor will do. But in most cases there are requirements to monitor and adjust the rotating speed, either autonomously by the fan itself or by remote control via a serial interface. In addition, an intelligent fan should be able to handle situations like rotor lock, overcurrent and overheating. 2.2 Speed Control 2.2.1 Hall Sensor Feedback There are many advantages for being able to control the speed of the rotor; acoustic noise and power consumption are reduced and the expected lifetime of mechanical constructs is improved. In order for the microcontroller to be able to control the rotary motion it needs to know in which phase the rotor is. For this purpose a buffered Hall sensor is used. The signal from the sensor toggles between logical high and low according to the rotational phase of the rotor, as illustrated in the figure below. The sensor signal toggles four times per revolution of the rotor. Figure 2-3. Signal from a Buffered Hall Sensor in a Rotating Fan. The sensor signal is used by the microcontroller to time the activation of stator coils. 2.2.2 PWM-Controlled Speed The in elaborate way to turn a rotor is to wire the sensor signal directly to a coil driving circuitry. This results in the rotor constantly trying to increase its speed of rotation until it reaches its mechanical limits. The result is a fan persistently rotating at full speed and producing the highest amount of noise. A more elaborate method of speed control is implemented by chopping the driving signal. This means that the stator coils are still activated according to the signal from the sensor, but rather than constantly powering the coil for the entire quarter-cycle the 3

drive signal toggles between active and inactive at a high frequency. The rotational speed of the fan is then directly proportional to the average voltage of the drive signal. The most efficient method to obtain a chopped drive signal is to use a hardware timer/counter with Pulse-Width Modulation (PWM) outputs. The ATtiny45 is equipped with a high-speed PWM waveform generator suitable for this purpose. The average voltage of the driving signal is directly proportional to the duty cycle of the PWM output. This means the software can easily control the speed of the fan by simply adjusting the duty cycle of the PWM outputs. The modulated coil drive signals are illustrated in Figure 2-4. Figure 2-4. PWM-Modulated Control Signals versus Hall-Signal 2.3 Serial Interface Many modern computer motherboards implement SMBus or I 2 C to provide hardware health monitoring data, like voltages, temperature and fan speed. The SMBus interface is a 2-wire serial interface, which is very similar to and usually backward compatible with the I 2 C interface. The AVR microcontroller used in this application is equipped with a Universal Serial Interface (USI), which can be programmed to operate in an I 2 C -compatible Two- Wire Mode. Using only two wires for communication, it is possible to remotely monitor the temperature, speed and status of the fan. In addition, the two-wire interface allows the remote device to start or stop the fan at will or to set the fan rotation to any desired speed. 3 Implementation of Fan Controller The software implementation has been done using IAR Embedded Workbench for AVR, version 4.11A. The source codes of the fan controller are freely available. To verify the design presented here, a printed circuit board has been created. Schematics and layouts are included at the end of this document. The fan controller is shown in the figure below. 4 AVR441

AVR441 Figure 2-5. Fan Controller, Top View. For ease of experimentation, the design presented here has all electronic components placed outside the fan casing. In an actual implementation, most connectors and components are not required and the essential electronics are housed inside the fan. 3.1 Hardware The hardware consists of an ATtiny45 AVR microcontroller, a Hall-effect sensor, two transistors and a few discrete components. The microcontroller is functionally and pin compatible with ATtiny25 and ATtiny85. With little or no modifications, other low pincount AVR microcontrollers can also be used in this design. The Hall-effect sensor has a fixed location in the fan stator. As the rotor and the permanent magnets move the magnetic flux detected by the Hall-sensor changes. The information conveyed from the Hall-sensor to the microcontroller is then used to decide which coil to activate. The coil currents can be in excess of 100 ma and the microcontroller therefore uses external transistors to control the current. The current flowing through the activated transistor and the coil makes the coil act as a magnet, which then draws the permanent magnet in the rotor towards it and makes the rotor turn. By accurate timing of coil currents the turning of the rotor can be extended to maintain a rotary motion. The fan controller schematics can be found in Appendix 6.1. 3.1.1 Supply Voltage Connectors The hardware requires an external DC voltage source to operate. The supply voltage should be 12 V and the source should be able to provide some 500 ma of current. Supply voltage should be provided to one of the connectors J1 or J15. Connectors J7 and J16 are voltage outputs, only, and intended for providing supply voltage to motor coils and the fan master. The fan master is explained later. 5

3.1.2 ISP and debugwire Interface The fan controller has a standard six-pin ISP interface for programming purposes. Programming can be done for example through an ATAVRISP programmer, or an STK500 development board. Alternatively, with an ATJTAGICE mkii the design can be debugged in real time over debugwire, using only the reset pin for communication. The connector is described in the table below. Table 2-1. Pin Layout of ISP Connector J2 Pin Name Description ISP debugwire 1 MISO Serial data out Connect - 2 VCC Supply voltage (1) Connect Connect 3 SCK Serial clock Connect (2) - 4 MOSI Serial data in Connect - 5 /RESET Reset Connect Connect 6 GND Ground Connect Connect Notes: 1. Provided by target (fan controller) 2. Not required, when target clocked by internal oscillator 3.1.3 Fan Connector Using the ISP when the fan is connected to the system might result in random fan movements during programming. This is because the same wires that are used for ISP programming are also connected to the coil-drive transistors. Normally this is not a problem. It can, however, be avoided by temporarily removing the jumpers that connect the control signals to the transistors, or by temporarily removing the supply voltage to the fan coils. For more information about the ISP interface, see Application Note AVR910: In- System Programming. For more information about debugwire, see the User Guide of ATJTAGICE mkii and the ATtiny25 data sheet. The fan connector is a 6-pole pin header, which carries signals to and from the motor. Signals are described in the table below. Table 2-2. Pin Layout of Fan Connector J3 Pin Name Description 1 L1 Ground side connection of first motor coil 2 H+ Positive input signal of unbuffered Hall-sensor (1) 3 L2 Ground side connection of second motor coil 4 H/H- Buffered or positive input of unbuffered Hall-sensor 5 GND Reset 6 VH Supply voltage for Hall-sensor Notes: 1. Not connected, when using buffered Hall-sensor 6 AVR441

AVR441 3.1.4 Two-Wire Serial Interface The fan controller is equipped with two connectors for two-wire serial interfacing. Several fan controllers can be cascaded and wired to one, common fan master. The serial connector is described in the table below. Table 2-3. Pin Layout of Serial Connectors J4 and J5 Pin Name Description 1 SCL Serial clock 2 SDA Serial data 3 N/c Not connected 4 GND Common ground Pull-up resistors are located at the fan master. See microcontroller data sheets for a description of the two-wire serial interface protocol. The two-wire interface is compatible with I 2 C. 3.1.5 Signal Routers The fan controller is equipped with signal routers, which makes it possible to re-route signals between the microcontroller and the auxiliary components. This is useful when trying out different combinations of features and microcontrollers. Signal routers are 2 x 5-pole pin headers, each labelled with the signal name it directs. Jumpers are used for signal routing. For example, signal router J13 directs the buffered signal from the Hall-sensor to one of the I/O-pins of the microcontroller. The table below lists all signal routers of the design. Table 2-4. Signal Routers Label Signal Description Default J8 EXT. IO External input or output N/c (1) J9 L2 Transistor control signal for motor coil L2 PB4 (2) J10 L1 Transistor control signal for motor coil L1 PB1 J11 IL Current measurement signal N/c J12 H+ Positive end of unbuffered Hall-signal N/c J13 H/H- Buffered/unbuffered signal from Hall-sensor PB3 J14 LED Output signal for LED drive N/c Notes: 1. Not connected, i.e. no jumper 2. In this case, use jumper to connect lowest row of pins (labelled PB4) 3.2 Firmware The firmware is written entirely in C language. This is to make the design easy to understand and to make further development of the design as straightforward as possible. 3.2.1 Overview The flow chart of the main program is shown in the figure below. 7

Figure 2-6. Flowchart of Main Program. Note that the Hall sensor readings and the activation of the coils are handled by the Pin Change interrupt while the mail loop is running. 3.2.2 Interrupt Service Every transition in the signal coming from the Hall-sensor triggers an interrupt. The interrupt service routine maintains a software extended timer/counter, monitors the state of the fan and applies fan control parameters. The flow chart of the interrupt service routine is shown in the figure below. 8 AVR441

AVR441 Figure 2-7. Flowchart of Pin Change Interrupt Service Routine. 3.2.3 Temperature The firmware continuosly polls the ADC for new conversion results. When detected, the firmware reads the new conversion result from the ADC and continues to update all parameters related to temperature. The program flow is illustrated in the figure below. 9

Figure 2-8. Flowchart of Temperature Monitor and Control Routine. 3.2.4 Speedometer The rotational speed of the fan is readily evaluated as the relationsip between the frequency of the timer/counter and the actual reading of the timer/counter. Since the timer/counter is only eight bits long it has been extended by means of software (see pin change interrupt handler). In other words, the timer/counter hardware register is not used directly in this function, as seen in the figure below. 10 AVR441

AVR441 Figure 2-9. Flowchart of Rotational Speed Monitor Routine. Note that the primary measure of fan speed is recorded in units if RPS (Rotations Per Second), but higher level processing is handled in units of RPM (Rotations Per Minute). This is because RPS readings are always below 100 and therefore nicely fit the data type of unsigned character, but at the end of the day fan performance is usually measured in units of RPM. 3.2.5 Timer 0 The hardware Timer/Counter0 is used as a reference for evaluating the actual speed of the fan. As the timer/counter is only 8 bits in length it does not provide enough resolution for accurately measuring the fan speed over the whole operating range. The hardware timer/counter is therefore extended by software, which can be seen in the pin change interrupt handler, where the hardware timer/counter is read and reset. This works well for moderately high rotational speeds but at lower speeds the 8-bit timer/counter will overflow before a pin change interrupt occurs. For this purpose the timer/counter overflow handler automatically updates the extended software counter, as can be seen in the figure below. Figure 2-10. Flowchart of Timer/Counter Overflow Handler. 3.2.6 Two-Wire Interface The fan controller uses the Universal Serial Interface hardware of the AVR to provide an I 2 C -compatible Two-Wire Interface. The required software intervention is rather 11

low and mainly consists of preloading variables to be transmitted by the hardware. The flow chart is shown in the figure below. Figure 2-11. Flowchart of Maintenance Routine for Two-Wire Interface. 3.2.7 Watchdog Timer The watchdog timer interrupt is triggered when the interval of transition signals coming from the Hall sensor exceeds a predefinied time limit. This means the interrupt service routine in the figure below is executed when the fan has stopped or is rotating at a very low speed. 12 AVR441

AVR441 Figure 2-12. Flowchart of Watchdog Timer Interrupt Service Routine. 3.2.8 Calibration During initialisation the software reads the first location of EEPROM, looking for the TWI address number of the fan. The number returned is assumed valid if it is positive, non-zero and no larger than eight. Else, the software assumes the EEPROM has been erased or is not properly set up and will proceed with device calibration, as shown in the figure below. 13

Figure 2-13. Flowchart of Calibration Routine. The calibration routine assumes the ambient temperature is 25 degrees Centigrade and makes a one-point calibration to adjust the offset accordingly. See device data sheet for information on temperature measurement accuracy. 3.2.9 Summary The table below summarizes the system requirements of the fan controller firmware. Table 2-5. Statistics of Fan Controller Firmware Measure Debug Release Non-Volatile Code Memory (Flash) 2199 bytes 1615 bytes Non-volatile Data Memory (EEPROM) 66 bytes 66 bytes Data Memory (SRAM) 95 bytes 95 bytes The firmware was compiled with IAR Embedded Workbench, version 4.11A. 4 Implementation of Fan Master In order to test and demonstrate the functionality of the serial bus on the fan controller a fan master has also been constructed. The fan master communicates with one or several fan controllers over a two-wire interface, as illustrated in the figure below. 14 AVR441

AVR441 Figure 2-14. One Fan Master Communicating with N Fan Controllers 4.1 Hardware The fan master is a slightly modified AVR Butterfly. The only additions are two pull-up resistors on the TWI bus, a pin header for TWI connection and a pin header for external power supply. The TWI connector is mounted at J405 (USI Connector) of the AVR Butterfly (see User s Guide). The external power supply is connected to pins 9 (GND) and 10 (VCC_EXT) of J401 (PORTD connector). Connectors with cables attached are shown in the figure below. Figure 2-15. Fan Master, Top View Pull-up resistors for the Two-Wire Interface are readily mounted on the back of the Fan Master. One resistor is soldered between pin 1 (SCL) of J405 (USI) and pin 10 (VCC_EXT) of J400 (PORTB), another between pin 2 (SDA) of J405 and pin 10 of J400. Each resistor should be at least 10 kohm. See figure below. Figure 2-16. Fan Master, Bottom View The figure above also shows a mounted J402 connector, which is required for reprogramming the Fan Master. See AVR Butterfly User s Guide for details. 15

4.2 Firmware The firmware of the fan master is based on the AVR Butterfly firmware. Some features have been removed and modifications have been done to implement a menu structure suitable for remote control and monitor of fans. The menu structure is explained briefly in the sections below. 4.2.1 Welcome Message When the fan master is powered up it will start scrolling the welcome message. Use joystick up or down to change mode. 4.2.2 Scan Mode Enter Scan Mode by selecting Scan on the LCD and pushing joystick rigth or by clicking on the middle of the joystick. In Scan Mode the fan master will scan the serial interface bus for fan controllers. The scan algorithm cycles TWI addresses 1 through 8, only. For every fan controller found details will be shown briefly, as follows (numerical information may vary): FAN 01 +25 C 25 RPS Each line will be flashed on the LCD for about one second. Exit Scan Mode by pushing joystick left. 4.2.3 Single Fan Mode Enter Single Fan Mode by selecting Single and clicking or pushing joystick right. In Single Fan Mode the fan master will display the same fan information as in Scan Mode but will not scan for other devices. Use joystick left and right to cycle between fan controllers (TWI addresses 1 through 8). The following two lines will be flashed on the LCD if no fan controller is found at the selected address (nn = TWI address): FAN nn NA Exit Single Fan Mode by repeatedly pushing joystick left until the message Single appears on the LCD. 4.2.4 Remote Control Mode Enter Remote Control Mode by selecting Remote and clicking or pushing joystick right. Then use joystick left and right select one fan controller (TWI address). The display will look as follows: Fn:xx:yy 16 AVR441 where n is the fan number (TWI address), xx is the actual rotational speed of the fan (in rotations per second) and yy is the setpoint speed of the fan. When this mode of operation is entered the fan master will read the actual rotational speed of the fan and use that as the default setpoint value.

AVR441 Use joystick left and right to change fan number (n). Use joystick up and down to change the setpoint value (yy) and watch the actual rotational speed follow (xx). Note that a typical fan saturates at about 50 RPS. Also note that very low speeds may inadvertently halt the fan. When decreasing speed to just a few RPS please allow the fan time to settle before further reducing the speed. Click joystick to completely stop the fan. The display will now show: Fn:xx:ST Click joystick again to restart the fan. The display will now show: Fn:xx:TM Note that the fan will start in temperature-controlled mode, which means the rotational speed is relative to the ambient temperature of the fan. Move joystick up or down to switch remote controlled mode. Exit Remote Control Mode by repeatedly pushing joystick left until the message Remote appears on the LCD. 4.2.5 Options To adjust LCD contrast select Options and click joystick or push joystick right. The LCD now scrolls the text Display. Again, click joystick or push joystick right. The LCD now scrolls the text Adjust Contrast. Now click the joystick. Use joystick up and down to change LCD contrast, then click joystick when done. Push joystick left twice to exit. 17

5 Quick Start 5.1 Stand-Alone Mode 5.2 Slave Mode 5.2.1 Master Firmware The fan controller described in this document can operate autonomously in standalone mode or as a slave, linked to a master. In stand-alone mode the fan controller works autonomously. To set up the fan controller in stand-alone mode simply plug the power source to the fan controller boards. Supply voltage should be about 12 VDC and may be connected to either J1 or J15. Polarity does not matter. The fan will start automatically. In this mode of operation it will constantly monitor the ambient temperature and adjust the rotational speed accordingly. By default, the fan controller tries to maintain the same rotational speed (in rotations per second, RPS) as temperature (in degrees centigrade). For example, at room temperature (25 degrees) the fan should rotate at 25 revolutions per second. In this mode each fan controller works autonomously but is also subject to remote control and monitor by a common master. Start by connecting one fan controller to the fan master. Use a cable to connect J5 and J16 of the fan controller to J405 and J401 of the fan master. Several fan controllers can be cascaded to the same serial bus, as illustrated in Figure 2-14. Each serial interface cable may be connected to either J4 or J5 (the connectors are identical). Please note that each fan controller must have a unique TWI address. The address is stored in EEPROM (see firmware description). Finally, connect power to the controller boards. Supply voltage should be about 12 VDC and may be connected to either J1 or J15. Polarity does not matter. All fans will start automatically and the fan master will show the welcome message. In this mode of operation each fan performs as in stand-alone mode until addressed by the fan master. The fan master can monitor the rotational speed and ambient temperature of each fan. It can also set the rotational speed of any fan. Use the joystick of the fan master to navigate. The menu structure of the master firmware is summarized in the table below. Table 5-1. Fan Master Menu Structure Menu Description Navigation TITLE Scrolls welcome message Joystick up/down to change menu SCAN Scans for fan controllers on bus Push to enter, joystick left to leave SINGLE Show data on selected fan controller Use joystick to look up fans REMOTE Set speed on any fan controller Up/down: speed. Push to start/stop OPTIONS LCD contrast adjustment Joystick up/down to change 18 AVR441

AVR441 6 Appendices 6.1 Schematic Figure 5-1. Fan Controller Schematic 6.2 Bill of Material Table 5-2. Bill of Material, Fan Controller Part Description Order Code (1) C1, C2 Electrolytic capacitor, 2.2 uf, 50 VDC, 2 mm 67-013-20 C3 (optional suppression capacitor) 65-183-69 D1 Zener diode, 4.3 V, 0.5 W 70-053-66 D2 Rectifier diode, 1N4001 70-003-67 D3 (LED, not populated) 75-053-40 19

Part Description Order Code (1) D4 Bridge rectifier, 1 A, 100 V 70-043-02 H1, H2, H3 (2) Jumpers, tinned, 2.54 mm 43-710-01 J1, J6 Pin header, straight, 2.54 mm, 1 x 2 43-716-05 J7, J16 Pin header, 2.54 mm, 1 x 2, with friction lock 43-808-61 J2, J3 Pin header, straight, 2.54 mm, 2 x 3 43-717-12 J4, J5 Pin header, 2.54 mm, 1 x 4, with friction lock 43-808-12 J8... J14 Pin header, straight, 2.54 mm, 2 x 5 43-717-38 J15 Chassis connector, 2.1 mm, angled 42-051-59 Q1, Q2 NPN Transistor, MPSA06 71-033-69 R1 Resistor, 220 ohm, 0.25 W, carbon film 60-104-17 R2, R7, R9 (not populated) R3, R6 Short (tinned copper wire, 0.5 mm) 55-160-34 R4, R5, R8 2.2 kohm, 0.25 W, carbon film 60-105-32 U1 Attiny25 microcontroller Notes: 1. ELFA order codes. See www.elfa.se 2. Not shown in schematic In addition, some miscellaneous parts may be required, depending on the configuration. This includes cables and jumpers, and the actual BLDC motor, of course. 20 AVR441

AVR441 6.3 Printed Circuit Board Figure 5-2. Silkscreen, top side (outer dimensions 160 x 100 mm) 21

Figure 5-3. Artwork, top side (outer dimensions 160 x 100 mm) 22 AVR441

AVR441 Figure 5-4. Artwork, bottom side (outer dimensions 160 x 100 mm) 23

7 Table of Contents Features... 1 1 Introduction... 1 2 Theory of Operation... 2 2.1 Position Sensor... 2 2.2 Speed Control... 3 2.2.1 Hall Sensor Feedback... 3 2.2.2 PWM-Controlled Speed... 3 2.3 Serial Interface... 4 3 Implementation of Fan Controller... 4 3.1 Hardware... 5 3.1.1 Supply Voltage Connectors... 5 3.1.2 ISP and debugwire Interface... 6 3.1.3 Fan Connector... 6 3.1.4 Two-Wire Serial Interface... 7 3.1.5 Signal Routers... 7 3.2 Firmware... 7 3.2.1 Overview... 7 3.2.2 Interrupt Service... 8 3.2.3 Temperature... 9 3.2.4 Speedometer... 10 3.2.5 Timer 0... 11 3.2.6 Two-Wire Interface... 11 3.2.7 Watchdog Timer... 12 3.2.8 Calibration... 13 3.2.9 Summary... 14 4 Implementation of Fan Master... 14 4.1 Hardware... 15 4.2 Firmware... 16 4.2.1 Welcome Message... 16 4.2.2 Scan Mode... 16 4.2.3 Single Fan Mode... 16 4.2.4 Remote Control Mode... 16 4.2.5 Options... 17 5 Quick Start... 18 5.1 Stand-Alone Mode... 18 5.2 Slave Mode... 18 5.2.1 Master Firmware... 18 6.1 Schematic... 19 6.2 Bill of Material... 19 6.3 Printed Circuit Board... 21 7 Table of Contents... 24 24 AVR441

AVR441 Disclaimer... 26 25

Ddisclaimer D Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Regional Headquarters Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland Tel: (41) 26-426-5555 Fax: (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581 Atmel Operations Memory 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 Microcontrollers 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 La Chantrerie BP 70602 44306 Nantes Cedex 3, France Tel: (33) 2-40-18-18-18 Fax: (33) 2-40-18-19-60 ASIC/ASSP/Smart Cards Zone Industrielle 13106 Rousset Cedex, France Tel: (33) 4-42-53-60-00 Fax: (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743 RF/Automotive Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany Tel: (49) 71-31-67-0 Fax: (49) 71-31-67-2340 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France Tel: (33) 4-76-58-30-00 Fax: (33) 4-76-58-34-80 Literature Requests www.atmel.com/literature Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL S TERMS AND CONDITIONS OF SALE LOCATED ON ATMEL S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel s products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. Atmel Corporation 2005. All rights reserved. Atmel, logo and combinations thereof, Everywhere You Are, AVR, AVR Studio and others, are the registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others.