You are on page 1of 15

Implementing DALI Receiver using EZ-Color Intelligent Lighting Controllers

AN47615
Author: Kaushik Subramanian Associated Project: Yes Associated Part Family: CY8CLEDxx Software Version: PSoC Designer 4.4 Associated Application Notes: None

Application Note Abstract


This application note discusses the implementation of a DALI Receiver system using Cypress EZ-ColorTM Intelligent Lighting controllers. A brief introduction to the DALI protocol with the system block diagram is followed by an overview of the DALI command library and its implementation in EZ-Color. An example of a DALI PHY circuit that can be used to interface EZ-Color with the DALI bus is also provided.

Introduction
The impact of digital revolution in the lighting industry is recent, yet rapid. Many lighting fixtures today with controllable features need sophisticated control interface than simple on/off switches. This has propelled the arrival of digital lighting control interfaces such as DMX512 and DALI (Digital Addressable Lighting Interface). While DMX512 has evolved to become a lighting control standard in the entertainment industry (stage lighting), DALI focuses on building lighting applications. This application note presents an overview of the DALI protocol and describes the implementation of the DALI Receiver using Cypress EZ-ColorTM Intelligent Lighting controllers. Figure 1. CY3261A EZ-Color Demonstration Board

Cypress EZ-Color devices provide a programmable platform to implement intelligent lighting management functions and digital lighting control interfaces. This includes applications with tunable white light, temperature, and optical feedback for improved color accuracy, and digital lighting control interfaces such as DMX512 and DALI. Figure 1 shows the CY3261A EZ-Color demonstration board. This board enables you to evaluate the EZ-Color platform to implement lighting control and advanced lighting management functions. Figure 2 shows the implementation of DALI Receiver on this platform. Figure 2. DALI Receiver using the Cy3261A EZ-Color Demonstration Board

December 3, 2008

Document No. 001-47615 Rev. **

[+] Feedback

AN47615

DALI Receiver using EZ-Color


There are many benefits in using EZ-Color platform to implement DALI Receiver for control gears. Some of the key advantages in using this solution are:

Integration with Cypresss lighting solutions IP: Cypresss DALI Receiver is easily integrated with other EZ-Color IP such as LED Color Control (in multi-LED systems) and tunable white light solutions with accurate color temperature control. Cypresss DALI Receiver decodes data on the DALI bus based on the interrupts generated when input data is detected. This removes the need for continuous bus polling and results in efficient design in system timing and power. The EZ-Color platform also provides programmable analog and digital resources that can be used to implement feedback systems based on temperature sensing and optical sensing (color, ambient light, and so on). Cypresss DALI Receiver solution currently supports commands listed in IEC 62386: Part 102. However, the system can be easily extended to support more commands for subsystems such as LED modules (IEC 62386: Part 207), Sequencers (IEC 62386: Part 210), or Color Controllers (IEC 62386: Part 208).

IEC 62386: Part 203 Discharge Lamps IEC 62386: Part 204 Low-voltage Halogen Lamps IEC 62386: Part 205 Supply Voltage Converter IEC 62386: Part 206 Digital to DC Voltage Conversion IEC 62386: Part 207 LED Modules IEC 62386: Part 208 Switching Function IEC 62386: Part 209 Color Control IEC 62386: Part 2010 Sequencer

DALI Applications and Advantages


DALI is primarily applied in commercial building lighting control such as in public and private offices, schools, museums, and others. DALI is suitable for:

Energy management applications such as scheduled automatic shutoff to meet energy codes and daylight harvesting. Supermarkets, retail spaces, and similar applications with frequent merchandise or layout changes. Small and open offices where users are given dimming control over their own lighting as part of a strategy to increase worker satisfaction. Conference rooms, classrooms, training rooms, and similar spaces that need different lighting scenes for multiple types of use. Larger installations with multiple buildings, where feedback on lighting component status helps in efficient lighting maintenance.

DALI Standard
DALI is a royalty free, interoperable open standard for digital lighting that is currently drafted as IEC Specification 62386. It is a command based protocol with many commands used to control electronic ballasts, that is, electronic devices that control lighting fixtures. These ballasts are also referred to as "DALI ballasts". Two key characteristics of all DALI ballasts are:

Digital: Ballasts can decode and respond to digital data. Addressable: There can be several ballasts on the same lighting network that are individually addressed and controlled.

