' MACRO PER CAMBIO UTENSILE TORNIO SU TORRETTA A 6 POSIZIONI, REL 3.01 DEL 11/8/2017
L_INC=GetLED(48) ' se ero in coordinate assolute allora il led era acceso
flag=0
old_feed=GetOEMDRO(821)
old_tool = GetCurrentTool()
new_tool = GetSelectedTool()
If new_tool=old_tool Then 'se il nuovo utensile è uguale al vecchio allora non fare nulla
End 'esce dalla macro
End If
If(new_tool>6 Or new_tool<1) Then 'il numero utensile > 8 o < 1
MachMsg("Il numero consentito di utensili è tra 1 e 6","ERRORE",0) 'scrive messaggio di errore
End 'esce dalla macro
End If
tool = GetSelectedTool()
SetCurrentTool( tool )
' SPOSTO GLI ASSI IN SICUREZZA
SetOEMDRO(821,100)
Code "G53 G0 G90 X10"
While IsMoving()
Wend
Code "G53 G0 G90 Z-100"
While IsMoving()
Wend
' IMPOSTO LA POSIZIONE DEL NUOVO UTENSILE SU TORRETTA
If new_tool < old_tool Then
new_tool=new_tool+6
End If
u_pos=(new_tool-old_tool)*60+75
Code "G0 G91 A" & u_pos ' vado sull'utensile
While IsMoving()
Wend
Code "G0 G91 A-82" ' blocco
While IsMoving()
Wend
SetOEMDRO(821,old_feed)
If (L_INC=0) Then
Code "G90" ' se ero in coordinate assolute le rimetto
End If