Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: Illya on May 08, 2014, 10:24:07 PM
-
This is my attempt at an output button toggle script (hopefully it is safe enough) for eg. output 2.
Works for me. :)
See later post for corrected code.
-
Oh I got ya now, thanks again
I was toggling the led but not the modbus output
edit:
that did not make any difference, led toggle but I am not seeing the outputs at the simulator change states.
-
Oh I got ya now, thanks again
I was toggling the led but not the modbus output
yes it takes time to get your head around it I still have a lot of scripts to try to figure out to get the machine running the way I would like .... But it can be done (allot of trial and error mostly error for me ;) )
actual script from buttons on my screen set ...this does work!!
--OUTPUT 5
--Get the instance of the controller
local inst= mc.mcGetInstance();
--Get the out5 handle
local out5= mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT5);
--Output TOGGLE
local outstate = mc.mcSignalGetState(out5);
if (outstate == 1) then
mc.mcSignalSetState(out5, false);
else
mc.mcSignalSetState(out5, true);
end
--OUTPUT 8
--Get the instance of the controller
local inst= mc.mcGetInstance();
--Get the out8 handle
local out8= mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT8);
--Output TOGGLE
local outstate = mc.mcSignalGetState(out8);
if (outstate == 1) then
mc.mcSignalSetState(out8, false);
else
mc.mcSignalSetState(out8, true);
end
-
Damn simulator was offline, works fine now thanks