XC800 Family AP08133 DALI Control Device using XC836 DALI Board Application Note V1.1, 2012-10 Microcontrollers Edition 2012-10 Published by Infineon Technologies AG 81726 Munich, Germany © 2012 Infineon Technologies AG All Rights Reserved. LEGAL DISCLAIMER THE INFORMATION GIVEN IN THIS APPLICATION NOTE IS GIVEN AS A HINT FOR THE IMPLEMENTATION OF THE INFINEON TECHNOLOGIES COMPONENT ONLY AND SHALL NOT BE REGARDED AS ANY DESCRIPTION OR WARRANTY OF A CERTAIN FUNCTIONALITY, CONDITION OR QUALITY OF THE INFINEON TECHNOLOGIES COMPONENT. THE RECIPIENT OF THIS APPLICATION NOTE MUST VERIFY ANY FUNCTION DESCRIBED HEREIN IN THE REAL APPLICATION. INFINEON TECHNOLOGIES HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND LIABILITIES OF ANY KIND (INCLUDING WITHOUT LIMITATION WARRANTIES OF NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OF ANY THIRD PARTY) WITH RESPECT TO ANY AND ALL INFORMATION GIVEN IN THIS APPLICATION NOTE. Information For further information on technology, delivery terms and conditions and prices, please contact the nearest Infineon Technologies Office (www.infineon.com). Warnings Due to technical requirements, components may contain dangerous substances. For information on the types in question, please contact the nearest Infineon Technologies Office. Infineon Technologies components may be used in life-support devices or systems only with the express written approval of Infineon Technologies, if a failure of such components can reasonably be expected to cause the failure of that life-support device or system or to affect the safety or effectiveness of that device or system. Life support devices or systems are intended to be implanted in the human body or to support and/or maintain and sustain and/or protect human life. If they fail, it is reasonable to assume that the health of the user or other persons may be endangered. AP08133 DALI Control Device using XC836 DALI Board XC83x Revision History: V1.1 2012-10 Previous Version(s): 1.0 Page Subjects (major changes since last revision) - Updated DALI Control Board Schematic - Part 1; Changed R5 from 1K to 560R. Trademarks We Listen to Your Comments Is there any information in this document that you feel is wrong, unclear or missing? Your feedback will help us to continuously improve the quality of this document. Please send your proposal (including a reference to this document) to: [email protected] Application Note 3 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board Table of Contents Table of Contents 1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2 Hardware Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3 3.1 3.1.1 3.1.2 3.1.3 3.2 3.2.1 3.2.2 DALI Control Device Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DALI Protocol Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . GPIO for DALI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Timer 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Timer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Application Protocol Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . GPIO for User Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Real-Time Clock (RTC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 11 11 12 13 14 14 15 4 4.1 4.2 4.3 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Supported Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Customising Automated Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Software Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 16 17 18 5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 6 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 APPENDIX - DALI Control Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Application Note 4 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board Overview 1 Overview Digital Addressable Lighting Interface (DALI) is a communication protocol for lighting control in buildings. The interface was first described in Annex E, IEC60929 standard for fluorescent lamp ballast. Subsequently, it was updated to the new standard IEC-62386, to include other lighting devices, such as LED, HID, and so on. The complete standard for control interface of electronic control gears was published in June 2009. The standard for lighting control devices is scheduled to be published in 2012. DALI requires only a pair of wires to form the bus for communication to all devices on a single DALI network. Each piece of operating equipment with a DALI interface can be communicated with, over DALI, individually. Using a bidirectional data exchange, a DALI controller can query and set the status of each connected lighting device. As a standalone system, DALI can be operated with a maximum of 64 devices. Alternatively, DALI can be used as a subsystem via DALI gateways for connection to building management systems. Grouped System : Brightness control within large open- plan office, lecture halls or conference rooms . DALI can provide zoned or localised control of lighting. Control could be offered through infra-red remote control or a software control with GUI support , or used together as an easy configuration tool to group loads together. Offering flexibility in customised lighting. DALI Control Device(s) (e.g. Control Panel, Remote Controller , software control with GUI support) DALI Bus DALI Power Supply DALI Control Gear (e.g. Lamp) DALI Control Gear (e.g. Lamp) Can connect up to 64 DALI Control Gear Complex System : Multiple DALI systems can be connected together utilising gateways to building management systems . Software programs offer more sophisticated programming functionality for grouped systems , such as scenesetting , timeclock , and partition control. Building Management System Gateway DALI Control Device(s) (e.g. Control Panel, Remote Controller , software control with GUI support) Gateway Gateway Gateway DALI Systems DALI Systems DALI Systems DALI Bus DALI Power Supply DALI Control Gear (e.g. Lamp) DALI Control Gear (e.g. Lamp) Can connect up to 64 DALI Control Gear Figure 1 DALI system types Application Note 5 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board Overview XC83 x DALI Slave Boa rd XC8 3x DAL I Slave Board XC83x SW St ack XC83x SW St ack DAL I PHY DAL I PHY Powe r Suppl y XC83x DALI Ma st e r Boa rd XC8 3x SW St ack Figure 2 DALI BUS DALI PHY Block Diagram for DALI Control Device and Control Gear An example solution for a DALI control device1) has been created using the Infineon XC836 DALI Board. This solution makes use of the available DIP switch on the XC836 DALI Board (KIT_DALI_RGB_XC836_DKV1) to send user commands to the connected DALI control gear. This document describes how the DALI control device software has been constructed and demonstrates the supported software functions. The following items are required for use with this application note: • 2 sets of XC836 DALI Board (KIT_DALI_RGB_XC836_DKV1) including DALI Control Gear Software Stack (AP08102) 1) IEC-62386 Part 300 for Control Devices is scheduled to be published in September 2012. This application example is targeted at providing a method for the user to send out DALI commands frames. Application Note 6 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board Hardware Setup 2 Hardware Setup This section describes the hardware setup required for this example application. The control device, which makes use of the XC836 DALI Board, has a standard 4 position DIP switch for user command decoding. Details on the DALI control gear software and setup can be found in AP08102 DALI Control Gear Software Stack. DALI Power Supply 1 5 V sup pl y wi th 1 0 0 Ω r e si sto r s to po wer up th e DA L I bu s l i n e DA L I Con tr o l V i a DIP S wi tch DALI Master Board (Control Device ) DALI Slave Board (Control Gear) Co mp r i si n g o f: - K IT_ DA LI_RGB _ X C 8 3 6_DK V 1 Compr i sin g o f: - K IT _DA L I _RGB _ X C8 3 6 _ DK V 1 - DA LI Con tr o l V i a DIP S wi tch Figure 3 Hardware Setup for Infineon Control Device and Control Gear The hardware setup for control device and control gear can be setup using the following steps: 1. Connect the DAP MiniWiggler to the DALI Control board and download the generated hexfile using XC800 FLOAD in DAVEBENCHTM or KEIL UVision4. (Control Device file: DALIKIT_Master.hex, Control Gear file: AP08102_v1_2_Slave.hex). 2. To supply power for the DALI bus, connect 100Ω resistors in series to each terminal of a power supply unit supplying 15VDC. This supplies the DALI bus for the DALI network devices. 3. Connect the DALI Control Device (Master) and Control Gear (Slave) to the DALI bus. This completes the DALI setup to control the device! Application Note 7 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board Hardware Setup Power Conn Connections for programming the DALI Control Gear using a DAP MINIWIGGLER 5V Supply (Connector X 3) 1 2 X3 VCC GND VCC GND Programming Pin 3 (Connector X 2) 2 1 X2 3 4 SPD 2 PC KIT_DAP_MINIWIGGLER_USB (KIT_DALI_RGB_XC836_DKV1) X3 X2 KIT_DAP_MINWIGGLER_USB KIT_DALI_RGB_XC836_DKV1 Figure 4 Programming the DALI Control Board using the DAP MiniWiggler DALI BUS Connect to DALI BUS 2 1 X1 (KIT_DALI_RGB_XC836_DKV1) DALI BUS Connector (Connector X 1) X1 DALI PHY DALI Control Board (KIT_DALI_RGB_XC836_DKV1) DALI PHY Figure 5 XC836 DALI Control Board Application Note 8 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board Hardware Setup POWER SUPPLY UNIT +15V 100Ω Connect 100Ω resistors in series to the Power supply terminals GND 100 Ω DALI BUS DALI Control Device DALI Control Device DALI Power Supply 1 5 V su p pl y with 1 0 0Ω r e si sto r s to p o we r up th e DAL I b u s li n e DA LI Co n tr o l Vi a DIP S witch DALI Master Board (Control Device ) Comp r isi ng of: - KIT_ DAL I_RGB _ X C 8 3 6_DK V1 DALI Slave Board (Control Gear) Co mp r i sin g o f: - K IT _DA L I _ RGB _X C83 6 _ DK V 1 - DA L I Co n tr o l V ia DIP S wi tch Figure 6 DALI Network Hardware Connection Application Note 9 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board DALI Control Device Software 3 DALI Control Device Software This section describes the program operational flow and the software structure used for developing this example solution. This operation is presented in Figure 7. MAIN PROGRAM FLOW Using the Real Time Clock (RTC) module on the XC836, the inputs from the DIP Switch are evaluated once every 500ms. START Once the evaluation is completed , the RTC is restarted . This triggers the evaluation for any new user inputs on the next 500ms event. RTC event occurs On an RTC event, stop the RTC and check for the user input on the DIP switch. Check for Port Status Any changes? Yes Address Cmd? No No Yes Update Address Execute DALI Commands Yes Start RTC Once the commands are executed, restart the RTC and wait for next RTC event. Wait Figure 7 Main Program Flow For code implementation, we have divided the software into two main layers: • • DALI protocol layer – Supports the translation of user commands into the desired DALI format to be sent through the DALI bus. Application code layer – Evaluates the user commands through the inputs from the DIP Switch on the XC836 DALI Board once every 500ms. The following XC83x device modules are required for the implementation: • • • • • GPIO for DALI Timer 0 Timer 2 GPIO for User Input Real-Time Clock (RTC) Note: Configuration is performed via Infineon’s Technologies’ free tool DAvETM 2, which generate the skeleton code based on the configurations set. The screen shots that follow are taken from DAvETM 2. Application Note 10 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board DALI Control Device Software 3.1 DALI Protocol Layer In the control device, the DALI protocol layer provides the translation of user commands into the desired DALI format to be sent and received through the DALI bus. For our example, the DALI bus chosen is P0.4 (Rxd) and P0.5 (Txd). 3.1.1 GPIO for DALI Port 0.5 and Port 0.4 is used to transmit and receive DALI frames respectively. Figure 8 Port 0 DAvETM 2 Configurations Application Note 11 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board DALI Control Device Software 3.1.2 Timer 0 Timer 0 module is used to send DALI command frames. Mode 1: 16 bit timer is selected for this purpose. Figure 9 Timer 0 DAvETM 2 Configurations Application Note 12 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board DALI Control Device Software 3.1.3 Timer 2 Timer 2 module is selected for reception of DALI command frames. The 16 bit timer function capture mode is selected. Timer 2 is started on a falling edge on T2EX input. Figure 10 Timer 2 DAvETM 2 Configurations Application Note 13 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board DALI Control Device Software 3.2 Application Protocol Layer The application layer provides the user interface control through the DIP switch on the XC836 DALI board. By making use of the real-time clock, the user input is evaluated once every 500ms. 3.2.1 GPIO for User Input Port 2 [0:3] are used to read in the user input from the DIP switch. Note: Debouncing is not required for this application as the inputs are read once every 500ms. However, if the user’s application requires more frequent assessments, external debouncing circuits or software debouncing methods, may be added for input consistency. Figure 11 Port 2 DAvETM 2 Configurations Application Note 14 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board DALI Control Device Software 3.2.2 Real-Time Clock (RTC) The RTC module is used to support sending DALI commands after a user defined time period. For this purpose, “Mode 1: Periodic wake-up mode with 75KHz oscillator clock” is selected for the RTC. Interrupt on compare counter match (ECRTC) is enabled, where a timer match of 500ms is selected. This is used as a time base for evaluating the DIP Switch inputs. The user can also configure the time base towards minute, hour or day timer matches. Figure 12 RTC DAvETM 2 Configurations Application Note 15 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board Getting Started 4 Getting Started This section provides an overview on how the user can use this application. Information on the software package contents and customization details are also included. 4.1 Supported Commands This section describes the usage of the DALI Control Device, which has a 4 position DIP switch used for user command selection. Figure 13 shows the user command selection available on the DIP switch. 1 Bit 2 2 Bit 1 3 Bit 0 4 ON Bit 3 S1 S1 1 1 ON Bit[3] = 1: Set Address Instruction - where DALI address is read from Bit[2:0] of DIP switch Bit[2:0] Bit[2:0] Bit[2:0] Bit[2:0] Bit[2:0] = 0; Broadcast address = 1; Short address #1 = 2; Short address #2 = 3; Short address #3 = Others ; Short address #0 DALI Control Device (KIT_DALI_RGB_XC836_DKV1) 0 ON 1 Bit[3] = 0: Set Command Instruction - where the selected DALI command is read from Bit [2:0] of DIP switch USR_CMD4 >>Bit[2:0] = 4 3 3 OFF Command assigned 2 2 USR_CMD0 >> Bit[2:0] = 0 ON Command assigned 4 4 S1 S1 3 3 USR_CMD2 >> Bit[2:0] = 2 USR_CMD6 >> Bit[2:0] = 6 4 4 USR_CMD1 >> Bit[2:0] = 1 USR_CMD5 >> Bit[2:0] = 5 S1 UP Command assigned S1 DOWN Command assigned USR_CMD7 >> Bit[2:0] = 7 2 2 USR_CMD3 >> Bit[2:0] = 3 GOTO SCENE 1 Command assigned 3 3 GOTO SCENE 0 Command assigned 4 4 S1 Figure 13 Toggling this activates this command 2 2 Toggling this activates this command S1 Control Device DIP Switch Commands Application Note 16 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board Getting Started 4.2 Customising Automated Commands DALI functions are assigned to the DIP Switch controls via a user configuration file (config.h). Table 1 shows the supported DALI commands and Table 2 gives the customisation possibility to the command assignments. Table 1 Supported DALI commands Supported Commands Description DALI_OFF Turns light off DALI_DIM_UP Set lighting level up by 1 level DALI_DIM_DOWN Set lighting level down by 1 level DALI_STEP_UP Fades lighting level up for 200ms DALI_STEP_DOWN Fades lighting level down for 200ms DALI_RECALL_MIN Sets connected lighting device level to minimum level DALI_RECALL_MAX Sets connected lighting device level to maximum supported level DALI_STEP_DOWN_OFF Set lighting level down by 1 level. If already at minimum, turn lights off. DALI_ON_AND_STEP_UP Turns on connected lighting device. If already on, set the arc power level up one level. DALI_GOTO_SCENE_XX This is a Scene Selection commands. Choosing this enables device for user configured Scene XX, where XX represents 00 to 15. Table 2 Customising the commands DALI Commands Description Customising the DALI Command list In the file: config.H, the timed command to be executed can be configured by the user at compile time. A list of supported DALI commands can be referenced from Table 1. • To add supported address: #define USR_ADDX <ADDRESS> • To add supported DALI command: #define USR_CMDX <DALI COMMAND> where DALI commands can be referenced from Table 1. Default command selection for file: config.H #define USR_ADD0 BROADCAST_ADDR #define USR_ADD1 SHORT_ADDR1 #define USR_ADD2 SHORT_ADDR2 #define USR_ADD3 SHORT_ADDR3 #define USR_ADD4 SHORT_ADDR0 #define USR_ADD5 SHORT_ADDR0 #define USR_ADD6 SHORT_ADDR0 #define USR_ADD7 SHORT_ADDR0 #define USR_CMD0 DALI_OFF #define USR_CMD1 DALI_DIM_UP #define USR_CMD2 DALI_DIM_DOWN #define USR_CMD3 DALI_GOTO_SCENE_00 #define USR_CMD4 DALI_ON_AND_STEP_UP #define USR_CMD5 DALI_DIM_UP #define USR_CMD6 DALI_DIM_DOWN #define USR_CMD7 DALI_GOTO_SCENE_01 Application Note 17 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board Getting Started 4.3 Software Package The file description for the software package is documented in Table 3 and Table 4. Table 3 Source files description Filename Description DALIKIT_Master.dav DAvE project DALIKIT_Master.uvproj Uvision project MAIN.c Performs main program initialisation IO.c Performs GPIO module initialisation RTC.c Performs RTC module initialisation T01.c Performs Timer 0 module initialisation for application control functions inclusive of DALI frame transmission activities. T2.c Performs Timer 2 module initialisation for DALI command interpreter functions inclusive of DALI frame reception activities. START_XC.A51 Start up code for XC8xx device. This is part of the C51 Compiler package. INT.c Performs Interrupt functions initialisation BOOTROM_ADDR.A51 Library address for bootrom user routines SHARED_INT.c Shared interrupts; LEDTS and RTC interrupt handling sections; Table 4 Header files description Filename Description MAIN.h SFR Header file for XC836 Microcontroller IO.h GPIO function prototypes and macros RTC.h RTC prototypes and macros T01.h Timer 01 function prototypes and macros T2.h Timer 2 function prototypes and macros INT.h Interrupt function prototypes and macros SHARED_INT.h Shared interrupt function prototypes and macros config.h Definitions of Address and DALI command assignments Application Note 18 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board Summary 5 Summary Infineon microcontrollers provides a great deal of flexibility for the creation of a wide variety of robust applications for the users. This application note demonstrates the ease of creating a DALI control device, using the general purpose port module and real-time clock module in the XC836. With the given instructions, the user can customise this solution to their application, making it easy to use in any DALI network. 6 References [1] IEC 62386 Digital addressable lighting interface; Part 101: General requirements - System (Edition 1.0, 200906) [2] IEC 62386 Digital addressable lighting interface; Part 102: General requirements - Control gear (Edition 1.0, 2009-06) [3] AP08102 DALI Control Gear Software Stack [4] XC836 User Manual 1.0 Application Note 19 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board References APPENDIX - DALI Control Board Schematic for KIT_DALI_RGB_XC836_DKV1 Figure 14 DALI Control Board Schematic - Part 1 Application Note 20 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board References Figure 15 DALI Control Board Schematic - Part 2 Application Note 21 V1.1, 2012-10 AP08133 DALI Control Device using XC836 DALI Board References X1 DALI Control Board (KIT_DALI_RGB_XC836_DKV1) FRONT Figure 16 BACK DALI Control Board Layout Application Note 22 V1.1, 2012-10 w w w . i n f i n e o n . c o m Published by Infineon Technologies AG AP08133