CNCSimulator Pro

user guide
×
Menu
Index

11.7. Examples

Let us start with a milling example that will make a bolt hole circle.
 
(Bolt hole circle drilling custom macro example)
 
#region
$Millimeters
$Mill
$Message "Make sure the macro interpreter is activated in settings" 4
$AddEmbeddedRegPart 5
$ReadTasDefinedTool
$DefineMillTool "N:Drill mm" 5 120.00 0.00 0.00 10.00 50.00 2
#endregion
 
O1000 (Main program)
T5 M06
G00 X70 Y70 Z35
G65 P1005 X70 Y70 Z30 R40 D10 A180 H8 F250 S2000 (Call the macro)
M30
 
O1005 (Bolt hole drilling custom macro)
#100=0 (Hole counter)
#101=360/#11 (Angle increment)
WHILE[#100 LT #11] DO 1        (Loop until the specified number of holes has been drilled)
#102 =#24 + COS[#1]*#18 (Calculate hole center X)
#103 =#24 + SIN[#1]*#18 (Calculate hole center Y)
G81 X#102 Y#103 R[#26+2] Z[#26-#7] F#9 S#19 (Drill the hole)
G80 (Cancel G81)
#100=#100+1 (Increase hole counter by one)
#1=#1+#101 (Increase the angle)
END 1 (END LOOP 1)
M99 (Return to main program)
 
As you can see, G65 is used to call a macro. The values of the X,Y,Z,R,D,A,H,F, and S words will be transferred to their corresponding local variables (A=#1, B=#2, etc.).
 
Open the Milling Center machine and make sure Millimeters are set as units in the settings. Run the example end execute it step by step as you keep an eye on the variables.
 
 
Here is another example, this time made for the Turning Center.
 
#region
$Millimeters (Alarm if not mm set)
$Lathe (Alarm if not lathe machine)
$AddEmbeddedRegPart 1 (Embedded workpiece 10)
#endregion
 
O100 (Main program)
N10 ET1 (Embedded Tool number 1)
N20 M6
N40 G00 X74 Z143 M09 M4 S2000
N50 G65 P1001 X45 Z100 D3.2 A2.5 F200 S1340 (Macro call)
N1960 M30
 
O1001
#100=#302 (Record current Z)
WHILE[#300GT#24+#7*2+#1*2] DO 1
G01 Z#26 (Rough cut)
G91 G00 X[#1*2] Z#1 (Retract A)
G90 Z#100 (Go back)
G01 X[#300-#7*2-#1*2] (Next diam)
END 1
G00 X#24 (Final diam)
G01 Z#26 (Final cut)
G91 G00 X[#1*2] Z#1 (Retract A)
G90 Z#100
M99