The program starts by defining parameters, uses them in commands, calculates values, and then executes CNC machine movements.
Execution Sample
CNC Programming
#100=50 (Set parameter 100 to 50)#101=20 (Set parameter 101 to 20)
G01 X[#100+#101] Y[#100-#101] F100 (Move using parameters)
M30 (End program)
This CNC program sets two parameters and uses them to calculate X and Y positions for a linear move.
Execution Table
Step
Action
Parameter/Variable
Value
Explanation
1
Set parameter #100
#100
50
Parameter #100 is assigned 50
2
Set parameter #101
#101
20
Parameter #101 is assigned 20
3
Calculate X position
X
70
X = #100 + #101 = 50 + 20
4
Calculate Y position
Y
30
Y = #100 - #101 = 50 - 20
5
Execute G01 move
X,Y
(70,30)
Move to X=70, Y=30 at feed rate 100
6
End program
M30
-
Program ends
💡 Program ends after executing M30 command
Variable Tracker
Parameter
Start
After Step 1
After Step 2
After Step 3
After Step 4
Final
#100
undefined
50
50
50
50
50
#101
undefined
undefined
20
20
20
20
X
undefined
undefined
undefined
70
70
70
Y
undefined
undefined
undefined
undefined
30
30
Key Moments - 3 Insights
Why do we use parameters like #100 and #101 instead of fixed numbers?
Using parameters allows easy changes and calculations. For example, in steps 1 and 2, we set #100 and #101 once, then reuse them in calculations at steps 3 and 4.
How does the CNC machine know what values to move to in the G01 command?
The machine calculates X and Y by adding or subtracting parameters as shown in steps 3 and 4, then moves to those positions in step 5.
What happens if we change a parameter value after it is used?
The program uses the parameter values at the time of calculation. Changing a parameter after step 4 won't affect the move already calculated in step 5.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the value of parameter #101 after step 2?
Aundefined
B20
C50
D70
💡 Hint
Check the 'Parameter/Variable' and 'Value' columns at step 2 in the execution table.
At which step does the program calculate the Y position?
AStep 5
BStep 3
CStep 4
DStep 2
💡 Hint
Look for the row where 'Calculate Y position' is the action in the execution table.
If parameter #100 was changed to 60 before step 3, what would be the new X value?
A80
B70
C60
D50
💡 Hint
X is calculated as #100 + #101. If #100=60 and #101=20, add them.
Concept Snapshot
Parametric programming uses variables (parameters) like #100 to store values.
You can perform calculations with these parameters in CNC commands.
This makes programs flexible and easy to change.
Example: #100=50 sets a parameter, then use X[#100+20] to move.
Program ends with M30.
Full Transcript
Parametric programming in CNC means using variables called parameters to store numbers. You start by setting parameters, for example #100=50. Then you use these parameters in commands, like moving the tool to X position calculated by adding parameters. The CNC machine calculates these values step by step and moves accordingly. This method makes programs easier to change and reuse. The program ends with the M30 command.
Practice
(1/5)
1. What is the main purpose of using variables in parametric programming for CNC machines?
easy
A. To make programs flexible and reusable
B. To increase the size of the CNC program
C. To slow down the machine speed
D. To remove all manual inputs
Solution
Step 1: Understand the role of variables
Variables store values that can change, allowing the program to adapt without rewriting code.
Step 2: Connect flexibility to parametric programming
Using variables lets the CNC program adjust dimensions or parameters easily, making it reusable for different parts.
Final Answer:
To make programs flexible and reusable -> Option A
Quick Check:
Variables = Flexibility [OK]
Hint: Variables let you change values without rewriting code [OK]
Hint: Remember multiplication before addition in brackets [OK]
Common Mistakes:
Adding before multiplying (10 + 20 = 30, then *2 = 60)
Ignoring brackets syntax
Assuming syntax error due to brackets
4. Identify the error in this parametric CNC code:
#10 = 5 #11 = [#10 + 3 G01 X[#11]
medium
A. Missing closing bracket ']' in variable assignment
B. Variable #10 cannot be assigned a value
C. G01 command syntax is incorrect
D. Variables cannot be used in G01 commands
Solution
Step 1: Check variable assignment syntax
#11 = [#10 + 3 is missing the closing bracket ']'.
Step 2: Verify other lines
#10 assignment is correct, G01 command syntax is valid with variable usage.
Final Answer:
Missing closing bracket ']' in variable assignment -> Option A
Quick Check:
Brackets must be balanced [OK]
Hint: Always close brackets in expressions [OK]
Common Mistakes:
Ignoring missing bracket errors
Thinking variables can't be used in G01
Assuming variable #10 assignment is wrong
5. You want to create a parametric program to drill holes spaced evenly along the X-axis. Which approach correctly uses parametric programming to set hole positions for 5 holes spaced 10 units apart starting at X=0?
hard
A. #100 = 0 WHILE [#100 < 50] DO G81 X[#100] Y0 Z-5 R1 #100 = [#100 + 10] ENDWHILE