SOLVED: LED-Warrior14 - receiving DALI telegrams

English posts only please

Moderator: Guido Körber

Post Reply
Kasper
Posts: 2
Joined: Sat Nov 11, 2017 3:56 pm

SOLVED: LED-Warrior14 - receiving DALI telegrams

Post by Kasper »

Hi,

I'm making DALI controller using LW14, Raspberry Pi 3, python2.7 and SMBUS library(i2c). I have everything hooked up correctly - Broadcast commands work.

To make it easier I'm trying to assign random long address and after to assign short address for 1 lamps. I'm checking long address 0xFFFFFF so each connected lamp with lower address should respond (1 lamp in my case) with 0xFF.

I'm not sure if I'm trying to get DALI telegram write way from LW14.

Please help me figure out what I'm doing wrong.

Here's my code (I'm posting without code tags because it's losing line breaks and become unreadable):

import smbus
import time

BROADCAST_DP = 0xFE
BROADCAST_C = 0xFF
ON_DP = 0xFE
OFF_DP = 0x00
ON_C = 0x05
OFF_C = 0x00
QUERY_STATUS = 0x90
RESET = 0x20
TERMINATE = 0xA1
INITIALISE = 0xA5
RANDOMISE = 0xA7
COMPARE = 0xA9
WITHDRAW = 0xAB
SEARCHADDRH = 0xB1
SEARCHADDRM = 0xB3
SEARCHADDRL = 0xB5
PROGSHORTADDR = 0xB7

i2c = smbus.SMBus(1)

def send_cmd(device_address, register, dali_address, dali_command):
i2c.write_i2c_block_data(device_address, register, [dali_address, dali_command])

def init():
dali_delay = 0.02
send_cmd(0x23, 0x01, BROADCAST_DP, OFF_DP)
time.sleep(1)
send_cmd(0x23, 0x01, BROADCAST_C, RESET)
time.sleep(dali_delay)
send_cmd(0x23, 0x01, BROADCAST_C, RESET)
time.sleep(dali_delay)
send_cmd(0x23, 0x01, INITIALISE, 0x00)
time.sleep(dali_delay)
send_cmd(0x23, 0x01, INITIALISE, 0x00)
time.sleep(dali_delay)
send_cmd(0x23, 0x01, RANDOMISE, 0x00)
time.sleep(dali_delay)
send_cmd(0x23, 0x01, RANDOMISE, 0x00)
time.sleep(dali_delay)
send_cmd(0x23, 0x01, SEARCHADDRH, 0xFF)
time.sleep(dali_delay)
send_cmd(0x23, 0x01, SEARCHADDRM, 0xFF)
time.sleep(dali_delay)
send_cmd(0x23, 0x01, SEARCHADDRL, 0xFF)
time.sleep(dali_delay)
send_cmd(0x23, 0x01, COMPARE, 0x00)
time.sleep(dali_delay)



response = i2c.read_byte_data(0x23,0x01)
print "reponse:" + bin(response)
print "status:" + bin(i2c.read_byte_data(0x23, 0x00))

send_cmd(0x23, 0x01, PROGSHORTADDR, 0b00000011)
time.sleep(dali_delay)
send_cmd(0x23, 0x01, WITHDRAW, 0b00000011)
time.sleep(dali_delay)

send_cmd(0x23, 0x01, 0b00000011, ON_C)
time.sleep(1)
send_cmd(0x23, 0x01, 0b00000011, OFF_C)
time.sleep(dali_delay)

send_cmd(0x23, 0x01, TERMINATE, 0x00)
time.sleep(dali_delay)
Last edited by Kasper on Sat Nov 11, 2017 10:33 pm, edited 1 time in total.
Kasper
Posts: 2
Joined: Sat Nov 11, 2017 3:56 pm

Re: LED-Warrior14 - receiving DALI telegrams

Post by Kasper »

Figured it out. You need to wait until DALI bus is ready and request the specified register than.
Post Reply