Title
Theory of CNC
Submitted to:
Sir Tayyab Quershi
Submitted by:
Roll no# 18-MT-21
Punjab Tianjin University Of Technology Lahore
G code
G stands for geometry, and it's the alphanumeric format the system uses to tell
the parts what to do. It indicates where to start, how to move and when to stop.
For machinists, the problem with using G codes is different machines use
variations on a standard set of alphanumeric numbers
M code
M-code (for “miscellaneous function”) is an auxiliary command; descriptions
vary. Many M-codes call for machine functions like “open workstation door,”
which is why some say “M” stands for “machine”, though it was not intended
to.
G-code is a type of function used in Numerical Control programming language
that contains the information to position a tool to do the actual work Since
G-codes are preparatory codes, in a CNC
program they begin with the letter G and direct the machine. Typical actions
G-code directs include: Changing a pallet.
Difference
1. GCodeisaGeometricCode,whichisusedformakeageometry/profileofa
component havingcylinder/barinCNCLatheorRectangularPlatesinCNC
Milling andCNCWEDM.
2. McodeisaMachineCodeorMiscellaneusCode,whichisusedformachinefunctions
inall CNCmachines.i.e.Coolanton/off,SpindleSpeedon/off,toolchange,
machinestop permanent/temporary etc.
M code G code
• M00: Program stop
• M01: Optional program
stop
• M02: End of program
• M03: Spindle on
clockwise
• M04: Spindle on
counterclockwise
• M05: Spindle stop
N: Line
number G:
Motion
X: Horizontal
position Y:
Vertical
position Z:
Depth
F: Feed rate
S: Spindle speed
T: Tool selection
M: Miscellaneous functions
I and J: Incremental
center of an arc R:
Radius of an ar
Nevertheless, after reading all of this, now we are able to manually make a real,
actual code. Here’s an example:
1. %
2. G21 G17 G90 F100
3. M03 S1000
4. G00 X5 Y5 ; point B
5. G01 X5 Y5 Z-1 ; point B
6. G01 X5 Y15 Z-1 ; point C
7. G02 X9 Y19 Z-1 I4 J0 ; point D
8. G01 X23 Y19 Z-1 ; point E
9. G01 X32 Y5 Z-1 ; point F
10. G01 X21 Y5 Z-1 ; point G
11. G01 X21 Y8 Z-1 ; point H
12. G03 X19 Y10 Z-1 I-2 J0 ; point I
13. G01 X13 Y10 Z-1 ; point J
14. G03 X11 Y8 Z-1 I0 J-2 ; point K
15. G01 X11 Y5 Z-1 ; point L
16. G01 X5 Y5 Z-1 ; point B
17. G01 X5 Y5 Z0
18. G28 X0 Y0
19. M05
20. M30
21. %
Impotance
Application of M codes
• Other letter designations (or, “words”) are used to specify feed rate (F),
spindle speed (S), tool addresses (T), etc.
• A full CNC program will be peppered with these letters as well as the
G and M-codes. Several M-codes are used to reference the control
panel for operator input. M01, an optional program stop, temporarily
halts the program and awaits input from the operator if the Opt Stop
button on the control panel is on. Otherwise, the M01 command is
ignored.
• This function might be used to allow the operator to remove chips.
• Another panel button labeled Block Skip will make the programs
skip over any code blocks that are preceded by a forward slash. This
is useful for auto-feeding operations as it can be used to skip over
the program stop command.
Need of G code and M code
• Technically a machine operator doesn’t need to know G-code. If the
CAM software has already created a cutting program, it feeds that
information to the CNC machining center. The software has already
determined the “speed and feed”, the tool path and all the other
variables needed to make the part. The operator can simply press the
start button and watch the part being made, but there are many
problems to this approach
• CAM programs seldomproduce the optimal tool path for the fastest
and most efficient cutting of a part, especially for complex geometries.
This is because, as mentioned above, it is “thinking” point-by-point
and step-by-step, not thinking globally. Only a human machinist with
real-world experience is capable of determining the ideal function of
the machine tool to meet the expectations of the customer’s design
intent. CAM is also optimized for maximum safety and machine tool
life, which translates as slow. Sometimes very slow.
G code and M code

