Hi everybody,
I'm a bit new to mach3 macros, gcode length compensation, and visual basic, but not all that new to programing. I guess my first question would be is there any way to get the script to trigger a break point during a call to m6 from the MDI? I think that might make debugging a little easier.
I'm having some difficulty with this modification of CNC4XR7's m6 tool change macro.
First I get the current tool and set the length compensation (because it might not be set for the first tool change).
I then call GetToolChangeStart (I think I am getting an incorrect Z value here... maybe this requires time to update after the G43?)
Then move to the tool change position, and wait for the user to change it.
I then move back to the starting XY position that was saved earlier
and here is where things go wrong...
when I move back to the Z position I usually end up trying to plunge into the mill bed.
I think I am making some mistake by not accounting for the work offset, the length compensation is not updating, or I have some error in my use of g43. I'm really scratching my head on this one... Any ideas what I'm doing wrong here?
Thanks,
Brian
'get the currently active tool
Dim Msg, Style, Title, Help, Ctxt, Response,MyString
OldTool = GetCurrentTool()
If OldTool = 0 Then
'do something here... this is not a valid condition!
DoOEMButton(1003) 'stop code
Msg = "Can't start from Tool 0! Load a different tool"
End
End If
Code "G43 H" & OldTool 'set the old tool length offset
'tool = GetSelectedTool()
'SetCurrentTool( tool )
'Tool Change Macro For Manual tool change 09/14 CNC4XR7
'OldTool = GetOEMDRO (1224) 'Tool In spindle DRO You must add this to your settings screen
x = GetToolChangeStart( 0 ) ' Get x tool change start position
y = GetToolChangeStart( 1 ) ' Get y tool change start position
z = GetToolChangeStart( 2 ) ' Get z tool change start position
Code "G53 G0 Z0" ' Move z to tool change position in Machine cord.
While IsMoving ' wait for z to move
Wend
Code "G53 G0 X-7 Y-10" ' Move to tool change position in Machine cord.
While IsMoving ' wait for z to move
Wend
tool = GetSelectedTool() ' tool to be changed to
NewTool = tool
Call SetUserDRO (1224,NewTool)
SetCurrentTool( NewTool ) ' input new tool into tool in spindle dro
Code "G43 H" & NewTool 'set new tool offset
' Verify Tool Change Complete
Msg = "Please Insert Tool Number " & " ( " & GetSelectedTool() & " ) " & " " & GetToolDesc(NewTool) ' Define message
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons
Style = 0 + 48 + 0 ' Define buttons.
Title = "Tool Change Requested" ' Define title
Help = "DEMO.HLP" ' Define Help file
Ctxt = 1000 ' Define topic 'context. ' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbOk Then ' User chose Ok
MyString = "Ok" ' Perform some action
End If
Message "Tool # " & GetCurrentTool() & " : " & GetToolDesc(GetCurrentTool()) & " Installed " & " Returning to Tool Change Start Position"
Code "G00 X" & x & "Y" & y 'Move above where the tool change was prompted
While IsMoving ' wait for z to move
Wend
Code "G00 X" & x & "Y" & y & "Z" & z 'Move back to where the tool change was prompted
'Code "G00 Z .25" 'Move Z back to .25" above zero in work cord.
While IsMoving
Wend
Code "G43 H" & tool ' Call tool offsets for new tool
End