Hi ,
I used a M6Start macro that someone had written for a 6 tool Boxford ATC.
That worked, sort of, for my Emco5 ATC converted with a stepper motor and one optical slot for homing.
The problem was that the macro could not see if the ATC was homed in the Manual screen, Home All.
It would turn at random, tool positions were not absolute.
I inserted this piece of VB code in the beginning of the macro;
'----------------------------------------
' First check if ATC is homed.
If IsActive(INPUT1) Then
Message " Input 1 is Active"
SensorState = "Active"
Else
Message " Input 1 is NOT Active, Home first."
Code "M30" 'End the execution of the G-Code.
End
End If
If SensorState = "Active" Then
Current_Tool = 1 'Set ATC Home as Current Tool.
End If
'-----------------------------------------
That set the Current_Tool as tool # one.
But, when a second tool change was asked for in the G-code things went wrong.
The macro insists to be homed again.
I need some code or place to store the information that the part homing command is to be skipped.
Say that I insert a variable like Homing_Done just before the end If;
If SensorState = "Active" Then
Current_Tool = 1 'Set ATC Home as Current Tool.
Homing_Done = 1
End If
I want to store this Homing_Done somewhere. Can that be done outside the macro and have the macro look for it each time the M6Start
is called in the current G-code?
This is the total macro;
' Boxford 160TCL Toolchanger Macro.
'
' Works by turning CW to just past the tool position
' and then CCW into a stop.
' Axis setup as rotary e.g. move 360 = 1 full turn.
' Adapted for the EMCO5cnc Automatic Tool Changer.
' Checks if ATC is Homed first and sets Current_Tool as #1.
' If not Homed it ends the program.
If IsLoading() Then
' Do Nothing, program loading
Else
' Dim Variables
Dim Num_Tools As Integer
Dim CW_Steps_Per_Tool As Integer
Dim CCW_Steps As Integer
Dim HoldingDRO As Integer
Dim Requested_Tool As Integer
Dim Current_Tool As Integer
Dim CW_Feed As Integer
Dim CCW_Feed As Integer
Dim moves As Integer
Dim total_move As Integer
'----------------------------------------
' First check if ATC is homed.
If IsActive(INPUT1) Then
Message " Input 1 is Active"
SensorState = "Active"
Else
Message " Input 1 is NOT Active, Home first."
Code "M30" 'End the execution of the G-Code.
End
End If
If SensorState = "Active" Then
Current_Tool = 1 'Set ATC Home as Current Tool.
End If
'-----------------------------------------
' set up some vars
Num_Tools = 6
CW_Move_Per_Tool = 360/Num_Tools
CCW_Move = 10
HoldingDRO = 1050
Requested_Tool = GetSelectedTool()
' Current_Tool = GetUserDRO(HoldingDRO)
CW_Feed = 700
CCW_Feed = 700
Current_Feed = GetOEMDRO(818)
' start tool change
Message ("Requested Tool No=" & Requested_Tool)
If Requested_Tool > Num_Tools Then
Message "Requested Tool No. too high, program stopped."
Code "M30"
End
End If
If Requested_Tool < 1 Then
Message "Requested Tool No. too low, program stopped."
Code "M30"
End
End If
If Requested_Tool = Current_Tool Then
' do nothing
Else
' lets do some changing
If Requested_Tool > Current_Tool Then moves = Requested_Tool -Current_Tool
If Requested_Tool < Current_Tool Then moves = Num_Tools - Current_Tool +Requested_Tool
total_move = (moves * CW_Move_Per_Tool)+(CCW_Move/2)
'Code "G01 x-10 F700"
'Code "z-10"
Code "G91 G94" 'incremental & Feed per minute
Code "G0 A" & total_move '& "F" & CW_Feed
Code "G0 A" & "-" & CCW_Move '& "F" & CCW_Feed
While IsMoving()
Wend
SetCurrentTool Requested_Tool
SetUserDRO HoldingDRO, Requested_Tool
Code "G90" ' back to absolute movement
Code "F" & Current_Feed
End If
End If
' end of tool change
Thanks for looking,
Jos
Holland