DALI

Light bus interface – Using the DALI bus

This bus implements a hardware interface commonly used to connect some commercial
DALI devices.

Please note:
CM3-Home is not a certified DALI controller! An open hardware is implemented on it so we can’t warranty the fully functionality with any DALI devices

What is the DALI bus ?

Features
  • Signals available on two screw terminals
  • Bus opto-isolated from the CPU side
  • Power supply provided on the bus for up to 16 devices without need an external power supply
  • Bus managed in bit banging mode

The bus can be powered by the internal isolated power supply closing the power jumper.

The example supplied drives a DALI controller to set the color of some LEDs strips.

Habpanel

Classic UI or mobile App
Basic UI

Dali – Implementing the protocol in bit-banging mode

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.

Please note:
CM3-Home is not a certified DALI controller! An open hardware is implemented on it so we can’t warranty the fully functionality with any DALI devices
Drive DALI devices with OpenHAB

In OpenHAB there is no specific binding for DALI protocol. A simple Python test program daly.py can be arranged adding RGB values as input parameters:

if len(sys.argv)==4:
	RedV = int(sys.argv[1])
	GreenV = int(sys.argv[2])
	BlueV = int(sys.argv[3])
	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[1]))
	send_color_green(int(sys.argv[2]))
	send_color_blue(int(sys.argv[3]))

Adding the specific functions:

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)

Just one colorwheel item is needed

items/dali.items

Color DaliColor "Color [%s]"  (dali) 

With a rule you can read the item status 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.

rules/dali.rules

var HSBType hsb
var red = 0
var green = 0
var blue = 0
var Cmd="/usr/bin/python@@/etc/openhab2/scripts/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

sitemaps/cm3home.sitemap

Frame label="Dali"
    {
    	Text label="Dali" icon=colorwheel
    	{
    		Colorpicker item=DaliColor
    	}
    }
Bit-banging a GPIO to realize the DALI protocol
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.

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.

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.

Original article

Hardware

The DALI bus depends on the specific power supply, this is an example used in a development board:

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.

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.

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:

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.

A the extreme, the signal is still acceptable at 10 times the working frequency.

Links

Share