What's new
What's new

Fanuc Macro B Program Archive

Moriseikiman

Aluminum
Joined
Dec 1, 2022
Hello!

I decided to start a thread where you could just present some of your self-made Fanuc macros for others to see, be it for inspiration on writing better macros in the future or maybe even for use, at their own risk :D Ideally I would like to see macros that are mostly general purpose and no discussion apart from some suggestions for improvement, to avoid clutter. I am a young beginner myself, just a handful of macros in. Some of my macros are not really meant for use, made mainly for learning purposes. Like the polygon turning macro for a 2-axis lathe... I will dig my files and finish and make new macros to put here at my own, slow pace.

I'm starting today by a ISO/Unified threading macro for G76 (and my chip break threading macro) that gives you a threading program without pulling out your thread charts or pocket calculators. It calculates the thread depth by the nominal diameter, pitch, thread angle, tool nose radius, and a clearance value (POSITIVE value increases the play of the thread, zero clearance makes a thread of the theoretical profile). Both ISO and UN use a similar thread profile (60deg, nominal diameter at 7/8 of a sharp profile) and this is why the program suits these two and pretty much nothing else.

There are a lot of possible arguments and some of them are only for the chip break threading macro (which will show up here at some point as well). The macro will call the chip breaking macro if an amount of chip breaks is specified, otherwise it calls G76.

You shouldn't be afraid of the high amount of possible arguments as most of those will use your default values you edit into the macro and you only call what needs to be different from those default settings. At the simplest, you can call a thread by only "G77 X16. Z-20. F2." and that's enough information to cut an M16x2.0 thread from starting point to Z-20mm, start to finish. All the other info comes from defaults unless told otherwise.
For the G77 you need to make a custom G-code macro call, on Fanuc 10 it's value 77 to parameter 7051.

I have only tested it on a metric OD thread so far (just tonight) and it gave a very close dimension (in my books anyway) on the first attempts. Imperial threads can be done by the TPI or pitch. It should be able to do LH and inside threads as well as work with negative X values but warning, I haven't tested those yet.

As is, it will not suit the machines that don't support IF-THEN statements. Probably all my macros will contain those...

Again, if you're going to attempt using this, proofread it yourself and be very cautious. Do a slow dry run first and observe the values. Most different use cases are still untested. Also the imperial stuff will probably remain untested for a long time.

