What's new
What's new

3 point center macro

cadcamwiz

Cast Iron
Joined
Dec 20, 2011
Location
Tennessee, Philippines, SoCal
Im not a big Macro guru but I was working on the Mori Maaps controler the other day using(find center 3 points) with my edge finder and wondered if it would be possible to wright a Macro to do this on Fanuc controls? any ideas or examples. It is nice for picking up bores with wore spots not to mention eliminating the math of spliting the dif.
 
Im not a big Macro guru but I was working on the Mori Maaps controler the other day using(find center 3 points) with my edge finder and wondered if it would be possible to wright a Macro to do this on Fanuc controls? any ideas or examples. It is nice for picking up bores with wore spots not to mention eliminating the math of spliting the dif.

This Macro program calculates the Centre X Y coordiantes, and the Radius of a circle, the circumference of which passes through any three points.

The program is started, and each time the Operator Message prompts "MAN TOUCH", select Hand Wheel to make the touch. Once the touch is made, select Auto Mode and press Cycle Start to record the current X Y coordinates. The process of "MAN TOUCH" prompt, manual touch with Hand Wheel, and coordinate recording by pressing Cycle Start will repeat until all three points have been recorded. If the control has the infrastructure for Auto contact with a Probe, the High Speed Skip G31 will be used if the control is by Fanuc, and no Manual intervention will be required. In this case, the probe could be roughly positioned in the centre of the circle/arc to be measured, and a diameter roughly equal to the proposed circle/arc to be measured passed as an argument by the Macro Call block.
For example:
G65 P9081 D100.0 S2 (D100.0 being the rough diameter of the feature to be measured)

The following is a conversion of a routine I wrote for a CAM software package. Accordingly, I haven't tested it on a machine as a User Macro program. However, I don't think I've made any mistakes so it should be right to go. Test it in fresh air first. Post back with result.

If you use it to set a Work Shift, you could pass the Work Shift number to set in the Macro Call block.
For example:
G65 P9081 S2
Where S value
1 = G54
2 = G55
3 = G56
4 = G57
5 = G58
6 = G59

Then in the macro
#[5201+[20*[#19]]]=#15 (X WORK SHIFT)
#[5202+[20*[#19]]]=#16 (Y WORK SHIFT)

Obviously the above two Macro statement go at the bottom of the following program after all calculations have been completed.

Regards,

Bill

%
O9081(CIRCLE THROUGH 3 POINTS MACRO)
#3006=1 (MAN TOUCH 1 - CYCLE START)
#3006=0
#1=#5021 (1ST X)
#2=#5022 (1ST Y)
#3006=1 (MAN TOUCH 2 - CYCLE START)
#3006=0
#3=#5021 (2ND X)
#4=#5022 (2ND Y)
#3006=1 (MAN TOUCH 3 - CYCLE START)
#3006=0
#5=#5021 (3RD X)
#6=#5022 (3RD Y)

