Unit 17: Computer aided manufacturing (CAM)

LO2: Be able to produce CNC programs for the manufacture of components

G-code Programming

Instructions and answers for tutors

These instructions should accompany the OCR learner resource activity which supports Cambridge Technicals in Engineering Level 3.

Activity 1

G-codes are the basis of the control of CNC machines and 3D printers. With complex shapes especially 3D forms, the coding is usually done by software from an imported model in STL format. This is because thousands of lines of code are required. In order to understand how the machines are driven by the code and how to edit if required, it is useful to be able to program simple shapes for cutting from sheet materials with constant z depth (often known as 2½D machining). Later the complexities of programming full 3D milling and lathe work can be explored.

Provide some G-code programs of simple shapes (2½D) and suitable G-code or machine simulation software for a router of milling machine. Have reference sheets with standard G and M codes.

Examples at:

Discuss the results thatlearners give in this table to ensure they understand where X. Y and Z coordinates are required and their positive and negative directions. Explain modal commands (set and reset). Other codes are introduced in later tasks.

In order to / Use this code
Program in millimetres (mm) / G21
Set feed rate per minute / G94
Stop the spindle (compulsory) / M00
End the program and return to program top / M30
Move the position rapidly / G00
Move the position in a straight line / G01
Stop the spindle (optional) / M01
Specify feed rate (mm/min) / F

Activity 2

This task will check the learners’ application of G-codes to simple straight line cuts using X, Y and Z coordinates. Feed rates would be the subject of another lesson so the value could be given.

Activity 3

This task introduces G02 and G03 (or G12/G13 if appropriate for your machines) for circular interpolation, also cutter size compensation (G41/G42). This can be seen neatly in TechSoft 2D Design software where a cutter compensation path can be created for export to the machine (not G-code).

Example code for circle:

G0 X50 Y80 Z2

G1 Z-5 M8 M3 S2300 F200

G2 I0 J-50

M30

Activity 4

Learners will need to consider cutting internal cuts first so that the remaining piece is held securely. The two holes can be cut in any order.

Learners should understand that cutters have a finite diameter which means that the cutter path must be offset into waste material and not follow the drawn lines in the design. The rectangle cannot be cut with right-angled corners because the cutter is circular, but may be finished in another way.

It is assumed that learners know the basic G and M codes required for this task. Also the standard codes at beginning and end of the program would have been covered previously.

The trial G-codes can be run in CNC simulator software or machine software that allows a simulation.

Unit 17: Computer aided manufacturing (CAM)

LO2: Be able to produce CNC programs for the manufacture of components

G-code Programming

Learner activity sheet

Activity 1

G-codes are the basis of the control of CNC machines and 3D printers. With complex shapes especially 3D forms, the coding is usually done by software from an imported model in STL format. This is because thousands of lines of code are required. In order to understand how the machines are driven by the code and how to edit if required, it is useful to be able to program simple shapes for cutting from sheet materials with constant z depth (often known as 2½D machining).

Import a simple G-code program into a CNC simulator or CNC machine program. It should be possible to see the model being cut line by line to understand the code. Refer to a list of common G and M codes and complete this table:

In order to / Use this code
Program in millimetres (mm)
Set feed rate per minute
Stop the spindle (compulsory)
End the program and return to program top
Move the position rapidly
Move the position in a straight line
Stop the spindle (optional)
Specify feed rate (mm/min)

Activity 2

Use your knowledge of G-codes to write a program to cut straight line shapes (1 mm deep). The letters L, M, N, V or W are suggested. Use sensible dimensions within a 50mm grid. Write or import the G-code program into a CNC simulator or CNC machine program to check your work.

Activity 3

Use your knowledge of G-codes to create a rectangular cut 50 x 60 mm and circular cut 50mm diameter. You will need an additional G-code for the circle. Write or import the G-code program into a CNC simulator or CNC machine program to check your work.

If you were to cut a rectangular piece 50 x 60mm or a disc exactly 50mm diameter would you need to use a different program? Try this out.

Activity 4

Figure 1 shows a design sketch for a loudspeaker front panel with two holes. The panel is to be cut from a sheet of 6mm thick MDF on a router with a 6mm end mill.

Figure 1

1.Decide on the order of cuts and why it’s important.

2.Work out why aspects of this design cannot be made on a router without modification.

3.Give the part some sensible dimensions and write a G-code program for the three cuts. Try your program in a CNC simulator.

Version 1