#Dali - Implementing the protocol in bit-banging mode <abstract> DALI, Digital Appliance Lighting Interface, is a standard wired communications protocol used for Home & Building lighting applications. The interface was originally specified to support connectivity for fluorescent light ballasts, but has also been designed to support other lighting technologies. </abstract> ## Drive DALI devices with OpenHAB In OpenHAB there is no specific binding for DALI protocol. A simple Python test program ([daly.py](https://github.com/tanzilli/cm3-utilities/blob/master/dali.py)) can be arranged adding RGB values as input parameters: <pre class="terminal"> if len(sys.argv)==4: RedV = int(sys.argv) GreenV = int(sys.argv) BlueV = int(sys.argv) if RedV > 254: RedV = 254 if GreenV > 254: GreenV = 254 if BlueV > 254: BlueV = 254 if RedV < 0: RedV = 0 if GreenV < 0: GreenV = 0 if BlueV < 0: BlueV = 0 send_color_red(int(sys.argv)) send_color_green(int(sys.argv)) send_color_blue(int(sys.argv)) </pre> Adding the specific functions: <pre class="terminal"> def send_color_red(value): global LED_RED print(LED_RED) print(value) send_start() send_short_address(LED_RED) send_value(value) send_stop() send_stop() time.sleep(0.001) def send_color_green(value): global BIT_DELAY global GPIO_TX_LINE send_start() send_short_address(LED_GREEN) send_value(value) send_stop() send_stop() time.sleep(0.001) def send_color_blue(value): global BIT_DELAY global GPIO_TX_LINE send_start() send_short_address(LED_BLUE) send_value(value) send_stop() send_stop() time.sleep(0.001) </pre> With a rule you can read an item status (a slider type for example) that returns the HSB values of the selected color. Those HSB values can be converted in RGB and sent as parameters to the Python program in order to setup the desired color. <pre class="terminal"> var HSBType hsb var red = 0 var green = 0 var blue = 0 var Cmd="/home/openhabian/dali.py" rule "HSBtoRGB" when Item DaliColor changed then hsb = DaliColor.state as HSBType red = (hsb.red * 2.55).intValue green = (hsb.green * 2.55).intValue blue = (hsb.blue * 2.55).intValue val results = executeCommandLine(Cmd+"@@"+red+"@@"+green+"@@"+blue,5000) logInfo("Exec",results) end </pre> ## Testing DALI protocol through bit-banging Raspberry GPIOs * [daly.py](https://github.com/tanzilli/cm3-utilities/blob/master/dali.py) GPIOs used: * TX - GPIO 31 <img src="./raspberry_pinout.jpg" class="img-responsive center-block" width="50%"/> * [Hardware details on CM3-Home](https://www.acmesystems.it/CM3-HOME_light-bus) * [DALI commands](./dali_commands.pdf) ## Bus and protocol The physical interface consists of 2 wires, DALI Power and DALI Data. The DALI system consists of one DALI Control module with up to 63 DALI devices. * DALI Power line provides the power only for the communication protocol of a maximum 22.5V and limits the current for the system to 250mA. * The DALI Data line provides the half duplex communication at a data rate of 1200 bits/second using a bi-phase (Manchester) decoding. Bi-phase decoding is accomplished with the following: * a logical zero consists of sending a physical low signal for 416 µs immediately followed with a physical high signal for 416 µs. * a logical one consists of sending firstly a physical high signal for 416 µs followed by a physical low signal. A physical high signal on the DALI Data line is a voltage level between +9.5V and +22.5V. A physical low signal on the DALI Data line is a voltage level between -6.5V and +6.5V. <img src="./figura7.jpg" class="img-responsive center-block"/> The DALI digital layer consists of 2 frames, a forward frame and a backward frame. * A forward frame is a frame sent from a DALI controller to a DALI ballast. It is constructed by a START bit (always logical 1), followed by 1byte Address,1byte Command and two STOP bits (a high level with no transitions). * A DALI ballast communicates back to the DALI control using only a 1byte backward frame consisting of a START bit,1byte,2 STOP bits. <img src="./figura8.jpg" class="img-responsive center-block"/> The DALI protocol allows a master controller options to address all ballasts by either broadcast to all, Groups of ballasts, and individual addressing. The most commonly used direct commands allow the controller to modify lighting brightness, scene settings for groups, fading capability and varying rates. Also including are Query command that request the ballast to send a backward frame with configuration data such as, power levels, scene levels, current address. Using “extended” Configuration command the DALI controls can modify addresses of each ballast thus eliminating manual configuration of the DALI system. The “extended” configuration command will follow immediately after a DALI controller sends an INITIALIZE ($A5) command, which informs all other DALI devices on the bus to ignore further commands until a TERMINATE command is observed or 30 s elapses in time. <img src="./figura9.jpg" class="img-responsive center-block"/> * [Original article](http://www.ledsmagazine.com/articles/2005/11/microcontrollers-provide-connectivity-of-hb-led-lighting-products.html) ## Hardware The DALI bus depends on the specific power supply, this is an example used in a development board: <img src="./DaliPWR.png" class="img-responsive center-block" width="50%"/> With kind of schematic the voltage on the bus depends too much from the load. How is shown on the graphs Vout begins to go down before the current is half of the maximum load. The DALI specification imposes a 2mA maximum load for each device on the bus, but analyzing some of the available devices, it's evident that this limit is often exceeded. Furthermore, most of the real devices consume this current constantly. This kind of power supply would be too much limited on the maximum number of the connectable device. <img src="./PWR-Transistor.png" class="img-responsive center-block" width="50%"/> Using an integrated, current limited power supply, the circuit works much better, with a much more accurate Imax regulation and, above all, a sharper knee at the current threshold. The voltage is stable until the intervention of the current limiter. <img src="./PWR-Enhanced.png" class="img-responsive center-block" width="50%"/> The DALI system is designed to be realized in an easy and cheap way, it's very tolerant both on voltage and on signals shape. These are the specifications: <img src="./Dali-Spec.png" class="img-responsive center-block" width="35%"/> The circuit has been designed to stay widely within specifications, in order to be able to tolerate any degradation when the bus is not perfectly realized or with strange loads. A generator that injects a 50% duty cycle, 3.3V square wave to the TX input composes the test bench. The measurement is on the RX output. The DALI bus is in loopback by nature: TX and RX are connected on the same pair of wires. The circuit parameters have been fine tuned to have on the output a signal as close as possible to the one at the input. The graph shows a shape well within the specifications even with a frequency double of the working one. <img src="./2400.png" class="img-responsive center-block" width="50%"/> A the extreme, the signal is still acceptable at 10 times the working frequency. <img src="./10000.png" class="img-responsive center-block" width="50%"/> * [Specifications](https://www.artisticlicence.com/WebSiteMaster/User%20Guides/the%20dali%20guide.pdf) * [Sistema DALI per il controllo digitale - Flyier Osram](http://www.zanino.it/downloadDB/Copia1_sistemadaliorsam.pdf) * [ARPN Journal of Engineering and Applied Sciences](http://www.arpnjournals.com/jeas/research_papers/rp_2015/jeas_0915_2476.pdf) * Mikroel DALI Click * [Product description](https://shop.mikroe.com/dali-click) * [Schematic](https://download.mikroe.com/documents/add-on-boards/click/dali/dali-click-manual-v100.pdf) * [Microchip USB to DALI interface](https://www.digikey.com/product-detail/en/microchip-technology/DM160215/DM160215-ND/4902423) * Atmel * [DALI Master with ATxmega32E5 Reference Design](http://www.atmel.com/tools/dali-master-with-atxmega32e5-reference-design.aspx?tab=documents) * Application Notes * [Microchip](http://ww1.microchip.com/downloads/en/AppNotes/01465A.pdf) * [Renesas](https://www.eeweb.com/blog/renesas/dali-control-gear-software-solution) * [STM](https://www.digikey.com/en/articles/techzone/2013/aug/designing-wired-lighting-control-networks-to-dali-standard) * Schematics examples * (1.png) * (2.png) * (3.png) * (4.png) @include='bio_guido_ottaviani' @include='bio_sergio_tanzilli'
Le attività del TanzoLab si svolgono ogni mercoledi sera, salvo casi speciali, dalle ore 18:30 presso i locali della Acme Systems srl e consistono in:
Le attività vengono coordinate tramite questo sito, in cui vengono pubblicati tutti i lavori svolti o in via di sviluppo, e tramite un gruppo Telegram con cui per interagire direttamente via chat con gli altri membri.
2018 Ⓒ TanzoLab