Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: jhandel on November 13, 2018, 10:16:38 PM

Title: Custom Error and stopping a program?
Post by: jhandel on November 13, 2018, 10:16:38 PM
Howdy all..

  I am trying to figure out the best way to achieve the following...

I have several inputs that signify an error that are setup on various input ports  (High level feedbacks from my CLEARpath Servos, a Spindle alarm, and a low air pressure alarm)...  I would like to configure Mach 4 so that if any of these 6 (or 7 if I add a 4th axis)  inputs activate (high or low depending) its treated like an error and stops the program (like hitting E-STOP or a limit switch would)..  What is the best way to configure (or program) custom error trapping and error messages in mach 4 so I can alarm out if something goes wrong..

Thanks
Josh
Title: Re: Custom Error and stopping a program?
Post by: joeaverage on November 13, 2018, 11:57:43 PM
Hi,
easy enough.....lets assume you have assigned one of your fault inputs to ISIG_INPUT10 then you need to put
the following in the SigLib table which is near the top of the screenload script.

Code: [Select]
[mc.ISIG_INPUT10]=function(state)
local inst=mc.mcGetInstance()
if state==1 then
mc.mcCntlEStop(inst)
end
end,

You will need to repeat this for as many fault inputs you have, probably using ISIG_INPUT11, ISIG_INPUT12 etc.

Craig