DALI System
The DALI system uses a two-wire bus based communication medium. Each DALI Loop supports a maximum of 64 Control Devices or DALI Masters and a maximum of 64 Control Gears or DALI Slaves. Typical control devices include switches, scene controllers, dimmers, occupancy sensors, and communication modules that link the DALI bus to other networks such as Ethernet. Examples of control gears are ballasts that drive lighting fixtures such as fluorescent lamps, LED lamps, or halogen lamps. Figure 3. DALI Loop

The DALI standard is described in the following three key specifications from IEC:

IEC 62386: Part 101 DALI System IEC 62386: Part 102 DALI Slave (Control Gear) IEC 62386: Part 103 DALI Master (Control Device)

In addition to these specifications, DALI also addresses particular requirements for different types of DALI slaves such as fluorescent lamps, LED lamps, supply voltage controllers, and others. Some examples are:

IEC 62386: Part 201 Fluorescent Lamps IEC 62386: Part 202 Emergency Lighting
Document No. 001-47615 Rev. ** 2

December 3, 2008

[+] Feedback

AN47615

Figure 3 on page 2 shows a simple DALI Loop configuration with 64 slaves (control gears) and one dimming controller (control device). Each slave on the network is assigned a unique individual address. The dimmer sends commands to the ballasts to regulate the lamp intensity. DALI also supports commands for several query functions that retrieve status information from the ballasts. DALI employs bidirectional half-duplex asynchronous serial data transmission between nodes on the DALI bus with a data rate of 1200 bits per second. The digital signals on the two-wire bus are Manchester Coded with a steady voltage difference between the wires in the range of 9.5V to 22.5V (typically 16V). Voltage difference above 9.5V represents logic high or 1, while a voltage difference below 6.5V represents logic low or 0. Figure 4 shows the voltage levels of signals on the DALI bus. The DALI bus is powered by a DALI power supply unit that allows a maximum current input of 250 mA on the bus. Each device connected on the bus can consume a maximum of 2 mA. This feature enables the presence of low power sensors on the network that may not require a separate high voltage power line. Figure 4. DALI Bus Signal Voltage Levels

DALI Addressing
The DALI protocol provides three different addressing schemes to address DALI slaves on the network.

Individual Addressing
Ballasts may be assigned a unique individual address. There are 64 possible addresses (0-63). No two ballasts can have the same address on a DALI loop. Sending an Individual Address Command sends commands on a DALI loop to specific ballasts. The ballast with this address responds to the Individual Address command. An individual address can be:

Short Address: An address between 0-63 that may be assigned to a device and normally used in individual Address command. Random Address: This is a sequentially assigned number for a device on the DALI bus, without respect to the physical location, and is typically used during bus configuration. This is a 3-byte address.

Group Addressing
A group is a collection of addresses. Using group addressing, the DALI Master can control more than one device simultaneously. A DALI slave can belong to a maximum of 16 groups at once.

Broadcast Addressing
This scheme allows the controller to select and control all devices on the network. All DALI slaves must execute commands sent with a broadcast address.

DALI Command Library


The DALI protocol consists of specifications with requirements for DALI Masters (control devices) and DALI Slaves (control gears). In addition, there are separate subspecifications with particular requirements for different lighting fixtures such as halogen lamps, LED lamps, fluorescent lamps and other DALI slaves such as voltage controllers and sequencers. There are three broad types of commands: The control gears (DALI slaves) respond to the control devices (DALI master) by setting the level high or low. A high level is simply achieved by not interfering with the default high level on the bus set by the master. A low level is obtained by forcing a short circuit across the wires. This is possible because the DALI standard mandates the maximum current supply on the bus as 250 mA. Control Device Communication Commands. These commands are used for communication between two or more DALI Masters in a network with multiple DALI Masters. These commands are listed in IEC 62386: Part 101. Control Gear Generic Control Commands. These commands are used for communication between a DALI Master and one or more DALI slaves on the network. These commands are listed in IEC 62386: Part 102, which also describes the general requirements common to all DALI Slaves. Control Gear Specific Control Commands. These commands are used for communication between a DALI Master and specific types of DALI slaves on the network. The commands control properties that are specific to a particular lighting fixture such as LED lamps or fluorescent
December 3, 2008 Document No. 001-47615 Rev. ** 3

[+] Feedback

AN47615

lamps. These are listed in Parts 2xx of the IEC 62386. For example, the commands listed in Part 207 are used when the DALI Master controls specific properties of DALI enabled LED lamps on the network. Table 3 on page 14 lists the control gear generic control commands that are found in IEC 62386: Part 102. Cypresss DALI Receiver Solution implements this library with a few exceptions.

