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

364 lines
11 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.6">
<POU Name="MAIN" Id="{34c8c45c-58c6-4f5f-9362-3ad98fa8450c}" SpecialFunc="None">
<Declaration><![CDATA[PROGRAM MAIN
VAR
fbSpindel : FB_Spindel;
fbWZW : FB_WZW;
fbZentralschmierung : FB_Zentralschmierung;
fbMMS : FB_MMS;
fbAbsaugtopf : FB_Absaugtopf;
fbStaubsauger : FB_Staubsauger;
fbVakuumpumpe : FB_Vakuumpumpe;
fbDruckluft : FB_Druckluftueberwachung;
fbVakuumfelder : FB_Vakuumfelder;
fbWickler : FB_Papiervorschub;
fbAnschlag : FB_AnschlagAbsaugung;
fbDCommand : FB_CmdDInfo;
fbTCommand : FB_CmdTInfo;
fbOldDCommand : FB_CmdOldDInfo;
bDebug : Bool;
rtToolChangeDone : R_TRIG;
rtToggleMMS : R_TRIG;
bMMSEnabled : BOOL;
rtNCStart : R_TRIG;
rtNCStop : R_TRIG;
fbBlinker : FB_Blinker;
bFirstRun : BOOL := TRUE;
tonM19 : TON;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[HLI3_Init();
PRG_Messages(); // Messages Eventlogger V1
// PRG_MessagesV2(); // Messages Eventlogger V2
(* Call CNC related code only if the HLI has been initialized succesfully! *)
IF CNCSystem.bHLIInit THEN
IF bFirstRun THEN
bFirstRun := FALSE;
CNCSystem.Channel[0].ToolData.DCommand := fbDCommand;
CNCSystem.Channel[0].ToolData.TCommand := fbTCommand;
CNCSystem.Channel[0].ToolData.DCommandOldTool := fbOldDCommand;
GVL_OEM.pVe := ADR(gpVECh[0]^.ext_var32[0]);
GVL_OEM.pVe^.ToolInSpindle := GVL_ToolMgmt.diToolInSpindle;
END_IF
PRG_CNCAxesHandler();
PRG_CNCManualMode();
PRG_CNCChannelHandler();
PRG_CNCVariablesViewer();
PRG_ManualFnc();
(* OEM program start *)
rtNCSTart(CLK := GVL_OEM.bBtnNCStart);
rtNCStop(CLK := GVL_OEM.bBtnNCStop);
IF rtNCStart.Q THEN
PLCMachineMode[0].Start := TRUE;
END_IF
IF rtNCStop.Q THEN
PLCMachineMode[0].Stop := TRUE;
END_IF
fbBlinker();
CASE CNCSystem.Channel[0].ActState OF
HLI_IMCM_PROCESS_ACTIVE:
GVL_OEM.bBtnNCStartLED := TRUE;
GVL_OEM.bBtnNCStopLED := FALSE;
HLI_IMCM_PROCESS_HOLD:
GVL_OEM.bBtnNCStartLED := fbBlinker.bQ;
GVL_OEM.bBtnNCStopLED := TRUE;
ELSE
GVL_OEM.bBtnNCStartLED := FALSE;
GVL_OEM.bBtnNCStopLED := TRUE;
END_CASE
PRG_Einspeisung();
GVL_HMI.bAxisEnableAllowed := PRG_Einspeisung.bInfeedActive AND fbDruckluft.bDruckluftOk;
fbSpindel(
bCmdOpenSpindle := fbWZW.bCmdOpenSpindle OR GVL_Debug.bCmdOpenSpindle,
bSensor3 := GVL_OEM.byteInputSpindlePin4.0,
bSensor4 := GVL_OEM.byteInputSpindlePin2.0,
bAirCurtainEnabled := GVL_Debug.bAirCurtainEnabled,
bCmdStopSpindle := fbDruckluft.bStopSpindle,
bSperrluft => GVL_OEM.byteOutputSpindlePin2.2,
bKonusReiniung => GVL_OEM.byteOutputSpindlePin4.2,
bATCOn => GVL_OEM.byteOutputSpindlePin2.1,
bATCOff => GVL_OEM.byteOutputSpindlePin4.1);
GVL_HMI.iSpindleLoadPercent := GVL_OEM.iSpindleLoad / 10;
fbWZW(
bExecute := CNCSystem.Channel[0].M[10].bState_rw,
bExecutePreselect := GVL_ToolMgmt.bExecuteToolPrep,
bReset := PLCReset,
bSpindleInPosition := TRUE,
bPreselectOnly := FALSE,
uiToolPocket := GVL_ToolMgmt.stToolToPrep.pos,
bInfeedActive := PRG_Einspeisung.bInfeedActive,
bSpindleOpen := fbSpindel.bSpindleOpen);
rtToolChangeDone(CLk := fbWZW.bDone);
IF rtToolChangeDone.Q AND CNCSystem.Channel[0].M[10].bState_rw THEN
CNCSystem.Channel[0].M[10].bState_rw := FALSE;
END_IF
fbZentralschmierung(
bCmdStartCycle := GVL_Debug.bStartLubricationCycle OR bDebug,
bCycleSensor := GVL_OEM.byteInputSpindlePin2.4,
bBusy => GVL_Debug.bLubricationActive,
bReset := PLCReset);
// MMS über M-Befehl
IF CNCSystem.Channel[0].M[8].bState_rw THEN
bMMSEnabled := TRUE;
CNCSystem.Channel[0].M[8].bState_rw := FALSE;
END_IF
IF CNCSystem.Channel[0].M[9].bState_rw THEN
bMMSEnabled := FALSE;
CNCSystem.Channel[0].M[9].bState_rw := FALSE;
END_IF
// MMS über taster
rtToggleMMS(CLK := GVL_Debug.bToggleMMS);
IF rtToggleMMS.Q THEN
bMMSEnabled := NOT bMMSEnabled;
END_IF
// Dissable MMS on Reset
IF PLCReset THEN
bMMSEnabled := FALSE;
END_IF
GVL_Debug.bMMSActive := bMMSEnabled;
fbMMS(bEnable := bMMSEnabled);
// Absaugung
fbAbsaugtopf(
bCmdTopfHoch := GVL_Debug.bAbsaugungHoch,
bCmdTopfRunter := GVL_Debug.bAbsaugungRunter,
bReset := PLCReset,
bSensorKlemmungInaktiv := GVL_OEM.byteInputSpindlePin4.6,
bSensorKlemmungAktiv := GVL_OEM.byteInputSpindlePin2.5,
bSensorTopfUnten := GVL_OEM.byteInputSpindlePin2.3,
bSensorTopfOben := GVL_OEM.byteInputSpindlePin4.5,
bVentilTopfRunter => GVL_OEM.byteOutputSpindlePin4.3,
bVentilKlemmungAus => GVL_OEM.byteOutputSpindlePin2.6);
fbAnschlag(
bEnable := GVL_HMI.bEnableStepper OR PLCAxisEnable,
bReset := PLCReset,
bCmdStartHoming := GVL_HMI.bStartHoming OR fbAbsaugtopf.bHomingKlemmung,
bCmdPosition := fbAbsaugtopf.bBewegeKlemmung,
fTargetPosition := fbAbsaugtopf.fPositionKlemmung,
bHomeSwitch := GVL_OEM.byteInputSpindlePin2.7,
bHomed => fbAbsaugtopf.bKlemmungReferenziert,
bDone => fbAbsaugtopf.bBewegungKlemmungFertig);
// Staubsauger
fbStaubsauger(
bToggleEnable := GVL_Debug.bStaubsauger,
bVacuumOn => GVL_Debug.bStaubsaugerOn);
// Vakuumpumpe
fbVakuumpumpe(
bToggle := GVL_OEM.bBtnToggleVakuumpumpe);
// Vakuumfeldsteuerung
fbVakuumfelder(
bExecuteHMI := GVL_HMI.bExecVacFieldChange,
nFieldNumber := GVL_HMI.bSelectedField);
// Papiervorschub
GVL_OEM.uiEncoderValuePaper := GVL_OEM.byteInputEncoder0;
GVL_OEM.uiEncoderValuePaper := SHL(GVL_OEM.uiEncoderValuePaper,8) + GVL_OEM.byteInputEncoder1;
fbWickler(
bInfeedEnabled := PRG_Einspeisung.bInfeedActive,
bReset := PLCReset,
uiEncoderValue := GVL_OEM.uiEncoderValuePaper);
PRG_Safety();
PRG_Master_Slave();
PRG_Debug();
// Druckluftüberwachung
fbDruckluft(
bDruckluftOk := GVL_OEM.byteInputDruckluft0.0,
bSpindleStopped := fbSpindel.bSpindleStopped);
// Werkzeugtausch behandlung
PRG_Platztausch();
// Aktuelles Werkzeug in der Spindel speichern
GVL_ToolMgmt.diToolInSpindle := GVL_OEM.pVe^.ToolInSpindle;
// Tote M-Befehle quittieren
IF CNCSystem.Channel[0].M[45].bState_rw THEN
CNCSystem.Channel[0].M[45].bState_rw := FALSE;
END_IF
IF CNCSystem.Channel[0].M[21].bState_rw THEN
CNCSystem.Channel[0].M[21].bState_rw := FALSE;
END_IF
IF CNCSystem.Channel[0].M[22].bState_rw THEN
CNCSystem.Channel[0].M[22].bState_rw := FALSE;
END_IF
IF CNCSystem.Channel[0].M[71].bState_rw THEN
CNCSystem.Channel[0].M[71].bState_rw := FALSE;
END_IF
IF CNCSystem.Channel[0].M[72].bState_rw THEN
CNCSystem.Channel[0].M[72].bState_rw := FALSE;
END_IF
(* OEM program end *)
END_IF
(* Reset the reset flag from HMI *)
PLCReset := FALSE;]]></ST>
</Implementation>
<LineIds Name="MAIN">
<LineId Id="6" Count="0" />
<LineId Id="24" Count="0" />
<LineId Id="47" Count="0" />
<LineId Id="18" Count="0" />
<LineId Id="7" Count="1" />
<LineId Id="639" Count="1" />
<LineId Id="642" Count="0" />
<LineId Id="645" Count="0" />
<LineId Id="830" Count="0" />
<LineId Id="648" Count="2" />
<LineId Id="641" Count="0" />
<LineId Id="647" Count="0" />
<LineId Id="9" Count="2" />
<LineId Id="13" Count="0" />
<LineId Id="42" Count="0" />
<LineId Id="62" Count="0" />
<LineId Id="232" Count="0" />
<LineId Id="360" Count="0" />
<LineId Id="363" Count="0" />
<LineId Id="361" Count="0" />
<LineId Id="364" Count="7" />
<LineId Id="385" Count="0" />
<LineId Id="384" Count="0" />
<LineId Id="372" Count="1" />
<LineId Id="375" Count="2" />
<LineId Id="379" Count="0" />
<LineId Id="381" Count="0" />
<LineId Id="380" Count="0" />
<LineId Id="378" Count="0" />
<LineId Id="386" Count="0" />
<LineId Id="388" Count="1" />
<LineId Id="374" Count="0" />
<LineId Id="362" Count="0" />
<LineId Id="57" Count="0" />
<LineId Id="261" Count="0" />
<LineId Id="150" Count="1" />
<LineId Id="170" Count="0" />
<LineId Id="152" Count="1" />
<LineId Id="249" Count="0" />
<LineId Id="529" Count="0" />
<LineId Id="154" Count="3" />
<LineId Id="263" Count="0" />
<LineId Id="262" Count="0" />
<LineId Id="115" Count="0" />
<LineId Id="105" Count="0" />
<LineId Id="113" Count="0" />
<LineId Id="688" Count="0" />
<LineId Id="443" Count="0" />
<LineId Id="107" Count="4" />
<LineId Id="119" Count="4" />
<LineId Id="184" Count="3" />
<LineId Id="420" Count="0" />
<LineId Id="189" Count="0" />
<LineId Id="314" Count="1" />
<LineId Id="304" Count="1" />
<LineId Id="307" Count="0" />
<LineId Id="306" Count="0" />
<LineId Id="311" Count="2" />
<LineId Id="310" Count="0" />
<LineId Id="316" Count="1" />
<LineId Id="319" Count="2" />
<LineId Id="318" Count="0" />
<LineId Id="466" Count="4" />
<LineId Id="308" Count="1" />
<LineId Id="286" Count="0" />
<LineId Id="337" Count="2" />
<LineId Id="418" Count="1" />
<LineId Id="796" Count="0" />
<LineId Id="569" Count="1" />
<LineId Id="572" Count="0" />
<LineId Id="574" Count="0" />
<LineId Id="417" Count="0" />
<LineId Id="568" Count="0" />
<LineId Id="721" Count="1" />
<LineId Id="756" Count="0" />
<LineId Id="795" Count="0" />
<LineId Id="757" Count="0" />
<LineId Id="793" Count="0" />
<LineId Id="791" Count="0" />
<LineId Id="755" Count="0" />
<LineId Id="1068" Count="0" />
<LineId Id="794" Count="0" />
<LineId Id="494" Count="0" />
<LineId Id="498" Count="0" />
<LineId Id="495" Count="2" />
<LineId Id="599" Count="3" />
<LineId Id="1104" Count="0" />
<LineId Id="609" Count="2" />
<LineId Id="831" Count="1" />
<LineId Id="939" Count="2" />
<LineId Id="943" Count="0" />
<LineId Id="978" Count="0" />
<LineId Id="1013" Count="0" />
<LineId Id="1103" Count="0" />
<LineId Id="1014" Count="0" />
<LineId Id="112" Count="0" />
<LineId Id="78" Count="0" />
<LineId Id="83" Count="0" />
<LineId Id="247" Count="1" />
<LineId Id="233" Count="0" />
<LineId Id="541" Count="2" />
<LineId Id="539" Count="0" />
<LineId Id="655" Count="0" />
<LineId Id="652" Count="0" />
<LineId Id="656" Count="0" />
<LineId Id="654" Count="0" />
<LineId Id="653" Count="0" />
<LineId Id="651" Count="0" />
<LineId Id="866" Count="0" />
<LineId Id="1049" Count="0" />
<LineId Id="1055" Count="0" />
<LineId Id="1050" Count="0" />
<LineId Id="1056" Count="2" />
<LineId Id="1054" Count="0" />
<LineId Id="1060" Count="1" />
<LineId Id="1059" Count="0" />
<LineId Id="1063" Count="1" />
<LineId Id="1062" Count="0" />
<LineId Id="1066" Count="1" />
<LineId Id="1065" Count="0" />
<LineId Id="540" Count="0" />
<LineId Id="234" Count="0" />
<LineId Id="2" Count="0" />
<LineId Id="95" Count="0" />
<LineId Id="22" Count="0" />
<LineId Id="19" Count="0" />
</LineIds>
</POU>
</TcPlcObject>