Challenge - 5 Problems
Subprogram Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediateOutput of a subprogram call with parameters
What will be the tool position output after running this CNC subprogram call?
CNC Programming
O1000 (Main program)
G0 X0 Y0
M98 P2000 L3
M30
O2000 (Subprogram)
G1 X[#1*10] Y[#1*5] F100
M99Attempts:
2 left
💡 Hint
Check how parameters are passed to subprograms in CNC code.
✗ Incorrect
The subprogram uses parameter #1 for calculations, but the main program calls M98 P2000 L3 without passing any parameter #1. Therefore, #1 defaults to 0, so the tool moves to X0 Y0 each time.
📝 Syntax
intermediateIdentify the syntax error in subprogram call
Which option contains a syntax error in calling a subprogram with repetition?
CNC Programming
M98 P3000 L5
Attempts:
2 left
💡 Hint
Look for missing values after letters in the command.
✗ Incorrect
Option B has 'L' without a number, which is invalid syntax. The repetition count must be specified after L.
🚀 Application
advancedUsing subprograms to drill multiple holes
You want to drill 4 holes spaced 20mm apart on the X-axis starting at X0 Y0. Which subprogram call and main program combination will correctly drill all holes?
CNC Programming
O1000 (Main program)
G0 X0 Y0
M98 P2000 L4
M30
O2000 (Subprogram)
G81 X[#1] Y0 Z-5 R1 F75
M99Attempts:
2 left
💡 Hint
How do you pass different parameters for each repetition in CNC subprogram calls?
✗ Incorrect
The M98 L4 repeats the subprogram 4 times but does not change parameter #1 automatically. Without looping logic or parameter changes, #1 stays the same (default 0).
🔧 Debug
advancedDebugging unexpected tool position after subprogram call
After running this CNC program, the tool does not move as expected. What is the cause?
CNC Programming
O1000 G0 X0 Y0 #100=10 M98 P2000 L3 M30 O2000 G1 X[#100*#1] Y0 F100 M99
Attempts:
2 left
💡 Hint
Check how parameters and variables are used inside subprograms.
✗ Incorrect
The subprogram uses #1 as a multiplier, but the main program does not pass #1. So #1 defaults to zero, making the position zero.
🧠 Conceptual
expertEffect of nested subprogram calls with repetition
Consider a main program calling subprogram O2000 with L2, and O2000 calls subprogram O3000 with L3. How many times will O3000 run?
CNC Programming
O1000 M98 P2000 L2 M30 O2000 M98 P3000 L3 M99 O3000 G1 X10 Y10 F100 M99
Attempts:
2 left
💡 Hint
Multiply the repetition counts of nested calls.
✗ Incorrect
O2000 runs 2 times, each time calling O3000 3 times, so total 2*3=6 runs of O3000.
