Logic Machine Forum
Button dimming (8-bit value) - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Button dimming (8-bit value) (/showthread.php?tid=1334)



Button dimming (8-bit value) - Jayce - 09.04.2018

Hey,

I'm trying to dim a RGB led strip using nothing but a button and logic machine. Basically what I need is to get 8-bit value from a button so that when I hold the button, value toggles between going up and down. Is this possible? If not, what is the best way to control dimming dali lights using a simple button (or two, one up one down), preferably without using any scripts.


RE: Button dimming (8-bit value) - Erwin van der Zwart - 09.04.2018

Hi,

Check this article: https://forum.logicmachine.net/showthread.php?tid=275&pid=1238#pid1238

BR,

Erwin


RE: Button dimming (8-bit value) - Jayce - 10.04.2018

(09.04.2018, 15:56)Erwin van der Zwart Wrote: Hi,

Check this article: https://forum.logicmachine.net/showthread.php?tid=275&pid=1238#pid1238

BR,

Erwin

Thank you very much for help, bear in mind I'm a beginner though. I tried what you posted about 3bit dimming object, got to a point where i'm supposed to set value after _ in longpresstime_xx. I can't seem to find longpresstime_xx anywhere in the javascript that I pasted in custom javascript. Could you help me please?

EDIT: Nevermind, I figured it out but now I'm having problems with linking the dim UP and DOWN buttons to a real physical buttons I have set up and to the RGB led strip.


RE: Button dimming (8-bit value) - Erwin van der Zwart - 10.04.2018

Hi,

You could try something like this:

Code:
addressbyteoutput = '32/1/1'
stepsize = 10
value = event.getvalue()
current = grp.getvalue(addressbyteoutput)
if value < 8 then
 if current <= stepsize then
   output = 0
   if current ~= output then
     grp.write(addressbyteoutput, output)
   end
 else
   output = current - stepsize
   if current ~= output then
     grp.write(addressbyteoutput, output)
   end
 end
elseif value > 8 then
 if current >= (100 - stepsize) then
   output = 100
   if current ~= output then
     grp.write(addressbyteoutput, output)
   end
 else
   output = current + stepsize
   if current ~= output then
     grp.write(addressbyteoutput, output)
   end
 end
end
BR,

Erwin


RE: Button dimming (8-bit value) - Jayce - 10.04.2018

Hello,

Excuse me again, how do I try that? Where should I put the script and what should the addressbyteoutput address be? As I said I'm a beginner, if you have time, could you please walk me through this?

Right now I'm in a state where I have done all from the link you sent me, I have two buttons in my visualization, one UP and one DOWN, both have longpresstime set to 10 (1 second). Also, I have 1/1/199, which is my LED strip that I scanned from dali section in LM, I can control the strip with 1 byte unsigned integer.


RE: Button dimming (8-bit value) - Erwin van der Zwart - 10.04.2018

Hi,

Just create a 4 bit object that is connected to your physical KNX pushbutton (dimming object), add the script as event based to this object, create a byte SCALE object for your RGB DALI unit and set this object (1/1/199) as addressbyteoutput.

Then it should work..

But do i understand it correct from your last post that you use LM dali interface? If that is the case you should be able to use the commands from http://openrb.com/docs/dali.htm and then you should not be needing this script..

BR,

Erwin


RE: Button dimming (8-bit value) - Jayce - 11.04.2018

Yes, I'm using Logic Machines DALI Gateway, sorry for not mentioning earlier.


RE: Button dimming (8-bit value) - Jayce - 13.04.2018

Sorry to bother again but would you mind walking me through the method with dali commands you said? Also, what I mean by dimming the RGB strip with pushbutton is that when I hold the button the value goes gradually up. Not sure if I mention this either.


RE: Button dimming (8-bit value) - Erwin van der Zwart - 13.04.2018

Hi,

How are you going to config the pushbutton? 
As 4 bit dimming?

BR,

Erwin


RE: Button dimming (8-bit value) - Jayce - 16.04.2018

Hello,

Yes, I have set the pushbutton so it is 1bit switching and 3bit dimming. That makes 4bit.


RE: Button dimming (8-bit value) - admin - 16.04.2018

We plan to implement 4-bit dimming in DALI gateway plugin soon.


RE: Button dimming (8-bit value) - Bobby - 16.04.2018

Is it possible to make a single switch:
1 short push , toggle on / off (remember last state if dimmed)
1 long push, dim up and for next long push, dim down and so on?


RE: Button dimming (8-bit value) - Jayce - 16.04.2018

It doesn't have to be 4bit for me, is there any way to make it work so a pushbutton controls dimming of a dali light when using LMs dali gateway? All I'd like it to do is to dim up/down while I hold the button.

Thank you.


RE: Button dimming (8-bit value) - Daniel - 16.04.2018

Hi
You can do it as fallow.
Create 4 bit dim object 3.007 and let all parameters as default.
Create event based script on this object and use this script.

Code:
step = 10    --dimming step
stepTime = 0.5  --- dimming interval
ballastAddress = 1  
gatewayID='internal'

-----------------------------------------------------------------------------------------------------

valuein = event.getvalue()

require('user.dali')

   res, err = dalicmd(gatewayID, 'queryactual', { addrtype = 'short', address = ballastAddress })
 -- read ok
        if res then
     status = res:byte()
        end

while( valuein==11 ) do
 status = status + step
    if (status >254) then
             dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress, value = 254})
         else
     dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress, value = status})
    end
 valuein = grp.getvalue(event.dst)
 os.sleep(stepTime)
end
   

while( valuein==3 ) do
 status = status - step
     if (status <0) then
         dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress, value = 0})
         else
       dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress, value = status})
     end  
 valuein = grp.getvalue(event.dst)
 os.sleep(stepTime)
end

Modify parameters
Add this object on to visu and test.
Should work :Smile
Dalli arc is logarithmic curve so you will have slower dim on low values and fast on bigger.

BR


RE: Button dimming (8-bit value) - Jayce - 17.04.2018

Works very well, thank you very much.


RE: Button dimming (8-bit value) - alexll - 09.11.2021

(10.04.2018, 10:50)Erwin van der Zwart Wrote: Hi,

You could try something like this:

Code:
addressbyteoutput = '32/1/1'
stepsize = 10
value = event.getvalue()
current = grp.getvalue(addressbyteoutput)
if value < 8 then
 if current <= stepsize then
   output = 0
   if current ~= output then
     grp.write(addressbyteoutput, output)
   end
 else
   output = current - stepsize
   if current ~= output then
     grp.write(addressbyteoutput, output)
   end
 end
elseif value > 8 then
 if current >= (100 - stepsize) then
   output = 100
   if current ~= output then
     grp.write(addressbyteoutput, output)
   end
 else
   output = current + stepsize
   if current ~= output then
     grp.write(addressbyteoutput, output)
   end
 end
end
BR,

Erwin

Hello. I'm trying this event script with a 4 bit object from KNX, but it only dimms with many "long-pressed" actions, and not mantaining the KNX button switch. Is it the problem on the KNX side or script's?


RE: Button dimming (8-bit value) - admin - 09.11.2021

Why do you need a script if this switch supports "dimming steps" mode?


RE: Button dimming (8-bit value) - alexll - 09.11.2021

(09.11.2021, 09:09)admin Wrote: Why do you need a script if this switch supports "dimming steps" mode?

Is that the solution? I've never used that option. I'm going to try that. Thank you!

Edit: Confirmed. It works using "dimming steps" option + your 4 bit object dimming script. It has to be done like that because I needed to dim some Philips Hue LED strips from a KNX single button.