A fixture offset calculator custom macro

By Brian Glick of Vermeer Corporation


Here is a macro I developed to allow operators to calculate their own fixture offsets right on the machine. The macro tracks any point on the work piece as it indexes on the rotary axis.


I have an Excel spreadsheet that does this (probably similar in function to the one offered on this site), but the operators have to go find one of the programmers so we can calculate their offsets for them. Meanwhile, the machine is sitting idle. Using this macro the operator can accomplish this without leaving the machine.


Macro instructions for the following example: After touching off the origin of the part on side B270 using work offset G54 you need to calculate the machine coordinates of that same point when the pallet is rotated to B290 using work offset G55.


  • 1. Touch off the main origin that will be used to calculate all the other offsets and enter this value into the correct work offset. We will use G54 for an example.

  • 2. Pull up the macro in Edit mode and enter the work offset number that you just used. This is the offset the macro will read from to perform the calculations. Follow the formatting instructions provided by the comments in the macro. #100 = 54.

  • 3. Enter the B-axis angle that the machine is at when touching off the first work offset. #101=270.

  • 4. Enter the work offset you want to write your new work offset to. #102 = 55.

  • 5. Enter the B-axis angle for the offset you need to calculate. #103 = 290.

  • 6. Reset to the beginning of the program and run the macro. It will read the values out of G54 and calculate them for B290 and write the new values into G55

Note: You can use offsets G54-G59 and G54.1 P1-P48 with this macro. I have it set up to calculate one offset at a time, but it would be possible to have it perform several. If you prefer that no one edited the macro you could remove the first four lines and have the operator enter the values directly into the variables on the macro variable page. This macro requires that variables #530 and #531 are set to equal the machine coordinates for the center of rotation on the X and Z respectively. These two variables are located in the macro itself. Do not change them on the macro variable page or the program will overwrite them. These values will be different from machine to machine so do not copy the macro from one machine to another without changing these variables in the body of the macro.


Abbreviations:

  • OP = Original position

  • NP = New position

  • C.O.R = Center of rotation

  • O8111 (FIXTURE OFFSET CALCULATOR)

  • (OPERATOR EDITS THE NEXT FOUR VARIABLES)

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

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

  • #100=54. (ENTER ORIGINAL WORK OFFSET)

  • #101=270. (ENTER ORIGINAL B AXIS VALUE)

  • #102=55. (ENTER NEW WORK OFFSET)

  • #103=290. (ENTER NEW B AXIS VALUE)

  • (DO NOT EDIT BELOW THIS LINE)

  • (CENTER OF ROTATION VALUES—MACHINE SPECIFIC)

  • #530=-20.67 (X VALUE CENTER OF ROTATION FOR MACHINE)

  • #531=-40.565 (Z VALUE CENTER OF ROTATION FOR MACHINE)

  • IF[#101NEFUP[#101]] GOTO100 (Checks to make sure B value is a whole number)

  • IF[#103NEFUP[#103]] GOTO100 (Checks to make sure B value is a whole number)

  • IF[#100LT1.] GOTO110 (Checks to make sure offset value is not less than one)

  • IF[#102LT1.] GOTO110 (Checks to make sure offset value is not less than one)

  • IF[#100GT59.] GOTO110 (Checks to make sure offset value is not greater than 59)

  • IF[#102GT59.] GOTO110 (Checks to make sure offset value is not greater than 59)

  • IF[#101GT359.] GOTO120 (Checks to make sure B value is not greater than 359)

  • IF[#102GT359.] GOTO120 (Checks to make sure B value is not greater than 359)

  • N5

  • (DETERMINE WORK OFFSET TO READ FROM)

  • (DETERMINE SYSTEM VARIABLES FOR G54-G59)

  • IF[#100LT54.] GOTO10

  • #104=#100-54. (SETS #104 TO G54=0, G55=1...)

  • #105=20.*#104

  • #106=#[5221.+#105]

  • #107=#[5222.+#105]

  • #108=#[5223.+#105]

  • GOTO15

  • N10

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

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

  • #105=20.*#104

  • #106=#[7001.+#105]

  • #107=#[7002.+#105]

  • #108=#[7003.+#105]

  • N15 (CALCULATE X POSITION FROM C.O.R.)

  • IF[#106LT#530] GOTO20

  • #110=[#106-#530]*[-1.]

  • GOTO25

  • N20

  • #110=#530-#106

  • N25 (CALCULATE Z POSITION FROM C.O.R.)

  • IF[#108LT#531] GOTO30

  • #111=#108-#531

  • GOTO35

  • N30

  • #111=[#531-#108]*[-1.]

  • N35 (CALCULATE RADIUS OF ROTATION--C.O.R. TO O.P.)

  • #112=SQRT[[#110*#110]+[#111*#111]]

  • (FIND ANGLE OF ABOVE LINE FROM 0 DEG.)

  • #113=ACOS[#110/#112]

  • (IF Z POSITION IS NEGATIVE FROM C.O.R. SUBTRACT)

  • (ANGLE FROM 360 DEGREES)

  • IF[#111LT0] GOTO40

  • #114=#113

  • GOTO45

  • N40

  • #114=360.-#113

  • N45

  • #115=#103-#101 (DEGREES TRAVELED ON B AXIS)

  • #116=#114-#115 (ADD DEGREES TO ANGLE FROM ABOVE)

  • IF[#116LT0] GOTO50 (IF ANGLE IS NEGATIVE ADD 360 DEG TO IT)

  • #117=#116

  • GOTO55

  • N50

  • #117=360.+#116

  • N55

  • #118=#112*COS[#117] (B.C. X LOCATION FOR NEW POSITION)

  • #119=#112*SIN[#117] (B.C. Z LOCATION FOR NEW POSITION)

  • #120=#530-#118 (SHIFT X LOCATION BASED ON COORDINATES FOR C.O.R.)

  • #121=#531+#119 (SHIFT Z LOCATION BASED ON COORDINATES FOR C.O.R.)

  • N60

  • (DETERMINE WORK OFFSET TO WRITE NEW OFFSETS TO)

  • (DETERMINE SYSTEM VARIABLES FOR G54-G59)

  • IF[#102LT54.] GOTO70

  • #124=#102-54. (SETS #124 TO G54=0, G55=1...)

  • #125=20.*#124

  • #126=5221.+#125

  • #127=5222.+#125

  • #128=5223.+#125

  • GOTO75

  • N70

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

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

  • #125=20.*#124

  • #126=7001.+#125

  • #127=7002.+#125

  • #128=7003.+#125

  • N75 (WRITE OFFSET)

  • #[#126]=#120

  • #[#127]=#107

  • #[#128]=#121

  • GOTO999

  • (ALARMS)

  • N100#3000=100(B_AXIS_INCREM)

  • N110#3000=110(WORK_OFFSET_OUT_RANGE)

  • 120#3000=120(B_AXIS_OUT_RANGE)

  • N999 M30

cnc reverse logo.jpg
0

44 Little Cahill Road

Cary, IL  60013

Ph: 847-639-8847

  • Facebook Social Icon