ATC and Tool length sensor; While is Moving () is skipped; Emergency mode
Good evening everyone,
As already heard in the title, I have a problem with my self-written ATC (automatic tool change) and the combined tool lengths measured.
There are 2 problems:
1. The While Is Moving command is skipped in my opinion.
That means if the machine, for example, the old tool snaps into the holder in y,
it opens the spindle before it has reached the end point.
2. When I test the ATC without a tool (otherwise it always falls out), the old tool still engages and as soon as it lifts in Z,
it moves a few mm and then triggers the emergency stop switch.
This also happens when the machine is miles away from the limit switches. The soft limit was deactivated for every test.
I noticed that while I was looking at the input signals of all limit switches and reference switches on the diagnosis side,
they were all briefly activated at the same time as the emergency stop signal.
I have already checked all cables and connections, I hope you can help me.
I also attach the ATC code.
Code:
'ToolChange Macro für Bettgestützte Wechsler 12/2020 HolzCNC-3D
Sub Main()
OldTool = GetCurrentTool() 'Tool in Spindel DRO, Mann muss das zum Einstellbildschirm hinzufügen
x = GetToolChangeStart( 0 )
y = GetToolChangeStart( 1 )
z = GetToolChangeStart( 2 )
a = GetToolChangeStart( 3 )
b = GetToolChangeStart( 4 )
c = GetToolChangeStart( 5 )
tool = GetSelectedTool()
NewTool = tool
'Tool Change Macro (Bettgestützte)
MaxToolNum = 8 'Maximale Werkzeuganzahl im Wechsler
ToolDown = -150.0 'Z Pos. zum greifen oder lösen des WKZs
ToolUp = -10.0 'Z Höhe um sicher über den Werkzeugen und Wechsler zu verfahren
ToolDown2 = -120.0 'Z Höhe Zeite sicherheits höhe kurz vorher
ToolVor = -20 'Y position eingerasteter zustand Achtung muss Identisch mit Case Tabelle sein
ToolBack = -40.0 'Y position vorpositionieren
Feed = 500 'Forschub zum ein und ausrasten und zum spindel andocken
'Werkzeug länge vermessen Macro
Schalter = 30 'Höhe des werkzeuglängen sensors
XSchalter = -800 'x position des Schalters
YSchalter = -20 'y position des schalters
ZVorpos = -200 'z position bis zu der im Eilgang verfahren wird
If NewTool = OldTool Then
Exit Sub
End If
'Neues Werkzeug ist 0 also Spindel wird leer
If NewTool = 0 Then
'Schutz öffnen
ActivateSignal(Output7) 'Einschalten des Druckluft Ventiels zum öffnen des Schutzes
Code "G4 P2" 'Warte zwei Sekunde
'Auf sichere Position fahren
Code "G00 G53 Z" & ToolUp
While IsMoving()
Wend
Code "G00 G53 A0"
While IsMoving()
Wend
'Fahre Leerplatz vom alten Werkzeug an
Call MovePos(OldTool)
While IsMoving()
Wend
'Fahre vor den Halter
Code "G53 Y" & ToolBack
While IsMoving()
Wend
'Z Absenken vor dem Halter
Code "G53 Z" & ToolDown
While IsMoving()
Wend
'Werkzeug langsam einrasten
Code "G01 G53 F" & Feed & "Y" & ToolVor
While IsMoving()
Wend
'Werkzeug Spanner öffnen
ActivateSignal(Output9) 'Einschalten des Druckluft Ventiels zum lösen des Werkzeugs
Code "G4 P2.0" 'Warte zwei Sekunde
'Leere Spindel nach oben Fahren
Code "G01 G53 F" & Feed & "Z" & ToolDown2
While IsMoving()
Wend
'Werkzeug Spanner Schliesen
DeActivateSignal(Output9) 'Auschalten des Druckluft Ventiels zum spannen des Werkzeugs
Code "G4 P1.0" 'Warte zwei Sekunde
'Leere Spindel Ganz nach oben Fahren
Code "G00 G53 Z" & ToolUp
While IsMoving()
Wend
'Schutz schliesen
DeActivateSignal(Output7) 'Auschalten des Druckluft Ventiels zum schliesen des Schutzes
Code "G4 P2.0" 'Warte zwei Sekunde
'Neues Werkzeug übernehmen bzw Werkzeug 0
Call SetUserDRO (1200,NewTool)
SetCurrentTool( NewTool )
'Fahre auf Home Position
Code "G28"
Exit Sub
End If
'Aktuelles Werkzeug ist 0 also Spindel ist leer
If OldTool = 0 Then
'Schutz öffnen
ActivateSignal(Output7) 'Einschalten des Druckluft Ventiels zum öffnen des Schutzes
Code "G4 P2" 'Warte zwei Sekunde
'Auf sichere Position fahren
Code "G00 G53 Z" & ToolUp
While IsMoving()
Wend
Code "G00 G53 A0"
While IsMoving()
Wend
'Fahre Platz von Neuem Werkzeug an
Call MovePos(NewTool)
While IsMoving()
Wend
'Werkzeug Spanner öffnen
ActivateSignal(Output9) 'Einschalten des Druckluft Ventiels zum lösen des Werkzeugs
Code "G4 P2.0" 'Warte zwei Sekunde
'Z Vorpossitionieren
Code "G00 G53 Z" & ToolDown2
While IsMoving()
Wend
'Fahre in Z auf Werkzeug
Code "G01 G53 F" & Feed & "Z" & ToolDown
While IsMoving()
Wend
'Werkzeug Spanner schliesen
DeActivateSignal(Output9) 'Auschalten des Druckluft Ventiels zum spannen des Werkzeugs
Code "G4 P2.0" 'Warte zwei Sekunde
'Werkzeug ausrasten in Y
Code "G01 G53 F" & Feed & "Y" & ToolBack
While IsMoving()
Wend
'Fahre in Z auf sichere Position
Code "G01 G53 F" & Feed & "Z" & ToolDown2
While IsMoving()
Wend
'Fahre in Z auf sichere Position Gnaz Oben
Code "G00 G53 Z" & ToolUp
While IsMoving()
Wend
'Schutz schliesen
DeActivateSignal(Output7) 'Auschalten des Druckluft Ventiels zum schliesen des Schutzes
Code "G4 P2.0" 'Warte zwei Sekunde
'Neues Werkzeug übernehmen
Call SetUserDRO (1200,NewTool)
SetCurrentTool( NewTool )
'##################Werkzeug länge messen######################
If GetOEMDRO (824) <>0 Then
Code "G0G53 Z" & ToolUp'Hochfahren in Z
While IsMoving()
Wend
code "g0 g53 x" & XSchalter 'x position des Schalters
While IsMoving()
Wend
code "g0 g53 y" & YSchalter'y position des schalters
While IsMoving()
Wend
code "g0 g53 z" & ZVorpos 'z position bis zu der im Eilgang verfahren wird
While IsMoving()
Wend
code "g31 z-1000 f500" 'erstes antasten
While IsMoving()
Wend
code "g53 g0 z" & GetOEMDRO(85)+3 'zusätzlich abheben
While IsMoving()
Wend
code "g31 z-1000 f50" 'fein tasten
While IsMoving()
Wend
Z_Shift = Schalter 'schalter höhe
Axis_Pos = GetOEMDRO(85) 'Z position des fräsers
Tool_Offset = Axis_Pos - Z_Shift 'offset berechnen
Call setOEMDRO(42, Tool_Offset) 'Werkzeug länge eintragen
Code "G0G53 Z" & ToolUp 'fahre auf Save z
Code "G28" 'fahre auf home position
MsgBox "Ihr Fräsprogramm muss die Befehhlszeile G43 H" & GetOEMDRO (824) _
& " M6 T" & GetOEMDRO (824) _
& " für den Werkzeugwechsel enthalten"'824 ist die werkzeugnummer
Else
MsgBox "Keine Werkzeug-Nummer gewählt",0
End If
'##################Werkzeug länge messen ende######################
'Fahre an den Punkt an dem der Werkzeugwechsel aufgerufen wurde
Code "G00 X" & x & " Y " & y
Code "G00 A" & a
Exit Sub
End If
'Loop falsche eingabe zu grose werkzeugnummer
While NewTool > MaxToolNum
NewTool = Question ("Geben Sie eine neue Werkzeugnummer ein bis max " & MaxToolNum)
Wend
'Wechsel zwischen Werkzeugen
'Schutz öffnen
ActivateSignal(Output7) 'Einschalten des Druckluft Ventiels zum öffnen des Schutzes
Code "G4 P2" 'Warte zwei Sekunde
'Auf sichere Position fahren
Code "G00 G53 Z" & ToolUp
While IsMoving()
Wend
Code "G00 G53 A0"
While IsMoving()
Wend
'Fahre Leerplatz vom alten Werkzeug an
Call MovePos(OldTool)
While IsMoving()
Wend
'Fahre vor den Halter
Code "G53 Y" & ToolBack
While IsMoving()
Wend
'Z Absenken vor und über dem Halter
Code "G53 Z" & ToolDown2
While IsMoving()
Wend
'Z Absenken vor dem Halter
Code "G01 G53 F" & Feed & "Z" & ToolDown
While IsMoving()
Wend
'Werkzeug langsam einrasten
Code "G01 G53 F" & Feed & "Y" & ToolVor
While IsMoving()
Wend
'Werkzeug Spanner öffnen
ActivateSignal(Output9) 'Einschalten des Druckluft Ventiels zum lösen des Werkzeugs
Code "G4 P2.0" 'Warte zwei Sekunde
'Leere Spindel nach oben Fahren
Code "G01 G53 F" & Feed & "Z" & ToolDown2
While IsMoving()
Wend
'Neues Werkzeug anfahren
Call MovePos(NewTool)
While IsMoving()
Wend
'Fahre in Z auf Werkzeug
Code "G01 G53 F" & Feed & "Z" & ToolDown
While IsMoving()
Wend
'Werkzeug Spanner schliesen
DeActivateSignal(Output9) 'Auschalten des Druckluft Ventiels zum spannen des Werkzeugs
Code "G4 P2.0" 'Warte zwei Sekunde
'Werkzeug langsam ausrasten in Y
Code "G01 G53 F" & Feed & "Y" & ToolBack
While IsMoving()
Wend
'Fahre in Z auf sichere Position
Code "G01 G53 F" & Feed & "Z" & ToolDown2
While IsMoving()
Wend
'Fahre in Z auf sichere Position Ganz Oben
Code "G00 G53 Z" & ToolUp
While IsMoving()
Wend
'Schutz schliesen
DeActivateSignal(Output7) 'Auschalten des Druckluft Ventiels zum schliesen des Schutzes
Code "G4 P2.0" 'Warte zwei Sekunde
'Neues Werkzeug übernehmen
Call SetUserDRO (1200,NewTool)
SetCurrentTool( NewTool )
'##################Werkzeug länge messen######################
If GetOEMDRO (824) <>0 Then
Code "G0G53 Z" & ToolUp'Hochfahren in Z
While IsMoving()
Wend
code "g0 g53 x" & XSchalter 'x position des Schalters
While IsMoving()
Wend
code "g0 g53 y" & YSchalter'y position des schalters
While IsMoving()
Wend
code "g0 g53 z" & ZVorpos 'z position bis zu der im Eilgang verfahren wird
While IsMoving()
Wend
code "g31 z-1000 f500" 'erstes antasten
While IsMoving()
Wend
code "g53 g0 z" & GetOEMDRO(85)+3 'zusätzlich abheben
While IsMoving()
Wend
code "g31 z-1000 f50" 'fein tasten
While IsMoving()
Wend
Z_Shift = Schalter 'schalter höhe
Axis_Pos = GetOEMDRO(85) 'Z position des fräsers
Tool_Offset = Axis_Pos - Z_Shift 'offset berechnen
Call setOEMDRO(42, Tool_Offset) 'Werkzeug länge eintragen
Code "G0G53 Z" & ToolUp 'fahre auf Save z
Code "G28" 'fahre auf home position
MsgBox "Ihr Fräsprogramm muss die Befehhlszeile G43 H" & GetOEMDRO (824) _
& " M6 T" & GetOEMDRO (824) _
& " für den Werkzeugwechsel enthalten"'824 ist die werkzeugnummer
Else
MsgBox "Keine Werkzeug-Nummer gewählt",0
End If
'##################Werkzeug länge messen ende######################
'Fahre an den Punkt an dem der Werkzeugwechsel aufgerufen wurde
Code "G00 X" & x & " Y " & y
Code "G00 A" & a
End Sub
Sub MovePos(ByVal ToolNumber As Integer)
Select Case ToolNumber
Case Is = 1
XPos = -20.00
YPos = -20.00
Case Is = 2
XPos = -40.00
YPos = -20.00
Case Is = 3
XPos = -60.00
YPos = -20.00
Case Is = 4
XPos = -80.00
YPos = -20.00
Case Is = 5
XPos = -100.00
YPos = -20.00
Case Is = 6
XPos = -120.00
YPos = -20.00
Case Is = 7
XPos = -140.00
YPos = -20.00
Case Is = 8
XPos = -160.00
YPos = -20.00
End Select
Code "G53 X" & XPos & " Y " & YPos
End Sub
Main
Re: ATC and Tool length sensor; While is Moving () is skipped; Emergency mode
1) Is it actually hitting a limit switch, or just giving the error?
2) Are you using a motion controller? If so, which one?
Re: ATC and Tool length sensor; While is Moving () is skipped; Emergency mode
No the limit switch is not touched, it only gives the error
oh i forgot to mention that i have the china controler from novusun nvem V2 or something like that. I'm not sure how this is written right now.
I hope I am not judged badly here because of my choice of controller. I know that there is no good opinion about this controller.
At the moment I am considering whether I should switch to the CSMIO iP-S for 6 axes.
Re: ATC and Tool length sensor; While is Moving () is skipped; Emergency mode
Try to add a "sleep 50" inside the while loop, maybe will do the trick
Regards
Re: ATC and Tool length sensor; While is Moving () is skipped; Emergency mode
Quote:
Originally Posted by
sebba
Try to add a "sleep 50" inside the while loop, maybe will do the trick
Regards
ok i will try this out.
Re: ATC and Tool length sensor; While is Moving () is skipped; Emergency mode
Quote:
No the limit switch is not touched, it only gives the error
It may be noise triggering the input?
As for the macro, it could be an issue with the plugin for your controller. Most Chinese controllers have some issues with Mach3 macros. The sleep might help. You might also want to try a different versions of Mach3, as most plugins work best with the version of Mach3 they were written for, and may have issues with other versions.