Yeah, I don't know why people use the message box. There is NOTHING more aggravating. You can paint yourself into a corner quickly if you move some code from say like a macro script to the PLC script! mc.mcCntlSetLastError() is a much better choice. Or mc.CntlLog() and watch the diagnostic log window.
Also, in the new builds, I have put in:
number: rc = mc.mcCntlMacroAlarm(number: inst, number: error, string: message)
number: rc = mc.mcCntlMacroStop(number: inst, number: error, string: message)
Using mc.mcCntlMacroAlarm() basically does the same thing that writing a number to #3000 does in G code.
#3000 = 16 (Error 16 condition)
is the same as
mc.mcCntlMacroAlarm(inst, 16, 'Error 16 condition')
This will cause "Error 16 condition" in the status history, stop the cycle (not E-Stop), and raise the OSIG_ALARM signal. The alarm can only be canceled by hitting reset. OSIG_ALARM can be used to drive a yellow beacon light or similar that is commonly found on production CNC machines.
Using mc.mcCntlMacroStop() basically does the same thing that writing a number to #3006 does in G code.
#3006 = 12 (Error 12 condition)
is the same as
mc.mcCntlMacroStop(inst, 12, 'Error 12 condition')
This will cause "Error 16 condition" in the status history and stop the cycle (not E-Stop) without raising the OSIG_ALARM signal. It does not need to be canceled by a reset. Basically, it is the same as hitting the cycle stop button.
These functions are good for M code scripts because they will stop the machine if they are used for error conditions. The rest of the script may process, but the control will not advance to the next line of G code. But typically one would return from the script right after calling one of these functions. Of course, in order to use these functions, you have to write scripts that check for error conditions in the first place, right?
If you are going to write scripts, it doesn't really matter if it is for a hobby machine or an industrial production machine, do it right. People sometimes say "it is just a hobby machine", etc... And I call BS!!!! Doing things the right way will save you time and money in the future.
Steve