Page 1 of 1

M200 G code yes no

Posted: Wed Feb 07, 2018 3:43 pm
by bakeng
I need to add a pause and ask a question to my g code. Based on the user answer jump to a certain point in my program.
I tried M200 but could never get it to work.
Basiclly I just want to ask the machine operator if a hole needs to be drilled. If not skip that part of the code.

Re: M200 G code yes no

Posted: Wed Feb 07, 2018 4:44 pm
by cncsnw
That would be M224.

You will have to phrase your question so it takes a numeric answer. E.g.

Code: Select all

M224 #101 "Enter 1 to drill the hole, or enter 0 to skip"
IF [#101 != 1] THEN GOTO 20
  ; drill the hole...
N20

Re: M200 G code yes no

Posted: Wed Feb 07, 2018 4:55 pm
by bakeng
I will give it a try.
Thanks

Re: M200 G code yes no

Posted: Wed Feb 07, 2018 5:28 pm
by cnc_smith
Here is another way to right the G-code with the M224. This one has a GOTO to go back to ask the question again if they do not answer 1 or 2. This way if they fat finger a number besides 1 or 2 it does not go through and do any part of the program.


download/file.php?mode=view&id=1783&sid ... 35d8fb72ad

Re: M200 G code yes no

Posted: Thu Feb 08, 2018 9:19 am
by bakeng
Thanks guys. I will try these today.
Seems odd you cant look for a Y or N instead of a number.
Can the #300 variables be used? It looks like they are for text (string) format.

Re: M200 G code yes no

Posted: Thu Feb 08, 2018 11:07 am
by cnc_smith
Yes the M300 variable can be used but not for a comparison.
You are right the they are for text (string) format.

They can be used in M223, M234, M225.

Also the can be used with the M120 and M121. M120 & M121 are used to write information to a file or append a file with additional information

Example of M120:
M224 #300 "Please enter the file name that you wish to save your data to:\n"
#350 = "c:\cncm\"
M120 "#350\ncfiles\#300.cnc" ; This writes the information to the file name they gave in the M224 in the directory c:\cncm\ncfiles with the extension .cnc. This would save the operator writing the full path and make sure it is going into the directory that the program is expecting it to go into with the correct extension.

There is a lot that can be done but I what to try and kept it KIS at this time. I have write macros that have more than 2 options for answer then have used the numbers in comparison with other variables. I have missed putting in checks to make sure the answer for the number was not out of range and got burnt by going into a section that could and/or did case a crash and also got programming errors will trying to test the macro.

As the saying goes" You try to write code to cover for the Idiot, but the keep making Smarter Idiots that that can still break it."

Re: M200 G code yes no

Posted: Thu Feb 08, 2018 11:26 am
by bakeng
Believe me, I understand.
I am mainly an automation engineer and am a master level programmer in several languages.
Its amazing what an "idiot" can do to an "idiot proof" machine.
When I'm asked to design and build an "idiot proof" machine, I always ask the customer if they really want idiots running there machine.