Code:
%
O9011
(ISO/UNIFIED THREADING MACRO FOR FANUC)
(F=THREAD PITCH MM OR IN/REV #9)
(T=THREAD PITCH TPI #20)
(X=THREAD NOMINAL DIA #24)
(Z=THREAD END ABS #26)
(W=THREAD END INC #23)
(C=CLEARANCE FROM CALCULATED NOMINAL VALUE IN DIA. #3)
(A=THREAD ANGLE NORMALLY 60 #1)
(R=NOSE R OF INSERT #18)
(B=NUMBER OF CHIP BREAKS FOR CBT CYCLE #2)
(Q=NUMBER OF FINISH CUTS FOR CBT #17)
(I=TAPER RADIUS VALUE. AFFECTS STARTING SIDE  #4)
(U=FINISH PASS DEPTH FOR CBT #21)
(D=1ST PASS DEPTH IN DIAMETER DECIMAL VALUE#7)
(M=INFEED MODE FOR G76 1-4 #13)
 
(THREAD LENGTH)
IF [#26EQ#0 ]THEN#26=#5042+#23

(THREAD PITCH)
IF [#11NE#0 ]THEN#9= [ROUND [#20*1000/25.4]/1000] (TPI IN METRIC)
IF [#4006EQ20 ]AND [#20NE#0 ]THEN#9= [ROUND [1000/#20]/1000] (TPI IN INCH)
#9= ABS [#9]
 
(START POS)
#10=#5041 (X POS STORE)
#11=#5042 (Z POS STORE)

IF [#7GT5 ]THEN#3000=1 (1ST CUT DEPTH)
IF [#13GT4 ]THEN#3000=1 (INFEED PARAMETER)

#24= ABS [#24] (MOST POS/NEG WILL BE DECIDED BY MACRO FOR FOOLPROOFING)
#1= ABS [#1]
#18= ABS [#18]


(SOME DEFAULT VALUES. EDIT FOR YOUR DEFAULT SETUP. ONLY GOOD FOR METRIC MODE NOW)
IF [#1EQ#0 ]THEN#1=60
IF [#3EQ#0 ]THEN#3=0.1
IF [#18EQ#0 ]THEN#18=0.2
IF [#17LT1 ]THEN#17=1
IF [#7EQ#0 ]THEN#7=1.0
IF [#21EQ#0 ]THEN#21=0.02
IF [#13LT1 ]THEN#13=1

 
(THREAD FINISH DIA)
#6= [ROUND [[#24-1/TAN [#1/2]*#9*7/8-#3+[#18*2]]*1000]/1000]
IF [ABS [#10]LT#24 ]THEN#6= [ROUND [[#24+1/TAN [#1/2]*#9*1/8+#3-[#18*2]]*1000]/1000]

(THREAD FINISH DIA FOR NEGATIVE X)
 IF [#10LT0 ]THEN#6=- [#6]
 
IF [#2EQ#0 ]GOTO1
G65 P9012 F#9 X#6 Z#26 B#2 A#1 Q#17 I#4 U#21 D#7
GOTO2
N1
G76 X#6 Z#26 F#9 D [ROUND [#7*500]]I#4 K [[#24-#6]/2]A#1 P#13
N2
 
M99
%

Also there's a lot of unnecessary stuff if you only want to use G76. But I'm not personally that concerned about memory anymore since I just upgraded from 20m to 480m of memory. That's more than plenty for a lathe and hand written programs.

I will update this if I make any further improvements, I still have a couple ideas for extra bells and whistles. Like a finish cut for the G76 mode if possible with G92 (I will experiment on it, the different infeed methods of G76 could make it impossible) and maybe the use of 500 series variables for the defaults
 
Last edited:
No guarantees expressed or implied. From a 2008 Archive. I'd change some stuff today. Perhaps a young buck wants to.
;
%
O7101(THREAD MILL CYCLE)
#20=.250( THREAD OUTSIDE DIA )
#21=.197( CUTTING DIA )
#27=28( PITCH TPI )
#16=1357( ROTATIONAL SPEED R.P.M. )
#19=.0008( FEED IN/TOOTH )
#15=.500( DEPTH OF THREAD )
( NO TOOL RADIUS COMPENSATION - D1=0 )
#7=1/#27
#8=[#20-#21]/2
#10=#8/2
#18=3*#19*#16
#17=#18*[#20-#21]/#20
#20=#7
#23=1/8*#7
#22=#23-#7
G00G17G43Z2.0S#16M03
G01Z#22F80.0M08
G91
G42D20X#10Y#10Z0F#17
G02X#10Y-#10Z-#23I0J-#10
WHILE[#15GT#20]DO1
G02X0Y0Z-#7I-#8J0
#20=#20+#7
END1
G02X-#10Y-#10Z-#23I-#10J0
G01G40X-#10Y#10Z0F80.0
G90G01Z2.0F80.0
M99
%
 
G12 Spiral MACRO - Go easy on me... May 1997 vintage.
%
O9012(G12 SPIRAL CUT MACRO)
#3003=1
(14MAY97)
(FOR FANUC 15M AND 16M ONLY)
(15M PARAMETER 7052=12)
(16M PARAMETER 6052=12)
(G12,I,K,Q,D,F AND ALSO C)
(OMIT K,Q FOR REGULAR CIRCLE CUTTING)
(DECIMAL POINT NOT NEEDED ON ARGUMENT D)
(ALL OTHER ARGUMENTS MUST SHOW A DECIMAL POINT)
(C MAY ALSO BE USED FOR # OF FULL 360 DEGREE)
(ROTATIONS BEFORE TOOL RETURNS TO CENTER)
(IF C IS NOT USED, #3 DEFAULTS TO 1.)
(I=#4,K=#6,Q=#17,D=#7,F=#9,C=#3)
#31=#4001
#32=#4002
#33=#4003
IF[#3NE#0]GOTO1
#3=1
N1#3=ABS[FIX[#3]]
#7=ABS[FIX[#3]]
IF[#9NE#0]GOTO2
#9=#4109
N2#9=ABS[#9]
IF[#4009EQ80]GOTO3
#3000=150(NOT IN G80 STATUS)
N3IF#[#4007EQ40]GOTO4
#3000=151(NOT IN G40 STATUS)
N4IF[#4NE#0]GOTO5
#3000=152(I VALUE NOT GIVEN)
N5IF[#7NE#0]GOTO10
#7=0
N10#20=[2000+#7]
IF[[ABS[#20]]LT[ABS[#4]]]GOTO20
#3000=153(TOOL RADIUS TOO LARGE)
N20#19=100
IF[#4006NE21]GOTO21
#19=2540
N21IF[#6NE#0]GOTO25
#29=1
#21=#4-#20
#22=#21/2
G17
G91
G2X#21Y0I#22J0F#9
WHILE[#29LE#3]DO1
X0Y0I-#21J0
#29=#29+1
END1
X-#22Y-#22I-#22J0
X-#22Y#22I0J#22F#19
GOTO40
N25IF[#17NE#0]GOTO30
#3000=154(Q VALUE NOT GIVEN)
N30#17=ABS[#17]
IF[[ABS[#6]]GT[ABS[#4]]]GOTO35
#3000=155(I NOT LESS THAN K)
N35IF[#4GT0]GOTO36
#6=-[ABS[#6]]
#17=-#17
GOTO37
N36#6=ABS[#6]
N37#101=#5001
#102=#5002
#21=#4-#20
#22=#21/2
#16=#6-#20
#15=#16/2
#30=ABS[#16]-ABS[#21]
G17
G91
G2X#21Y0I#22J0F#9
X0Y0I-#21J0
WHILE[#30GT[ABS[#17]]]DO2
G1X#17F[#9/2]
G2X0Y0I-[#21+#17]J0F#9
#30=#30-ABS[#30]
END2
G90
#29=1
G1X[#101+#15]F#19
Y[#102+#15]
G2[#101+#16]Y#102I0J-#15F#9
WHILE[#29LE#3]DO3
X[#101+#16]Y#102I-#16J0
#29=#29+1
END3
X[#101+#15]Y[#102-#15]I-#15J0
X#101Y#102I0J#15F#19
N40G#31G#32G#33
F#9
#3003=0
M99
%
 
G13 Spiral MACRO;

%
O9013 (G13 SPIRALING MACRO)
#3003=1
(14MAY97)
(FOR FANUC 15M AND 16M ONLY.)
(15M PARAMETER 7053=13)
(16M PARAMETER 6053-13)
(G13,I,K,Q,D,F AND ALSO C)
(OMIT K,Q FOR REGULAR)
(CIRCLE CUTTING)
(DECIMAL PT NOT NEEDED FOR ARGUMENT D)
(ALL OTHER ARGUMENTS MUST SHOW A DECIMAL PT)
(C MAY ALSO BE USED FOR # OF FULL 360 DEGREE)
(ROTATIONS BEFORE TOOL RETURNS TO CENTER)
(IF C IS NOT USED, #3 DEFAULTS TO 1.)
#31=#4001
#32=#4002
#33=#4003
IF[#3NE#0]GOTO1
#3=1
N1#3=ABS[FIX[#3]]
#7=ABS[FIX[#7]]
IF[#9NE#0]GOTO2
#9=#4109
N2#9=ABS[#9]
IF[#4009EQ80]GOTO3
#3000=150(NOT IN G80 STATUS)
N3IF[#4007EQ40]GOTO4
#3000=151(NOT IN G40 STATUS)
N4IF[#4NE#0]GOTO5
#3000=152(I VALUE NOT GIVEN)
N5IF[#7NE#0]GOTO10
#7=0
N10#20=#[2000=#7]
IF[[ABS[#20]]LT[ABS[#4]]]GOTO20
#3000=153(TOOL RADIUS TOO LARGE)
N20#19=100
IF[#4006NE21]GOTO21
#19=2540
N21IF[#6NE#0]GOTO25
#29=1
#21=#4-#20
#22=#21/2
G17
G91
G3X#21Y0I#22J0F#9
WHILE[#29LE#3]DO1
X0Y0I-#21J0
#29=#29+1
END1
X-#22Y#22I-#22J0
X-#22Y-#22I0J-#22F#19
GOTO40
N25IF[#17NE#0]GOTO30
#3000=154(Q VALUE NOT GIVEN)
N30#17=ABS[#17]
IF[[ABS[#6]]GT[ABS[#4]]]GOTO35
#3000=155(I NOT LESS THAN K)
N35IF[#4GT0]GOTO36
#6=-[ABS[#6]]
#17=-#17
GOTO37
N36#6=ABS[#6]
N37#101=#5001
#102=#5002
#21=#4=#20
#22=#21/2
#16=#6=#20
#15=#16/2
#30=ABS[#16]-ABS[#21]
G17
G91
G3X#21Y0I#22J0F#9
X0Y0I-#21J0
WHILE[#30GT[ABS[#17]]]DO2
G1X#17F[#9/2]
G3X0Y0I-[#21+#17]J0F#9
#30=#30-ABS[#17]
END2
G90
#29=1
G1X[#101+#15]F#19
Y[#102=#15]
G3X[#101+#16]Y#102I0J#15F#9
WHILE[#29LE#3]DO3
X[#101+#16]Y#102I-#16J0
#29=#29+1
END3
X[#101+#15]Y[#102+#15]I-#15J0
X#101Y#102I0J-#15F#19
N40G#31G#32G#33
F#9
#3003=0
M99
%
 
Adding this haimer centering macro I did from the fundamentals thread. Again your mileage may vary and this will perform some automatic moves (announced before executing by messages) so be careful not to wreck your haimer.

This is pretty neat to use at least on F10M, since the user messages of the macro are displayed all the time unless you change the view from the message display, which you don't need to and shouldn't do. The idea is that you call this on MDI and then switch to jog mode, jog to position, then switch to MDI and press start once, then jog again and press again until done. All explained in the user messages while doing it. It's not ideal for sure to change the mode many times but it's the best way I could think of for a haimer. I will gladly receive ideas to make it less hassle to use.

The Z offset setting option is enabled by including argument Z with any value besides null to the macro call.

Also the optional second take for Y-axis is mostly useless because you can pre-center the haimer by jogging it and finding the high/low spot of the boss/bore. Just delete those lines that start with slash if not using that.

It worked. Here's what I did, a XY center and optional Z work offset setting macro with the features I thought to be useful for my use. The messages pretty much will tell what is about to happen next and there's a second take for Y if not using block delete. That's for round features where the first one is eyeballed to center so it could potentially be off. If accidentally pressing the start button twice in the same position, it will start over. There are some automatic moves (that the message box will also tell before executing) so need to be careful.
It is not entirely foolproof, for example if moving the wrong axis during centering but I thought it's foolproof enough for me...
Code:
%
O9040
N1
#3006=1 (HAIMER CENTERING  BY J. KAJULA)
G53 M5 G94
IF [#19EQ#0 ]THEN#19=1
IF [#19GT6 ]THEN#3000=1 (OUT OF RANGE)
IF [#19LT1 ]THEN#3000=1 (OUT OF RANGE)
#3006=1 (JOG TO 1ST POS IN Y-AXIS)
#1=#5022
#3006=1 (Y POS 1 STORED. JOG TO Y POS 2)
#2=#5022
IF [#2EQ#1 ]GOTO99
#3= [#1+#2]/2
#3006=1 (WARNING. MOVES 30MM UP AND CENT. Y)
G1 F5000 G91 Z30.0
G1 G90 G53 Y#3
#3006=1 (JOG TO X POS 1)
#4=#5021
#3006=1 (JOG TO X POS 2)
#5=#5021
IF [#4EQ#5 ]GOTO99
#6= [#4+#5]/2
#3006=1 (WARNING. MOVES 30MM UP AND CENT. X)
G1 G91 Z30.0
G1 G90 G53 X#6
/#3006=1(JOG IN Y POS 1 FOR REMEAS. Y)
/#1=#5022
/#3006=1(Y POS 1 STORED. JOG TO Y POS 2)
/#2=#5022
IF [#2EQ#1 ]GOTO99
/#3=[#1+#2]/2

(STORING THE POS IN G54-G59 OFFSETS AS SELECTED BY ARGUMENT S1-6, DEFAULT G54)
# [5201+20*#19]=#6 (STORE X)
# [5202+20*#19]=#3 (STORE Y)
IF [#26NE#0 ]GOTO100
GOTO101

N100

#3006=1 (JOG INTO Z0 POS)
# [5203+20*#19]=#5023-#2099 (TAKES HAIMER LENGTH FROM TOOL OFFSET 99!!!!)
N101
#3006=1 (READY)
M99
N99#3006=1 (FAIL. START OVER)
GOTO1
%
 
Last edited:
Here is a simple one I wrote for making rod end spacers.
%
O05012
(ROD END SPACER AL)
(FOR ALUMINUM)
(PART NUMBER BMR1886)
G103 P1.0
(500-#511 ARE OPERATOR INPUTS)
#500 = 1. (STOCK OD)
#501 = 1.425 ( OVERALL PART LENGTH)
#502 = 0.749 (MINOR OD)
#503 = 0.925 (MID MINOR OD)
#504 = 0.56 (BORE ID)
#505 = 0.994 (MAJOR OD)
#506 = 0.425 (MINOR LENGTH)
#507 = 0.55 (MID LENGTH)
#508 = 1.175 (TO END OF TAPER LENGTH)
#509 = 0.5 (DRILL SIZE)
#510 = 0 (0 FOR NO OD GROOVE OR 1 FOR OD GROOVE)
#511 = 1.85 (GROOVE LOCATION)
#512= 0. (SAFE TOOL CHANGE POSITION)
(SET WITH LONGEST TOOL IN TURRET)
(G53 Z MACHINE POSITION)
(1 INCH FROM END OF STOCK)
(**********************************************************)

(DO NOT CHANGE ANYTHING BELOW THIS LINE UNLES YOU TALK TO ME ABOUT IT- RICHARD)
#520 = [#500+.1]
#521 = [#502 - 0.06 ]
#522 = [#501 + .1]
#523 = [#501 + 0.2 ]
#524 = [#501 - .02]
#525 = [#505 -.04]
#526 = [#504 - #509 ]
#527 = [#501 + .118]
#3100 = [ #527 +.025] (PART LENGTH)
#3101 = 2.6 (INITIAL PUSH LENGTH)
#3102 = 1.0
#550 = #3100
#551 = #3101
#552 = #3102
(*********************************************************)
M01(ON SET UP- RUN TO HERE AND RESET TO ASSIGN VARIABLES)

(MCLN R-12-4B)
(CNMG432 .032 TNR)
(INSERT-SVK52813)

T202
M31
G50 S3400
G96 S675 M03
G00 G54 X#520 Z.25 M08
G72 P1500 Q1600 D0.075 W0.01 F0.013
N1500 G0 Z0.
G01 X-0.032
N1600 G0 Z0.25
G00 X#500
G71 P1000 Q2000 U0.02 W0.01 D0.160 F0.008
N1000 G0 X#502 Z0.1
G1 Z-#506
X#503
Z - #507
X#505 Z-#508
Z-#522
N2000 X#520
M9
G0 G53 Z#512
M1

(MCLN R-12-4B PREFERED)
(CNMG431 .0156 TNR)
(INSERT-SVK52803)

(MVJN R-12-4B ALLOWED)
(VNMG331 .0156 TNR)
(INSERT-SVK53614)

N1
T101
M31
G50 S3400
G96 S675 M03
G0 G54 X.849 Z0.0
G01 X-0.032 F0.005
G0 Z.035
G01 X#521
Z0.0
G01 X#502 Z-.03
Z-#506
X[#503-.03]
X#503 Z [ - #506 -0.015 ]
Z-#507
X#505 Z-#508
Z-#522
X#520
IF[#510 EQ 0]GOTO9100
G0 Z-#511
G1 X[#505 - .015]
G4 P1.0
G0 X#520
M09
N9100
G00 G53 Z#512
M01

N7
T707 (TWIST DRILL)
G97 S2800 M03
G00 G54 X0 Z1.0 M8
G81 Z-#523 R0.1 F0.005
M09
G00 G53 Z#512
M01


(A06M-SCLCR2)
(3/8-BB)
(CCGX 21.51)
(INSERT-SVK69145)

IF[#526 EQ 0.0]GOTO8800
N3
T303
G50 S3400
G96 S450 M03
G00 G54 X #509 Z1.0 M08
G1 Z0.1 F0.1
IF[#526 LT 0.02 ] GOTO8850
G71 P3000 Q4000 D0.1 U-0.02 W0.01 F0.003
N3000 G01 X[#504 + .04] Z0.0
G01 X#504 Z-0.02
Z [ - #522 + 0.08 ]
N4000 X #509
N8850
G0 Z0.1
G01 X[#504 + .04] Z0.0 F0.006
G01 X#504 Z-0.02
Z [-#522 + 0.08 ]
X #509
G00 Z1.
M09
G00 G53 Z#512
M01

N8900

N10 T1111
( .118 WIDE CUT_OFF)
(QD-NN2G60-25A)
G50 S2800
G96 S450 M03
G00 X#520 Z1.0 M8
G01 Z-#527 F0.1
G01 X#525 F0.008
G00 X#520
Z-[#527 - .02]
M36
G01 X#505
X#525 Z-#527
G75 X0.4 I0.01 F0.006
G0 X#520
M09
G00 G53 X0 Z#512
G105
M37
/ M99
M30


(A06M-SCLCR2)
(3/8-BB)
(CCGX 21.51)
(INSERT-SVK69145)
N8800
N33
T303
G50 S3400
G96 S450 M03
G00 G54 X#504 Z1.0 M08
G1 Z0.1 F.1
G01 X[#504 + .06] Z0.0 F.005
G01 X#504 Z-0.03
X#504
G0 Z.1
M09
G00 G53 Z#512
GOTO8900



%
 
How About this one? it's for automatically algorithmically offsetting tool compensations based on probe data with a weighted average feature.


O8813(AUTO PROBE SINGLE POINT)

(VARIABLE NAMES)
SETVN535[BADPART]
SETVN538[AVERAGE]
(#554 IS NEW TOOL OFFSET TOTAL AMOUNT)
(#553 IS SKIP OFFSETING)

(SET VARIABLE DEFAULTS IF NOT OTHERWISE SPECIFIED)
IF[#8EQ#0]THEN#8=.8(DEFAULT COMP PERCENTAGE)
IF[#13EQ#0]THEN#13=.5(DEFAULT COMP PERCENTAGE)
IF[#9EQ#0]THEN#9=144(DEFAULT TO #144)
IF[#19EQ#0]THEN#19=3(DEFAULT TO 3 PROBE MEASUREMENTS)
#31=568(1ST VARIABLE FOR 1ST MEASUREMENT)
[#AVERAGE]=0(CLEAR INCASE OF OLD VALUE)
#32=0(INITIALIZE BAD PROBE COUNTER)
#33=0(INITIALIZE MEASUREMENT COUNTER)

(IMPROPER INPUT CHECK)
IF[#8GT1]THEN#3000=101(ACCEPTABLE MEASUREMENT OFFSET PERCENTAGE IS OVER 1 "E")
IF[#13GT1]THEN#3000=101(UNACCEPTABLE MEASUREMENT OFFSET PERCENTAGE IS OVER 1 "M")
IF[#19LT3]THEN#3000=101(MINIMUM OF 3 MEASUREMENTS "S" MUST BE TAKEN)
IF[[#6NE0]AND[#6NE1]]THEN#3000=101(OPPOSITE OR CONGRUENT NOT SPECIFIED CORRECTLY "K")
IF[#17EQ#0]THEN#3000=101(NO N BLOCK SET FOR BAD PROBE HIT EXIT "Q")
IF[#18EQ#0]THEN#3000=101(NO N BLOCK SET FOR CLEAN EXIT "R")
IF[#2EQ#0]THEN#3000=101(NO N BLOCK SET FOR UNACCEPTABLE MEASUREMENT EXIT "B")
IF[#4EQ#0]THEN#3000=101(NO SYSTEM VARIABLE SET FOR ADJUSTMENT "I")
IF[#11EQ#0]THEN#3000=101(NO VARIABLE SET TO SAVE MEASUREMENT "H")
IF[#20GT.005]THEN#3000=101(CHEAT EXCEEDS MAX VALUE "T")
IF[#553GT1]THEN#3000=101(SKIP OFFSET VARIABLE HAS INVALID INPUT)
IF[[#BADPART]GT2]THEN#3000=101(BAD PART VARIABLE HAS INVALID INPUT)
IF[[#21NE#0]AND[#21NE1]]THEN#3000=101(INVALID INPUT INTO "U" FLAG)
IF[[#9NE144]AND[#9NE140]AND[#9NE141]AND[#9NE142]]THEN#3000=101(INVALID INPUT INTO "F" FLAG)
IF[[#24EQ#0]AND[#25EQ#0]AND[#26EQ#0]]THEN#3000=101(X Y AND Z ALL HAVE NO INPUT??)
IF[[#24NE#0]AND[#25NE#0]AND[#26NE#0]]THEN#3000=101(X Y AND Z ALL HAVE INPUT??)
IF[[#24NE#0]AND[#25NE#0]AND[#26EQ#0]]THEN#3000=101(X AND Y BOTH HAVE INPUT??)
IF[[#24EQ#0]AND[#25NE#0]AND[#26NE#0]]THEN#3000=101(Y AND Z BOTH HAVE INPUT??)
IF[[#24NE#0]AND[#25EQ#0]AND[#26NE#0]]THEN#3000=101(X AND Z BOTH HAVE INPUT??)
IF[[#7LT#3]AND[#3LT#1]]THENGOTO1(IF NOT TRUE ALARM ON NEXT LINE)
#3000=101("D"<"C"<"A" DEVIATIONS MUST BE IN DECENDING VALUE)
N1
IF[#19GT7]THEN#3000=101("S" EXCEEDING MAX VALUE)


N102(JUMP SPOT FOR CLEAN PROBE)
(START OF MEASUREMENT LOOP)
WHILE[#33LT#19]DO1

G65P9513X#24Y#25Z#26

(ADD CHEAT IF APPLICABLE)
IF[#20NE#0]THEN#[#9]=#[#9]+[#20]

(ADD 1 TO UNACCEPTABLE PROBE MEASUREMENT COUNTER IF OVER FILTER)
(DONT COUNT THIS MEASUREMENT)
IF[ABS[#[#9]]GT[#1]]THEN#33=#33-1
IF[ABS[#[#9]]GT[#1]]THEN#32=#32+1

(IF THE MEASUREMENT IS BAD 3 TIMES)
(AND UNACCEPTABLE PROBE MEASUREMENT HAS BEEN TRIGGERED FOR THE 1ST TIME)
(SAVE MEASUREMENT AND EXIT UNLESS "U" IS SET TO 1 THEN ALARM OUT)
IF[[#32EQ3]AND[[#BADPART]NE2]]THEN[#BADPART]=1
IF[[#32EQ3]AND[[#BADPART]NE2]]THEN#[#11]=[#[#9]]
IF[[#32EQ3]AND[[#BADPART]NE2]AND[#21EQ1]]THENGOTO121(EXIT BAD PROBE IF "U" iS SET)
IF[[#32EQ3]AND[[#BADPART]NE2]]THENGOTO111(EXIT CLEAN)

(UNACCEPTABLE PROBE MEASUREMENT 2ND TIME)
IF[[#32EQ3]AND[[#BADPART]EQ2]]THENGOTO121(EXIT BAD PROBE)

(CLEAN PROBE AFTER BAD HIT)
IF[ABS[#[#9]]GT[#1]]THENGOTO101(CLEAN PROBE)

(VIRTUALLY NO DEVIATION GOOD MEASUREMENT)
(QUICK EXIT)
IF[ABS[#[#9]]LT#7]THEN#[#11]=[#[#9]]
IF[ABS[#[#9]]LT#7]THENGOTO111(EXIT CLEAN)


(SAVE CONSECUTIVE MEASUREMENTS)
IF[ABS[#[#9]]LE[#1]]THEN#[#31]=[#[#9]]
IF[ABS[#[#9]]LE[#1]]THEN#31=#31+1

(OPTIONAL ROTATION)

G0H[#5]
#33=#33+1
END1
#31=#31-1


(CALCULATE AVERAGE)
#33=0(RESET COUNTER)
WHILE[#33LT#19]DO2
[#AVERAGE]=[[#AVERAGE]+[#[#31]]]
#31=#31-1
#33=#33+1
END2
[#AVERAGE]=[[#AVERAGE]/#19]


(SET THE FINAL MEASUREMENT)
#[#11]=[#AVERAGE]


(UNACCEPTABLE DEVIATION 2ND TIME)
IF[[ABS[#AVERAGE]GT#3]AND[[#BADPART]EQ2]]THENGOTO131(EXIT UNACCEPTABLE MEASUREMENT)


(SKIP OFFSETING IF #SKIPOF IS SET TO 1)
IF[#553EQ1]THENGOTO111(CLEAN EXIT)

(IF THE DEVIATION IS ACCEPTIBLE)
IF[[ABS[#AVERAGE]LE#3]AND[#6EQ1]]THEN#[#4]=[#[#4]]-[[#AVERAGE]*#8]
IF[[ABS[#AVERAGE]LE#3]AND[#6EQ0]]THEN#[#4]=[#[#4]]+[[#AVERAGE]*#8]
IF[ABS[#AVERAGE]LE#3]THENGOTO111(EXIT CLEAN)

(IF THE DEVIATION IS UNACCEPTABLE FOR THE 1ST TIME)
(SET BAD VALUE TOO 1 AND COMP ACCORDINGLY)
IF[[ABS[#AVERAGE]GT#3]]THEN[#BADPART]=1
IF[[ABS[#AVERAGE]GT#3]AND[#6EQ1]AND[#554NE1]]THEN#[#4]=[[#[#4]]-[[#AVERAGE]*#13]]
IF[[ABS[#AVERAGE]GT#3]AND[#6EQ0]AND[#554NE1]]THEN#[#4]=[[#[#4]]+[[#AVERAGE]*#13]]
IF[[ABS[#AVERAGE]GT#3]AND[#6EQ1]AND[#554EQ1]]THEN#[#4]=[[#[#4]]-[#AVERAGE]]
IF[[ABS[#AVERAGE]GT#3]AND[#6EQ0]AND[#554EQ1]]THEN#[#4]=[[#[#4]]+[#AVERAGE]]
IF[[ABS[#AVERAGE]GT#3]]THENGOTO111(EXIT CLEAN)






(SUB COMMANDS)

N101(CLEAN PROBE)
M752
M1751
M6
G4U2.
M7
G4U2.
M751
G4U1.
G0H[#5]
#33=#33+1
GOTO102

N111(EXIT CLEAN)
IF[[ABS[#AVERAGE]GT#3]AND[[#BADPART]NE2]]THEN[#BADPART]=1
M99P[#18]

N121(EXIT BAD PROBE)
[#BADPART]=1
M99P[#17]

N131(EXIT UNACCEPTABLE MEASUREMENT)
[#BADPART]=1
M99P[#2]
%
 
It is called like this while running a Renishaw Probe


G65P8813A.005C0.0008D.0002Z0.005H501.I2113.K1.Q101.B201.R301.
N101
#3000=101(T1313 Z UPPER #144 BAD PROBE HIT)
N201
#3000=101(T1313 Z UPPER #144)
N301
 








 
Back
Top