Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: Newlands on January 12, 2021, 01:14:08 PM
-
Apologies for this rather basic question, but I've just spent 3 days trying to get the Cycle START, Feed HOLD and Cycle STOP buttons working on my control panel, and only today realised that it needs some code written in the screen editor!
Thanks to a search on here I managed to get the buttons working (at least they seem to be) by adding the following:
SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
machEnabled = state;
ButtonEnable()
end,
[mc.ISIG_INPUT0] = function (state)
end,
-- The following three blocks enable the buttons on the control panel to work
[mc.ISIG_INPUT0] = function (state)
if (state == 1) then
CycleStart() --0 G Code executed when Cycle START button is pressed
end
end,
[mc.ISIG_INPUT1] = function (state)
if (state == 1) then
mc.mcCntlFeedHold(0) --Stepper motors stop when Feed HOLD button is pressed,
-- spindle remains running, code can be resumed from the same point
end
end,
[mc.ISIG_INPUT2] = function (state)
if (state == 1) then
CycleStop(0) -- Stepper motors and spindle are stopped, cycle is aborted
end
end,
I'd be very grateful if someone could check that it is going to perform as it should, and in particular whether "then.. mc.mcCntlFeedHold(0)" and "then.. CycleStop(0)" are the correct form to use for this. Many thanks. Steve.
-
looks like it should work but the cycle stop is a bit risky. This is a legacy item from Mach3. Pressing feedhold then when the machine is stopped pressing reset is a much better way. The code looks okay, the only thing better you can do is to get the instance with mc.mcGetInstance() rather than passing a zero.
-
Thanks Brian. I'm afraid I'm very new to Mach4, and even newer to any sort of scripting or coding, so it has all been copied from others after a lot of reading and YouTube viewing!
When you say that a CycleStop is risky, is that because it is a bit of a shock to the machine/motors/ball screws? I can imagine in practice that if something goes wrong then the e-stop would be quicker and easier to go for with my setup.
I will have to read up on mc.mcGetInstance() as at the moment that means little to me. Time for some more forum searching I think.
Steve
-
You don't need to do it it is just good practice...
If you have trouble post here. I am sure we can figure it out ;)