Question
I was wondering if anyone had a sample CNC program that uses parametric programming. I have ordered a new Biesse CNC router and I'm currently learning CNC programming from a book. Unfortunaetly it does not have any parametric code and this is one of the things that I'm interested in. Does anyone have any sample code or links to sites that have sample code?
Forum Responses
(CNC Forum)
From contributor A:
Parametric is not code. It is simple math formulas. If you did buy a new machine from Biesse you will have training in North Carolina where they will teach you this. Which machine did you buy?
Imagine - I have no machine and a book teaching CNC programming based on the ISO format (with no parametric code or samples). Once I have this book mastered I then want to introduce myself to parametric CNC programming. Can anyone provide some samples (don't care about the result - just want to see the formulas used) or references to web sites that show examples or the basics for this type of CNC programming? Thanks in advance for any help.
I hope that makes sense to someone other than me. This example is as basic as it gets, but the possibilities are endless.
O0001 (Program number)
#100=1. (Diameter of end mill)
#101=3.0 (X position of hole)
#102=1.5 (Y position of hole)
#103=.5 (Depth of counterbored hole)
#104=400 (Speed in RPM)
#105=3.5 (Feedrate in IPM)
#106=3. (Tool length offset number)
#107=2.0 (Diameter of counterbored hole)
G90 G54 S#104 M03 (Select abs mode, coordinate system, start spindle)
G00 X#101 Y#102 (Rapid to hole center)
G43 H#106 Z.1 (Instate tool length compensation, rapid to approach Z position)
G01 Z-#103 F[#105 / 2]
Y[#102 + #107 / 2 - #100 / 2] F#105
G02 J-[#107 / 2 - #100 / 2]
G01 Y#102
G00 Z.1
M30
If people continue to add examples to this post it could become a helpful reference for people who want to learn a bit of parametric CNC programming, as there seems to be a lack of available sample code.
N10 G70 HC=1 LY=20 PLPZ=0.75 FIL=0 BLO=0 ACC=0 RUO=0 PRS=1 PRL=1 Z=PRK KA=0.000 LZ=0.750 LX=80
N30 RR=6 TX=4 TY=3
N40 PAN=1 ST1="CC" ST2="NULL" L=PCUA
N50 X97.25 Y-0.5 TP=1 PRF=0.752 L=PON F=22.9 VF=3. S=18000 G41 G46 TRZ=0 M55
N60 G1 X97 Y-0.25 F22.9
N70 X.25 G1
N80 Y=LPY-TY-.25 G1
N90 X=TX+.25
LPX = Panel X
LPY = Panel Y
RR = Radius
TX = Toe Notch X
TY = Toe Notch Y
This program will adjust the program according to the panel size. Also the parameters are for the radius corner and toe notch.
O4028(HOLE BORING)
(VERSION 1.2 - 08/19/89 - HOGS OUT CENTER OF CIRCLE)
(TO HOG OUT CENTER OF HOLE SET H TO 1 WHEN CALLING MACRO)
(START POS SHOULD BE OVER CENTER OF HOLE)
(A=#1=DIAMETER ADJUSTMENT)
(D=#7=DIAMETER OF HOLE)
(F=#9=FEEDRATE)
(H=#11=SET TO 1 TO HOG CENTER)
(R=#18=RAPID TRAVEL DIST TO WORK SURFACE)
(T=#20=OFFSET # FOR TOOL RADIUS)
(Z=#26=DEPTH OF HOLE FROM WORK SURFACE)
#2=#5001(X START POS)
#3=#5002(X START POS)
The code below is used to machine the mortise for a lock faceplate on the beveled edge of a door. The parameters are passed to the sub and regardless of the length, width or thickness of the faceplate, or the thickness of the door or edge (Y+, Y-) it is machined correctly (or as the parameters were passed, no one said those were right). You can see that no actual machine code is in this mess of text until N480.
The code below is an old version I have sitting on my drive here at home. So if you want to pick it apart and find my math errors don't fret too much, I'm sure I've re-written the routine on the machine.
;SUBROUTINE FOR MORTISE LOCK FACEPLATES
;WILL COMPENSATE IN Y AND Z FOR BEVELED EDGE (VALUE PASSED IN QEG SHOULD BE TRUE EDGE OF DOOR)
;BE CERTAIN BEVEL DIMENSION PASSED MATCHES DATIMACC ANGLE SETTING FOR AGGREGATE USED
;FACEPLATE WILL CENTER IN Z AND CENTER ON THE MORTISE POCKET IN X
;TOOL CHANGE MADE BEFORE CALL TO SUB
;----------------------------------------------------------
;[PARAMETERS]
; QBV=BEVEL
; QEG=EDGE REF
; HCL=SPINDLE CL IN X
; QOC=OFFSET TO CL OF MORTISE FROM HCL
; QFW=FACEPLATE WIDTH
; QFL=FACEPLATE LENGTH
; QFD=FACEPLATE DEPTH
;----------------------------------------------------------
;[EXAMPLE]
;N90 PAN=2 ST1="AGGRE1" ST2="NULL" L=PCUA
;N100 QBV=3.58 QEG=0.00 QOC=31.75 HCL=889.0 QFW=31.8 QFL=203.5 QFD=5.60 L=S23 G0
;----------------------------------------------------------
;VERIFICATION (FAILED CHECKS EXIT AT :1)
;EQUIPPED TOOLING (OUR AGGREAGTE TOOLS ALL BEGIN WITH "A")
N20 ST1=RDM("ATTREZZAGGIO","TP"+$S(2),"UTE")
N30 JM($L(ST1,1) $C(65)):1
;SPINDLE ANGLE
N40 SA=RDM("MANDAGGR"+$S(1),ST1,"ANGZ")
N50 JM!($S(SA)=$S(QBV)):1
;TOOL NAME
N60 ST2=RDM("MANDAGGR"+$S(1),ST1,"UTE")
;AGGRE TOOL TYPE
N70 ST3=RDM("PUNTA",ST2,"TIPO")
N80 JM(ST3 $C(80)):1
;CUTTING DIAM
N90 ATD=RDM("PUNTA",ST2,"DIAM")
;CUTTING RADIUS
N100 ATR=ATD/2
;TRIG CORRECTIONS
;MOVEMENT COMP (Z)
N110 ACR=((_C(QBV))*ATD)/2
;MOVEMENT COMP Y
N130 ACY=_T(QBV*ATD)
;CENTER POINT IN X
N140 PCX=HCL+QOC
;EDGE DETERMINATION AND CONDITIONAL VAR DECLARATIONS
N150 JM(QEG (LY/2)):6
;BOTTOM OF MORTISE IN Y
N390 BMY=(AMP-DCIY)-ACHY
;TOP OF MORTISE IN Y
N400 TMY=(AMP+DCIY)+ACHY
N410 JM:7
:6
;BOTTOM OF MORTISE IN Y
N420 BMY=(AMP+DCIY)+ACHY
;TOP OF MORTISE IN Y
N430 TMY=(AMP-DCIY)-ACHY
:7
N440 API=AMP
N450 APO=API
N460 APU=CMZ
N470 APD=APU
N480 PAN=2 UT=1 ORX=PCX ORY=ASY MO=0 AN1=AAN QZ=-6.36 PRF=0 ANG=QBV USC=1 RES=1 Z=PRK PCT=0 PG40=1 PRC=0 L=G100
N490 Z=CMZ G1
N500 Y=EDY G1
N510 Y=API Z=CMZ G1
N520 X=ASX G1
N530 X=AEX G1
:4
N540 APD=APD+ACD
N550 JM(APD=>BMZ):5
N560 APU=APU-ACD
N570 API=API+ACY
N580 APO=APO-ACY
N590 Y=API Z=APU G1
N600 X=ASX G1
N610 Y=APO Z=APD G1
N620 X=AEX G1
N630 Y=API Z=APU G1
N640 JM:4
:5
N650 Y=TMY Z=TMZ G1
N660 X=ASX G1
N670 Y=BMY Z=BMZ G1
N680 X=AEX G1
N690 Y=TMY Z=TMZ G1
N700 X=PCX G1
N710 Y=ASY G1
N720 L=PSU
N730 L=POFF
;CLEAR VARS HERE BEFORE EXIT
:1
N770 ST1="" ST2="" ST3="" QEG=NIL QFW=NIL QFL=NIL QFD=NIL
%
[FORATURA01]
%
[TABELLEFORI01]
%
[LABELC01]
2=1850
3=2054
6=2503
7=2601
4=2844
5=3033
1=3392
%
(POCKET CLEARING)
#100=(FINAL RADIUS------->) 2.6
#101=(WIDTH OF CUT------->) .2
#102=(FEED RATE---------->)100
#103=(Z RETURN CLEARANCE->)1
#104=(FINAL PASS FEEDRATE>) 50
#105=(CLOCKWISE RPM------>) 10000
#106=(DEPTH OF CUT------->) -.5
#107=(X POCKET CENTER---->)0
#108=(Y POCKET CENTER---->)0
T1M6
M8
N1M98P1
G0G54G43H1Z.1X#107Y#108S#105M3
F#102
G1Z#106
G3R#101 X#101
G3X#100Y0.0I-#101Q#101F#102
G3I-#100
G3R#100X0
G0Z#103
M30
Comment from contributor J:
Parametric programming is useful when used as an extension of the programmer. For instance, let’s say that you have arcs and straight lines in your program. It can be useful to control feed-rate based on formulas that calculate chip load in a turn verses chipload on a straight line move.
Instead of programming different feed-rates, it is possible to have the control calculate feed on the fly. At the top of the program there is a list of variables for feed and rpm. Make subprogram to calculate feed-rate based on size of arc. If move is straight then make feed a specific sfm (surface feed per min). Tool companies list formulas for their tools. Remember that imagination is the key. See it and then sketch your point of logic path you want to accomplish and finally program it.
Example; #100=85;sfm
#101=.005;chipload per tooth
#102=4;number of flutes
#103=.375;tool diameter
#104=(85*3.82/#103);rpm
#105=(#104*#101*#102);feed
This program becomes fun to the operator if he wants to experiment with tool life. Also these macros can be installed in posts to solve tool changer problems etc. I have even installed a macro in a post that automatically inserted tool comp and had a line of code that the operator could edit so he never had to go to his off-set page.