(GET PERPENDICULAR BISECTOR OF #1, #2 and #3, #4)
#7 = [#3 + #1] / 2
#8 = [#4 + #2] / 2
#9 = #3 - #1
#10 = -[#4 - #2]

(GET PERPENDICULAR BISECTOR OF #3, #4 and #5, #6)
#11 = [#5 + #3] / 2
#12 = [#6 + #4]/ 2
#13 = #5 - #3
#14 = -[#6 - #4]

(SEE WHERE THE LINE INTERSECT)
(X-CENTRE)
#15 = [#8 * #10 * #14 + #11 * #10 * #13 - #7 * #9 * #14 - #12 * #10 * #14] / [#10 * #13 - #9 * #14]

(Y-CENTRE)
#16 = [#15 - #7] * #9 / #10 + #8

(RADIUS)
#17= SQRT[ [ [#1-#15]* [#1-#15] ]+[ [#2-#16]*[#2-#16] ]]
.............
Rest of program
.............
Do whatever you want with the Centre and Radius information.
For example:
1. Register as Work Shift Offset,
2. Rapid or feed to X#15 Y#16
3. Whatever

M99
%
 
Last edited:
This Macro program calculates the Centre X Y coordiantes, and the Radius of a circle, the circumference of which passes through any three points.

The program is started, and each time the Operator Message prompts "MAN TOUCH", select Hand Wheel to make the touch. Once the touch is made, select Auto Mode and press Cycle Start to record the current X Y coordinates. The process of "MAN TOUCH" prompt, manual touch with Hand Wheel, and coordinate recording by pressing Cycle Start will repeat until all three points have been recorded. If the control has the infrastructure for Auto contact with a Probe, the High Speed Skip G31 will be used if the control is by Fanuc, and no Manual intervention will be required. In this case, the probe could be roughly positioned in the centre of the circle/arc to be measured, and a diameter roughly equal to the proposed circle/arc to be measured passed as an argument by the Macro Call block.
For example:
G65 P9081 D100.0 S2 (D100.0 being the rough diameter of the feature to be measured)

The following is a conversion of a routine I wrote for a CAM software package. Accordingly, I haven't tested it on a machine as a User Macro program. However, I don't think I've made any mistakes so it should be right to go. Test it in fresh air first. Post back with result.

If you use it to set a Work Shift, you could pass the Work Shift number to set in the Macro Call block.
For example:
G65 P9081 S2
Where S value
1 = G54
2 = G55
3 = G56
4 = G57
5 = G58
6 = G59

Then in the macro
#[5201+[20*[#19]]]=#15 (X WORK SHIFT)
#[5202+[20*[#19]]]=#16 (Y WORK SHIFT)

Obviously the above two Macro statement go at the bottom of the following program after all calculations have been completed.

Regards,

Bill

%
O9081(CIRCLE THROUGH 3 POINTS MACRO)
#3006=1 (MAN TOUCH 1 - CYCLE START)
#3006=0
#1=#5021 (1ST X)
#2=#5022 (1ST Y)
#3006=1 (MAN TOUCH 2 - CYCLE START)
#3006=0
#3=#5021 (2ND X)
#4=#5022 (2ND Y)
#3006=1 (MAN TOUCH 3 - CYCLE START)
#3006=0
#5=#5021 (3RD X)
#6=#5022 (3RD Y)

(GET PERPENDICULAR BISECTOR OF #1, #2 and #3, #4)
#7 = [#3 + #1] / 2
#8 = [#4 + #2] / 2
#9 = #3 - #1
#10 = -[#4 - #2]

(GET PERPENDICULAR BISECTOR OF #3, #4 and #5, #6)
#11 = [#5 + #3] / 2
#12 = [#6 + #4]/ 2
#13 = #5 - #3
#14 = -[#6 - #4]

(SEE WHERE THE LINE INTERSECT)
(X-CENTRE)
#15 = [#8 * #10 * #14 + #11 * #10 * #13 - #7 * #9 * #14 - #12 * #10 * #14] / [#10 * #13 - #9 * #14]

(Y-CENTRE)
#16 = (#15 - #7) * #9 / #10 + #8

(RADIUS)
#17= SQRT[ [ [#1-#15]* [#1-#15] ]+[ [#2-#16]*[#2-#16] ]]
.............
Rest of program
.............
Do whatever you want with the Centre and Radius information.
For example:
1. Register as Work Shift Offset,
2. Rapid or feed to X#15 Y#16
3. Whatever

M99
%

Brilliant.
A little work to be done to convert it to automated routine with Probe - vector movements and calculations of probe diameter and XY offset. My next project.
 
Pretty sad that a lowly POS Fadal control has been able to do this since at least the late 80's, all by itself, menu driven, no macros to program... bip bip bip done.

but a state of the art Fanuc, the great and wonderful standard of archaic machine controls still can't do it without a custom macro 30 years later.

Pathetic.
 
Brilliant.
A little work to be done to convert it to automated routine with Probe - vector movements and calculations of probe diameter and XY offset. My next project.

I thought you'd like that PROBE.

If the Probe is initially positioned at the rough centre of the Circle/Arc, and a rough diameter passed as an argument in the Macro Call block, the vector movement would not be difficult. I'm sure you get the drift on that.

The other thing that would be worthwhile to include in an Auto touch Macro would be to pass a rough Start and End angle for the three hits, so as to accommodate an Arc. These could be interpreted as Optional arguments by the Macro program, and therefore, with their omission, a full circle with hits of 120 degree spacing would be assumed.

As stated in my original Post, the partial Macro program listing is a conversion of a Software Routine I wrote. The math is solid, and the routine works perfectly in my software. The only mistake, if any, that may have made, is in transposing my more descriptively named variables to those used by the Fanuc User Macro language. Accordingly, if you discover any errors, I can send you my script for your own conversion if it helps. However, having said that, I'm confident that the Macro form of the routine will work OK.

I wouldn't mind seeing your resulting code.

Regards,

Bill
 
Yes, thanks so much and nice work angelw. I hope everyone else can use this as it is a life saver in many cases.

As for Bobw' statement, it is sadthat Fanuc has been dragging ass and there new stuff is still outdated. If anyone ever needed a face lift it is Fanuc.
 
I thought you'd like that PROBE.

If the Probe is initially positioned at the rough centre of the Circle/Arc, and a rough diameter passed as an argument in the Macro Call block, the vector movement would not be difficult. I'm sure you get the drift on that.

The other thing that would be worthwhile to include in an Auto touch Macro would be to pass a rough Start and End angle for the three hits, so as to accommodate an Arc. These could be interpreted as Optional arguments by the Macro program, and therefore, with their omission, a full circle with hits of 120 degree spacing would be assumed.

As stated in my original Post, the partial Macro program listing is a conversion of a Software Routine I wrote. The math is solid, and the routine works perfectly in my software. The only mistake, if any, that may have made, is in transposing my more descriptively named variables to those used by the Fanuc User Macro language. Accordingly, if you discover any errors, I can send you my script for your own conversion if it helps. However, having said that, I'm confident that the Macro form of the routine will work OK.

I wouldn't mind seeing your resulting code.

Regards,

Bill

This is what I wrote. Be carefull, still not proved on the machine.

Few basic facts when measuring with the probe:
1. The effective probe tip diameter is not equal to geometric diameter, and also slightly differs in X and Y.
2. The probe tip center is off center from spindle center line.

This values are set during the probe calibration procedure and stored either in program or in 500 variables.

3. As the center of the circle is not known (finding it is in fact our task), the probe is placed before the execution of the routine somewhere "close". As the result the vector movement is not normal to the circle, and we do not know which point on the probe tip sphere is in touch with the circle (ring) surface. What we do know is that the center of the tip is laying on the circle concentric to the ring and the radius of that circle is equal to the differnce between the radius of the measured circle and the radius of the probe tip.

The program looks like that:

G65P9081D--A--B--C--F--Q--

%
O9081 (3 POINT CIRCLE)
G53
#120=500 (BASE NUMBER FOR PROBE DATA)
(#500 = 2.95 (EFFECTIVE RADIUS OF PROBE TIP IN X DIRECTION))
(#501 = 2.94 (EFFECTIVE RADIUS OF PROBE TIP IN Y DIRECTION))
(#502= 0.12 (OFFSET OF PROBE TIP CENTER FROM SPINDLE CENTERLINE IN X))
(#503=-0.07(OFFSET OF PROBE TIP CENTER FROM SPINDLE CENTERLINE IN X))
(G65P9081D--A--B--C--F--Q--)
#14=#5021
#15=#5022
#16=.1 (BACKOFF COEFFICIENT)
IF[#9NE#0]GOTO10
#9=5000 (FAST FEED)
#8=30 (MEASURING FEED)
N10
IF[#17NE#0]GOTO20
#17=10 (PREHIT AND AFTERHIT DISTANCE)
N20
#32=0
N40
#33=#32+1
#21=[#7/2-#17]*[COS#[#33]]
#22=[#7/2-#17]*[SIN#[#33]]
#23=[#7/2+#17]*[COS#[#33]]
#24=[#7/2+#17]*[SIN#[#33]]
#25=[#21-#23]*#16
#26=[#22-#24]*#16
N50
G91
G31X#21Y#22F#9
IF[#5061EQ#5041]GOTO60
#3000=91 (PATH OBSTRUCTED)
N60
IF[#5062EQ#5042]GOTO65
#3000=91 (PATH OBSTRUCTED)
N65
G31X#23Y#24F[#9*0.3]
IF[#5061NE#5041]GOTO70
#3000=92 (PROBE FAIL)
N70
IF[#5062NE#5042]GOTO75
#3000=92 (PROBE FAIL)
N75
#4=#5021
#5=#5022
G9X#25Y#26F#9
G31X[#4-#5021]Y[#5-#5022]F30
G0X[#14-#5021]Y[#15-#5022]
IF[#33EQ1]GOTO80
IF[#33EQ2]GOTO90
IF[#33EQ3]GOTO100
N80
#10=#5061+#[#120+3]
#11=#5062+#[#120+4]
#32=1
GOTO40
N90
#20=#5061+#[#120+3]
#21=#5062+#[#120+4]
#32=2
GOTO40
N100
#30=#5061+#[#120+3]
#31=#5062+#[#120+4]

N110
#1=#10
#2=#11
#3=#20
#4=#21
#5=#30
#6=#31

(GET PERPENDICULAR BISECTOR OF #1, #2 and #3, #4)
#7 = [#3 + #1] / 2
#8 = [#4 + #2] / 2
#9 = #3 - #1
#10 = -[#4 - #2]

(GET PERPENDICULAR BISECTOR OF #3, #4 and #5, #6)
#11 = [#5 + #3] / 2
#12 = [#6 + #4]/ 2
#13 = #5 - #3
#14 = -[#6 - #4]

(SEE WHERE THE LINE INTERSECT)
(X-CENTRE)
#15 = [#8 * #10 * #14 + #11 * #10 * #13 - #7 * #9 * #14 - #12 * #10 * #14] / [#10 * #13 - #9 * #14]

(Y-CENTRE)
#16 = (#15 - #7) * #9 / #10 + #8

(RADIUS)
#17= SQRT[ [ [#1-#15]* [#1-#15] ]+[ [#2-#16]*[#2-#16] ]] + [#[#120]+#[#120+1]]/2

M99
%

Remarks and improvements will be highly appreciated.
 
Hi PROBE,
I haven't looked at the whole program closely, but you would need to accommodate small diameter holes with regards to the PREHIT distance. Perhaps something like the following. However, done this way, a separate AFTERHIT variable would be required, or hard code a value as its really only to ensure that a touch is made.

Regards,

Bill

IF[#17NE#0]GOTO20
#17=10 (PREHIT AND AFTERHIT DISTANCE) (PREHIT ONLY)
N20
IF[#7/2 LE #17]TH #17=#7/2 (THIS WILL TRAP FOR PREHIT BEING LARGER THAN EXPECTED TOUCH RADIUS)
 
Last edited:
Pretty sad that a lowly POS Fadal control has been able to do this since at least the late 80's, all by itself, menu driven, no macros to program...

As has Heidenhain, since the early 80s.

But certainly Microsoft has shown us that you don't need a good product - or even an average one - to become the world standard.
 
Good job PROBE.

Regards,

Bill

G65P9081D--A--B--C--F--Q--R-- (ADDED SEPARATE AFTERHIT ARGUMENT)

%
O9081 (3 POINT CIRCLE)
G53
#120=500 (BASE NUMBER FOR PROBE DATA)
(#500 = 2.95 (EFFECTIVE RADIUS OF PROBE TIP IN X DIRECTION))
(#501 = 2.94 (EFFECTIVE RADIUS OF PROBE TIP IN Y DIRECTION))
(#502= 0.12 (OFFSET OF PROBE TIP CENTER FROM SPINDLE CENTERLINE IN X))
(#503=-0.07(OFFSET OF PROBE TIP CENTER FROM SPINDLE CENTERLINE IN X))
(G65P9081D--A--B--C--F--Q--R--)
#14=#5021
#15=#5022
#16=.1 (BACKOFF COEFFICIENT)
IF[#9NE#0]GOTO10
#9=5000 (FAST FEED)
#8=30 (MEASURING FEED)
N10
IF[#17NE#0]GOTO20
#17=10 (PREHIT DISTANCE)
N20
IF[#7/2 LE #17]TH #17=#7/2 (ADDED COMPARISON OF CIRCLE RAD AND PREHIT VALUE)
IF[#18NE#0]GOTO30 (ADDED CHECK FOR VACANT AFTERHIT VARIABLE)
#18=10 (AFTERHIT DISTANCE)
N30
#32=1 (INITIALIZE #32 AT INDEX 1)
N40
(WHILE LOOP REPLACES GOTO STATEMENTS TO SET #10 #11 #20 #21 #30 #31)
WHILE [#32 LT 4]DO1
#21=[#7/2-#17]*[COS#[#32]]
#22=[#7/2-#17]*[SIN#[#32]]
#23=[#7/2+#18]*[COS#[#32]]
#24=[#7/2+#18]*[SIN#[#32]]
#25=[#21-#23]*#16
#26=[#22-#24]*#16
N50
G91
G31X#21Y#22F#9
IF[#5061EQ#5041]GOTO60
#3000=91 (PATH OBSTRUCTED)
N60
IF[#5062EQ#5042]GOTO65
#3000=91 (PATH OBSTRUCTED)
N65
G31X#23Y#24F[#9*0.3]
IF[#5061NE#5041]GOTO70
#3000=92 (PROBE FAIL)
N70
IF[#5062NE#5042]GOTO75
#3000=92 (PROBE FAIL)
N75
#4=#5021
#5=#5022
G9X#25Y#26F#9
G31X[#4-#5021]Y[#5-#5022]F30
G0X[#14-#5021]Y[#15-#5022]
#[10*#32]=#5061+#[#120+3]
#[10*#32+1]=#5062+#[#120+4]
#32=#32+1 (INDEX FOR NEXT ANGLE)
END 1

N110
#1=#10
#2=#11
#3=#20
#4=#21
#5=#30
#6=#31

(GET PERPENDICULAR BISECTOR OF #1, #2 and #3, #4)
#7 = [#3 + #1] / 2
#8 = [#4 + #2] / 2
#9 = #3 - #1
#10 = -[#4 - #2]

(GET PERPENDICULAR BISECTOR OF #3, #4 and #5, #6)
#11 = [#5 + #3] / 2
#12 = [#6 + #4]/ 2
#13 = #5 - #3
#14 = -[#6 - #4]

(SEE WHERE THE LINES INTERSECT)
(X-CENTRE)
#15 = [#8 * #10 * #14 + #11 * #10 * #13 - #7 * #9 * #14 - #12 * #10 * #14] / [#10 * #13 - #9 * #14]

(Y-CENTRE)
#16 = (#15 - #7) * #9 / #10 + #8

(RADIUS)
#17= SQRT[ [ [#1-#15]* [#1-#15] ]+[ [#2-#16]*[#2-#16] ]] + [#[#120]+#[#120+1]]/2

M99
%
 
Last edited:
This is the version with the addition of boss measurment. The command for boss includes Z, which is INCREMENTAL distance which Z should move from starting position to the height of hit position - nuturally always negative value.

Bill, (and nturally everybody), your verification is cordially expected.
G65P9081D--A--B--C--F--Q--R--Z-- (ADDED SEPARATE AFTERHIT ARGUMENT)

%
O94XX (3 POINT CIRCLE)
(G65P9081D--A--B--C--F--Q--R--Z--)
G53
M98P9499
#14=#5021
#15=#5022
#16=.1 (BACKOFF COEFFICIENT)
IF[#26NE#0]GOTO3
#26=0
#29=1
GOTO5
N3
#29=-1
N5
IF[#9NE#0]GOTO10
#9=5000 (FAST FEED)
#8=30 (MEASURING FEED)
N10
IF[#17NE#0]GOTO20
#17=10 (PREHIT DISTANCE)
N20
IF[#7/2 LE #17]TH #17=#7/2 (ADDED COMPARISON OF CIRCLE RAD AND PREHIT VALUE)
IF[#18NE#0]GOTO30 (ADDED CHECK FOR VACANT AFTERHIT VARIABLE)
#18=10 (AFTERHIT DISTANCE)
N30
#32=1 (INITIALIZE #32 AT INDEX 1)
N40
(WHILE LOOP REPLACES GOTO STATEMENTS TO SET #10 #11 #20 #21 #30 #31)
WHILE [#32 LT 4]DO1
#21=[#7/2-#29*[#17+#[#120]]]*[COS#[#32]]
#22=[#7/2-#29*[#17+#[#120]]]*[SIN#[#32]]
#23=[#7/2+#29*#18]*[COS#[#32]]
#24=[#7/2+#29*#18]*[SIN#[#32]]
#25=#29*[#21-#23]*#16
#27=#29*[#22-#24]*#16
N50
G91
G31X#21Y#22F#9
IF[#5061EQ#5041]GOTO60
#3000=91 (PATH OBSTRUCTED)
N60
IF[#5062EQ#5042]GOTO65
#3000=91 (PATH OBSTRUCTED)
N65
IF[#29EQ1]GOTO67
G31Z#26F[#9*.3]
IF[#5063EQ#5043]GOTO69
#3000=91 (PATH OBSTRUCTED]
N69
G31X#23Y#24F[#9*0.3]
IF[#5061NE#5041]GOTO70
#3000=92 (PROBE FAIL)
N70
IF[#5062NE#5042]GOTO75
#3000=92 (PROBE FAIL)
N75
#4=#5021
#5=#5022
G9X#25Y#27F#9
#6=#5021
#7=#5022
G31X[#4-#5021]Y[#5-#5022]F30
IF[#29EQ1]GOTO80
G9X[#6-#5021]Y[#7-#5022]
N80
G0Z-#26
G0X[#14-#5021]Y[#15-#5022]
#[10*#32]=#5061+#29*#[#120+3]
#[10*#32+1]=#5062+#29*#[#120+4]
#32=#32+1 (INDEX FOR NEXT ANGLE)
END 1

N110
#1=#10
#2=#11
#3=#20
#4=#21
#5=#30
#6=#31

(GET PERPENDICULAR BISECTOR OF #1, #2 and #3, #4)
#7 = [#3 + #1] / 2
#8 = [#4 + #2] / 2
#9 = #3 - #1
#10 = -[#4 - #2]

(GET PERPENDICULAR BISECTOR OF #3, #4 and #5, #6)
#11 = [#5 + #3] / 2
#12 = [#6 + #4]/ 2
#13 = #5 - #3
#14 = -[#6 - #4]

(SEE WHERE THE LINES INTERSECT)
(X-CENTRE)
#15 = [#8 * #10 * #14 + #11 * #10 * #13 - #7 * #9 * #14 - #12 * #10 * #14] / [#10 * #13 - #9 * #14]

(Y-CENTRE)
#16 = (#15 - #7) * #9 / #10 + #8

(RADIUS)
#17= SQRT[ [ [#1-#15]* [#1-#15] ]+[ [#2-#16]*[#2-#16] ]] + [#[#120]+#[#120+1]]/2

M99
%
 
Hi PROBE,
If you thought it worthwhile, you could Error Trap for a Positive Z argument, and either Fix it without warning, or alert the operator and give the opportunity to Abort; something like the following. However, a positive Z argument will fail safe, with the error being obvious to the operator.

N3
IF[#26LT0]GOTO4
#3006=1(+Z RESET ABORT-START CONT) Omit for Fix without warning.
#3006=0
#26=-#26
N4
#29=-1

A quick check reveals only a Typo, GOTO67.

Regards,

Bill

%
O94XX (3 POINT CIRCLE)
(G65P9081D--A--B--C--F--Q--R--Z--)
G53
M98P9499
#14=#5021
#15=#5022
#16=.1 (BACKOFF COEFFICIENT)
IF[#26NE#0]GOTO3
#26=0
#29=1
GOTO5
N3
#29=-1
N5
IF[#9NE#0]GOTO10
#9=5000 (FAST FEED)
#8=30 (MEASURING FEED)
N10
IF[#17NE#0]GOTO20
#17=10 (PREHIT DISTANCE)
N20
IF[#7/2 LE #17]TH #17=#7/2 (ADDED COMPARISON OF CIRCLE RAD AND PREHIT VALUE)
IF[#18NE#0]GOTO30 (ADDED CHECK FOR VACANT AFTERHIT VARIABLE)
#18=10 (AFTERHIT DISTANCE)
N30
#32=1 (INITIALIZE #32 AT INDEX 1)
N40
(WHILE LOOP REPLACES GOTO STATEMENTS TO SET #10 #11 #20 #21 #30 #31)
WHILE [#32 LT 4]DO1
#21=[#7/2-#29*[#17+#[#120]]]*[COS#[#32]]
#22=[#7/2-#29*[#17+#[#120]]]*[SIN#[#32]]
#23=[#7/2+#29*#18]*[COS#[#32]]
#24=[#7/2+#29*#18]*[SIN#[#32]]
#25=#29*[#21-#23]*#16
#27=#29*[#22-#24]*#16
N50
G91
G31X#21Y#22F#9
IF[#5061EQ#5041]GOTO60
#3000=91 (PATH OBSTRUCTED)
N60
IF[#5062EQ#5042]GOTO65
#3000=91 (PATH OBSTRUCTED)
N65
IF[#29EQ1]GOTO67 (IF[#29EQ1]GOTO69)
G31Z#26F[#9*.3]
IF[#5063EQ#5043]GOTO69
#3000=91 (PATH OBSTRUCTED]
N69
G31X#23Y#24F[#9*0.3]
IF[#5061NE#5041]GOTO70
#3000=92 (PROBE FAIL)
N70
IF[#5062NE#5042]GOTO75
#3000=92 (PROBE FAIL)
N75
#4=#5021
#5=#5022
G9X#25Y#27F#9
#6=#5021
#7=#5022
G31X[#4-#5021]Y[#5-#5022]F30
IF[#29EQ1]GOTO80
G9X[#6-#5021]Y[#7-#5022]
N80
G0Z-#26
G0X[#14-#5021]Y[#15-#5022]
#[10*#32]=#5061+#29*#[#120+3]
#[10*#32+1]=#5062+#29*#[#120+4]
#32=#32+1 (INDEX FOR NEXT ANGLE)
END 1

N110
#1=#10
#2=#11
#3=#20
#4=#21
#5=#30
#6=#31

(GET PERPENDICULAR BISECTOR OF #1, #2 and #3, #4)
#7 = [#3 + #1] / 2
#8 = [#4 + #2] / 2
#9 = #3 - #1
#10 = -[#4 - #2]

(GET PERPENDICULAR BISECTOR OF #3, #4 and #5, #6)
#11 = [#5 + #3] / 2
#12 = [#6 + #4]/ 2
#13 = #5 - #3
#14 = -[#6 - #4]

(SEE WHERE THE LINES INTERSECT)
(X-CENTRE)
#15 = [#8 * #10 * #14 + #11 * #10 * #13 - #7 * #9 * #14 - #12 * #10 * #14] / [#10 * #13 - #9 * #14]

(Y-CENTRE)
#16 = (#15 - #7) * #9 / #10 + #8

(RADIUS)
#17= SQRT[ [ [#1-#15]* [#1-#15] ]+[ [#2-#16]*[#2-#16] ]] + [#[#120]+#[#120+1]]/2

M99
 
Old thread, found it on the google.. But wanted to thank angelw for this 3-point center macro. I used it on a HMC to find the off-center distance of a cylindrical part on the B-axis by probing 3 points around the B-axis. Figured I could contribute to the thread by sharing it here.

The way I probed the points here only works accurately if the off-center amount is small, but it worked great in my case.

It is assumed that the Work Offset XZ is the center of B-axis rotation.

G90 G10 L20 P1 X-279.999 Y-193.542 Z-730.045 B0. (WORK OFFSET CENTER OF ROTATION)
M01
G91 G30 Z0.
G91 G30 X0. Y0.
M01
T50 M6 (PROBE)
G90 G54.1 P1
G17
M144 (PROBE ON)
M19
M11
G0 X0. Y10. B0.
G43 H50 Z80.

G0 X0. Y10. Z60.

(PROBE XZ AT 3 POINTS AROUND B-AXIS)
(P1 X#20 Z#21 B#22)(B0)
(P2 X#23 Z#24 B#25)(B120)
(P3 X#26 Z#27 B#28)(B240)
G53
#10=0 (COUNTER)
WHILE[#10 LT 3] DO1
G0 B[#10*120.]
G0 X0. Y-3. Z60.
G65 P8501 Z-10. (PROBE Z)
G53
#[20+#10*3] = #5041 (X WCS)
#[21+#10*3] = #123 (Z WCS)
#[22+#10*3] = #5044 (B WCS)
G0 Z80.
#10 = #10+1 (INCR COUNTER)
END1

G0 X0. Y10. Z60.

(CONVERT PROBED POINTS TO CARTESIAN CSYS)
#1 = #20*COS[-#22] - #21*SIN[-#22] (X P1)
#2 = #21*COS[-#22] + #20*SIN[-#22] (Z P1)
#3 = #23*COS[-#25] - #24*SIN[-#25] (X P2)
#4 = #24*COS[-#25] + #23*SIN[-#25] (Z P2)
#5 = #26*COS[-#28] - #27*SIN[-#28] (X P3)
#6 = #27*COS[-#28] + #26*SIN[-#28] (Z P3)

(FIND CENTER POINT OF P1,P2,P3)

(GET PERPENDICULAR BISECTOR OF #1, #2 and #3, #4)
#7 = [#3 + #1] / 2
#8 = [#4 + #2] / 2
#9 = #3 - #1
#10 = -[#4 - #2]
(GET PERPENDICULAR BISECTOR OF #3, #4 and #5, #6)
#11 = [#5 + #3] / 2
#12 = [#6 + #4] / 2
#13 = #5 - #3
#14 = -[#6 - #4]
(SEE WHERE THE LINE INTERSECT)
(X-CENTRE)
#15 = [#8*#10*#14+#11*#10*#13-#7*#9*#14-#12*#10*#14]/[#10*#13-#9*#14]
(Z-CENTRE)
#16 = [#15 - #7]*#9 / #10+#8
(RADIUS)
#17 = SQRT[[[#1-#15]*[#1-#15]]+[[#2-#16]*[#2-#16]]]

#30 = SQRT[#15*#15+#16*#16] (OFF CENTER DISTANCE)
IF [#30 GT 1.] THEN #3000=1(OFF CENTER AMOUNT TOO LARGE)

G91 G10 L20 P1 X#15 Z#16 (UPDATE WORK OFFSET)


(CALCULATE WORK OFFSETS FOR ADDITIONAL B-ANGLES HERE)





M145 (PROBE OFF)
G91 G28 Z0.
G91 G30 X0. Y0.
G90
M99
 
So glad I found this post, thanks for sharing the math Bill!
I am trying to find the center of a family of parts, some of which are too large probe on a VF2 using the stock 4-point Renishaw cycle. I switched to the Renishaw 3-point vector cycle, and it allowed me to fit 16" diameter parts in the machine, but after a while it became really tedious to watch!
I broke the probing up into x3 single-point vector (9821) measurements, and use the above code to calculate the center. The probing cycle is now much faster, but if I compare the results to the stock Renishaw cycle I see discrepancies of up to 0.003". I know I can get better results with the stock cycle, so there must be an issue with my process:

I run the cycle using a WCS based off of the nominal fixture center so its the same coordinates for every part
I probe each point and write the results to a spare WCS (1st point writes to G121, second to G122, third to G123) so I can see the values as they update
I use those x6 X, Y coordinates to calculate my new center

However when I watch the offsets update I noticed the values are not what I would expect... I'm sure I missed something obvious, hopefully someone can enlighten me!

For example my nominal center is at X-10.0486 Y-10.0770
I used the 4-point Renishaw cycle and get a center of X-10.0488, Y-10.0743, this is about what I would expect to see.
I then run my vector cycle and see numbers like X-10.06XX, X-10.06XX in the spare offsets
The part I'm using for testing has a radius of 7", so I would expect to see the spare offset values be about 7" different than my nominal, instead it is very close to nominal.
Should I be using the #185 and #186 outputs instead? How/why are they different then just writing to a spare offset? I like to use the offset because I can get to the page showing all the values as they update in one button press vs paging through macro variables.
 
Last edited:
Hello GiroDyno

I suspect that error is due to Vector approach for each contact. In the 4 point routine, at least two of the contact approaches are made along a chord that is on centre line and the other two (the first two contacts are normally reasonably close to being on a centre line chord).

If you know the rough coordinates of arc, or circle centre you're measuring, you could calculate a radial path based on the rough centre location. On a part where the centre location is totally unknown, you could first get the centre locations by sending the probe off in the general direction of the arc surface and once you have the centre location coordinates, repeat the process with the probe travelling along a calculated radial path based on the centre location. You don't have to start the probe from the centre, just calculate the slope of the line from arc centre to the position you will start the probe from, then move the probe along the same slope path to make contact with the arc surface.

Regards,

Bill
 
That approach error was a thought I had, to account for that I always reset my machining WCS back to my nominal fixture WCS before probing, and then update the measured part location to use for machining. The part is located using a pin/bushing so fixture WCS should always be within .005" of the actual part center.
For fun I tried adding a 4th vector probe to the cycle (writing to G124), probing first at 45* and then every 90* from there. I then averaged the 4x X and Y values and was off by .003 from the Renishaw cycle.

The Renishaw 3-point cycle is plenty accurate, I wish I could repeat those results using individual points.

Here's (most of) the code, there's some other probing happening adjacent to the OD points which is why I don't want to use the stock cycle, sorry if the extra code makes it harder to interpret:

#100= #7 (OUTSIDE DIAMETER)
#101= #4 (INSIDE DIAMETER)
#102= #19 (SIDE, 0= LEFT, 1= RIGHT)
#103= #26 (DRILLED, 0= NO, 1= YES)
#104= [ #100 / 2 ] (OUTSIDE RADIUS)
#105= [ #104 - 0.5 ] (ANNULUS POINT)
#106= [ #104 + 0.5 ] (OD POINT)
(VECTOR PROBE POINTS)
#131= [ #105 * COS [50] ] (P1 X ANNULUS)
#141= [ #105 * SIN [50] ] (P1 Y ANNULUS)
#132= [ #105 * COS [160] ] (P2 X ANNULUS)
#142= [ #105 * SIN [160] ] (P2 Y ANNULUS)
#133= [ #105 * COS [300] ] (P3 X ANNULUS)
#143= [ #105 * SIN [300] ] (P3 Y ANNULUS)
#134= [ #106 * COS [50] ] (P4 X OD)
#144= [ #106 * SIN [50] ] (P4 Y OD)
#135= [ #106 * COS [160] ] (P5 X OD)
#145= [ #106 * SIN [160] ] (P5 Y OD)
#136= [ #106 * COS [300] ] (P6 X OD)
#146= [ #106 * SIN [300] ] (P6 Y OD)

#147= [ [ #101 / 2 ] + 0.5000 ] (P7 Y FLANGE)

(BEGIN PROBING OP2)
/ #5261= #5321 (X G56= G59 NOMINAL)
/ #5262= #5322 (Y G56= G59 NOMINAL)
G56 G90
(FIRST POINT G56)
G00 X#131 Y#141
G65 P9811 Z0 Q [ #120 + 0.25 ] S3 (G56 Z)
IF [ #5263 LT [ #123 + 0.25 ] ] GOTO5 (OP2 NOT PRESENT)
/ #112= 1 (OP2 PRESENT)
G00 G43 H24 Z#121
/ #7223= #5263 (G121 Z)
G00 X#134 Y#144
G65 P9810 Z#122
G65 P9821 A-130. D0.5 S121 (P4 VECTOR PROBE OD)
G00 Z#121
(PROBE G58 Z)
G00 X-0.2 Y#147
G65 P9811 Z0 S5 (G58 Z)
(SECOND POINT G122)
G00 X#132 Y#142
G65 P9811 Z0 S122 (G122 Z)
G00 X#135 Y#145
G65 P9810 Z#122
G65 P9821 A-20. D0.5 S122 (P5 VECTOR PROBE OD)
G00 Z#121
(THIRD POINT G123)
G00 X#133 Y#143
G65 P9811 Z0 S123 (G123 Z)
G00 X#136 Y#146
G65 P9810 Z#122
G65 P9821 A120. D0.5 S123 (P6 VECTOR PROBE OD)
G00 Z#121
G65 P9833 (PROBE OFF)
(END PROBING CYCLE)
/ M98 P9012 (FLATNESS ANALYSIS SUB)
/ M98 P9013 (CIRCLE CENTER SUB)
/ #5301= #5261 (X G58= G56)
/ #5302= #5262 (Y G58= G56)

O09013 (CIRCLE CENTER SUB)
(#722?= P4 G121 MEAS)
(#724?= P5 G122 MEAS)
(#726?= P6 G123 MEAS)
(#15= X CALC)
(#16= Y CALC)
(#532?= G59 NOMINAL CENTER)
(#700?= G110 X, Y, NET DEVIATION)
#30= 0.0075 (POSITION TOLERANCE)

#1= #7221 (P4 X)
#2= #7222 (P4 Y)
#3= #7241 (P5 X)
#4= #7242 (P5 Y)
#5= #7261 (P6 X)
#6= #7262 (P6 Y)
(PERPENDICULAR BISECTOR P4/P5)
#7= [ #3 + #1 ] / 2
#8= [ #4 + #2 ] / 2
#9= #3 - #1
#10= - [ #4 - #2 ]
(PERPENDICULAR BISECTOR P5/P6)
#11= [ #5 + #3 ] / 2
#12= [ #6 + #4 ] / 2
#13= #5 - #3
#14= - [ #6 - #4 ]
(INTERSECTION)
#15= [ #8 * #10 * #14 + #11 * #10 * #13 - #7 * #9 * #14 - #12 * #10 * #14 ] / [ #10 * #13 - #9 * #14 ] (X CENTER)
#16= [ #15 - #7 ] * #9 / #10 + #8 (Y CENTER)

(CALC DEVIATION, WRITE TO G110)
#7001= [ #15 - #5321 ] (X DEV)
#7002= [ #16 - #5322 ] (Y DEV)
#7003= SQRT[ [ #7001 * #7001 ] + [ #7002 * #7002 ] ] (NET DEV)

(POSITION TEST)
IF [ #7003 GT #30 ] GOTO1

(SET NEW G56 XY)
#5261= #15 (G56 X)
#5262= #16 (G56 Y)

(CLEAR OFFSETS)
#7221= 0
#7222= 0
#7241= 0
#7242= 0
#7261= 0
#7262= 0
(RETURN TO MAIN)
M99

(POSITION ERROR)
N1 G53 G00 G90 Z0.
G53 G00 G90 Y0.
#3006= 101 (NEW OFFSET DEVIATION TOO LARGE)
M30
%
 
Last edited:
Useful method to cope with approach error is to repeat the measurements, each time updating the starting points coordinates with just found values. The number of repeats depends of course on demanded level of accuracy.
 








 
Back
Top