DMX dimming using the Logic Machine

The following script enables you to dim all channels monitoring a KNX group. The code assumes you have created dummy objects (starting 10/0/1) in the Logic Machine for each DMX dimmer channel. That way we can visualize the status of the dimmer and recall the values from other scripts.

Depending on the group value of the dimming group the DMX full on value gets edited accordingly.

I have commented out the logging of each dimming step, but if you are debugging, that might be helpful.

-- This software may be used and distributed according to the terms of the -- GNU General Public License version 3, incorporated herein by reference. -- config variables dmxchan = 12 -- number of max DMX channels to change dimprefix = '10/0/' -- for dummy groups dimgroup = '1/0/1' -- group that dims all dmxon = 255 dmxoff = 0 -- end config variables -- percentage up/down values of the 03.007 KNX value local percentages = {1,1,0.5,0.25,0.12,0.06,0.03,0.01,1,1,0.5,0.25,0.12,0.06,0.03,0.01} -- read value as of moment of change value = grp.getvalue(dimgroup) -- define the up down as a percentage of the full on value dimstep = math.floor(dmxon * percentages[value]) while (value >= 9 and value < =15) do -- Dimming UP for i = 1, dmxchan, 1 do -- I have created dummy objects in the LM to store the dimming value of each channel. 10/0/x DMXvalue = grp.getvalue(dimprefix .. i) if (DMXvalue >= 0 and DMXvalue < = 255) then DMXvalue = DMXvalue + dimstep if (DMXvalue > 255) then DMXvalue = dmxon end else DMXvalue = dmxon end DMX.set(i, DMXvalue) -- update the dimmer status group for specific channel grp.update(dimprefix .. i, DMXvalue) end -- update the Status group for all Dimmers, helps for visualizations grp.update(dimprefix .. 0, DMXvalue) -- give the device enough time to process os.sleep(0.1) value = grp.getvalue(dimgroup) --log('Dimm up ' .. DMXvalue) end while (value >= 1 and value < = 7) do -- Dimming Down for i = 1, dmxchan, 1 do DMXvalue = grp.getvalue(dimprefix .. i) if (DMXvalue >= 0 and DMXvalue < = 255) then DMXvalue = DMXvalue - dimstep if (DMXvalue < 0) then DMXvalue = dmxoff end else DMXvalue = dmxoff end DMX.set(i, DMXvalue) -- update the dimmer status group for specific channel grp.update(dimprefix .. i, DMXvalue) end -- update the Status group for all Dimmers grp.update(dimprefix .. 0, DMXvalue) -- give the device enough time to process os.sleep(0.1) value = grp.getvalue(dimgroup) --log('Dimm down ' .. DMXvalue) end [/prettify]

The screenshot shows you how I added the status into my visualization.
Logic Machine DMX Dimming visualization object

Here you see the dummy objects I created.
Logic Machine DMX Dimming dummy objects

CONTROL DIMMING (4-bit)
9 10 11 12 13 14 15 8 0 7 6 5 4 3 2 1
100% Increase 50% Increase 25% Increase 12% Increase 6% Increase 3% Increase 1% Increase Stop Stop 1% Decrease 3% Increase 6% Increase 12% Increase 25% Increase 50% Increase 100% Increase

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.