The Start Point For A Custom Macro

With most user-created canned cycle applications for custom macro, you must provide a starting position from which the custom macro will begin its operation. In many cases, this leads to some redundancy in programming because the cutting tool may already be in the starting position prior to the G65 command that calls the custom macro.

Columns From: 8/18/2009 Modern Machine Shop,

Click Image to Enlarge

Mike Lynch

Mike Lynch

Consider how a G71 rough turning or boring multiple repetitive cycle works on a Fanuc-controlled CNC turning center. The machine will assume that the cutting tool is positioned at the appropriate starting position prior to the G71 command (flush with the stock diameter in X and clear of the face in Z). Rough turning or boring will begin from this position. We can do the same thing with any custom macro. In fact, we can improve a bit upon this technique.

In the October 2008 Tech Talk column, we provided a custom macro for helically milling a counterbore. We’ll use this custom macro as the example for this technique. In the original version, we require the person using the macro to specify the X and Y location for the center of the counter-bored hole to be machined. Again, this was somewhat redundant. It is likely that the person using the custom macro will have already programmed the cutting tool to move to the center of the hole prior to calling the custom macro—at least for the first hole to machine.

Our suggestion requires that you understand two new things: First, the current position of the machine is constantly monitored with three system variables. #5001 monitors the current absolute X position, #5002 monitors the current absolute Y position and #5003 monitors the current absolute Z position. At any given time, for example, #5001 will contain the same value shown in the X-axis absolute position display.

Second, you must understand how a local variable is represented when its corresponding letter address argument is left out of the calling G65 command. In this case, the local variable is vacant—it has no value. The local variable representation for vacancy is #0. We can test for vacancy in the custom macro. If a given letter address argument is left out of the call statement, its corresponding local variable will be vacant—and we can make the custom macro use the current position as the position used by the custom macro.

Here are the modified programs related to this application. Notice that X, Y and Z have been left out of the calling command in line N170 of the calling program O0001. We’re assuming that the cutting tool is centered on the hole to be helically milled in X and Y and 0.1 inch above the surface to be machined in Z.

O0001
N150 T03 M06 (Place cutter in spindle)
N155 G54 G90 S1000 M03
N160 G00 X3.0 Y3.0
N165 G43 H01 Z0.1 M08
N170 G65 P1000 D0.5 H2.0 T1.0 Q0.075 M1.0 F10.0
N175 G91 G28 Z0 M19
N180 M30

Here is the modified custom macro for this application:

O1000
IF[#24 NE #0] GOTO 2
#24=#5001 (Set current abs X position to #24)
N2 IF[#25 NE #0] GOTO 3
#24=#5002 (Set current abs Y position to #25)
N3 IF[#26 NE #0] GOTO 4
#26=#5003 – 0.1 (Set current abs Z position minus 01. to #26)
N4 IF [#13 EQ 0]GOTO 5 (Test milling style)
#105 = 3 (Climb milling)
GOTO 6
N5 #105 = 2 (Conventional milling)
N6G00 X#24 Y#25 (Move to hole center)
X[#24-#11/2+#20/2] (Move to start position in X)
Z[#26 +0.1] (Move to clearance position in Z)
G#105 I[#11/2-#20/2] Z#26 F#9 (Helical move to surface)
#100 = FUP[#7/#17] (Number of passes)
#101 = #7/#100 (Depth per pass)
#102 = 0-#101 (Current ending depth)
#103 = 1 (Counter)
N1 IF [#103 GT #100] GOTO 75 (Test if finished)
G#105 I[#11/2-#20/2] Z#102 F#9 (Make helical pass)
#102 = #102 -#101 (Step current ending depth)
#103 = #103 +1 (Step counter)
GOTO 1 (Go back to test)
N75 G#105 I[#11/2-#20/2] F#9 (Flatten bottom of hole)
G00 X#24 Z[#26+0.1] (Come out of hole in Z and to center in X)
M99

The objective of this technique is to eliminate redundancy and shorten the calling G65 command. As you can see, line N170 of the calling program is much shorter, containing three fewer letter address arguments.

 

 

Comments are reviewed by moderators before they appear to ensure they meet Modern Machine Shop’s submission guidelines.
blog comments powered by Disqus
MMS ONLINE
Channel Partners
  • Techspex