User Tools

Site Tools


mycnc:m6_tool_change_macro:m6_tool_change_macro

This is an old revision of the document!


M6 Tool Change Macro

T-code of G-codes has higher priority than M6. For a command

M6T2

T2 will be executed first, then M6.

T1 … T99 are defined as macros in myCNC software. T-macro normally contains jsut 1 line to setup Global register #5409 - The Next Tool Number. Examples -

T1
G10 L80 P5409 Q1
T2
G10 L80 P5409 Q2
T3
G10 L80 P5409 Q3
T4
G10 L80 P5409 Q4
T5
G10 L80 P5409 Q5
T6
G10 L80 P5409 Q6

As a result, M6 macro procedure has information about both

  • Current Tool Number #5400 and
  • The Next Tool Number #5409

and able to handle correct Tool change

Beside tool changing operations M6 macro should have code line at the End of the macro to change The Current Tool Number Register itself.

G10 L81 P5400 Q5409 (Copy value from "Next Tool Number" to "Current Tool Number")

If The Current Tool Number register changed the myCNC control applies all offsets and Tool Length for new Tool Number

M06 Tool Change for Lathe/Turning machine (v1)

  • Lathe machine has drum-style Tool changer for 6 tools.
  • The drum rotated by stepper driver/motor. The driver connected to C-axis of a myCNC controller.
  • The drum has a Home sensor to find the initial position.
  • The drum rotated in positive (CCW) direction only.
  • The drum should be rotated in opposite direction to 5 degrees to lock it.
M6
(M06 - Tool change macro procedure)
(#5400 - Current Tool number)
(#5409 - Next Tool Number)
 
G10 L81 P200 Q5021 (X)(Save Current Program Position in Registers 200,202)
G10 L81 P202 Q5023 (Z)
 
#100=1000 (XY speed)
#110=1000 (Z speed)
#120=100  (C/Rotation speed)
 
 
IF [ #5400 EQ #5409 ] 400 (Desired tool is the same as current, goto the End)
IF [ #5409 LT 0 ] 400 (Desired tool<0, error, goto the End)
 
;G53 G90 G0 Z [#5433 - 1.0 ] F#110 (Move to safe position)
;G53 G90 G0 X [#5433 - 1.0 ] F#100 (Move to safe position)
 
(Register 300 to store tool difference)
 
#300= #5409-#5400
if [ #300 GT 0 ]  100 
 
#300=#300+6 (add 6 if next tool less than current tool)
 
N100
 
#300=#300*60 (multiply 60 degrees)
 
M7 (unlock the drum locker)
G91 G0 C5   F#120 (rotate 5 degrees to release the drum lock)
G91 G0 C#300 F#120 (move rotate to the next tool)
G91 G0 C-5   F#120 (lock the drum by reverse revolving to 5 degrees)
M9 (lock the drum locker)
 
 
G10 L81 P5400 Q5409(set current tool number)
 
N300
 
G10 L81 P5400 Q5409 (set current tool number)
 
;G53 G90 G0 X#200 Z#202 F#100 (Move to initial position stored in registers #200, #202)
 
N400 (The end label)

M06 Tool Change for Knife/Pen, with lift controlled through air pneumatics

The following changes can be made to the default M6 macro in order to eliminate lift at the beginning of the tool change through the machine going up/down, and instead turn on and off the outputs which will control the tool change:

M6
G10 L81 P101 Q5041
G10 L81 P102 Q5042
 
(M63 sets both ports 1 and 2 off - assigned ports for pen and knife respectively)
M63P1 
M63P2
G4 P1 (one second pause)
 
(G90 G0 Z15)  (Lift To Safe height is commented out)
(G53 G90 G0 Z[ #5433 - 0.5 ]) (Lift to the Top is commented out)
 
(Whole turns removed)
G10 L80 P7005 Q0 ()
M212 (Move to C=0)
G90 G10 L70 P#5220 C0 (Assign C=0 as work position)
G90 G0 C0 (Double check C=0)
 
 
N100
if [ #5409 NE 2 ] 200
(Tool 2 Knife)
G10 L80 P7005 Q1 (turns on tangential knife programming)
M63P1 (pen output is off)
M62P2 (knife output is on)
G4 P1 (one second pause)
GOTO 2000
 
 
N200
if [ #5409 NE 4 ] 300
(Tool 4 Pen)
G10 L80 P7005 Q0 (turns off tangential knife programming)
M63P2 (knife output is off)
M62P1 (pen output is on)
G4 P1 (one second pause)
GOTO 2000
 
 
N2000
 
G10 L81 P5400 Q5409    (set current tool number)
G4 P0.3 (Pause 0.3sec to update new Z correction in the controller)
 
G90 G0 X#101 Y#102

In this example, Pen is assigned as tool 4, with output 1 controlling its movement up/down during the tool switch, and Knife is assigned as tool 2, with output 2 controlling its movement up/down (assuming some sort of pneumatic system is activated when output 1/2 are turned on/off). M62 is a Hardware PLC procedure which turns a select port ON, while M63 turns a select output OFF.

Overall, it is still necessary to use the M6 procedure in addition to M62/63 for the selected outputs, as M6 allows to compensate for the offset between the different tools.

Note that in order to prevent z-axis movement at the beginning of the program, it is also required to set the Lift Height to 0 during the DXF import.

mycnc/m6_tool_change_macro/m6_tool_change_macro.1570466158.txt.gz · Last modified: 2019/10/07 12:35 by ivan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki