APPLICATION NOTE Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide Atmel AVR XMEGA E Features • • Atmel® AVR® ATxmega32E5 microcontroller DALI (Digital Addressable Lighting Interface) Slave Physical Interface • Optocoupler translate signals between the DALI physical layer and the MCU • Voltage conversion from DALI voltage level to MCU voltage level • Lighting Control • • • • • • Buck converter Up to 300mA LED current with External N-CH MOSFETS 1kHz PWM Input with Dimming Duty Cycle Removable LED board to facilitate customer’s LED load connection One dual LED is controlled by user PDI Program/Debug interface Description The reference design of DALI Slave based on ATxmega32E5 is developed to demonstrate DALI protocol functions. The reference hardware includes three parts, DALI physical layer interface, MCU, and LED drive circuit. The LED string is controlled by the DALI commands through the ATxmega32E5. For this reference design, the hardware design files (schematic, BOM and PCB Gerber) and software source code can be downloaded from Atmel website. The provided hardware documentation can be used with no limitations to manufacture the reference hardware solution for the design. Figure 1. DALI Slave with ATxmega32E5 42174A−AVR−08/2013 Table of Contents 1. Related items ..................................................................................... 3 2. Overview ............................................................................................ 4 2.1 2.2 2.3 2.4 Components for set up ...................................................................................... 4 Preprogramming firmware ................................................................................. 5 Power supply..................................................................................................... 5 Programming the kit .......................................................................................... 5 3. Connectors ........................................................................................ 6 3.1 3.2 3.3 3.4 PDI header ........................................................................................................ 6 Power Jack ....................................................................................................... 6 DALI BUS connector ......................................................................................... 6 LED Load and Temperature Sensor header ..................................................... 7 4. Peripherals ......................................................................................... 8 4.1 4.2 4.3 4.4 4.5 DALI physical layer interface............................................................................. 8 Buck LED Driver.............................................................................................. 10 LED Load ........................................................................................................ 11 LED Indicator .................................................................................................. 11 Temperature Sensor ....................................................................................... 11 5. Code examples ................................................................................ 13 6. Revision history................................................................................ 14 Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 42174A−AVR−08/2013 2 1. Related items The following list contains links to the most relevant documents for the DALI Slave • ATxmega32E5/ ATxmega16E5/ ATxmega8E5 Preliminary Datasheet ATxmega32E5 is the microcontroller used in this solution. • Atmel AVR XMEGA MANUAL The document contains complete and detailed description of all modules included in the Atmel AVR XMEGA E microcontroller family. • IEC 62386-101, IEC 62386-102, IEC 62386-207 The Digital Addressable Lighting Interface (DALI) was defined in IEC 62386. • AVR1612: PDI programming driver The Program and Debug Interface (PDI) is an Atmel® proprietary interface for external programming and on-chip debugging of the device. This application note describes how to implement PDI programming. • Atmel Studio 6 Atmel Studio 6 is a free Atmel IDE for development of C/C++ and assembler code for Atmel microcontrollers. • Atmel JTAGICE3 JTAGICE3 is a mid-range development tool for Atmel 8- and 32-bit AVR microcontrollers with on-chip debugging for source level symbolic debugging, Nano Trace (if supported by the device) and device programming. Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 42174A−AVR−08/2013 3 2. Overview The Atmel AVR DALI Slave based on ATmega32E5 kit is intended to demonstrate the Atmel AVR ATXmega32E5 microcontroller which is used to communicate with DALI master and light source. Figure 2-1 shows the available features on the board. Figure 2-1. Overview of DALI Slave kit with ATxmega32E5 2.1 Components for set up The components in Table 2-1 are necessary for perform all functions of the reference design. Table 2-1. Components for kit setup Component Function Reference hardware Kit The main board and LED load Power Supply Power for the kit Programming Tool with PDI interface Debug and Programming DALI Master Control the Kit for simulate a normal lamp behavior DALI BUS Power Supply Provide Power Supply for DALI BUS Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 42174A−AVR−08/2013 4 2.2 Preprogramming firmware The ATxmega32E5 on the kit is programmed with the default firmware. The detailed description of the firmware is available in the AT03922 DALI Slave with XMEGA E – Software User’s Guide. 2.3 Power supply The kit needs an external power supply which can deliver 12V and up to 500mA. The actual current requirement for the board is much less than 500mA but in order to be able to power optional expansion boards this margin is recommended. The 12V is regulated down to 3.3V with an onboard LDO regulator, which provides power to the entire main board. Please note that the 32MHz CPU clock frequency is used in this application, thus the VCC of the MCU must be greater than 2.7V. Please refer to the datasheet of the ATxmega32E5 for more details. The 12V voltage is converted to proper voltage and supply LED string. 2.4 Programming the kit The kit can be programmed from an external programming tool through the PDI interface. Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 42174A−AVR−08/2013 5 3. Connectors The DALI Slave kit based on ATxmega32E5 has PDI header J3, Power Jack J4, DALI BUS connector J12 and LED header J14. They are shown in Table 3-1 Table 3-1. 3.1 Connector and functions Connector Function J3 PDI interface for programming and debug J4 12VDC Power Jack J12 DALI BUS connector J14 LED Load and Temperature Sensor connector PDI header The AVR ATxmega32E5 can be programmed and debugged via PDI header. Any tools which carry the PDI interface can program and debug the kit. JTAGICE3 is recommended here for programming. The definition of the PDI interface can be found in Table 3-2. Table 3-2. 3.2 AVR ATxmega32E5 programming and debugging interface - PDI Pin on programming header PDI 1 DATA 2 VCC 3 - 4 - 5 CLK 6 GND Power Jack The diameter of the Power Jack pin is 2mm, which is connected to DC+ of the power jack plug. The Jack spring is connected to DC- of the power jack plug. Table 3-3. 3.3 Power Jack Pin on power jack Name on the Power Jack 1 DC- 2 DC- 3 DC+ DALI BUS connector The J12 is the DALI bus connector. It connects to the DALI bus directly. According to the DALI protocol, these pins have no polarity requirement. Table 3-4. DALI BUS Connector Pin on DALI BUS Connector Name on the DALI BUS 1 DALI BUS 2 DALI BUS Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 42174A−AVR−08/2013 6 3.4 LED Load and Temperature Sensor header The connector J14 provides a connection for the LED string and Temperature Sensor. The header is polarity sensitive. Table 3-5. LED Load and Temperature Sensor header Pin on LED Load header Name on the LED Load header 1 V+ 2 V- 3 VCC 4 NTC 5 GND Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 42174A−AVR−08/2013 7 4. Peripherals Figure 4-1 shows the DALI Slave system block diagram based on Atmel ATxmega32E5 device. Figure 4-1. DALI Slave system block diagram DALI RX DALI bus 4.1 DALI physical layer Interface PWM ATxmega32E5 DALI TX STATE LED driver DALI physical layer interface The DALI physical layer interface bridges the voltage level between DALI bus and microcontroller ATxmega32E5 device. According to the DALI protocol, the HIGH level is from 9.5V to 22.5V, and the LOW level is from -6.5V to 6.5V. The logic level should be converted to the logic which MCU can accept. For the MCU ATxmega32E5 used in this kit, the interface logic should be 0 to 3.3V. Figure 4-2 shows the diagram of the DALI physical layer interface. Figure 4-2. DALI Physical Layer Interface Current Source Optocoupler MCU Rx Comparator DALI Bus Rectify Bridge Optocoupler MCU Tx Two optocouplers are used to isolate the voltage level between the DALI bus and microcontroller. Using the comparator in above circuit has advantage over other simplified design in • Suitable for all working temperature range Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 42174A−AVR−08/2013 8 • • Trim the input waveform of signal for MCU Big tolerance for the difference of components for mass production The peripheral modules on ATxmega32E5 reduce the overhead of the firmware. • The USART module is connected to XMEGA Custom Logic (XCL) module and serial frame length can be extended up to 256 bit. The combination of ATxmega32E5 LUT and USART can implement encoding and decoding. The combination can receive and transfer data with Manchester code directly without external firmware consumption. For Manchester encoding, USART needs to operate in synchronous mode. SCK of USART is used as Manchester clock signal. Transmit data from shift register is used as Manchester data. To encode the data, XCL linked to USART is used to execute XOR logic. The logic output from XCL is connected to USART TXD pin. Figure 4-3. Manchester encoding For Manchester decoding, since there is no synchronous input clock signal. USART runs in asynchronous mode for data reception and PLC of LUT controls the variable length of data bits stream. The maximum length of the stream is limited to 256 by PLC. EDMA can be used to receive data from USART receiver register. Figure 4-4. Manchester decoding Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 42174A−AVR−08/2013 9 The connection from the DALI physical layer interface to the MCU is shown in Table 4-1. Table 4-1. 4.2 The connection from the DALI physical layer interface to the MCU Pin on AVR ATxmega32E5 DALI physical layer interface PD2 DALI_INPUT PD3 DALI_OUTPUT Buck LED Driver Buck converter and linear driver are used to drive LED string. Figure 4-5 shows the diagram of the BUCK LED driver. Figure 4-5. Diagram of BUCK LED driver In the Buck converter, the MCU ATxmega32E5 generates the fixed 1MHz PWM to drive Q1 MOSFET, and the Buck converter output proper voltage for LED string. When MCU detected the voltage at the Drain of the Q2 more than 1V, the MCU will immediately turn off the PWM signal, and then turn off the Q1 MOSFET. So the voltage of the C will turn down until the voltage at the Drain of the Q2 less than 1V and then turn on Q1 MOSFET to provide power for LED. This process is immediately achieved by on-chip hardware modules - linking the Event System Controller module to the Fault Extension module in the ATxmega32E5. In the Buck Converter circuit, the response speed of the Q1 MOSFET should be as fast as possible, and delay time should be as short as possible between the PWM output of the MCU and the drive of the Q1 MOSFET. So the accelerating circuit is needed in the BUCK Converter. The linear driver is used to drive LED string. The MCU ATxmega32E5 generates the fixed 1kHz PWM to drive external N-Ch MOSFET. And Change the duty cycle of the PWM for dimming at the user’s request. The transistor Q3 and sample resistance Rs compose the constant-current circuit for LED. Figure 4-6 shows the current waveform of the LED. Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 10 42174A−AVR−08/2013 Figure 4-6. Current Waveform of the LED Table 4-2. Pin on AVR ATxmega32E5 Buck Circuit PWM PC5 PWM1_V Table 4-3. 4.3 Buck Circuit PWM connection Linear Driver of the LED connection Pin on AVR ATxmega32E5 Linear Driver of the LED PC6 PWM2_L PA0 ILED_AC_IN+ LED Load Pay attention that DO NOT look at the LEDs directly when they are lit. Otherwise LEDs may potentially harm the user’s eyes. 4.4 LED Indicator There is a dual LED (Red and Green) available on the board that can be used to indicate the working condition of the kit. The green LED and the red LED can be individually activated by driving the connected I/O line to VCC. The dual LED can also emit orange light when both red and green LEDs are activated. Table 4-4. 4.5 LED connections. Pin on AVR ATxmega32E5 LED PD4 Green LED PD5 Red LED Temperature Sensor The temperature sensor circuit uses a NTC resistor to sense the temperature of the LED load. Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 11 42174A−AVR−08/2013 Table 4-5. Temperature Sensor connection. Pin on AVR ATxmega32E5 Temperature Sensor PA3 NTC Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 12 42174A−AVR−08/2013 5. Code examples The example application is based on the Atmel Software Framework that is included in Atmel Studio 6. The Atmel Software Framework can also be found as a separate package online at: http://www.atmel.com/tools/avrsoftwareframework.aspx. For more information about the code example, see the application note AT03922: DALI Slave with XMEGA E – Software User’s Guide. Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 13 42174A−AVR−08/2013 6. Revision history Doc. Rev. Date Comments 42174A 08/2013 Initial document revision Atmel AT04022: DALI Slave with XMEGA E Hardware User Guide [APPLICATION NOTE] 14 42174A−AVR−08/2013 Atmel Corporation Atmel Asia Limited Atmel Munich GmbH Atmel Japan G.K. 1600 Technology Drive Unit 01-5 & 16, 19F Business Campus 16F Shin-Osaki Kangyo Building San Jose, CA 95110 BEA Tower, Millennium City 5 Parkring 4 1-6-4 Osaki USA 418 Kwun Tong Road D-85748 Garching b. Munich Shinagawa-ku, Tokyo 141-0032 Tel: (+1)(408) 441-0311 Kwun Tong, Kowloon GERMANY JAPAN Fax: (+1)(408) 487-2600 HONG KONG Tel: (+49) 89-31970-0 Tel: (+81)(3) 6417-0300 www.atmel.com Tel: (+852) 2245-6100 Fax: (+49) 89-3194621 Fax: (+81)(3) 6417-0370 Fax: (+852) 2722-1369 © 2013 Atmel Corporation. All rights reserved. / Rev.: 42174A−AVR−08/2013 Atmel®, Atmel logo and combinations thereof, Enabling Unlimited Possibilities®, AVR®, XMEGA®, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others. 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 THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, 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 AND 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 products 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 products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.