Physical Addressing
This method is easier than the Random Addressing mechanism described in the previous section. The master broadcasts an INITIALIZE command followed by a PHYSICAL SELECTION command that puts all the DALI ballasts in the physical addressing method. The user then physically selects the DALI ballast using jumpers, dip switches, or buttons that physically activate DALI ballast. When the ballast is physically selected, it responds to the masters queries and the master can then assign a new short address. The DALI ballasts on the bus must be physically selected in a sequential manner and then assigned short addresses.

DALI Bus Setup


The DALI bus is defined as an auto-setting bus because the ballast addresses are assigned or modified by the DALI Master, and the system does not necessarily require hardware methods (jumpers or dip-switches) to set the ballast's short address. Typically, a new ballast on the DALI bus has no short address and this is assigned by the DALI Master. A short address is assigned to a DALI Slave (control gear) using a startup sequence in two different methods:

DALI Packet Structure


The DALI protocol uses 3 types of packets.

Forward Packet Type I


This packet structure is used for communication between two or more DALI masters when there are multiple masters on the bus. The packet consists of:

Random Addressing Physical Addressing

Random Addressing
Initially, all DALI slaves (DALI ballasts) on the bus have no short address (short address = 255 represents no short address assigned). The random address of a DALI slave is 3 bytes long (factory programmed) and the probability of two different ballasts on the bus with the same random address is very low. The startup sequence allows the DALI Master to determine the random addresses of all DALI ballasts present on the bus and assign a unique short address to each such slave. The master broadcasts a SEARCH ADDRESS (also 3 bytes long) to all DALI slaves on the bus. Then the master queries the bus with a COMPARE command. If a ballast with a random address less than or equal to the search address is present on the bus, it responds to the COMPARE command. All other ballasts remain idle. Based on this procedure, the master executes an optimized search algorithm and determines if there are any DALI ballasts with the chosen Search Address. If no such ballast is found, the DALI Master moves on to another Search Address. If DALI ballast with its random address equal to the DALI Masters Search Address is found, then this ballast is selected and assigned a unique short address (0-63). This ballast is then excluded from the startup sequence using a WITHDRAW command, and the algorithm continues to assign short addresses to the remaining DALI slaves.

1 start bit 8 bits of address 16 bits of data (commands or data) 2 stop bits

Forward Packet Type II


This packet structure is used by the DALI Master to communicate with one or more DALI Slaves on the bus. These packets are commonly used by DALI controllers such as dimmers or switches to control lighting fixtures and other devices on the DALI bus. The packet consists of:

1 start bit 8 bits of address 8 bits of data (command or data) 2 stop bits

December 3, 2008

Document No. 001-47615 Rev. **

[+] Feedback

AN47615

Backward Packet
This packet structure is used by the DALI slave to respond to the DALI master when queried for data. The DALI protocol supports several commands that retrieve status information from DALI slaves. The Backward packet structure is used during this process. The packet consists of:

The key features of this solution are:

Decode and execute DALI commands to support DALI control gears defined in IEC 62386: Part 102. Direct Arc Power Control (to directly set the dimming value of the ballast) and Indirect Control commands are supported. Supports storage of DALI control gear characteristic parameters such as minimum light output level and maximum light output level. Supports physical, automatic, and group addressing modes. Supports Forward Packet Type II and Backward Packet structures that enable communication between DALI master and DALI slaves on the bus. Integrates control for up to 4 DALI slaves, which enables optimal design of RGB based ballasts.


1. 2. 3.

1 start bit 8 bits of data 2 stop bits

Notes Start and stop bits are logic 1. Each packet is sent continuously without a time lag between successive bytes. The baud rate is 1200 bits per second with Manchester coding.

DALI Receiver using EZ-Color


Cypress EZ-Color Intelligent Lighting controllers provide a powerful programmable platform that integrates the DALI Receiver with other EZ-Color lighting solutions IP. Cypresss DALI Receiver IP is used to control DALI control gears on the bus by decoding and executing DALI commands for dimming control and lighting management.

The Cypress DALI solution is provided as a set of library files and functions that implement DALI Receiver on the EZ-Color platform using Cypress PSoC DesignerTM environment. PSoC Designer is a development tool (available free for download from www.cypress.com) that enables you to configure, customize, and efficiently manage the programmable resources in the EZ-Color device family. Along with PSoC ProgrammerTM, the development environment helps you to write related firmware, compile, and build projects that are then programmed into the EZ-Color devices.

