Okay, here is the code for the Axis Fault
Put this in the PLC Script.
I have each Axis mapped to a separate input so I know which Axis has faulted.
Since it is in the PLC script, I made a "Message Counter" to leave only one message instead of leaving thousands of messages in the Log.
But, as you can see by looking through the script, if there is a fault, it will turn on the Alarm output (I use it to light up the red beacon), leave the Axis Fault Message, and Put the machine in E Stop.
--X Axis Fault
local inst = mc.mcGetInstance()
local XAlarm = mc.mcSignalGetHandle(inst, mc.OSIG_ALARM)
local Input16 = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT16)
local hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT16)
local State = mc.mcSignalGetState(hSig)
XAxisAlarmCounter = testcount
if State == 1 then
while (MessageCountX + 1) == XAxisAlarmCounter do
mc.mcCntlSetLastError(inst, "X Axis Fault.")
XAxisAlarmCounter = XAxisAlarmCounter + 1
end
mc.mcSignalSetState(XAlarm, 1)
mc.mcCntlEStop(inst)
else
MessageCountX = testcount
end
There are many ways of doing this, I plan on trying to make it a little more clean by making it a function, but for now, this does work very well.