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) 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))
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)
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.
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
GPIOs used: * TX - GPIO 31
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.
Bi-phase decoding is accomplished with the following:
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.
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.
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.
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