Hello Guest it is April 18, 2024, 12:43:51 AM

Author Topic: A axis T/C help with VB script to only move to next tool through sucessive num t  (Read 2636 times)

0 Members and 1 Guest are viewing this topic.

Well folks. My VB writing skills are horrid, I am wondering if you might point me in the right direction to modify the following macro to do the following-

Rotate my 8 position (stepper driven) toolchanger in only one direction.

When I run the macro below (created by hood I believe) I get the tool turret (my rotary axis A) moving in the direction that will bring it to the requested tool in the shortest number of steps. While normally, this would be good, my gear train has sufficient backlash to make it better, if the turret only rotates in one direction regardless of how close the next called tool is to the current loaded tool.

I have a theory of how to do this-

Say for example-  current tool is 1, called tool is 7, (normally this would rotate through position 8 and then stop at seven) I want it to rotate to position 2, 3, 4, 5, 6, and stop at seven. I know this is inefficient, but it will fix the backlash issue created by "ang short rotation"

I have tried to run hoods macro with both ang short rot  both on and off, it only makes a difference when running code. when calling tool positions inside the macro, mach appears to ignore the ang short rot setting and revert to moving the fastest way possible.

Any thoughts on how to make the macro always move in + degrees from its current tool location through each intermediary position until reaching the called tool?

I tried some things in the VB editor, but keep getting syntax errors.





"""""""""""""""""""""""""""
  If GetSelectedTool() = GetCurrentTool() Then
End
 End If
 
 
 If GetSelectedTool = 1 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A0"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 If GetSelectedTool = 2 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A45"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 
 If GetSelectedTool = 3 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A90"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 If GetSelectedTool = 4 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A135"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 If GetSelectedTool = 5 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A180"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 
 If GetSelectedTool = 6 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A225"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If 
 
 
 If GetSelectedTool = 7 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A270"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 
 If GetSelectedTool = 8 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A315"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If   


"""""""""""""""""""""""""""
Well folks. Removing G53 fixed the issue. It now only rotates in one direction regardless of current tool position relationship to tool called.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
As I said in reply to your PM you can shorten that code considerably. Also you could try keeping your shortest path method but take out the backlash by slightly over-shooting on reversals and then correcting. This is untried but should do the trick.

Code: [Select]
selectedTool = getSelectedTool()
currentTool = getCurrentTool()

If selectedTool <> currentTool Then
  code "G53 G1 A" & ((selectedTool - 1) * 45) - 10
  While isMoving()
    sleep 10
  Wend

  code "G53 G1 A" & (selectedTool - 1) * 45
  While isMoving()
    sleep 10
  Wend

  SetCurrentTool selectedTool 
End If


You could reduce the value of 10 to just greater than your backlash if you want.