top of page

Three-point arc center macro

By Brian Glick of Vermeer Corporation


This is a macro I wrote to be able to find the center of an arc from three points. This gives 3-point touch off capability to machines that did not come with this feature – even if your machine doesn’t have a touch probe. A simple edge finder can be used. Basically what this does is allows the machine operator to touch three separate points on an arc (with the edge finder) and the custom macro will automatically write the machine coordinates representing the center of the arc into the specified work offset.


The macro uses the ACOS function which not all controllers support, so the first thing you need to determine is whether this function works on your machine. To do this, go into MDI and enter the following equation #100=ACOS[.5] and hit cycle start. If the controller supports this function it will return a value of 60 in variable #100 and you are in business; if not, it will most likely alarm out with “MACRO FORMAT ERROR”. We have a Fanuc 16MB that will read it and 16MA that will not.


If your machine does not support ACOS (arc cosine), you will have to modify the custom macro. Remember, ACOS renders the angle from the cosine function. All machines with custom macro do support the ATAN (arc tangent) function – which renders the angle from the tangent (side opposite divided by the side adjacent). While it will require more calculations, you should be able to modify the custom macro to use the ATAN function to get the data you need.


To use this program follow these instructions:

  • 1. Load program and enter the work offset you want to use on the first line where #140=?. Follow the format instructions provided in the comments.

  • 2. Load edge finder into spindle. (Light up point finder works best)

  • 3. Put in Memory mode and press cycle start

  • 4. Program stops on M0

  • 5. Put control into Handle mode and touch first point on arc.

  • 6. While keeping edge finder in place go back to Memory mode and press cycle start. The current position of the machine will be recorded and the program will stop on the next M0.

  • 7. Repeat steps 5 and 6 for the second and third points.

  • 8. The macro will write the coordinates to the center of the arc into the offset specified at the beginning of the program

This macro works on the basis of creating lines between the adjacent points found in the steps above. For example: a line connecting point 1 and point 2 and a line connecting point 2 and point 3. These lines are then bisected and the intersection of the bisecting lines is the center of the arc. Sounds easy, but there is a lot of trigonometry going on to find all the needed information.


You can also use the macro to measure the radius of the arc. The radius value from the center of the arc to the center of the tool is entered into variable #532 and then all you need to do is add the radius of the edge finder to this value if touching off the ID of an arc, or subtract it if touching the OD. This will give you an accurate measurement of the arc. Very helpful if you have a partial radius or something that is difficult to measure normally.


NOTE: Any points on the arc will work. You can touch 3 places close together or far apart. The further apart the more accurate you will be, but you can pretty much use this on any arc that is big enough to touch in three places. I would suggest touching the points in order CW or CCW although it seems to work if mixed up in any order. The program checks the radius of each point and if it falls out of a specified tolerance (I have it set at .005” but I have not seen any difference more than .0005”) in relation to each other the macro alarms out. This macro can write to offsets G54-G59 and G54.1 P1-P48.


I have added comments to the various lines to show what is going on in the body of the macro. Here are the definitions for some of my abbreviations.

  • P1 = 1st point

  • P2 = 2nd point

  • P3 = 3rd point

  • M1 = midpoint of line p1 – p2

  • M2 = midpoint of line p2 – p3

  • C1 = center of arc

