Fun with Renishaw probing routines.
So I was going through one of my probing routines and repurposing it for a different project.
In this case the machine is probing a series of roughly placed fixture plates. The routine finds the fixture locations and also counts them so an operator can just place as many or as few as they have available in work area. The angle of each fixture plate is stored in separate macro variables. When the actual machining operation happens the angle is used with G68 angle correction.
To find if a fixture exists, protected move is used with an option to stop but not alarm out the machine upon contact with a work piece.
One gotcha I did not realize early on has to do with look ahead and doing macro math. Obviously you need to turn off look ahead with G103 P1 prior to doing any math. The gotcha has to do with the probe cycles. Renishaw uses G103 P1 too, and to avoid breaking everyone's standard programs they include G103 P0 in their probe shutdown routine. So you need to kill look ahead again after calling for probe shutdown.
This is from a HAAS but I do something very similar on some FANUC based machines.
I comment the shit out of my probing routines so I am not lost years later.
In any case here is the probing snippet.
(FIXTURE BLOCK OFFSETS G154 P71-P78)
(IF WORK OFFSETS ARE EVER CHANGED MAKE SURE MACRO VARIABLES)
(THAT DIRECTLY REFERENCE WORK OFFSETS CHANGE AS WELL)
(EX. #15403 IS G154 P71 Z OFFSET)
(UP TO 8 PLATES AT A TIME)
(LAYOUT IS AS FOLLOWS)
( 5 6 7 8)
( 1 2 3 4)
(ACTUAL LAYOUT IS ARBITRARY)
(BUT SETUP SHOULD BE CONSISTENT)
(MACRO VARIABLES 822-830 ARE RESERVED)
(USED TO STORE THE ANGLE SHIFT OF EACH PLATE)
(822 FOR G154 P71, 823 FOR G154 P72, ...)
G21 G90 G17 (METRIC, ABSOLUTE POSITIONING, XY PLANE)
#11= 8 (NUMBER OF FIXTURE PLATES)
#12= 0 (FIXTURE PLATE LOOP COUNTER)
G53 G00 Z0. (Z0 CLEAR)
(***FIXTURE COUNT AND LOCATION PROBE LOOP***)
(JUST PROBES THE FIXTURE PLATES NO DEVICE PROBING)
G154 P71 (WORK OFFSET OF FIRST FIXTURE)
M06 T10 (SWITCH TO PROBE)
G00 X0 Y0 (MOVE TO FIXTURE XY ORIGIN)
G00 Z100. G43 H10 (LENGTH COMP OF PROBE)
G65 P9832 (TURN ON PROBE)
(LOOP THROUGH ALL POSSIBLE PLATE POSITIONS)
N10 IF [ #12 GE #11 ] GOTO100
G154 P [ 71 + #12 ] (SET WORK OFFSET)
G65 P9810 X23. Y-7. F3000. (MOVE OFF REF EDGE)
G65 P9810 Z-7. (PROTECTED Z MOVE BELOW FIXTURE TOP)
G65 P9810 Y5. M1. (CHECK IF BLOCK EXISTS)
IF [ #198 EQ 0 ] GOTO100 (ESCAPE LOOP IF NO BLOCK WAS FOUND)
G01 Y-7. F1000. (NON PROTECTED MOVE AWAY FROM BLOCK TO CLEAR TRIGGER)
G65 P9810 Z15. (PROTECTED Z MOVE TO 15mm ABOVE)
(PROBING THE CORNER OF THE MOUNTING PLATE)
(SETS BASELINE WORKOFFSET AND ANGLE)
G65 P9810 X-5. Y-5. (MOVE OFF REF CORNER)
G65 P9810 Z-7. (MOVE BELOW SURFACE)
(RENISHAW WORK OFFSET ARGUMENTS ARE A BIT WEIRD)
(NEED TO PASS THE OFFSET NUMBER IN DECIMAL NOTATION)
G65 P9816 X0 Y0. S [ 154.71 + [ #12 * 0.01 ] ] I40. J40. Q10. (4 POINT CORNER PROBE)
#[ 822 + #12 ]= #189 (STORE FRONT REF EDGE ANGLE)
G154 P [ 71 + #12 ] (UPDATE WORK OFFSET)
G65 P9810 Z15. (PROTECTED Z MOVE TO 15mm ABOVE)
G65 P9810 X23.0 Y23.0 (MOVE TO Z PROBE LOCATION)
G65 P9811 Z0. S [ 154.71 + [ #12 * 0.01 ] ] (PROBE Z HEIGHT)
G154 P [ 71 + #12 ] (UPDATE WORK OFFSET)
G65 P9810 Z20. (PROTECTED Z CLEAR)
#12= #12 + 1 (INCREMENT FIXTURE COUNT)
GOTO10 (RETURN TO BEGINING OF LOOP)
N100 (FIXTURE PROBE LOOP ESCAPE DESTINATION)
#11= #12 (CORRECT FIXTURE COUNT BASED ON PROBING)
G65 P9833 (TURN OFF PROBE)
G103 P1
G53 G00 Z0. (Z CLEAR)