Application Report SPRABR8 – January 2013 DALI Communication on the AC LED Lighting and Communications Developer’s Kit Brett Larimore .................................................................................................................................. ABSTRACT The AC LED Lighting and Communications Developer’s Kit provides a great way to learn and experiment with using a single MCU to accurately control a series of LED strings and efficiently control the power stages needed to make the LEDs work. This application report explains how to use the TMDSIACLEDCOMKIT to communicate via the DALI protocol. The accompanying Code Composer Studio™ project enables the MCU to control the kit’s power stages, LED strings, and serves as a DALI slave. The MCU used to perform all these tasks is a Piccolo™ F28027 microcontroller. Figure 1. TMDSIACLEDCOMKIT Code Composer Studio, Piccolo, C2000 are trademarks of Texas Instruments. All other trademarks are the property of their respective owners. SPRABR8 – January 2013 Submit Documentation Feedback DALI Communication on the AC LED Lighting and Communications Developer’s Kit Copyright © 2013, Texas Instruments Incorporated 1 DALI Summary www.ti.com WARNING This EVM is meant to be operated in a lab environment only and is not considered by TI to be a finished end-product fit for general consumer use. This EVM must be used only by qualified engineers and technicians familiar with risks associated with handling high voltage electrical and mechanical components, systems and subsystems. This equipment operates at voltages and currents that can result in electrical shock, fire hazard or personal injury if not properly handled or applied. Equipment must be used with necessary caution and appropriate safeguards employed to avoid personal injury or property damage. It is your responsibility to confirm that the voltages and isolation requirements are identified and understood, prior to energizing the board and or simulation. When energized, the EVM or components connected to the EVM should not be touched. 1 2 3 Contents DALI Summary .............................................................................................................. 2 Implementation .............................................................................................................. 3 References ................................................................................................................... 8 List of Figures 1 TMDSIACLEDCOMKIT..................................................................................................... 1 2 Manchester Encoding ...................................................................................................... 3 3 DALI Hardware Interface ................................................................................................... 3 4 Major Files in the DALI Project ............................................................................................ 5 5 Example of DALI Host GUI ................................................................................................ 6 6 AC LED Lighting and Communications Board Jumpers and Connectors Diagram ................................ 7 List of Tables 1 1 DALI Commands Supported ............................................................................................... 4 DALI Summary Digital addressable lighting interface (DALI) is a common lighting standard that is used primarily to control lighting in building and home networks. It is often used as a more feature rich alternative to 0 V - 10 V dimmers. DALI has the ability to control up to 64 single units, control 16 groups and create 16 scenes. DALI has a full set of more the 250 commands that can be used to do things from changing dimming values, editing ballast addresses, and querying the status of various ballasts. DALI is defined first in IEC 60929 Annex E and updated in IEC 62386. The major reason for the update was to include support for LED modules and color control. The DALI software given in the application report mentioned in Section 2 shows how to use DALI as specified in IEC 60929 Annex E and performs a subset of the full instruction set. 2 DALI Communication on the AC LED Lighting and Communications Developer’s Kit Copyright © 2013, Texas Instruments Incorporated SPRABR8 – January 2013 Submit Documentation Feedback Implementation www.ti.com The DALI protocol is a half-duplex digital communications interface composed of forward and backward frames. The forward frames consists of one start bit, one address byte, one data byte, and two stop bits. The backward frame (the response) consists of one start bit, one data byte, and two stop bits. DALI uses Manchester encoding, which means that within a bit frame, and low-to-high transition is defined as a “1”, whereas, a high-to-low transition is defined as a “0” (see Figure 2). 0 1 Figure 2. Manchester Encoding 2 Implementation A hardware interface and a Code Composer Studio project were developed to control the LLC resonant stage, control the LED stages, and receive DALI commands on a F28027 device. The driver software for DALI communications is found within the DALI folder of the Code Composer Studio project. The DALI driver and project are meant to be used as an aid in developing a DALI system. This project can be found at www.ti.com/controlsuite: development_kits\IsoACLighting_vX.X\IsoACLighting-F28027-DALI 2.1 Hardware interface Optoisolators and a schmitt-trigger inverter convert the DALI signal into unipolar signals, which can be converted to DALI commands by the Piccolo C2000™ microcontroller (see Figure 3). DAL I 3V3 R8 10K 3V3 3V3 C7 DAL I-TX DAL I+ U5 74AC14 12V0 1 2 3 4 5 6 7 TP3 TB7 Trm-2 R6 DNP U4 ASSR 3 1 2 2 1 4 DAL I- R9 R7 DNP 1A 1Y 2A 2Y 3A 3Y GND 100n Vcc 6A 6Y 5A 5Y 4A 4Y 14 13 12 11 10 9 8 R11 10K 2 DAL I-RX R10 2 TP4 1 4 2 3 10K 2 3V3 U6 SFH615 200R 2 2 DAL I+ DAL I- Figure 3. DALI Hardware Interface The DALI-RX net terminal in Figure 3 connects to GPIO-19 on the F28027 device. GPIO-19 is then configured to be an eCAP peripheral input in the initialization phase of the device startup. The C2000 microcontroller’s eCAP capture unit is able to count cycles between transitions, which allows the C2000 device to translate the Manchester encoding to DALI commands (with the help of software). DALI-TX is attached to GPIO-18, which is used directly as a GPIO. The state of the GPIO is governed by software and the timing is governed by a counter within the eCAP peripheral. Note that the above TX and RX are relative to the fixture controlled by the Piccolo F28027. SPRABR8 – January 2013 Submit Documentation Feedback DALI Communication on the AC LED Lighting and Communications Developer’s Kit Copyright © 2013, Texas Instruments Incorporated 3 Implementation www.ti.com Although the DALI standard recommends allowing incorrect connection of + and -, it has not been done in this version of hardware. To resolve this, one would need to add a diode bridge at the input to U6, such that U6 will only ever see a unipolar input. Although not tried by TI, R6 and R7 could be populated with 10K resistors if the TMDSIACLEDCOMKIT is to be used as a DALI master. This provides the pull-up and pull-downs needed such that the two signals are made differential. 2.2 DALI Software Driver The DALI.c file primarily defines the DALI driver, whereas, the DALI_command.c and DALI_special_command.c define what each specific command should do. The software driver assumes that the C2000 device (and light device) is the slave in a DALI network. The software driver uses the C2000 device’s eCAP peripheral to decode the DALI communication input as well as to give the timing for the DALI transmissions that are needed to answer the master’s query commands. The reason that the eCAP can be used in this way is because the eCAP has two modes of operation. In capture mode, the eCAP triggers on a particular edge and records the timestamp of a given transition. In this way, the eCAP can be used to measure the time between two edges. Knowing that the DALI bit period is about 416 µs long, a Manchester encoded bitstream can be interpreted in 1s and 0s to find the correct DALI command. This DALI bitstream is then translated into changing the actual_level, which is the light output for the DALI slave. The other mode of the eCAP peripheral is APWM mode. In this mode, a certain period is defined and the eCAP peripheral fires an interrupt when the period value is reached. The eCAP peripheral’s timer then restarts at 0. This allows the DALI transmit function to have a known timebase from which to transmit a DALI packet. The C2000 device’s GPIO18 is used as a GPIO to transmit DALI and GPIO19 is configured as an eCAP to receive DALI commands. Table 1. DALI Commands Supported Commands Fully Supported Commands That are Partially Supported (1) Commands Not Supported 0-8 42-47 16-33 64-128 144-155 194-197 237-241 48-63 160-165 224-227 242-251 130-143 252-255 158-159 Commands Not Tested Reserved Commands 129 9 10-15 156-157 228 34-41 Standard Commands 176-193 166-175 198-223 229-236 Special Commands 256-258 259 260-261 264-266 267 269 268 271 270 273-275 262-263 272 (1) 2.3 Commands listed as partially supported do work, but do not store data to non-volatile memory as required. DALI Project Before working with this project, you should have already run and experimented with the IsoACLightingF28027 project found at www.ti.com/controlsuite: development_kits\TMDSIACLEDCOMKIT_v1.0\IsoACLighting-F28027 4 DALI Communication on the AC LED Lighting and Communications Developer’s Kit Copyright © 2013, Texas Instruments Incorporated SPRABR8 – January 2013 Submit Documentation Feedback Implementation www.ti.com That project and its documentation thoroughly explain the TMDSIACLEDCOMKIT and how the F28027 controls the kit’s power stages. The IsoACLighting-F28027-DALI project builds on the knowledge found there. Hardware-wise, the only change that may need to be done to make the DALI project work is that the jumpers at [Main]-J4 and [Main]-J5 both need to be moved and placed to connect positions 2 and 3. The key software difference between the IsoACLighting-F28027 project and the IsoACLighting-F28027DALI project is that the IsoACLighting-Comms.c file has changed and now interfaces and calls functions in the DALI.c file. The Comms.c file also initializes and turns on the resonant stage so that the DALI interface can directly change the brightness of the LED strings without needing to do anything with the LLC resonant stage. This DALI.c file contains the DALI driver. Figure 4 gives some details on the major files used in the DALI project. IsoACLighting-Main.c file IsoACLighting-Comms.c DALI.c DALI_command.c Initializes the power stages Serves as a bridging file between the Main.c file and the DALI.c file DALI-init() - Initializes DALI interrupts Provides support for commands 1-255 Configures the power stage interrupts Initializes the DMX512 system by calling the Comms_Init function in IsoACLighting-Comms.c Runs several periodically called tasks such as Comms_Run() Initializes system variables such as the DALI address that the light should look at Calls DALI_init() in DALI.c Starts up the LLC Resonant power stage after some time has gone passed Calls the DALI_updateBallast() function in DALI.c periodically. DALI_updatesBallast() responsible for updating the brightness of the light. Provides fading functionality as well. Calls the DALI_translate function periodically. DALI_translate() - This function is responsible for taking the information taken from the DALI interrupts and turning these into commands. Calls DALI_command or DALI_special_command depending on the type of command received. DALI_special_command.c Provides support for commands 256-275 Figure 4. Major Files in the DALI Project To run the project and have DALI communications work, you need a DALI master such as the Tridonic DALI-BM RS-232 (with winDIM 4.0) or another DALI master. 1. Run the software and configure the hardware as instructed in build 1 and 2 of the TMDSIACLEDCOMKIT-CCS guide. 2. Attach the USB cable to [M8]-JP1. 3. Ensure that [Main]-J3 is populated. 4. Put jumpers across positions 2 and 3 of [Main]-J4 and [Main]-J5. 5. Attach a DALI master to TB7. Attach the “+” terminal of the master to the “+” terminal of TB7. 6. Setup the DALI master and software as instructed in the master’s user manuals and guides. 7. Connect a 12 V DC supply to [M7]-JP1. 8. Switch [M7]-SW1 to the “Ext” position. 9. Open Code Composer Studio. 10. Import the IsoACLighting-F28027-DALI project found at www.ti.com/controlsuite: development_kits\TMDSIACLEDCOMKIT_vX.X\ IsoACLighting-F28027-DALI 11. Compile the software. 12. Connect and Flash the code by clicking the “bug” button. 13. Reset the processor and then click restart (so that the program starts at the beginning of main) in Code Composer Studio. SPRABR8 – January 2013 Submit Documentation Feedback DALI Communication on the AC LED Lighting and Communications Developer’s Kit Copyright © 2013, Texas Instruments Incorporated 5 Implementation www.ti.com 14. Enable real-time mode and enable continuous refresh of the watch window in Code Composer Studio. 15. Click the green play button to run the software. (Step 16 should be done shortly after this step is complete.) 16. Carefully plug the AC cable into the wall. Once this step is complete, the board will be dangerous to touch. Note that the LLC resonant power supply is automatically set to turn on about 10 seconds after the board is powered. 17. Use the DALI master’s software to communicate brightness information to the kit. By default the ballast has no group or scenes assigned to it. The controlCARD’s LED LD3 should toggle when any DALI command is received by the F28027 MCU. 18. Look at the below variables (and many more) from a Code Composer Studio watch window . Each of these is defined as a character, but should be viewed as an integer in the watch window: (a) actual_level – the brightness value reference given by the DALI (b) Gui_IsetLed[0-5] – the brightness level for each LED string (provided by the actual_level variable). This variable is Q14. (c) short_address – the address of the DALI light; 0xFF (broadcast only) by default (d) min_level – the minimum value that the light can output; set as 90 (e) max_level – the maximum value that the light can output; set as 254 (f) group_0_7 and group_8_f – 8-bit variables in which each bit corresponds to whether the light is in a particular group or not (g) scene – an array that corresponds to the light’s defined value in a particular scene 19. Use the DALI master to turn off the LEDs on the TMDSIACLEDCOMKIT once done. 20. Unplug the power cable from the wall. 21. Wait at least 60 seconds before touching the board. NOTE: This demo can also be run without the external DC/DC power supply connected and without Code Composer Studio. However, it is safer to use the external power supply first. Once the DALI code is Flashed into the device, which is done in the procedure above, you can rerun the above with the following exceptions: remove the DC/DC supply, switch [M7]- SW1 away from “Ext”, and skip steps 10 - and 16. Figure 5. Example of DALI Host GUI 6 DALI Communication on the AC LED Lighting and Communications Developer’s Kit Copyright © 2013, Texas Instruments Incorporated SPRABR8 – January 2013 Submit Documentation Feedback SPRABR8 – January 2013 Submit Documentation Feedback Copyright © 2013, Texas Instruments Incorporated [Main] BS5 Banana Jack for secondary side GND [Main] J16 +12V DC header for fan [Main] BS4 Banana Jack for Resonant output [M7] SW1 – Low Voltage Power Switch [M7] JP1 – 12-15V external power connector [Main] BS6 – Banana Jack for LED Bus input [Main] J2 – 400V-to-12V enable jumper [Main] J20 – 400V-to-18V enable jumper [Main] TB1-TB6 – LED string connectors for LED panel [Main] BS2 – Banana Jack for primary side GND [Main] BS3 – Banana Jack for Resonant Input [Main] TB7 – DALI communications header [Main] BS1 – Banana Jack for PFC output [Main] J4-J7 – Communications selection jumpers [Main] J1 – 100-pin DIMM controlCARD connector [Main] P1 – Universal AC Connector (85-250Vac) [Main] J3 – JTAG TRSTn Jumper [M8] JP1 – USB Connection for onboard emulation www.ti.com Implementation Figure 6. AC LED Lighting and Communications Board Jumpers and Connectors Diagram DALI Communication on the AC LED Lighting and Communications Developer’s Kit 7 References 3 References • • • 8 www.ti.com www.ti.com/controlsuite: – TMDSIACLEDCOMKIT_CCS — provides detailed information on the IsoACLighting project within Code Composer Studio. The document goes through the project in an easy to use labstyle format. development_kits\TMDSIACLEDCOMKIT_vX.X\~Docs\ TMDSIACLEDCOMKIT_CCS.pdf – TMDSIACLEDCOMKIT-HWdevPkg — a folder containing various files related to the hardware on the AC LED Lighting and Communications Developer’s Kit board (schematics, bill of materials, Gerber files, PCB layout, and so forth). development_kits\TMDSIACLEDCOMKIT_vX.X \ ~TMDSIACLEDCOMKIT-HwdevPkg[R4]\ – TMDSIACLEDCOMKIT-HWGuide — presents full documentation on the hardware found on the AC LED Lighting and Communications Developer’s board. development_kits\TMDSIACLEDCOMKIT_vX.X\~Docs\ TMDSIACLEDCOMKIT -HWGuide.pdf Digital Addressable Lighting Interface (DALI) Implementation Using MSP430 Value Line Microcontrollers (SLAA422) DALI Activity Group Manual — Provides an overview of the DALI standard.http://www.daliag.org/c/manual_gb.pdf DALI Communication on the AC LED Lighting and Communications Developer’s Kit Copyright © 2013, Texas Instruments Incorporated SPRABR8 – January 2013 Submit Documentation Feedback IMPORTANT NOTICE Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, enhancements, improvements and other changes to its semiconductor products and services per JESD46, latest issue, and to discontinue any product or service per JESD48, latest issue. Buyers should obtain the latest relevant information before placing orders and should verify that such information is current and complete. All semiconductor products (also referred to herein as “components”) are sold subject to TI’s terms and conditions of sale supplied at the time of order acknowledgment. TI warrants performance of its components to the specifications applicable at the time of sale, in accordance with the warranty in TI’s terms and conditions of sale of semiconductor products. Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty. Except where mandated by applicable law, testing of all parameters of each component is not necessarily performed. TI assumes no liability for applications assistance or the design of Buyers’ products. Buyers are responsible for their products and applications using TI components. To minimize the risks associated with Buyers’ products and applications, Buyers should provide adequate design and operating safeguards. TI does not warrant or represent that any license, either express or implied, is granted under any patent right, copyright, mask work right, or other intellectual property right relating to any combination, machine, or process in which TI components or services are used. Information published by TI regarding third-party products or services does not constitute a license to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of the third party, or a license from TI under the patents or other intellectual property of TI. Reproduction of significant portions of TI information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied by all associated warranties, conditions, limitations, and notices. TI is not responsible or liable for such altered documentation. Information of third parties may be subject to additional restrictions. Resale of TI components or services with statements different from or beyond the parameters stated by TI for that component or service voids all express and any implied warranties for the associated TI component or service and is an unfair and deceptive business practice. TI is not responsible or liable for any such statements. Buyer acknowledges and agrees that it is solely responsible for compliance with all legal, regulatory and safety-related requirements concerning its products, and any use of TI components in its applications, notwithstanding any applications-related information or support that may be provided by TI. Buyer represents and agrees that it has all the necessary expertise to create and implement safeguards which anticipate dangerous consequences of failures, monitor failures and their consequences, lessen the likelihood of failures that might cause harm and take appropriate remedial actions. Buyer will fully indemnify TI and its representatives against any damages arising out of the use of any TI components in safety-critical applications. In some cases, TI components may be promoted specifically to facilitate safety-related applications. With such components, TI’s goal is to help enable customers to design and create their own end-product solutions that meet applicable functional safety standards and requirements. Nonetheless, such components are subject to these terms. No TI components are authorized for use in FDA Class III (or similar life-critical medical equipment) unless authorized officers of the parties have executed a special agreement specifically governing such use. Only those TI components which TI has specifically designated as military grade or “enhanced plastic” are designed and intended for use in military/aerospace applications or environments. Buyer acknowledges and agrees that any military or aerospace use of TI components which have not been so designated is solely at the Buyer's risk, and that Buyer is solely responsible for compliance with all legal and regulatory requirements in connection with such use. TI has specifically designated certain components as meeting ISO/TS16949 requirements, mainly for automotive use. In any case of use of non-designated products, TI will not be responsible for any failure to meet ISO/TS16949. Products Applications Audio www.ti.com/audio Automotive and Transportation www.ti.com/automotive Amplifiers amplifier.ti.com Communications and Telecom www.ti.com/communications Data Converters dataconverter.ti.com Computers and Peripherals www.ti.com/computers DLP® Products www.dlp.com Consumer Electronics www.ti.com/consumer-apps DSP dsp.ti.com Energy and Lighting www.ti.com/energy Clocks and Timers www.ti.com/clocks Industrial www.ti.com/industrial Interface interface.ti.com Medical www.ti.com/medical Logic logic.ti.com Security www.ti.com/security Power Mgmt power.ti.com Space, Avionics and Defense www.ti.com/space-avionics-defense Microcontrollers microcontroller.ti.com Video and Imaging www.ti.com/video RFID www.ti-rfid.com OMAP Applications Processors www.ti.com/omap TI E2E Community e2e.ti.com Wireless Connectivity www.ti.com/wirelessconnectivity Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265 Copyright © 2013, Texas Instruments Incorporated