The program:

  • O8110 (3 POINT ARC CENTER)

  • #140=54. (OPERATOR ENTER OFFSET)

  • (G54=54., G55=55.,ETC.)

  • (G54.1 P1=1., P2=2., ETC.)

  • IF[#140LT1.] GOTO501

  • IF[#140LT54] GOTO10

  • #141=#140-54. (SETS #141 TO G54=0, G55=1...)

  • GOTO15

  • N10

  • #141=#140-1. (SETS #141 TO G54.1 P1=0, P2=1, P3=2...)

  • N15

  • M0 (TOUCH 1ST POINT)

  • N16 (P1)

  • #100=#5021 (STORE MACHINE ABS POSITION)

  • #101=#5022

  • M0 (TOUCH 2ND POINT)

  • N17 (P2)

  • #102=#5021 (STORE MACHINE ABS POSITION)

  • #103=#5022

  • M0 (TOUCH 3RD POINT)

  • N18 (P3)

  • #104=#5021 (STORE MACHINE ABS POSITION)

  • #105=#5022

  • #106=[#100+#102]/2. (M1 X VALUE)

  • #107=[#101+#103]/2. (M1 Y VALUE)

  • #108=[#102+#104]/2. (M2 X VALUE)

  • #109=[#103+#105]/2. (M2 Y VALUE)

  • #1=ABS[#100-#102]

  • #2=ABS[#101-#103]

  • #110=SQRT[[#1*#1]+[#2*#2]] (P1-P2 LENGTH)

  • #1=ABS[#102-#104]

  • #2=ABS[#103-#105]

  • #111=SQRT[[#1*#1]+[#2*#2]] (P2-P3 LENGTH)

  • #112=#110/2. (M1-P2 LENGTH)

  • #113=#111/2. (P2-M2 LENGTH)

  • #1=ABS[#106-#108]

  • #2=ABS[#107-#109]

  • #114=SQRT[[#1*#1]+[#2*#2]] (M1-M2 LENGTH)

  • (FIGURE ANGLES OF SSS TRIANGLE MADE BY M1, P2, M2)

  • (LAW OF COSINES)

  • #1=[[#113*#113]+[#112*#112]-[#114*#114]]/[2.*#113*#112]

  • #115=ACOS[#1] (1ST ANGLE--P2)

  • #2=[[#112*#112]+[#114*#114]-[#113*#113]]/[2.*#112*#114]

  • #116=ACOS[#2] (2ND ANGLE--M1)

  • #117=[180.-#115]-#116 (3RD ANDGLE--M2)

  • (FIGURE ADJACENT ASA TRIANGLE MADE BY M1, M2, C1)

  • (LAW OF SINES)

  • #118=90.-#116 (1ST ANGLE M1)

  • #119=90.-#117 (2ND ANGLE M2)

  • #120=[180.-#118]-#119 (3RD ANGLE C1)

  • #121=[#114*[SIN[#119]]]/SIN[#120] (M1-C1 LENGTH)

  • #122=[#121*[SIN[#118]]]/SIN[#119] (M2-C1 LENGTH)

  • #1=ABS[#100-#106]

  • #2=ABS[#101-#107]

  • #123=ATAN[#1]/[#2] (FIND ANGLE M1-P1 FROM Y AXIS)

  • (DETERMINE WHICH QUADRANT VECTOR M1-P1 IS AIMING FOR)

  • (TO DETERMINE THE CORRECT ANGLE FROM 0 DEG--X POSITIVE AXIS)

  • (QUADRANTS ARE NOT NUMBERED IN STANDARD FORMAT)

  • (X+Y+ IS 1, X-Y+ IS 3, X-Y- IS 4, X+Y- IS 2)

  • IF[#100LT#106] GOTO30

  • #5=1.

  • GOTO35

  • N30#5=3.

  • N35

  • IF[#101LT#107] GOTO40

  • #5=#5

  • GOTO45

  • N40#5=#5+1.

  • N45

  • IF[#5EQ3.] GOTO50

  • IF[#5EQ4.] GOTO55

  • IF[#5EQ2.] GOTO60

  • IF[#5EQ1.] GOTO65

  • N50

  • #124=90.+#123

  • GOTO100

  • N55

  • #124=270.-#123

  • GOTO100

  • N60

  • #124=270.+#123

  • GOTO100

  • N65

  • #124=90.-#123

  • (M1-C1 LINE NEEDS ROTATED CW OR CCW TO GET CORRECT

  • ANGLE FROM 0 DEG)

  • N100

  • #7=-90. (ROTATES CW FIRST)

  • #33=0 (FLAG)

  • GOTO170

  • N165#7=90. (ROTATES CCW)

  • #33=1 (FLAG)

  • N170

  • #125=#124+#7 (UPDATES ANGLE)

  • #126=#121*COS[#125] (X B.C. LOCATION OF C1 BASED OFF RADIUS M1-C1 AND ANGLE #125 M1=0,0)

  • #127=#126+#106 (SHIFTS CENTER OF B.C. ON THE X TO CORRECT VALUE OF M1 AND GIVES CORRECT X VALUE FOR C1)

  • #128=#121*SIN[#125] (Y B.C. LOCATION OF C1 BASED OFF RADIUS M1-C1 AND ANGLE #125 M1=0,0)

  • #129=#128+#107 (SHIFTS CENTER OF B.C. ON THE Y TO CORRECT VALUE OF M1 AND GIVES CORRECT Y VALUE FOR C1)

  • #1=ABS[#100-#127]

  • #2=ABS[#101-#129]

  • #130=SQRT[[#1*#1]+[#2*#2]] (DETERMINE RADIUS OF CIRCLE FROM C1 TO P1)

  • #1=ABS[#102-#127]

  • #2=ABS[#103-#129]

  • #131=SQRT[[#1*#1]+[#2*#2]] (DETERMINE RADIUS OF CIRCLE FROM C1 TO P2)

  • #1=ABS[#104-#127]

  • #2=ABS[#105-#129]

  • #132=SQRT[[#1*#1]+[#2*#2]] (DETERMINE RADIUS OF CIRCLE FROM C1 TO P3)

  • (CHECKS TO MAKE SURE THREE RADIUS VALUES ARE THE SAME WITHIN .005 TOLERANCE)

  • (IF NOT IT GOES BACK AND FLIPS THE M1-C1 LINE THE OTHER WAY AND THEN GOES THRU THE CHECKS AGAIN.)

  • IF[[ABS[#130-#131]]GT.005] GOTO300

  • IF[[ABS[#130-#132]]GT.005] GOTO300

  • IF[[ABS[#131-#131]]GT.005] GOTO300

  • #530=#132 (STORES RADIUS)

  • N200

  • GOTO400

  • N300

  • IF[#33EQ0] GOTO165 (READS FLAG TO SEE IF IT HAS CHECKED ANGLE BOTH WAYS IF SO IT GOES TO ALARM)

  • GOTO500

  • N400

  • (DETERMINE SYSTEM VARIABLES FOR G54-G59)

  • IF[#140LT54.] GOTO450

  • #135=20.*#141

  • #136=5221.+#135

  • #137=5222.+#135

  • #[#136]=#127 (WRITE OFFSET)

  • #[#137]=#129

  • GOTO999

  • N450

  • (DETERMINE SYSTEM VARIABLE FOR G54.1 P1-48)

  • #135=20.*#141

  • #136=7001.+#135

  • #137=7002.+#135

  • #[#136]=#127 (WRITE OFFSET)

  • #[#137]=#129

  • GOTO999

  • N500 #3000=100(ERROR)

  • N501 #3000=101(OFFSET-ERROR)

  • N900

  • N999

  • M30

685 views0 comments

Recent Posts

See All
bottom of page