Fix white-space danage
This commit is contained in:
@@ -26,47 +26,47 @@ VAR
|
||||
//bOutput28 AT %Q*: BOOL:= TRUE;
|
||||
|
||||
(******Error Handling********)
|
||||
fbErrorSystem: FB_ErrorSystem;
|
||||
aFbAxesError: ARRAY [1..gvl_app.axisNum] OF FB_NC_Error;
|
||||
|
||||
//fbEL1018 : EL1018;
|
||||
//fbEL2808 : EL2808;
|
||||
//fbEL5101 : EL5101;
|
||||
//fbEL9505 : EL9505;
|
||||
//fbEL1252 : EL1252;
|
||||
//fbEL9410 : EL9410;
|
||||
//fbEL7037 : EL7037;
|
||||
//fbEK1110 : EK1110;
|
||||
|
||||
fbErrorSystem: FB_ErrorSystem;
|
||||
aFbAxesError: ARRAY [1..gvl_app.axisNum] OF FB_NC_Error;
|
||||
|
||||
//fbEL1018 : EL1018;
|
||||
//fbEL2808 : EL2808;
|
||||
//fbEL5101 : EL5101;
|
||||
//fbEL9505 : EL9505;
|
||||
//fbEL1252 : EL1252;
|
||||
//fbEL9410 : EL9410;
|
||||
//fbEL7037 : EL7037;
|
||||
//fbEK1110 : EK1110;
|
||||
|
||||
(******Startup, Shutdown and UPS********)
|
||||
iStartup : UINT := 0;
|
||||
bColdstartDone : BOOL := FALSE;
|
||||
bExecuteReadEncRefSys : BOOL := TRUE;
|
||||
tmrRetry : TON;
|
||||
iRetry : INT;
|
||||
fbReadEncRefSys : ARRAY [1..gvl_app.axisNum] OF MC_ReadParameter;
|
||||
fbUPS : FB_S_UPS_CX51x0;
|
||||
eUpsMode : E_S_UPS_Mode := eSUPS_WrPersistData_Shutdown;
|
||||
fbRestorePosition : ARRAY [1..GVL_app.axisNum] OF MC_SetPosition;
|
||||
iStartup : UINT := 0;
|
||||
bColdstartDone : BOOL := FALSE;
|
||||
bExecuteReadEncRefSys : BOOL := TRUE;
|
||||
tmrRetry : TON;
|
||||
iRetry : INT;
|
||||
fbReadEncRefSys : ARRAY [1..gvl_app.axisNum] OF MC_ReadParameter;
|
||||
fbUPS : FB_S_UPS_CX51x0;
|
||||
eUpsMode : E_S_UPS_Mode := eSUPS_WrPersistData_Shutdown;
|
||||
fbRestorePosition : ARRAY [1..GVL_app.axisNum] OF MC_SetPosition;
|
||||
|
||||
|
||||
END_VAR
|
||||
VAR PERSISTENT
|
||||
iPositionAtShutdown : ARRAY [1..gvl_app.axisNum] OF LREAL;
|
||||
bMovingAtShutdown : ARRAY [1..gvl_app.axisNum] OF BOOL;
|
||||
iPositionAtShutdown : ARRAY [1..gvl_app.axisNum] OF LREAL;
|
||||
bMovingAtShutdown : ARRAY [1..gvl_app.axisNum] OF BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[fbUPS(eUpsMode := eUpsMode); (* call UPS-FB instance in first lines of the fastest PLC Task *)
|
||||
|
||||
IF eGlobalSUpsState = eSUPS_PowerFailure THEN
|
||||
(* first cycle of powerfailure *)
|
||||
(* execute code that should only be done once with each powerfailure, i.e. increase powerfailure counter *)
|
||||
SHUTDOWN();
|
||||
(* first cycle of powerfailure *)
|
||||
(* execute code that should only be done once with each powerfailure, i.e. increase powerfailure counter *)
|
||||
SHUTDOWN();
|
||||
ELSIF eGlobalSUpsState > eSUPS_PowerFailure THEN
|
||||
(* next cycles of powerfailure *)
|
||||
(* skip regular code execution for the remaining cycles of the powerfailure/writing of persistent data/quick shutdown ... *)
|
||||
RETURN;
|
||||
(* next cycles of powerfailure *)
|
||||
(* skip regular code execution for the remaining cycles of the powerfailure/writing of persistent data/quick shutdown ... *)
|
||||
RETURN;
|
||||
END_IF
|
||||
|
||||
STARTUP();
|
||||
@@ -135,99 +135,99 @@ fbEL1808(
|
||||
<Action Name="SHUTDOWN" Id="{cb5c9254-2e5f-47b1-9baa-10e728a961b0}">
|
||||
<Implementation>
|
||||
<ST><![CDATA[FOR i:=1 TO gvl_app.axisNum DO
|
||||
iPositionAtShutdown[i]:=gvl.axes[i].Axis.NcToPlc.ActPos;
|
||||
bMovingAtShutdown[i]:=gvl.axes[i].Axis.Status.Moving;
|
||||
iPositionAtShutdown[i]:=gvl.axes[i].Axis.NcToPlc.ActPos;
|
||||
bMovingAtShutdown[i]:=gvl.axes[i].Axis.Status.Moving;
|
||||
END_FOR]]></ST>
|
||||
</Implementation>
|
||||
</Action>
|
||||
<Action Name="STARTUP" Id="{0c7ee537-7bd9-4833-b428-c17cbb57e893}">
|
||||
<Implementation>
|
||||
<ST><;
|
||||
<ST><;
|
||||
END_FOR
|
||||
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
fbRestorePosition[i](
|
||||
Axis:= gvl.axes[i].Axis,
|
||||
Execute:= ,
|
||||
Position:= iPositionAtShutdown[i]);
|
||||
fbRestorePosition[i](
|
||||
Axis:= gvl.axes[i].Axis,
|
||||
Execute:= ,
|
||||
Position:= iPositionAtShutdown[i]);
|
||||
END_FOR
|
||||
|
||||
IF bColdstartDone = FALSE THEN
|
||||
CASE iStartup OF
|
||||
0: // First cycle
|
||||
IF NOT bColdstartDone THEN
|
||||
iStartup:=iStartup+1;
|
||||
iretry:=0;
|
||||
END_IF
|
||||
1: // Read Enc Ref Sys - incremental or absolute
|
||||
bExecuteReadEncRefSys:=TRUE;
|
||||
iStartup:=iStartup+1;
|
||||
tmrRetry(in:=FALSE);
|
||||
2: // Check if Enc Ref Sys has been read for all axis -> if not read again
|
||||
tmrRetry(in:=TRUE, pt:=T#100MS);
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
IF fbReadEncRefSys[i].Valid = FALSE THEN
|
||||
IF tmrretry.Q THEN
|
||||
bExecuteReadEncRefSys:=FALSE;
|
||||
iStartup:=iStartup-1;
|
||||
iRetry:=iRetry+1;
|
||||
END_IF
|
||||
RETURN;
|
||||
ELSE
|
||||
iStartup:=iStartup+1;
|
||||
EXIT;
|
||||
END_IF
|
||||
END_FOR
|
||||
3: // Check if axis is incremental, opt-in/restore home and not moving at shutdown -> if so restore
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
IF fbReadEncRefSys[i].Value=0 AND NOT(bMovingAtShutdown[i]) THEN
|
||||
IF gvl.axes[i].config.iRestorePosition=2 THEN
|
||||
gvl.axes[i].config.nHomeSeq:=15;
|
||||
gvl.axes[i].control.eCommand:=10;
|
||||
//Doesn't work yet because you can only home to zero position
|
||||
//gvl.axes[i].config.######:=iPositionAtShutdown[i];
|
||||
END_IF
|
||||
END_IF
|
||||
END_FOR
|
||||
iStartup:=iStartup+1;
|
||||
4: // Execute position restore with or without bHome set
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
IF fbReadEncRefSys[i].Value = 0 THEN
|
||||
CASE GVL.axes[i].config.iRestorePosition OF
|
||||
1: fbRestorePosition[i].Execute:=TRUE;
|
||||
2: gvl.axes[i].control.bExecute:=TRUE;
|
||||
END_CASE
|
||||
END_IF
|
||||
END_FOR
|
||||
iStartup:=iStartup+1;
|
||||
5: // Check set position or direct homing is finished on axes that were opt-in
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
IF fbReadEncRefSys[i].Value = 0 THEN
|
||||
CASE gvl.axes[i].config.iRestorePosition OF
|
||||
1:
|
||||
IF NOT fbRestorePosition[i].Done THEN
|
||||
RETURN;
|
||||
END_IF
|
||||
2:
|
||||
IF NOT gvl.axes[i].status.bHomed THEN
|
||||
RETURN;
|
||||
END_IF
|
||||
END_CASE
|
||||
END_IF
|
||||
END_FOR
|
||||
iStartup:=iStartup+1;
|
||||
6: // Reset set position FBs and Finish
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
fbRestorePosition[i].Execute:=FALSE;
|
||||
END_FOR
|
||||
bColdstartDone:=TRUE;
|
||||
END_CASE
|
||||
CASE iStartup OF
|
||||
0: // First cycle
|
||||
IF NOT bColdstartDone THEN
|
||||
iStartup:=iStartup+1;
|
||||
iretry:=0;
|
||||
END_IF
|
||||
1: // Read Enc Ref Sys - incremental or absolute
|
||||
bExecuteReadEncRefSys:=TRUE;
|
||||
iStartup:=iStartup+1;
|
||||
tmrRetry(in:=FALSE);
|
||||
2: // Check if Enc Ref Sys has been read for all axis -> if not read again
|
||||
tmrRetry(in:=TRUE, pt:=T#100MS);
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
IF fbReadEncRefSys[i].Valid = FALSE THEN
|
||||
IF tmrretry.Q THEN
|
||||
bExecuteReadEncRefSys:=FALSE;
|
||||
iStartup:=iStartup-1;
|
||||
iRetry:=iRetry+1;
|
||||
END_IF
|
||||
RETURN;
|
||||
ELSE
|
||||
iStartup:=iStartup+1;
|
||||
EXIT;
|
||||
END_IF
|
||||
END_FOR
|
||||
3: // Check if axis is incremental, opt-in/restore home and not moving at shutdown -> if so restore
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
IF fbReadEncRefSys[i].Value=0 AND NOT(bMovingAtShutdown[i]) THEN
|
||||
IF gvl.axes[i].config.iRestorePosition=2 THEN
|
||||
gvl.axes[i].config.nHomeSeq:=15;
|
||||
gvl.axes[i].control.eCommand:=10;
|
||||
//Doesn't work yet because you can only home to zero position
|
||||
//gvl.axes[i].config.######:=iPositionAtShutdown[i];
|
||||
END_IF
|
||||
END_IF
|
||||
END_FOR
|
||||
iStartup:=iStartup+1;
|
||||
4: // Execute position restore with or without bHome set
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
IF fbReadEncRefSys[i].Value = 0 THEN
|
||||
CASE GVL.axes[i].config.iRestorePosition OF
|
||||
1: fbRestorePosition[i].Execute:=TRUE;
|
||||
2: gvl.axes[i].control.bExecute:=TRUE;
|
||||
END_CASE
|
||||
END_IF
|
||||
END_FOR
|
||||
iStartup:=iStartup+1;
|
||||
5: // Check set position or direct homing is finished on axes that were opt-in
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
IF fbReadEncRefSys[i].Value = 0 THEN
|
||||
CASE gvl.axes[i].config.iRestorePosition OF
|
||||
1:
|
||||
IF NOT fbRestorePosition[i].Done THEN
|
||||
RETURN;
|
||||
END_IF
|
||||
2:
|
||||
IF NOT gvl.axes[i].status.bHomed THEN
|
||||
RETURN;
|
||||
END_IF
|
||||
END_CASE
|
||||
END_IF
|
||||
END_FOR
|
||||
iStartup:=iStartup+1;
|
||||
6: // Reset set position FBs and Finish
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
fbRestorePosition[i].Execute:=FALSE;
|
||||
END_FOR
|
||||
bColdstartDone:=TRUE;
|
||||
END_CASE
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Action>
|
||||
|
||||
Reference in New Issue
Block a user