📖 Scenario: You work in a workshop where CNC machines cut circular shapes. You need to write a simple CNC program that draws a full circle using G-code commands.
🎯 Goal: Create a CNC program that draws a full circle with a radius of 10 units, starting from the center point (X0 Y0).
📋 What You'll Learn
Create variables for the circle center coordinates and radius
Set the feed rate for the cutting tool
Write the G-code command to cut a full circle using the correct arc command
Output the complete CNC program code
💡 Why This Matters
🌍 Real World
CNC machines use G-code to cut precise shapes. Writing correct circle commands helps automate manufacturing.
💼 Career
Understanding G-code basics is essential for CNC programmers and machinists to create and troubleshoot machining programs.
Progress0 / 4 steps
1
Set up circle parameters
Create variables called center_x and center_y and set both to 0. Also create a variable called radius and set it to 10.
CNC Programming
Hint
Use simple assignment statements to set the values.
2
Set feed rate
Create a variable called feed_rate and set it to 1000.
CNC Programming
Hint
Feed rate controls how fast the tool moves.
3
Write G-code for full circle
Create a variable called gcode_circle that contains the G-code command to cut a full circle starting at (X0 Y0) with radius 10, using the feed rate variable feed_rate. Use the G02 command for clockwise arc, and set the arc center offsets I and J to the radius values. Format the string exactly as: G02 X0 Y0 I10 J0 F1000 but use the variables for radius and feed_rate.
CNC Programming
Hint
Use an f-string to insert variables into the G-code command.
4
Output the CNC program
Print the gcode_circle variable to display the full CNC command.
CNC Programming
Hint
Use the print function to show the G-code command.
Practice
(1/5)
1. What does the G02 command do in full circle CNC programming?
easy
A. It turns the spindle on.
B. It cuts a counterclockwise arc or circle.
C. It sets the machine to absolute positioning mode.
D. It cuts a clockwise arc or circle.
Solution
Step 1: Understand G02 command purpose
G02 is used to cut arcs or circles in a clockwise direction.
Step 2: Compare with other commands
G03 cuts arcs counterclockwise, so G02 must be clockwise.
2. Which of the following is the correct syntax to program a full clockwise circle with radius 10 ending at (X0, Y0) using G02?
easy
A. G02 X0 Y0 I10 J0 F100
B. G02 X0 Y0 I0 J10 F100
C. G02 X0 Y0 I-10 J0 F100
D. G02 X0 Y0 I0 J-10 F100
Solution
Step 1: Understand I and J parameters
I and J specify the center offset from the start point in X and Y directions respectively. For radius 10 on X-axis, I=10, J=0.
Step 2: Check direction and feedrate
G02 is clockwise, feedrate F100 is valid. So syntax with I10 J0 is correct.
Final Answer:
G02 X0 Y0 I10 J0 F100 -> Option A
Quick Check:
Center offset I=10, J=0 for radius 10 [OK]
Hint: I and J are center offsets; positive I means right of start [OK]
Common Mistakes:
Swapping I and J values
Using negative radius offsets incorrectly
Omitting feedrate F
3. What will be the result of this CNC code snippet?
G90
G21
G00 X0 Y0
G02 X0 Y0 I10 J0 F150
medium
A. The code will cause a syntax error and stop.
B. The machine will move in a straight line to X10 Y0.
C. The machine will cut a full clockwise circle with radius 10 at origin.
D. The machine will cut a counterclockwise arc with radius 10.
Solution
Step 1: Analyze positioning and units
G90 sets absolute positioning, G21 sets units to millimeters.
Step 2: Interpret G02 command
G02 with X0 Y0 and I10 J0 means cut a clockwise arc starting and ending at origin with center offset 10mm in X, making a full circle.
Final Answer:
The machine will cut a full clockwise circle with radius 10 at origin. -> Option C
Quick Check:
G02 with same start/end and I/J offset = full circle [OK]
Hint: Same start/end point with I/J offset = full circle [OK]
Common Mistakes:
Thinking G02 moves in straight line
Confusing clockwise with counterclockwise
Assuming syntax error due to zero end point
4. Identify the error in this full circle CNC program snippet:
G90
G21
G03 X0 Y0 I10 J0 F100
medium
A. Start and end points are the same but I and J do not form a valid circle center.
B. I and J values should be negative for G03.
C. Feedrate F100 is missing.
D. G03 cannot be used for full circles.
Solution
Step 1: Check start and end points
Start and end points are both at X0 Y0, which is valid for full circle.
Step 2: Validate I and J center offsets
I=10 J=0 means center is 10 units right of start. For a full circle, the center must be correctly offset to form a circle. Here, the center offset is valid, but the direction G03 is counterclockwise, so the path may not complete correctly if the machine expects a different center.
Step 3: Identify the actual problem
In many CNC controls, for a full circle with G03, the center offset must be negative or adjusted to match the direction. Using I10 J0 with G03 causes an invalid arc path.
Final Answer:
I and J values should be negative for G03. -> Option B
Quick Check:
Center offset must match arc direction [OK]
Hint: Center offsets must match arc direction for full circles [OK]
Common Mistakes:
Assuming feedrate is missing
Thinking G03 can't do full circles
Using wrong sign for I/J without checking direction
5. You want to program a full circle of radius 15 mm centered at X20 Y20 using G03 (counterclockwise). The start point is at X35 Y20. Which is the correct G-code line to cut this circle?
hard
A. G03 X35 Y20 I-15 J0 F120
B. G03 X35 Y20 I15 J0 F120
C. G03 X35 Y20 I0 J-15 F120
D. G03 X35 Y20 I0 J15 F120
Solution
Step 1: Determine center offset from start point
Start point is X35 Y20, center is X20 Y20. Offset I = centerX - startX = 20 - 35 = -15, J = 20 - 20 = 0.
Step 2: Match arc direction with offsets
G03 is counterclockwise, so negative I offset is correct to go around center counterclockwise.
Final Answer:
G03 X35 Y20 I-15 J0 F120 -> Option A
Quick Check:
Center offset I = -15 matches start and center [OK]
Hint: Center offset = center - start; sign matters for direction [OK]
Common Mistakes:
Using positive I when negative is needed
Swapping I and J values
Ignoring start point coordinates
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.