- LEGO and DMX
- DMX slave?
- My first LEGO DMX fixture
- Compatibility issues
- DMX – a few findings
- LEGO DMX Fire Machine
Second LEGO DMX fixture: a Fire Machine 🙂
Similar script on EV3, listening to DMX channel 1 and reacting to just two values:
- 255 turns the BIC lighter ON
- 0 turns it OFF again
Working quite good with QLC+ as a DMX controller (at 9 Hz DMX frame rate) and other DMX fixtures on the loop (in this video a Fonestar PAR-18L set to DMX channel 2):
‘DMXfire.py’ script:
#!/usr/bin/env python3
from ev3dev2.motor import MediumMotor, OUTPUT_A, SpeedPercent
from time import sleep
import pyftdi.serialext
port = pyftdi.serialext.serial_for_url('ftdi://ftdi:232:AG0KAEQB/1', baudrate=250000)
#works good with QLC+ at 9 Hz
port.timeout = 0.0226
# clear input buffer (not sure if everything needed)
port.reset_input_buffer()
port.read(514)
port.reset_input_buffer()
channels = [0]*512
CH_FIRE = 1
fire = MediumMotor(OUTPUT_A)
fire.reset()
fire.position_sp = 0
fire.speed_sp = 1560
fireON = False
while True:
port.reset_input_buffer()
dmx_data = port.read(514)
i = 0
error = False
for b in dmx_data:
if i == 0 or i == 1:
if b != 0:
error = True
else:
channels[i-2] = b
i = i + 1
if error:
# first 2 bytes should be zero ("start-of-packet procedure" and "start frame")
print("Error!")
else:
if channels[CH_FIRE -1] == 255:
if fireON == False:
# turn Fire ON
print('Fire triggered ON')
fireON = True
fire.position_sp = 3050
fire.run_to_abs_pos()
elif channels[CH_FIRE -1] == 0:
if fireON == True:
# turn Fire OFF
print('Fire triggered OFF')
fireON = False
fire.position_sp = 0
fire.run_to_abs_pos()
print("FireON: ", fireON)
sleep(0.1)