Logic Machine Forum
toggle - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: toggle (/showthread.php?tid=1927)



toggle - balatis - 20.02.2019

hi
i have a signal from a  proximity o-1 state i would like every circle  (o-1) to have a toogle state and second this toggle i would like to is update from status object of the load .
thanks in advance


RE: toggle - admin - 22.02.2019

Can you explain what task do you have in more detail?


RE: toggle - balatis - 22.02.2019

(22.02.2019, 10:07)admin Wrote: Can you explain what task do you have in more detail?

i have a signal from a  proximity o-1 state ,every movement it give me signal 1 and when stop movement it give me 0 this is a cycle.
i would like when i have a cycle from proxymity with a script to give me a toggle operation, alongside the toggle operation i want to be informed for the state from status feedback if it has value 0 or1  .
thanks in advance


RE: toggle - gtsamis - 22.02.2019

(20.02.2019, 20:20)balatis Wrote: hi
i have a signal from a  proximity o-1 state i would like every circle  (o-1) to have a toogle state and second this toggle i would like to is update from status object of the load .
thanks in advance

Try this..

Code:
--Get proximity value
value=event.getvalue()

-- 'Light Feedback' is the address/name of the actual state of the load
-- 'Light OnOff' is the address/name of the actual load  
if value then
  lightFB = grp.getvalue('Light Feedback')
  grp.write('Light OnOff', not lightFB)
end



RE: toggle - balatis - 22.02.2019

(22.02.2019, 19:44)gtsamis Wrote:
(20.02.2019, 20:20)balatis Wrote: hi
i have a signal from a  proximity o-1 state i would like every circle  (o-1) to have a toogle state and second this toggle i would like to is update from status object of the load .
thanks in advance

Try this..

Code:
--Get proximity value
value=event.getvalue()

-- 'Light Feedback' is the address/name of the actual state of the load
-- 'Light OnOff' is the address/name of the actual load  
if value then
  lightFB = grp.getvalue('Light Feedback')
  grp.write('Light OnOff', not lightFB)
end

Ιt it work for one cycle only


RE: toggle - gtsamis - 22.02.2019

The event script should run on proximity sensor GA.

Does the feedback object works correctly? Are you trying to toggle it too fast?

Try changing the code as below in order to give it some time to update the feedback object

Code:
--Get proximity value
value=event.getvalue()

-- 'Light Feedback' is the address/name of the actual state of the load
lightFB = grp.read('Light Feedback')
os.sleep(0.5)

-- 'Light OnOff' is the address/name of the actual load  
if value then  
lightFB = grp.getvalue('Light Feedback')
grp.write('Light OnOff', not lightFB)
end


If it doesn't work give me a call

BR 
George


RE: toggle - balatis - 23.02.2019

(22.02.2019, 22:09)gtsamis Wrote: The event script should run on proximity sensor GA.

Does the feedback object works correctly? Are you trying to toggle it too fast?

Try changing the code as below in order to give it some time to update the feedback object

Code:
--Get proximity value
value=event.getvalue()

-- 'Light Feedback' is the address/name of the actual state of the load
lightFB = grp.read('Light Feedback')
os.sleep(0.5)

-- 'Light OnOff' is the address/name of the actual load  
if value then  
lightFB = grp.getvalue('Light Feedback')
grp.write('Light OnOff', not lightFB)
end


If it doesn't work give me a call

BR 
George
thanks George!