Figure 5. EZ-Color System Solution for DALI Receiver

DALI Enabled Buttons/Slider for on/ off and dimming

DALI BUS

DALI Interface Board

USB to DALI Bridge

USB

DALI Receiver

DALI Power Supply

LED Ballasts

December 3, 2008

Document No. 001-47615 Rev. **

[+] Feedback

AN47615

The Cypress DALI library is written in C and compiled using ImageCraft compiler. The DALI Receiver is implemented using additional hardware resources in EZ-Color such as counters, timers, and EEPROM. While the EZ-Color platform is designed to work with 5V and 3.3V systems, the DALI bus operates at higher voltages, typically 16V. As a result, an external DALI interface board is necessary for the DALI Receiver to communicate with other devices on the bus. Figure 5 on page 5 shows a system solution for the DALI Receiver using EZ-Color. The following commands in IEC 62386 are not supported now. Table 1. Unsupported Commands in IEC 62386
Code 09 81 C5 E0 - FE FF Description Enable DAPC sequence Enable write memory Read memory location Application extended commands Query extended version number

The Cypress DALI library employs the method described in the previous section with frame-synchronization, using an additional 8-bit timer. Its period is fixed and it is greater than bit time (833 s). This new timer is used to measure the time elapsed from one falling edge to the next one. If this time is greater than a half bit, it is necessary to reload the main timer with a period of bit duration (so after bit duration there is a new interrupt and the bus is sampled). Otherwise, it is necessary to reload the main timer with a period of bit time. Note that even if the library does not receive a falling edge, the main timer samples the DALI bus every 1-bit time. The end of the packet is determined when no falling edges are received in two-bit time. The library can control up to 4 ballasts simultaneously. The constant TOT_NUM_LED represents the number of ballasts controlled on the DALI bus (from 1 to 4). This feature is useful when the library is installed in a device with RGB light control.

Cypress DALI Library APIs Fundamental APIs

void DALI_Init(void) Initialize DALI library. char DALI_ManageInterface (unsigned char *level) This function must be called in the main loop every 6 ms. The function returns TRUE if LEDs' intensity must be changed, FALSE otherwise. If the value returned is TRUE, the new values for LEDs' intensity are stored in the array indicated by the pointer passed to the function. Note that the dimension of the array must be equal to the number of channels (N_TOT_LED define constant in daliconst.h)

Manchester Decoding
In the DALI protocol, bits are transmitted with bi-phase encoding. When transmitting logic high or 1, the master pulls the bus to a low level (approximately 0V) for half bitperiod and then pulls the bus to a high level for the second half. So if the receiver reads the bit after the first half, it reads the right bit. The DALI bus is usually high and the first bit (start bit) is always 1. As a result, the first change in level is a falling edge on the bus. This falling edge can be used to start an 8-bit timer with a period of bit time. When the timer generates an overflow interrupt, the DALI Receiver reads the bus and this is the start bit. In the interrupt service routine the timer period is forced to 1 bit time. Similarly, after a starting offset of bit time, the library can read the second half of the bit (the real bit) exactly in the middle.

Optional APIs

void DALI_SetInterfaceFailure (char channel, char flag); This function is used to report a failure status of the DALI bus (when the voltage is not high enough).

Software Library
Figure 6 on page 7 shows the flow diagram of the Cypress DALI Library structure. It is a simplified flow chart of the routine dali_ManageInterface which is the library's main function. This function must be executed at least every 6 ms. The DALI Library uses interrupt based processing for input data signals on the DALI bus. New packets are processed through interrupts and Manchester encoding is decoded through software. When a new packet is received, the library determines if the command needs to be executed. Therefore, the first step is to resolve the destination address, that is, determine if the incoming address is a short address or a group address, or if it is a special or broadcast command.
December 3, 2008

void DALI_SetLampFailure (char channel, char flag); With this function you can report to the library that the device has some problem with LEDs.

void DALI_SetPhysicalSelection (char channel, char flag); With this function you can report to the library that the device is physically selected.

void DALI_SetDeviceType(char ch, char type); With this function you can change the device type (default is 6).

Document No. 001-47615 Rev. **

[+] Feedback

AN47615

void DALI_SetBallastStatus(char channel, char flag); With this function you can modify ballast status: flag = TRUE Device is ready and can work flag = FALSE Device is not ready; stop communication

Using Cypress DALI Library in PSoC Designer


This section describes the sequence of steps to implement a DALI Receiver in EZ-Color using Cypress DALI Library in PSoC Designer. 1. Add the following user modules:
6 7 8

