Question about Gcode "grammar"

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

Post Reply
hman
Posts: 8
Joined: Sun May 19, 2019 6:05 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: B0D5CC46CB03-1206170337
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Question about Gcode "grammar"

Post by hman »

This came about as a side issue on another problem, since solved. My question is in regard to adding parenthetical comments to Gcode.

Background:
(1) I bought a (FANTASTICALLY well set up! Thanks, Marty) DynaMyte DM2400 CNC milling machine from Marty a bit over a year ago. I was initially interested in getting started with a specific part. A mutual friend, Brian Lamb, wrote the Gcode for this part as a demo, and the code worked perfectly. I recall that the code included comments (delimited by parentheses) both on separate lines and as comments on lines containing Gcode commands, following the commands.

(2) I've hand-coded numerous Gcode programs on Notepad++, all with parenthetical comments both on separate lines and after Gcode commands. Never any problem running them on the DM under Acorn (other than that one strange glitch recently, that I discussed with Marty).

During our conversation, Marty told me that comments should never appear on the same line as Gcode, except when delimited by a semicolon. I mentioned (1) and (2) to him. He suggested I post a question on the forum. So my question to all of you is, what's the rule? Semicolons may well be preferred, but is there any specific "thou shalt not" concerning parens? I've tried looking through the Acorn documentation and can't really find anything. If I'm doing something wrong, I'd certainly appreciate your citing an actual reference ... manual title, page number, etc. Thanks!
martyscncgarage
Posts: 9912
Joined: Tue Mar 28, 2017 12:01 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: Yes
CPU10 or CPU7: Yes
Location: Mesa, AZ

Re: Question about Gcode "grammar"

Post by martyscncgarage »

From Chapter 11"CNC Program Codes" of the CNC12 4.14 Mill Operator's Manual:

11.2.12 : — Visible Comment Identifier
The colon (:) is used to indicate the start of a comment line within a CNC program. The colon must be the
first character on the line.
Example:
: select absolute positioning
G90
: XY plane
G17
: Visible comments will be displayed on screen with the G - codes .

11.2.13 ; — Internal Comment Identifier
The semicolon (;) is used to indicate the start of an internal comment within a CNC program line. All characters after the semicolon are ignored when the program is run. Internal comments are used to document
NC programs or temporarily omit the remainder of a line.
Example:
G90 ; select absolute positioning
G17 ; XY plane
G1 X1 Y1 F10
G0 ; X0 Y0 ; G0 selected with no movement
Reminder, for support please follow this post: viewtopic.php?f=20&t=383
We can't "SEE" what you see...
Mesa, AZ
martyscncgarage
Posts: 9912
Joined: Tue Mar 28, 2017 12:01 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: Yes
CPU10 or CPU7: Yes
Location: Mesa, AZ

Re: Question about Gcode "grammar"

Post by martyscncgarage »

Bottom line, each manufacturer's control "grammar" may be slightly different from another. This is why Post Processors are used.
Read up here for more info: https://www.cnccookbook.com/cnc-post-processor-cam/

Centroid follows Fanuc OT and 0M for the most part when no Post Processor is listed for Centroid (fairly uncommon these days)
Writing G small G code files by hand is no problem and you shouldn't run into any problems provided you follow Chapters 11, 12 & 13.
The "CNC Program Codes" in the manual: https://www.centroidcnc.com/centroid_di ... -v4.14.pdf

Have you read up in Chapter 10 on Intercon? Have you tried the tutorials? John, I think you would really like it since you are doing much hand coding.
Intercon is great for relatively simple one off parts. Keith goes over a part in the Mill Training Video:


Good luck and have fun!
Marty
Reminder, for support please follow this post: viewtopic.php?f=20&t=383
We can't "SEE" what you see...
Mesa, AZ
cncsnw
Posts: 3763
Joined: Wed Mar 24, 2010 5:48 pm

Re: Question about Gcode "grammar"

Post by cncsnw »

That distinction between "visible comment" and "internal comment" has been in Centroid's documentation for more than 27 years, and in that time has never meant what it says.

All comments appear on the G code screen as the executing G codes scroll by.

The only difference between a "colon" comment and a "semi-colon" comment is that the colon has to be the first character on the line. Originally, there was no particular reason for that other than history. Now that we have G98, G65 and M120/M121 codes that may contain fully-specified filenames (e.g. G65 "c:\cncm\MySpecialFeature.txt"), interpreting a mid-line colon as the start of a comment would be a problem.

