Is there a g code command to abort a macro or program if an error is discovered?
I want to abort my tool change macro if it determines that the tool rack position given is out of bounds. I can just goto the end of the macro but I really wanted it to abort to stop the program completely so the tool change error flag is left set.
I see there is M00 or M200/M201/M224 to notify the operator. which I could just call in a loop until they cancel.
Can you abort from G Code?
Moderator: cnckeith
Re: Can you abort from G Code?
As an idiom, I typically use "ERROR". For example:
"ERROR" is not actually a recognized keyword (yet). But since it is not valid G code either, it will cause the job to be aborted with a parse error (probably "Missing parameter").
If the "IF" condition is not met, then CNC12 does not even attempt to parse the remainder of the line, so no error is triggered in that case.
If enough users adopt this use of the word "ERROR", perhaps Centroid will eventually make it a recognized keyword and add such niceties as copying the message into the message box in the status window, and into the message log file.
Code: Select all
IF [#4120 < 1 || #4120 > #9161] THEN ERROR Tool number out of range!
"ERROR" is not actually a recognized keyword (yet). But since it is not valid G code either, it will cause the job to be aborted with a parse error (probably "Missing parameter").
If the "IF" condition is not met, then CNC12 does not even attempt to parse the remainder of the line, so no error is triggered in that case.
If enough users adopt this use of the word "ERROR", perhaps Centroid will eventually make it a recognized keyword and add such niceties as copying the message into the message box in the status window, and into the message log file.
-
- Posts: 399
- Joined: Thu Dec 03, 2020 4:54 am
- Acorn CNC Controller: No
- Allin1DC CNC Controller: No
- Oak CNC controller: Yes
- CNC Control System Serial Number: none
- DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
Re: Can you abort from G Code?
Thanks. Good idea, I'll do that.
Seems like having an error key word would make a lot of sense. Especially on a user configurable system like this where safety decisions are made in user macros.
Seems like having an error key word would make a lot of sense. Especially on a user configurable system like this where safety decisions are made in user macros.