char DALI_AreDataPending(void); You can call this function to find if data is waiting to be stored in EEPROM; if this is the case, the power supply must not be turned off.

1 x Counter8 2 x Timer8 1 x E2PROM

void DALI_SetShortAddr(char channel, char addr) With this function you can change the short address of one virtual DALI device. Note This function is available only if constant RANDOM_ADDR is commented.

Figure 6. DALI Library Flowchart 2. Rename Counter8_1 to Counter8_DALI, Timer8_1 to Timer8_DALI, Timer8_2 to Timer8_DALI_TIME, and E2PROM_1 to DALI_E2PROM.

3.

Set DALI_E2PROM's size to 128 bytes and put its first block at the end of FLASH (in the following figure you can see the example of a 32 kB flash).

4.

Place Counter8_DALI, Timer8_DALI, and Timer8_DALI_TIME so that the output of Counter8_DALI can be used to feed clock to the 2 timers (Timer8_DALI and Timer8_DALI_TIME must be connected to the same clock source). Set up Counter8_DALI Timer8_DALI and Timer8_DALI_TIME to satisfy the following rules:

5.

Timer8_DALI interrupt frequency must be as close as possible to 1200 Hz. Timer8_DALI period must be as high as possible (period values such as 5, 10, 20, ... are not a good choice; 100, 150, 200, ... are better values)

December 3, 2008

Document No. 001-47615 Rev. **

[+] Feedback

AN47615

8. 9.

Generate the application. Switch to application editor.

10. Add the following files to the project:

dali.c dali.h dali_api.c dali_api.h dali_int.c dali_int.h daliconst.h

11. Open template boot.tpl and set up the following interrupt vectors for DALI: GPIO Interrupt Vector ljmp _DALI_FallingEdgeRxISR PSoC Block DBB21 Interrupt Vector ljmp _DALI_Timer8_DALI_ISR PsoC Block DBB22 Interrupt Vector ljmp _DALI_Timer8_DALI_TIME_ISR

6.

Set up DALI tx/rx pins:


7.

Rename P1[0] to TX_DALI and set drive mode to Strong, DisableInt. Rename P1[1] to RX_DALI and set drive mode High-Z, FallingEdge.

12. Open file main.c and add the following elements (see screenshots):

Comment the constants TX_NORM_HIGH and RX_NORM_HIGH in dali_int.c file to set a default low level on the DALI bus. When retained uncommented, the default level is set high.

Include the header for dali.c. Define a new variable unsigned char tmp. Add calls to DALI_Init function DALI_ManageInterface function. and

13. Adjust the following constant values in dali_int.c: T_1_BIT_2400 is (Timer8_DALI_Period + 1) * 0.5 T_1_BIT_DALI is Timer8_DALI_Period T_1_4_BIT_DALI is (Timer8_DALI_Period + 1) * 0.25 T_1_2_BIT_DALI is (Timer8_DALI_Period + 1) * 0.5 T_3_4_BIT_DALI is (Timer8_DALI_Period + 1) * 0.75 14. Loop main period is set to 6 ms. This sets the sampling window for the incoming DALI bit data. All constants in the dali.c file are adjusted to set the loop time period to 6 ms.

December 3, 2008

Document No. 001-47615 Rev. **

[+] Feedback

AN47615

15. DALI_TIME_PERIOD constant in dali_int.c must be set to a value so that Timer8_DALI_TIME generates an interrupt every 1 ms. For example, if the clock source of Timer8_DALI_TIME has a period of 6, 5 us, you can set DALI_TIME_PERIOD to 153 ( 6.5 us * (153 + 1) = 1.001 ms )

16. Unlock the last two blocks of PSoC's FLASH to enable writing into E2PROM. Change the last two W in the file flashsecurity.txt to U. 17. Build the project.

Figure 7. PSoC Designer Device Editor View with DALI Library

Figure 8. PSoC Designer Application Editor View with DALI Library

Figure 9: PSoC Designer Application Editor View with DALI Library

December 3, 2008

Document No. 001-47615 Rev. **

[+] Feedback

AN47615

Figure 10. PSoC Designer Application Editor View with DALI Library

Figure 11. Changes to flashsecurity.txt

Multi-channel DALI Slave using Cypress DALI Library


Cypress DALI Library supports up to 4 DALI slaves using the same instantiation. This is particularly useful in RGB based applications in multi-LED systems. These systems use dimming control of R, G, and B LEDs to generate a spectrum of colors. To extend the DALI library to support more than 1 channel, the value of TOT_LED_NUM is modified, with a value between 1 and 4.

