Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: abdulasis on October 30, 2020, 06:07:38 AM
-
Hi I'm Asis
I'm newbie use mach4.
I feel hard macro script for mach4 I ever use mach3.
Now I want for create macro
Active Output1 for start motor ,
Then
Wait for Signal_Input2 for stop signal Output1
Please help me for explained step for create macro or example code .
Thank you.
Asis
function m100()
--active sigoutput1
--wait input2 time 10 second
--setstate sigoutput1 turn off
if (mc.mcInEditor() == 1) then
m100()
end
-
This might help.
The newest is the 3rd post from the bottom.
https://www.machsupport.com/forum/index.php?topic=43260.msg279695#msg279695
Bill
-
This might help.
The newest is the 3rd post from the bottom.
https://www.machsupport.com/forum/index.php?topic=43260.msg279695#msg279695
Bill
Thank you MR.Bill I read your PDF it's good for newbie.
-
function m100()
--local inst2 = mc.mcGetInstance()
--local hsig2 = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT0)
local inst2, hSig2, rc2
inst2 = mc.mcGetInstance()
local inst = mc.mcGetInstance()
local hsig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT0)
local spinstate = mc.mcSignalGetState(hsig)
hSig2, rc2 = mc.mcSignalGetHandle(inst2, mc.OSIG_OUTPUT23) -- Get handle for output 1
rc2 = mc.mcSignalSetState(hSig2, 1) --turn on output 1
if (rc2~= 0) then --Check our return call
mc.mcCntlSetLastError(inst, "There was an error")
end
if (spinstate == 0 ) then
mc.mcCntlSetLastError(inst, "5555566")
--mc.mcSignalSetState(hsig, 0)
else
mc.mcCntlSetLastError(inst, "123")
--mc.mcSignalSetState(hsig, 1)
end
end
if (mc.mcInEditor() == 1) then
m100()
end
this is my code.
now I can
- use OutputSignal23 for active
- Use If (spinstate == 0 ) then....
it'sworking.
I want change If (spinstate == 0 ) then to while signal Input0 active then Stop signal output23 how to code for while loop ?
Thank you.