Re: [CAD_CAM_EDM_DRO] G & M Codes?????????????
Posted by
Mark Whitis
on 2006-07-18 18:05:34 UTC
> I was told that the G codes were "Geometry" and the M codes "Miscellaneous"Miscellaneous is probably correct, though "geometry" is probably just
> Now, I can't verify that those are the correct terms but some years ago that
> is what I was told. Of course, some G codes now handle jumps and
> sub-routines which have been added to the capabilities of the CNC controllers. M codes
> still seem to do miscellaneous tasks such as starting spindles, tool
> changes, coolant, program end and in some cases, jumps, sub-routine calls,
> sub-routine end, etc.
folk etemology (because it did not appear to originally have anything to
do with geometry), or could be similar to situations where people come up
with acronyms first and find words to fit them later. More likely
they were "General" and "Miscellaneous".
When g-code was first developed, I believe it was in the 60s on hardwired
logic controllers that had no intellegence. I have vague recollections
of designing some circuits like that, myself, a bit later. The single
letter followed by a number syntax is a relection of this (actually,
I am surprised they didn't put the number first since that
simplifies the logic). Even when microprocessors came around,
in the early days when everything had to be done in assembler or
even raw machine code and program sizes were very limited, it wasn't
uncommon to see similar syntaxes. The primary factor for using
G and M may have been that they were what was left over after
the "good" letters were used for the many axes, though early machines
didn't probably have as many. It is also important to realize
that the selection of the letters could have been to save logic (more
below). Logic was very expensive then, you not only had the cost
of the chips, but the board area, and the PCB had to be laid out
without the aid of a computer and photoplotter with tape and decals
and reduced using a litho camera. "G" could also stand for "GO"
and G and M could easily have been reversed as "Motion" and
"General Purpose I/O". G could also have stood for "Gerber", since the
gerber photoplotter was one of the first, if not the first, user
or in a gerber context, "general". In a gerber file, "G04" is a
comment. The gerber photoplotters had a xenon flash lamp or other
bright light source and optics which imaged an aperature wheel onto
the film. They had "draw" and "flash" operations.
Wikipedia says (http://en.wikipedia.org/wiki/Numerical_control) that
the "G" in "G-code" stands for "Gerber" not the "G" in some instructions.
The G codes were likely rare in early g-code, if they were present
at all.
Here are the codes used in gerber files, though these are based on
somewhat more modern devices than the original implementation.
It is quite possible that the earliest devices did not support
multiple options for absolute/incremental and inches/millimeters
and may not have offered linear or circular interpolation (requiring
the computer to send a lot more instructions) and so there is
a good chance that there was no such thing as a "G" code in the
early g-code.
Xnnn xaxis value
Ynnn yaxis value
D01 move to specified XY location with shutter open (or repeatedly
strobe flash lamp)
D02 move to the specified XY location with shutter closed (or flash
lamp off)
D03 move to the specified XY location then "flash" the aperature
G90/G91 absolute/incremental coordinates
G70/G71 inches vs millimeters
G54Dxx aperature slect on some models. On others you select
an aperature by using Dxx where xx > 3.
Mxxx (described as Miscellaneous in a recent doc)
Basically different types of stop codes
G02/G03/G75 draw arcs/circles
"G" codes are called "Preperatory codes"
"*" was the command seperator
Nxx a sequence number
The chararcters that were probably recognized by early gerber
photoplotters and their binary codes are:
0 00110000
1 00110001
2 00110010
3 00110011
4 00110100
5 00110101
6 00110110
7 00110111
8 00111000
9 00111001
X 01011000
Y 01011001
D 01000100
M 01001101
G 01000111
N 01001110
* 00101010
+ 00101011
- 00101101
The minus sign and decimal point might also have been used.
There are a number of logic shortcuts that can be taken with these.
D7=0, D6=0, D5=1, D4=1 character is a digit.
Take the value in the accumulator shift it left 4 bits and
add the value shifted left 2 bits to multiply by 10. Then
add the value in D0...D3.
The remaining codes can be partially decoded (i.e. there are other unused
characters that might have the same effect) by a 3 to 8 multiplexor on
bits D0...D3 and the fact that D7...D4 did not match the digit pattern.
With partial decoding, some letters were not usable as they would collide
with others. Also, the internal logic is likely to involve storing the
destination register number "X", "Y","D", "G", and "M", and "N" when the
character is encountered to be used later at the end of the digit
sequence. A 3 bit destination selection register is sufficient to
distinguish betwen these destinations. "G" is also easy to decode as the
low order 3 bits are all logic "1". "M" shares the same low order 4 bit
pattern as a minus sign. All of the non-axis destination codes share the
same upper 4 bit pattern, which limits you to A...O.
The manual for a much more modern version of gerber codes (with many
extensions) can be found here:
http://www.contrive.it/Download/rs274xb.pdf
It uses "General" and "Miscellaneous" to describe G and M codes.
Calcomp pen plotters date back to 1958 (calcomp 565). It is hard to
determine if they used anything like g-code though since it appears only
the fortran library calls were standard and the mainframe computer
probably controlled the stepper motors directly. The bresenham
line-drawing algorithm
was developed on a calcomp plotter in 1962. Prior to the development of
that algorithm, it would have been difficult to make a hard wired g-code
controller as line drawing required too much multiplication and division.
However, it looks like the ferst NC machine tool was developed by
John T. Parsons and Frank L Stulen of the Parson's Company and
William M. Pease and James O McDonough of the MIT Servomechanisms laboratory in
1952 (patent number 2,820,187).
http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO1&Sect2=HITOFF&d=PALL&p=1&u=%2Fnetahtml%2FPTO%2Fsrchnum.htm&r=1&f=G&l=50&s1=2820187.PN.&OS=PN/2820187&RS=PN/2820187
This machine (A 5 axis gantry mill) did not use g-code, instead it used
fixed field punched cards, and does not appear to have done linear
interpolation. Instead, the motors ran indpendently between the
specifified points and a jagged edge was produced that was later touched
up with a file. It was used to make airplane parts such as airfoils.
Around the same time, GM was making a lathe that recorded the motions as
a machinist made the first copy.
The term "G & M code" itself is probably a misusage deriving
from quick reference charts that gave lists of G-codes and M-codes
(the other letters being parameters to G codes). The language
is G-code, not "G & M code". Google gives 220 matches for "G & M code"
and 469,000 for g-code, although a little over half are unrelated.
196,000 matches for '"G-code" OR gcode ( "numerical control" OR CNC OR
gerber OR RS274D OR RS274NGC OR RS274X)' Calling it "G & M code" is like calling
English "nouns and verbs" or the "C Programming Language" "operators and
statements".
M codes tend to do trivial functions, often controlled by relays. Such
as turning on and off coolant or stopping or pausing the paper tape
reader. G codes tend to do more complex operations that take
parameters or at least alter the internal state of the controller.
Interestingly, it looks like the APT language (check your Machinery's
handbook if you aren't familiar) preceeded g-code. APT was developed
at MIT in 1958. However, APT required a computer. It looks like
the evolution went like this:
- 1952: batch CNC - Parson's et. al. Where the computer did most
of the work ahead of time as a batch job and produced a card deck
to drive the machine. No standard language.
- 1958: APT was a refinement in how one described the job to the
computer
- 1960s: Numerical Control
Paper tape, g-code, hardware interpolation. A machinist or
engineer only needed a teletype to program the machine.
Teletypes were much cheaper than computers and allowed much
more widespread usage.
- real time CNC - when the computer bacame involved in the
operater interface (position display, backplots, manual entry,
position display, single stepping, etc.) whether
or not an external controller was doing the most
important real time work.
Discussion Thread
lc4short50
2006-07-18 11:31:24 UTC
G & M Codes?????????????
cnc002@a...
2006-07-18 11:41:20 UTC
Re: [CAD_CAM_EDM_DRO] G & M Codes?????????????
Harko Schwartz
2006-07-18 14:34:20 UTC
Re: G & M Codes?????????????
ballendo
2006-07-18 17:31:23 UTC
Re: G & M Codes?????????????
Mark Whitis
2006-07-18 18:05:34 UTC
Re: [CAD_CAM_EDM_DRO] G & M Codes?????????????
wthomas@g...
2006-07-18 18:30:58 UTC
W.E.T.: [CAD_CAM_EDM_DRO] Re: G & M Codes?????????????
Ken Ferrell
2006-07-18 19:15:21 UTC
Re: G & M Codes?????????????
cnc002@a...
2006-07-18 19:38:22 UTC
Re: [CAD_CAM_EDM_DRO] Re: G & M Codes?????????????
lcdpublishing
2006-07-19 06:53:46 UTC
Re: G & M Codes?????????????
Doug M
2006-07-19 09:46:54 UTC
Re: W.E.T.: [CAD_CAM_EDM_DRO] Re: G & M Codes?????????????
Graham Stabler
2006-07-19 11:27:29 UTC
Re: G & M Codes?????????????
Fred Smith
2006-07-19 14:05:44 UTC
Re: G & M Codes?????????????
Ken Ferrell
2006-07-20 14:43:16 UTC
Re: G & M Codes?????????????
ravi gehlot_eck
2006-07-21 04:49:58 UTC
group
caudlet
2006-07-21 06:25:38 UTC
Re: group (how to leave)
Fred Smith
2006-07-24 16:46:49 UTC
Re: G & M Codes?????????????