G code and M code

  • 1.
    Title Theory of CNC Submittedto: Sir Tayyab Quershi Submitted by: Roll no# 18-MT-21 Punjab Tianjin University Of Technology Lahore
  • 2.
    G code G standsfor geometry, and it's the alphanumeric format the system uses to tell the parts what to do. It indicates where to start, how to move and when to stop. For machinists, the problem with using G codes is different machines use variations on a standard set of alphanumeric numbers M code M-code (for “miscellaneous function”) is an auxiliary command; descriptions vary. Many M-codes call for machine functions like “open workstation door,” which is why some say “M” stands for “machine”, though it was not intended to. G-code is a type of function used in Numerical Control programming language that contains the information to position a tool to do the actual work Since G-codes are preparatory codes, in a CNC program they begin with the letter G and direct the machine. Typical actions G-code directs include: Changing a pallet. Difference 1. GCodeisaGeometricCode,whichisusedformakeageometry/profileofa component havingcylinder/barinCNCLatheorRectangularPlatesinCNC Milling andCNCWEDM. 2. McodeisaMachineCodeorMiscellaneusCode,whichisusedformachinefunctions inall CNCmachines.i.e.Coolanton/off,SpindleSpeedon/off,toolchange, machinestop permanent/temporary etc. M code G code • M00: Program stop • M01: Optional program stop • M02: End of program • M03: Spindle on clockwise • M04: Spindle on counterclockwise • M05: Spindle stop N: Line number G: Motion X: Horizontal position Y: Vertical position Z: Depth
  • 3.
    F: Feed rate S:Spindle speed T: Tool selection M: Miscellaneous functions I and J: Incremental center of an arc R: Radius of an ar
  • 4.
    Nevertheless, after readingall of this, now we are able to manually make a real, actual code. Here’s an example: 1. % 2. G21 G17 G90 F100 3. M03 S1000 4. G00 X5 Y5 ; point B 5. G01 X5 Y5 Z-1 ; point B 6. G01 X5 Y15 Z-1 ; point C 7. G02 X9 Y19 Z-1 I4 J0 ; point D 8. G01 X23 Y19 Z-1 ; point E 9. G01 X32 Y5 Z-1 ; point F 10. G01 X21 Y5 Z-1 ; point G 11. G01 X21 Y8 Z-1 ; point H 12. G03 X19 Y10 Z-1 I-2 J0 ; point I 13. G01 X13 Y10 Z-1 ; point J 14. G03 X11 Y8 Z-1 I0 J-2 ; point K 15. G01 X11 Y5 Z-1 ; point L 16. G01 X5 Y5 Z-1 ; point B 17. G01 X5 Y5 Z0 18. G28 X0 Y0 19. M05 20. M30 21. %
  • 5.
  • 6.
    Application of Mcodes • Other letter designations (or, “words”) are used to specify feed rate (F), spindle speed (S), tool addresses (T), etc. • A full CNC program will be peppered with these letters as well as the G and M-codes. Several M-codes are used to reference the control panel for operator input. M01, an optional program stop, temporarily halts the program and awaits input from the operator if the Opt Stop button on the control panel is on. Otherwise, the M01 command is ignored. • This function might be used to allow the operator to remove chips. • Another panel button labeled Block Skip will make the programs skip over any code blocks that are preceded by a forward slash. This is useful for auto-feeding operations as it can be used to skip over the program stop command. Need of G code and M code • Technically a machine operator doesn’t need to know G-code. If the CAM software has already created a cutting program, it feeds that
  • 7.
    information to theCNC machining center. The software has already determined the “speed and feed”, the tool path and all the other variables needed to make the part. The operator can simply press the start button and watch the part being made, but there are many problems to this approach • CAM programs seldomproduce the optimal tool path for the fastest and most efficient cutting of a part, especially for complex geometries. This is because, as mentioned above, it is “thinking” point-by-point and step-by-step, not thinking globally. Only a human machinist with real-world experience is capable of determining the ideal function of the machine tool to meet the expectations of the customer’s design intent. CAM is also optimized for maximum safety and machine tool life, which translates as slow. Sometimes very slow.