Machsupport Forum

G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: AJA on May 26, 2009, 09:05:08 PM

Title: G Code Help
Post by: AJA on May 26, 2009, 09:05:08 PM
I want to run this code 50 times and increment it in the Y axis in 0.100 increments.  How do I accomplish this?
Thanks
AJ

G00 X0 Y0 Z1
G01 Z0 F20
G18
G02 X-4 Z0 R3.4019
G17
G00 Z1
Title: Re: G Code Help
Post by: vmax549 on May 26, 2009, 09:48:55 PM
#2=0
M98 P100 L50
M30
%

o100
#1=.100
G00 X0 Y#2 Z1
G01 Z0 F20
G18
G02 X-4 Z0 R3.4019
G17
G00 Z1
#2=[#2+#1]
M99
%
Title: Re: G Code Help
Post by: AJA on May 27, 2009, 07:48:24 PM
Thanks vmax549,

Will you recommend a book which provides and explains examples in line by line form for the various g codes?  I use the Mach 3 user's guide but for a newbee it leaves some holes in the examples.
Thanks again
AJ
Title: Re: G Code Help
Post by: vmax549 on May 27, 2009, 09:26:13 PM
I can explain the above code if that helps,  what you were asking for went a little above basic Gcode(;-).

A good read is PeterSmid's    "CNC Programing, second edition"  BUT it can be quite a read for a beginner  BUT it does have a help CD encluded.  I still use it as a referrnece from time to time.

He does a good job of explaining.

IF you need a BASIC learner there is one on the WEB I'll try and track it down again and let you know.


THe book is: 
Easy CNC - A Beginners Guide to CNC

I have NOT read it myself but it does come recommended(;-)


(;-) TP
Title: Re: G Code Help
Post by: AJA on May 29, 2009, 07:39:58 AM
I understand the code as written, but noway would I have been able to place the lines in their correct order.

I have ordered both of the books which you recommended.  Perhaps some of their knowledge will be absorbed.

Thanks again
AJ
Title: Re: G Code Help
Post by: machininginc on July 17, 2009, 04:36:18 PM
I was taught to always use a % sign at the beginning  & the end of the program does this hold true for mach3
Title: Re: G Code Help
Post by: vmax549 on July 17, 2009, 06:11:08 PM
Not required but a good habit to be in.

(;-) TP
Title: Re: G Code Help
Post by: Sam on July 19, 2009, 04:01:16 AM
In some instances, mach does indeed need the carriage return. The "%" is just a visual cue that the carriage return (or whatever it's called nowadays) is actually there. Definitely a good habit to be in.
Title: Re: G Code Help
Post by: bdring on July 24, 2009, 08:06:20 PM
...if you need help decoding G-Code....

I wrote a web based G-Code commenter.  It adds plain English comments to G-Code.

http://www.eng-serve.com/cnc/gcode_comment.html  (http://www.eng-serve.com/cnc/gcode_comment.html)

Input

Code: [Select]
#2=0
M98 P100 L50
M30
%

o100
#1=.100
G00 X0 Y#2 Z1
G01 Z0 F20
G18
G02 X-4 Z0 R3.4019
G17
G00 Z1
#2=[#2+#1]
M99
%

It returns...

Code: [Select]
#2=0 ( #: Variable Assignment:#2=0 )
M98 P100 L50 ( M98:Call subroutine P:Line Number:100  L:Number of repititions:50 )
M30 ( M30:End program...rewind stop )
% ( %: Start or end of program )

o100 ( O:Subroutine label number:100 )
#1=.100 ( #: Variable Assignment:#1=.100 )
G00 X0 Y#2 Z1 ( G00:Rapid positioning #: Variable Assignment:#2 Z1 )
G01 Z0 F20 ( G01:Linear interpolation F:Feedrate:20 )
G18 ( G18:X-Z plane sel )
G02 X-4 Z0 R3.4019 ( G02:CW circular interpolation R:Arc radius:3.4019 )
G17 ( G17:X-Y plane sel )
G00 Z1 ( G00:Rapid positioning )
#2=[#2+#1] ( #: Variable Assignment:#2=[#2+#1] )
M99 ( M99:Return from subroutine )
% ( %: Start or end of program )
Title: Re: G Code Help
Post by: Fastest1 on October 14, 2009, 03:45:01 PM
Wow thanks for the commenter. That is quite helpful.
Title: Re: G Code Help
Post by: bdring on October 14, 2009, 03:57:01 PM
Thanks....

It is not perfect.  There are a lot of flavors of G-Code.  I was thinking of adding a "dialect" option so you could get better results for particular implementations like Mach3.  Things like Mach's M10P1 don't really mean anything in regular G-Code, but mean a lot to some Mach users.

Title: Re: G Code Help
Post by: j king on October 18, 2009, 08:52:12 PM
yes, Thanks  thats neat..
Title: Re: G Code Help
Post by: Chaoticone on October 18, 2009, 10:25:17 PM
The G-code commentor is great. Do you mind if I post some links?

Brett
Title: Re: G Code Help
Post by: bdring on October 18, 2009, 11:03:24 PM
Sure,

Link away.  I'm glad that old page is finally getting some users.