My guess is that the "visible" vs. "internal" distinction goes back at least to the CNC4 architecture, and maybe longer. In the decades since, no one has thought to take it out of the manual. Perhaps one of these decades someone can finally do that, and add mention of Fanuc-style parenthesized comments while they are at it.

The original question was about comments in parentheses, rather than after a colon or semi-colon. In all current software (probably for at least ten years now) comments in parentheses have been allowed, both on lines by themselves, and as line-end comments.

The only case I know of where you cannot use parentheses for line-end comments is in variable assignments:

Code: Select all

#1 = 2.345  ; this is a legal comment
G1 F10 X#1  (this is a legal comment too)
#2 = 6.543  (this comment causes 'syntax error in expression')
That is because parentheses can be used as part of a numeric expression in an assignment.

Code: Select all

#1 = (5+4) * 2 + sin(45)
cnckeith
Posts: 7164
Joined: Wed Mar 03, 2010 4:23 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: Yes
CNC Control System Serial Number: none
DC3IOB: Yes
CNC11: Yes
CPU10 or CPU7: Yes
Contact:

Re: Question about Gcode "grammar"

Post by cnckeith »

the CNC12 operator manuals are the best source of "centroid" gcode details. the G code and M code chapters are detailed with examples.

https://www.centroidcnc.com/centroid_di ... -v4.14.pdf

https://www.centroidcnc.com/centroid_di ... -v4.14.pdf
Need support? READ THIS POST first. http://centroidcncforum.com/viewtopic.php?f=60&t=1043
All Acorn Documentation is located here: viewtopic.php?f=60&t=3397
Answers to common questions: viewforum.php?f=63
and here viewforum.php?f=61
Gear we use but don't sell. https://www.centroidcnc.com/centroid_di ... _gear.html
hman
Posts: 8
Joined: Sun May 19, 2019 6:05 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: B0D5CC46CB03-1206170337
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Question about Gcode "grammar"

Post by hman »

Thanks to all for your replies.

Question to Marty, regarding something you posted: "Have you read up in Chapter 10 on Intercon? Have you tried the tutorials? John, I think you would really like it since you are doing much hand coding."

I've read about Intercon previously, and may yet try it. But so far, hand coding has worked well. But I've noticed that with the offline version of Centroid I purchased, and (now) also with Intercon, that the file interface is pretty much like the ancient DOS. Unlike Centroid on the mill PC, which has a Windows-style GUI. C'mon Centroid folks ... if you can do this in one place, why not in others???
martyscncgarage
Posts: 9912
Joined: Tue Mar 28, 2017 12:01 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: Yes
CPU10 or CPU7: Yes
Location: Mesa, AZ

Re: Question about Gcode "grammar"

Post by martyscncgarage »

hman wrote: Sun Nov 22, 2020 10:09 pm Thanks to all for your replies.

Question to Marty, regarding something you posted: "Have you read up in Chapter 10 on Intercon? Have you tried the tutorials? John, I think you would really like it since you are doing much hand coding."

I've read about Intercon previously, and may yet try it. But so far, hand coding has worked well. But I've noticed that with the offline version of Centroid I purchased, and (now) also with Intercon, that the file interface is pretty much like the ancient DOS. Unlike Centroid on the mill PC, which has a Windows-style GUI. C'mon Centroid folks ... if you can do this in one place, why not in others???
C'mon John, give it an honest try, its simple and it works.....you can stack "blocks" of intercon on top of each other to create a program. The canned cycles are time savers. Lastly, once you post the Intercon file to G code, you can see how your code should be formatted, even if you like to hand code. Can we teach an old dog new tricks? :) (All, John and I know each other, we belong to the local metalworking club here in the Phoenix, AZ area. John is a great guy, good sense of humor)


Marty
Reminder, for support please follow this post: viewtopic.php?f=20&t=383
We can't "SEE" what you see...
Mesa, AZ
hman
Posts: 8
Joined: Sun May 19, 2019 6:05 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: B0D5CC46CB03-1206170337
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Question about Gcode "grammar"

Post by hman »

Arf! I'll give it a try on my next project.

Meantime, any word on the DOS-like vs GUI file menu screens?
cncsnw
Posts: 3763
Joined: Wed Mar 24, 2010 5:48 pm

Re: Question about Gcode "grammar"

Post by cncsnw »

Try adding 8 to the value you have in Machine Parameter 4.
Post Reply