Files
Adeco_20220119-01/TC3_CNCPLCBase/OEM/FB_WZWArm.TcPOU
Matthias Heisig 51d6e7e5c4 Initial commit
2024-10-22 14:22:54 +02:00

274 lines
7.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.6">
<POU Name="FB_WZWArm" Id="{0bd61078-7831-4aaf-91a6-e74717f4416a}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_WZWArm
VAR_INPUT
bReset : BOOL;
bExecute : BOOL;
bInfeedEnabled : BOOL;
bSpindleOpen : BOOL;
END_VAR
VAR_OUTPUT
bCmdOpenSpindle : BOOL;
bError : BOOL;
bDone : BOOL;
END_VAR
VAR
// Achssteuerung
uiZSW1 AT %I* : UINT;
uiAKTSATZ AT %I* : UINT;
uiSTW1 AT %Q* : UINT;
uiSatzAnw AT %Q* : UINT;
// Zustandsautomat
nState : INT := 0;
// Start bei steigender Flanke
rtStart : R_TRIG;
// Hilfsvariablen
wZSW1 : WORD;
wAktSatz : WORD;
wSTW1 : WORD;
tofReset : TOF;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// Umrichterwerte lesen
wZSW1 := UINT_TO_WORD(uiZSW1);
wAktSatz := UINT_TO_WORD(uiAktSatz);
// Führung durch PLC
wSTW1.10 := 1;
// Reset der Achse wenn nötig
tofReset(IN := bReset, PT := T#250MS);
wSTW1.7 := tofReset.Q;
// Start bei steigender Flanke
rtStart(CLK := bExecute);
CASE nState OF
0 : // Idle
wStW1.0 := 0; // Ein
wStW1.1 := 0; // Nicht Austrudel
wStW1.2 := 0; // Kein Schnellhalt
wStW1.3 := 0; // Betrieb freigeben
wSTW1.4 := 0; // EPOS nicht Verwerfen
wSTW1.5 := 0; // EPOS kein Zwischenhalt
wSTW1.6 := 0; // EPOS Verfahrauftrag aktivieren 0 -> 1
bDone := TRUE;
bCmdOpenSpindle := FALSE;
IF rtStart.Q AND bInfeedEnabled THEN
bExecute := FALSE;
bDone := FALSE;
nState := 10;
END_IF
10: // Warten auf Einschaltbereit
wStW1.0 := 0; // Ein
wStW1.1 := 1; // Nicht Austrudel
wStW1.2 := 1; // Kein Schnellhalt
wStW1.3 := 1; // Betrieb freigeben
wSTW1.4 := 1; // EPOS nicht Verwerfen
wSTW1.5 := 1; // EPOS kein Zwischenhalt
wSTW1.6 := 0; // EPOS Verfahrauftrag aktivieren 0 -> 1
IF wZSW1.0 THEN // Einschaltbereit
nState := 20;
END_IF
20: // Warten auf Betriebsbereit
wStW1.0 := 1; // Ein
wStW1.1 := 1; // Nicht Austrudel
wStW1.2 := 1; // Kein Schnellhalt
wStW1.3 := 1; // Betrieb freigeben
wSTW1.4 := 1; // EPOS nicht Verwerfen
wSTW1.5 := 1; // EPOS kein Zwischenhalt
wSTW1.6 := 0; // EPOS Verfahrauftrag aktivieren 0 -> 1
IF wZSW1.2 THEN // Betriebsbereit
nState := 30;
END_IF
30: // Betreibsbereit -> Greifen
wStW1.0 := 1; // Ein
wStW1.1 := 1; // Nicht Austrudel
wStW1.2 := 1; // Kein Schnellhalt
wStW1.3 := 1; // Betrieb freigeben
wSTW1.4 := 1; // EPOS nicht Verwerfen
wSTW1.5 := 1; // EPOS kein Zwischenhalt
wSTW1.6 := 1; // EPOS Verfahrauftrag aktivieren 0 -> 1
// Starte beim ersten Satz
uiSatzAnw := 0;
IF wZSW1.12 AND (NOT wZSW1.10) THEN // Verfahrauftrag aktiv
nState := 40;
END_IF
40: // Warten auf in Position
wSTW1.6 := 0; // EPOS Verfahrauftrag aktivieren 0 -> 1
IF wZSW1.10 THEN
nState := 50;
END_IF
50: // Warten auf Spindel offen
bCmdOpenSpindle := TRUE;
uiSatzAnw := 1;
IF bSpindleOpen THEN
nState := 60;
END_IF
60: // Warten auf nächste Position (Werkzeuge getauscht)
wSTW1.6 := 1; // EPOS Verfahrauftrag aktivieren 0 -> 1
IF wZSW1.12 AND (NOT wZSW1.10) THEN
nState := 65;
END_IF
65: // Warten auf in Position
wSTW1.6 := 0; // EPOS Verfahrauftrag aktivieren 0 -> 1
IF wZSW1.10 THEN
nState := 70;
END_IF
70: // Warte auf Spindel zu
uiSatzAnw := 2;
wSTW1.6 := 0;
bCmdOpenSpindle := FALSE;
IF (NOT bSpindleOpen) THEN
nState := 80;
END_IF
80: // Warte auf nächste Position (Ruheposition)
wSTW1.6 := 1;
IF wZSW1.12 AND (NOT wZSW1.10) THEN
nState := 85;
END_IF
85: // Warte auf position erreicht
wSTW1.6 := 0; // EPOS Verfahrauftrag aktivieren 0 -> 1
IF wZSW1.10 THEN
nState := 90;
END_IF
90: // Ausschalten
wStW1.0 := 0; // Ein
wStW1.1 := 1; // Nicht Austrudel
wStW1.2 := 1; // Kein Schnellhalt
wStW1.3 := 1; // Betrieb freigeben
wSTW1.4 := 0; // EPOS nicht Verwerfen
wSTW1.5 := 0; // EPOS kein Zwischenhalt
wSTW1.6 := 0; // EPOS Verfahrauftrag aktivieren 0 -> 1
IF NOT wZSW1.1 THEN
nState := 0;
END_IF
99: // Error
bError := TRUE;
END_CASE
// Umrichterwerte schreiben
uiSTW1 := WORD_TO_UINT(wSTW1);]]></ST>
</Implementation>
<LineIds Name="FB_WZWArm">
<LineId Id="132" Count="0" />
<LineId Id="378" Count="0" />
<LineId Id="288" Count="0" />
<LineId Id="433" Count="1" />
<LineId Id="432" Count="0" />
<LineId Id="600" Count="0" />
<LineId Id="599" Count="0" />
<LineId Id="601" Count="1" />
<LineId Id="398" Count="1" />
<LineId Id="397" Count="0" />
<LineId Id="33" Count="1" />
<LineId Id="162" Count="0" />
<LineId Id="379" Count="4" />
<LineId Id="363" Count="0" />
<LineId Id="435" Count="0" />
<LineId Id="560" Count="1" />
<LineId Id="555" Count="1" />
<LineId Id="400" Count="0" />
<LineId Id="402" Count="0" />
<LineId Id="500" Count="0" />
<LineId Id="562" Count="0" />
<LineId Id="403" Count="0" />
<LineId Id="401" Count="0" />
<LineId Id="384" Count="1" />
<LineId Id="387" Count="4" />
<LineId Id="386" Count="0" />
<LineId Id="436" Count="0" />
<LineId Id="404" Count="0" />
<LineId Id="406" Count="1" />
<LineId Id="405" Count="0" />
<LineId Id="408" Count="1" />
<LineId Id="411" Count="4" />
<LineId Id="410" Count="0" />
<LineId Id="437" Count="0" />
<LineId Id="416" Count="0" />
<LineId Id="418" Count="1" />
<LineId Id="417" Count="0" />
<LineId Id="420" Count="1" />
<LineId Id="424" Count="4" />
<LineId Id="423" Count="0" />
<LineId Id="438" Count="0" />
<LineId Id="429" Count="0" />
<LineId Id="431" Count="0" />
<LineId Id="430" Count="0" />
<LineId Id="439" Count="0" />
<LineId Id="441" Count="1" />
<LineId Id="440" Count="0" />
<LineId Id="443" Count="1" />
<LineId Id="503" Count="0" />
<LineId Id="445" Count="4" />
<LineId Id="554" Count="0" />
<LineId Id="502" Count="0" />
<LineId Id="450" Count="0" />
<LineId Id="493" Count="0" />
<LineId Id="451" Count="3" />
<LineId Id="504" Count="0" />
<LineId Id="495" Count="0" />
<LineId Id="455" Count="0" />
<LineId Id="463" Count="1" />
<LineId Id="543" Count="1" />
<LineId Id="546" Count="2" />
<LineId Id="545" Count="0" />
<LineId Id="465" Count="1" />
<LineId Id="506" Count="0" />
<LineId Id="505" Count="0" />
<LineId Id="557" Count="1" />
<LineId Id="497" Count="0" />
<LineId Id="467" Count="4" />
<LineId Id="507" Count="0" />
<LineId Id="499" Count="0" />
<LineId Id="473" Count="1" />
<LineId Id="472" Count="0" />
<LineId Id="509" Count="1" />
<LineId Id="550" Count="2" />
<LineId Id="549" Count="0" />
<LineId Id="475" Count="1" />
<LineId Id="478" Count="5" />
<LineId Id="477" Count="0" />
<LineId Id="484" Count="3" />
<LineId Id="234" Count="1" />
<LineId Id="564" Count="0" />
<LineId Id="36" Count="0" />
<LineId Id="201" Count="0" />
<LineId Id="13" Count="0" />
<LineId Id="392" Count="0" />
</LineIds>
</POU>
</TcPlcObject>