Ciao Torn24, intanto grazie per la tua disponibilità, il problema è proprio quello della rotazione antioraria (-5°), che dovrebbe avvenire solo per posizionare l'utensile correttamente. Ho trovato e provato anche un'altra macro (che allego), questa procede correttamente, non torna indietro se l'utensile richiamato è di numero inferiore, ma ci deve essere qualcosa nella calcolo dei gradi che fa si che non azzecca una posizione.
Grazie anche a hellfire39 per l'interessamento: ho provato in Mach3 in General Config. ad utilizzare l'opzione "Ang Short Rot on G0", ma non funziona.
la macro presa in rete:
Sub Main()
Dim newtool As Integer
Dim acttool As Integer
Dim grad_pro_tool As Integer
Dim grad_to_pin As Integer
Dim grad_backwards as Integer
Dim number_bars As Integer
Dim dist_distance As Double
Dim f_fast As Integer
Dim f_slow As Integer
If IsLoading() Then
'do nothing during load GCode
'Exit Sub
Else
grad_pro_tool = 45 'fwd angular position for one Tool Change
grad_to_pin = 10 'overtravel fwd angular position for one Tool Change
grad_backwards = 10 'reverse rotation to Pawl
f_fast = 4000 'fast forward rotational speed to Tool Change
f_slow = 2000 'slow reverse rotational speed to Pawl
newtool = GetSelectedTool() 'get new tool number specified by the most recent tool change (M6) command
acttool = GetCurrentTool() 'get actual active tool number
'let's do some basic checks
'if new tool and act tool = 0
If ((newtool = 0) and (acttool = 0)) Then
message "new tool and actual tool = 0 -> do nothing"
Sleep(500)
Exit Sub
End If
'new tool = 0
If (newtool = 0) Then
message "new tool = 0 -> do nothing"
Sleep(500)
Exit Sub
End If
'new tool = act tool
If newtool = acttool Then
message "new tool = act tool -> do nothing"
Sleep(500)
Exit Sub
End If
'check toolnumber from 1 to 8 only
If (((newtool >

Or (newtool < 1)) and (newtool <> 0)) Then
DoButton(3)
Sleep(500)
message " tool number " & newtool & " not in range (1-8). Abort ! "
Exit Sub
End If
'X-Axis not homed
If GetOEMLED(807) Then
DoButton(3)
Sleep(500)
message "X-Axis not referenced -> Abort !!"
Exit Sub
End If
'Z-Axis not homed
If GetOEMLED(809) Then
DoButton(3)
Sleep(500)
message "Z-Axis not referenced -> Abort !!"
Exit Sub
End If
'let's do something
message "change tool from : " +CStr(acttool) + " to " + CStr(newtool)
'1000 ms (1s) delay to allow message above to be displayed
Sleep(1000)
'Calculate the number of cycles between the tools
If newtool > acttool Then number_bars = newtool - acttool
If newtool < acttool Then number_bars = 8 - acttool + newtool
'message "number_bars = " & number_bars
'1000 ms (1s) delay to allow message above to be displayed
'Sleep(1000)
'Convert distance to steps
dist_fast = (number_bars * grad_pro_tool) + grad_to_pin
'ATC X-Axis to Tool Change position = X-axis home position
message "ATC X-Axis to Tool Change position"
Code "G90 G53 G0 X-2.0"
While IsMoving()
Sleep(15)
Wend
'ATC Z-Axis to Tool Change position = Z-axis home position
message "ATC Z-Axis to Tool Change position"
Code "G90 G53 G0 Z-2.0"
While IsMoving()
Sleep(15)
Wend
'set A-Axis zero
Code "G92 A0"
'incremental Mode , units per Minute , Exact Stop
Code "G91 G94 G61"
'A-Axis rotate forward quickly to the new tool
message "A-Axis rotate forward quickly to the new tool"
Code "G01 A" & dist_fast & "F" & f_fast
While IsMoving()
Sleep(15)
Wend
'A-Axis reverse back slowly to Pawl
message "A-Axis reverse back slowly to Pawl"
Code "G01 A-" & grad_backwards & "F" & f_slow
While IsMoving()
Sleep(15)
Wend
'anounce new tool to system
SetCurrentTool(newtool)
'back to absolute mode
Code "G90" ' back to absolute movement
Message ""
End If