The following example project describes the use of Cypress DALI library in PSoC Designer to implement a DALI receiver and control the intensity of the Red LED on the CY3261 Demonstration Board over DALI bus. The CY3261A board requires an external DALI interface circuit to connect to the 22V DALI bus. Figure 12 shows the DALI PHY reference design board that is used in this example project. Figure 12. DALY PHY Reference Design Board

DALI Interface Board


Cypress provides a reference design for a DALI interface board that has been designed for 5V power supply. It can also work with 3.3V power supplies by suitably selecting R1 and R4. IC U3 (Schmitt trigger) is suggested if the EZColor device is placed far from the DALI interface on the board or if the BER (Bit Error Rate) in the communication is too high. Sample schematics are presented in Figure 15 on page 13. Figure 12 shows a picture of the DALI PHY reference design board.

Example Project using CY3261A EZ-Color Demonstration Board


The CY3261A EZ-Color Demonstration Board is a powerful platform to design, develop, and test lighting applications using the EZ-Color platform. It includes the CY8CLED16 EZ-Color Intelligent Lighting Controller that is interfaced to three high-brightness LEDs along with driver circuitry.
December 3, 2008 Document No. 001-47615 Rev. ** 10

[+] Feedback

AN47615

Figure 13. Tridonic DALI USB Controller and Power Supply

Figure 14. CY3261A EZ-Color Demonstration Board with DALI Receiver Example Project

Three additional components are required to completely implement the DALI Loop in this example:

Tridonic DALI USB Controller: This enables a PC based GUI to send out DALI commands on the bus, and control the LED. Tridonic DALI Power Supply: This provides power to the DALI bus. DALI PHY Board: This interface board translates the high level voltages on the DALI bus to 5V on the EZColor device. 1. Create a new project in PSoC Designer and add the DALI Library using the steps described in the previous sections. In the Device Editor Mode, add the following user modules:

The evaluation GUI tool (configTOOL v1.5) can be downloaded from www.tridonicatco.com. Figure 13 shows a picture of the DALI components from Tridonic. Figure 14 shows a snapshot of the DALI Evaluation setup using CY3261A Board and the Tridonic DALI components.

2.

SSDM User Module (SSDM_1) that is used to control the HB-LED on CY3261 Demo Board. Configure the input clock and resolution as desired (In the attached example project file, SSDM input clock is 200 kHz and SSDM dimming resolution used is 8 bits). Timer8 User Module (sysTimer8) is used to synchronize the main DALI loop to 6 ms. This is clocked by VC3, with a Period of 39 and CompareValue of 20.

3.

Route the output of the SSDM User Module to Port_1_2 which is connected to the Red LED on the CY3261 Demo Board. Pin Settings

4.

