Problema script ATC

Sezione dedicata a Mach3
Rispondi
buby
Senior
Senior
Messaggi: 612
Iscritto il: domenica 10 giugno 2007, 10:32
Località: Rg

Problema script ATC

Messaggio da buby » lunedì 15 novembre 2021, 14:57

Salve a tutti ho un problema, in parte risolto con questo script, diciamo che adesso funziona quasi come vorrei, ma dopo che appare la finestra di errore ( nel caso in cui non aggancia l'utensile ) e do OK lui continua e non so' se è la cosa migliore da fare, in realtà mi è venuto fuori cosi' ! Del resto se non aggancia il cono, potrei aggiungere una posizione di sosta per inserirlo manualmente e farlo continuare senza abortire la lavorazione. Premetto che non ho ancora studiato bene il linguaggio, sono all'inizio, mi date una mano? Thanks


Sub Main()
OldTool = GetOEMDRO (1200) 'Tool In spindle DRO You must add this to your settings screen
x = GetToolChangeStart( 0 )
y = GetToolChangeStart( 1 )
z = GetToolChangeStart( 2 )
a = GetToolChangeStart( 3 )
b = GetToolChangeStart( 4 )
tool = GetSelectedTool()
NewTool = tool

'----------------Tool Changer Macro (Bed Type)----------------------

MaxToolNum = 6 'Max number off tools for the changer
ToolDown = -150 'Z Pos to Get or drop a tool
ToolUp = 0 'Z Hieght to Rapid from tool to tool

'---------------------Control Led-----------------------------------
Led1 = SetUserLED(821, 0)
If GetOemLed (821)=0 Then
DoOEMButton(1003) 'Ferma tutto'
MachMsg("CONO NON AGGANCIATO","ERRORE",0)
Else

End If
'--------------------Auto Tool Zero---------------------------------

PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO
If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
End If
'-------------------------------------------------------------------
If NewTool = OldTool Then
Exit Sub
End If
While NewTool > MaxToolNum
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend
Code "G00 G53 Z " & ToolUp
While IsMoving()
Wend
Call MovePos(OldTool)
While IsMoving()
Wend
Code "G4 P0.75"
Code "G53 Z" & ToolDown
While IsMoving()
Wend
ActivateSignal(Output4) 'Turn On Draw bar to release the tool
Code "G4 P1.0" 'Wait for the tool to release
'SystemWaitFor (7) 'Wait for the tool Release Limit switch
Code "G53 Z-0.5" & ToolUp
Call MovePos(NewTool)
While IsMoving()
Wend
Code "G53 Z" & ToolDown
Code "G4 P0.75"
While IsMoving()
Wend
DeActivateSignal(Output4) 'Turn Off Draw bar to Clamp the tool
Code "G4 P1.0" 'Wait for the tool to Clamp
While IsMoving()
Wend
Led1 = SetUserLED(821, 0)
If GetOemLed (821)=0 Then
DoOEMButton(1003) 'Ferma tutto'
MachMsg("CONO NON AGGANCIATO","ERRORE",0)
Else

End If

Code "G53 Z" & ToolUp
Call SetUserDRO (1200,NewTool)
SetCurrentTool( NewTool )
While IsMoving()
Wend
ActivateSignal(Output5) 'Clamp the tool
Code "G4 P5.0" 'Wait for the tool to Clamp
While IsMoving()
Wend
DeActivateSignal(OUTPUT5)

'-----------------------------Auto Tool Zero-----------------------------
Led1 = SetUserLED(821, 0)
If GetOemLed (821)=0 Then
DoOEMButton(1003) 'Ferma tutto'
MachMsg("CONO NON AGGANCIATO","ERRORE",0)
Else

End If

Code "G53 X100 Y100" ' Move to Probe position
Code "G4 P1" ' this delay gives me time to get from computer to hold probe in place
Code "G31Z-50 F150" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the axact point the probe was hit
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
Code "G4 P0.25" 'Pause for Dro to update.
Code "G0 Z30." 'put the Z retract height you want here
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "G00 X" & x & " Y" & y 'Move back to where the tool change was prompted
End Sub
'---------------------------Tool Positio-------------------------------------
Sub MovePos(ByVal ToolNumber As Integer)

Select Case ToolNumber
Case Is = 1
Xpos = 100.00
YPos = 20.00
Case Is = 2
Xpos = 170.00
YPos = 20.00
Case Is = 3
Xpos = 240.00
YPos = 20.00
Case Is = 4
Xpos = 310.00
YPos = 20.00
Case Is = 5
Xpos = 380.00
YPos = 20.00
Case Is = 6
Xpos = 450.00
YPos = 20.00

End Select

Code "G53 X" & XPos & " Y" & YPos
End Sub
Main

torn24
God
God
Messaggi: 5075
Iscritto il: venerdì 1 febbraio 2008, 11:28
Località: Modena

Re: Problema script ATC

Messaggio da torn24 » martedì 16 novembre 2021, 8:23

Potresti, nella riga dove da il messaggio di errore, sotto il messaggio di errore cosi visualizza il messaggio, metti

Exit Sub

In questo modo esce dal programma cambio utensile non eseguendo più niente.
CIAO A TUTTI !

buby
Senior
Senior
Messaggi: 612
Iscritto il: domenica 10 giugno 2007, 10:32
Località: Rg

Re: Problema script ATC

Messaggio da buby » martedì 16 novembre 2021, 20:00

Grazie Torn, domani mattina mi dedico a fare tutte le prove del caso, vorrei anche considerando che il l secondo sensore del mandrino non lo sto usando, sfruttare l'ultimo ingresso che mi rimane per controllare la rastrelliera.

Rispondi

Torna a “Mach3”