Hello Guest it is April 29, 2024, 09:01:38 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - bhauser

Pages: 1
1
VB and the development of wizards / Re: Tool change Macro Issue
« on: February 15, 2021, 11:00:27 PM »
Thanks TPS!

         I appreciate the help!  This was a modification of somebody elses tool change macro that I found online...  So there is a lot of cruft.   

Code: [Select]
x = GetOEMDro( 800 ) ' Get x tool change start position
y = GetOEMDro( 801 ) ' Get y tool change start position
z = GetOEMDro( 802 ) ' Get z tool change start position

Do the 800->802 DRO's read out the current work offset or machine coordinates?  How do those DRO's change based on g90/g91?  I have to admit that the documentation I was able to find on this was unclear.

Code: [Select]
Call SetUserDRO (1224,NewTool)
This is a user DRO that was added to the settings screen by the original author...  I think I can get rid it.

Code: [Select]
' 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

This is just to wait until the user manually changes the tool.  Is there a way to cancel the current running gcode?  I think A cancel option would be a good thing to add!  That is if I can cancel the currently running program.

Thanks again!

      Brian




2
VB and the development of wizards / Tool change Macro Issue
« on: February 13, 2021, 08:03:35 AM »
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

Code: [Select]
'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       

Pages: 1