Set Port_2_7 (renamed as SHUT_DN in the example project file) to drive strong (this connects to the shutdown pin of the LM3402 driver chip on the CY3261A board. Set Port_1_3 and Port_1_4 to drive Strong. These connect to the other two LEDs on the board and are driven to OFF.

December 3, 2008

Document No. 001-47615 Rev. **

11

[+] Feedback

AN47615

5.

Edit the main.c file with the following code: 6. The project is now ready to be built and programmed into the device. Select Build from the Build menu in PSoC Designer. This compiles all the files of the project and generates a hex file if the compiler does not find any errors. When the project is successfully built, it can be programmed into the EZ-Color device using the MiniProg.

unsigned char tmp; unsigned char ticks; char fSysTimerOv; #pragma interrupt_handler void sysTimer8_ISR(void) { ticks++; if (ticks >= 3) { ticks = 0; fSysTimerOv = TRUE; } } void main() { //Port init PRT0DR = 0x00; PRT1DR = 0x00; PRT2DR = 0x20; sysTimer8_ISR

The completed example project is attached as a zip file with this application note. The Device Editor Mode of this project shows all the necessary user modules added and routed correctly. The Application Editor Mode shows the source files, header files, and library files required in this example project. The main.c file reflects the code described in the previous step. To see a working demonstration of this example, build the attached project and program the hex code into the CY3261A Demonstration Board. Using a similar setup as shown in Figure 9 on page 9, you must be able to control the Red LED on the board over DALI bus from the PC GUI. Notes 1. Check the psocconfigtbl.asm file to see if value 0B8h is written into the SSDM_1_POLY_REG register: mov reg[21h], 0B8h The main loop is synchronized to 6 ms using the sysTimer8 block. The SHUT_DOWN pin of the LM3402 is controlled by Port_2_7. This must be enabled or disabled in the program as needed. File Boot.asm file is modified as described in the DALI library instantiation. File flashsecurity.txt is modified to unlock the last two bytes of the PSoC Flash by marking them as U.

//Shut-down enabled

//Variables fSysTimerOv = FALSE; ticks = 0; SSDM_1_DisableInt(); SSDM_1_Start(); sysTimer8_EnableInt(); sysTimer8_Start(); DALI_Init(); M8C_EnableGInt; while(1) { //Synchronization with timer while (fSysTimerOv == FALSE); fSysTimerOv = FALSE; // Call DALI routine every 6ms if ( DALI_ManageInterface(&tmp) != FALSE ) if (tmp != 0xFF) { SSDM_1_WriteSignalDensity(tmp); if (tmp != 0) SHUT_DN_Data_ADDR &= ~SHUT_DN_MASK; else SHUT_DN_Data_ADDR |= SHUT_DN_MASK; } } // end of while loop

2. 3.

4. 5.

Summary
This application note presents an overview of the DALI standard. The Cypress DALI library is also discussed to implement the DALI receiver using the EZ-Color Lighting controllers. The example project described in this application note illustrates the use of Cypress DALI library using CY3261A EZ-Color Demonstration Board. A working copy of the project is attached and can be readily implemented on CY3261A with additional hardware.

December 3, 2008

Document No. 001-47615 Rev. **

12

[+] Feedback

AN47615

Appendix
DALI Interface Board Reference Design
Figure 15. DALI Interface Board Reference Design

Table 2. Bill of Material (BOM)


Qty 1 3 2 1 2 1 1 1 4 1 1 1 1 1 2 1 Label C1 C2,C3,C4 R1,R4 R2 R3,R7 R5 R6 D1 D2,D3,D4,D5 D6 Q1 JP2 J1 J2 U1,U2 U3 Value 1uF-Tant-B 25V 100 nF-0603, 25V 470R-0805 6R8-2512 2K7-0805 47K-0805 1K-0805 BAS16-7-SOT23 1N4148W-7-FSOD123 BZX284-C2V7SOD110 BC817-25LT1GSOT23 3x1 TH Header (M) 2x1 screw terminal block 5x1 TH Header (F) 4N37S-SMD6 SN74AHC1G14DBVRSOT23-5 Description CAP TANT 1.0UF 25V 20% SMD CAP .1UF 25V CERAMIC X7R 0603 RES 470 OHM 1/8W 1% 0805 SMD RES 6.8 OHM 1W 5% 2512 SMD RES 2.70K OHM 1/8W 1% 0805 SMD RES 47.0K OHM 1/8W 1% 0805 SMD RES 1.00K OHM 1/8W 1% 0805 SMD DIODE SWITCH 75V 350MW SOT23 DIODE SWITCH 100V 400MW SOD123 DIODE ZENER 400MW 2.7V 5% SOD110 TRANS NPN GP 500MA 45V SOT23 2.54 mm pitch 3x1 through hole header - M Screw Terminal Block 2x1 2.54 mm pitch 5x1 through hole header - M OPTOISOLATOR W/BASE SMD IC SCHMITT-TRG INV GATE SOT23-5 Size Tant B (3528-21) 0603 0805 2512 0805 0805 0805 SOT-23 SOD-123 SOD-110 SOT-23 SMD-6 SOT-23-5 Manufacturer Vishay/Sprague Panasonic - ECG Rohm Panasonic - ECG Rohm Rohm Rohm Diodes Inc Diodes Inc NXP Semiconductors ON Semiconductor Phoenix Contact LITE-ON INC Texas Instruments Mfr Part# 293D105X0025B2TE3 ECJ-1VB1E104K MCR10EZPF4700 ERJ-1TYJ6R8U MCR10EZPF2701 MCR10EZPF4702 MCR10EZPF1001 BAS16-7 1N4148W-7-F BZX284-C2V7 BC817-25LT1G 1935161 4N37S SN74AHC1G14DBVR

December 3, 2008

Document No. 001-47615 Rev. **

13

[+] Feedback

AN47615

Table 3. IEC 62386 Part 102 Command Library


Code 00 01 02 03 04 05 06 07 08 09 10 + scene 20 21 2A 2B 2C 2D 2E 2F 40 + scene 50 + scene 60 + group 70 + group 80 81 90 91 92 93 94 95 96 97 98 99 Description Extinguish the lamp without fading Dim up 200 ms using the selected fade rate Dim down 200 ms using the selected fade rate Set the actual arc power level one step higher without fading (arc power level is increased by 1) Set the actual arc power level one step lower without fading (arc power level is decreased by 1) Set the actual arc power level to the maximum value Set the actual arc power level to the minimum value Set the actual arc power level one step lower without fading (arc power level is decreased by 1) Set the actual arc power level one step higher without fading (arc power level is increased by 1) Enable DAPC sequence Set the light level to the value stored for the selected scene C1 Reset the parameters to default settings Store the current light level in the DTR Store the value in the DTR as the maximum level Store the value in the DTR as the minimum level Store the value in the DTR as the system failure level Store the value in the DTR as the power on level Store the value in the DTR as the fade time Store the value in the DTR as the fade rate Store the value in the DTR as the selected scene Remove the selected scene from the slave unit Add the slave unit to the selected group Remove the slave unit from the selected group Store the value in the DTR as a short address Enable write memory Returns the status of the slave as XX XX Check if the slave is working (YES/NO) Check if there is a lamp failure (YES/NO) Check if the lamp is operating (YES/NO) Check if the slave has received a level out of limit (YES/NO) Check if the slave is in reset state (YES/NO) Check if the slave is missing a short address (YES/NO) Returns the version number as XX XX (the device returns 0x0100 i.e. Version 1.0) Returns the content of the DTR as XX XX Returns the device type as XX XX (default type is 6) C2 C3 C4 C5 E0 - FE FF Code A1 00 A3 XX A5 XX A7 00 A9 00 AB 00 B1 HH B3 MM B5 LL B7 XX B9 XX BB 00 BD 00 C1 XX C3 XX C5 XX C7 XX Code 9A 9B 9C 9D A0 A1 A2 A3 A4 A5 B0 + scene C0 Description Returns the physical minimum level as XX XX Check if the slave is in power failure mode (YES/NO) Query content of DTR1 Query content of DTR2 Returns the current light level as XX XX Returns the maximum allowed light level as XX XX Returns the minimum allowed light level as XX XX Return the power on level as XX XX Returns the system failure level as XX XX Returns the fade time as X and the fade rate as Y XY Returns the light level XX for the selected scene XX Returns a bit pattern XX indicating which group (0-7) the slave belongs to XX Returns a bit pattern XX indicating which group (8-15) the slave belongs to XX Returns the high bits of the random address as HH HH Return the middle bit of the random address as MM MM Returns the lower bits of the random address as LL LL Read memory location Application extended commands (note 1) Query extended version number (note 1) Description All special mode processes shall be terminated Store value XX in the DTR Initialize addressing commands for slaves with address XX Generate a new random address Compare the random address with the search address Withdraw from the compare process Store value HH as the high bits of the search address Store value MM as the middle bits of the search address Store value LL as the lower bits of the search address Program the selected slave with short address XX Check if the selected slave has short address XX YES/NO The selected slave returns its short address XX XX Go into physical selection mode Enable device type XX (note 1) Store XX into DTR1 Store XX into DTR2 Write memory location

December 3, 2008

Document No. 001-47615 Rev. **

14

[+] Feedback

AN47615

About the Author


Name: Title: Contact: Kaushik Subramanian Applications Engineer kaushik.s@cypress.com

Document History
Document Title: Implementing DALI Receiver using EZ-Color Intelligent Lighting Controllers Document Number: 001-47615
Revision ECN Orig. of Change Submission Date Description of Change

**

2615395

QUS/AESA

12/03/2008

New application note.

PSoC is a registered trademark of Cypress Semiconductor Corp. "Programmable System-on-Chip," PSoC Designer, PSoC Express, and EZColor are trademarks of Cypress Semiconductor Corp. All other trademarks or registered trademarks referenced herein are the property of their respective owners.

Cypress Semiconductor 198 Champion Court San Jose, CA 95134-1709 Phone: 408-943-2600 Fax: 408-943-4730 http://www.cypress.com/ Cypress Semiconductor Corporation, 2008. The information contained herein is subject to change without notice. Cypress Semiconductor Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges. This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source Code except as specified above is prohibited without the express written permission of Cypress. Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress product in a life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges. Use may be limited by and subject to the applicable Cypress software license agreement.

December 3, 2008

Document No. 001-47615 Rev. **

15

[+] Feedback

You might also like