Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion solution/_Config/PLC/tc_project_app.xti
Original file line number Diff line number Diff line change
@@ -1,11 +1,59 @@
<?xml version="1.0"?>
<TcSmItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4024.62" ClassName="CNestedPlcProjDef">
<DataTypes>
<DataType>
<Name GUID="{18071995-0000-0000-0000-000000000041}" TcBaseType="true" HideSubItems="true" CName="AmsNetId">AMSNETID</Name>
<BitSize>48</BitSize>
<BaseType GUID="{18071995-0000-0000-0000-000000000001}">BYTE</BaseType>
<ArrayInfo>
<LBound>0</LBound>
<Elements>6</Elements>
</ArrayInfo>
<Format>
<Printf>%d.%d.%d.%d.%d.%d</Printf>
<Parameter>[0]</Parameter>
<Parameter>[1]</Parameter>
<Parameter>[2]</Parameter>
<Parameter>[3]</Parameter>
<Parameter>[4]</Parameter>
<Parameter>[5]</Parameter>
</Format>
</DataType>
</DataTypes>
<DataTypes>
<DataType>
<Name GUID="{18071995-0000-0000-0000-000000000041}" TcBaseType="true" HideSubItems="true" CName="AmsNetId">AMSNETID</Name>
<BitSize>48</BitSize>
<BaseType GUID="{18071995-0000-0000-0000-000000000001}">BYTE</BaseType>
<ArrayInfo>
<LBound>0</LBound>
<Elements>6</Elements>
</ArrayInfo>
<Format>
<Printf>%d.%d.%d.%d.%d.%d</Printf>
<Parameter>[0]</Parameter>
<Parameter>[1]</Parameter>
<Parameter>[2]</Parameter>
<Parameter>[3]</Parameter>
<Parameter>[4]</Parameter>
<Parameter>[5]</Parameter>
</Format>
</DataType>
</DataTypes>
<Project GUID="{FB261665-FD20-4BF2-97F8-2854C82B752D}" Name="tc_project_app" PrjFilePath="..\..\tc_project_app\tc_project_app.plcproj" TmcFilePath="..\..\tc_project_app\tc_project_app.tmc" ReloadTmc="true" AmsPort="852" FileArchiveSettings="#x000e" ClearInvalidPersist="true" SymbolicMapping="true">
<Instance Id="#x08502040" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="tc_project_app\tc_project_app.tmc" TmcHash="{C38143B7-B57C-03FF-2ED1-1847F1DEC6E1}">
<Instance Id="#x08502040" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="tc_project_app\tc_project_app.tmc" TmcHash="{65D4D45D-061D-4666-58A6-8CF5541F61E3}">
<Name>tc_project_app Instance</Name>
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
<Vars VarGrpType="1">
<Name>PlcTask Inputs</Name>
<Var>
<Name>MAIN.aEtherCATMasterNetId</Name>
<Type GUID="{18071995-0000-0000-0000-000000000041}">AMSNETID</Type>
</Var>
<Var>
<Name>MAIN.aEtherCATMasterNetId</Name>
<Type GUID="{18071995-0000-0000-0000-000000000041}">AMSNETID</Type>
</Var>
<Var>
<Name>Safety_Shutter.bPSSPermit1</Name>
<Comment><![CDATA[{attribute 'TcLinkTo' := 'TIID^Device 1 (EtherCAT)^KF201 (EK1200)^KF208 (EL1808)^Channel 5^Input'}]]></Comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
<TcPlcObject Version="1.1.0.1">
<POU Name="Cabinet_Monitoring" Id="{f09ddf2c-38c8-0b17-348a-c2e3aa836c88}" SpecialFunc="None">
<Declaration><![CDATA[PROGRAM Cabinet_Monitoring
VAR_INPUT
sEtherCATMasterNetId: T_AmsNetID;
END_VAR
VAR
//fbCabinetMonitoring: FB_ESSMonitoringMCU5001a; FB_ESSMonitoringMCU5001b; FB_ESSMonitoringMCU6001a; FB_ESSMonitoringMCU6001b; FB_ESSMonitoringMCU5002; FB_ESSMonitoringMCU5003;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[//Cabinet monitoring
(*fbCabinetMonitoring(
nEcMasterNetId:= , //AMS NetId of Device (EtherCAT) from I/Os
aErrorID=> ,
aErrorMsg=> ,
nEcMasterFramesLost=> ,
nCPULoad=> ,
fCycleExecTime_ms=> ,
nAlarmGrpBitNumber=> );
nEcMasterNetId := sEtherCATMasterNetId, //AMS NetId of Device (EtherCAT) from I/Os
aErrorID => ,
aErrorMsg => ,
nEcMasterFramesLost => ,
nCPULoad => ,
fCycleExecTime_ms => ,
nAlarmGrpBitNumber => );
*)
]]></ST>
</Implementation>
Expand Down
66 changes: 45 additions & 21 deletions solution/tc_project_app/POUs/MAIN.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ VAR
bRestoreExecute: BOOL := FALSE;
nReadEncRefSysRetry: UINT := 0; //Counts number of retries to read encoder reference system
nCheckRestoreRetry: UINT := 0; //Counts number of retries to restore axis position or position bias
iAxes: UINT; //Index for, for-loops in position recovery actions
iCnt: UINT; //Index for various for-loops
iCurrentAxis: UINT := 1; //Index for position recovery actions (not in for loops)

afbReadPositionBias: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_ReadParameter;
Expand All @@ -32,6 +32,11 @@ VAR

fbGetDeviceIdentification: FB_GetDeviceIdentificationEx;
dtAtStartup: DT;

{attribute 'TcLinkTo' := 'TIID^KF200-EC1 (EtherCAT Device)^InfoData^AmsNetId'}
aEtherCATMasterNetId AT%I*: AMSNETID;
sEtherCATMasterNetId: T_AmsNetId;

nTestNum: UINT := 0; //Variable used in ESS's FAT_SAT_tools scripts to keep track of the test number

//Read position at a specific time interval
Expand All @@ -46,7 +51,8 @@ END_VAR

]]></Declaration>
<Implementation>
<ST><![CDATA[POSITION_RECOVERY();
<ST><![CDATA[INIT();
POSITION_RECOVERY();
PROG();
AXES();

Expand Down Expand Up @@ -98,9 +104,9 @@ END_FOR
fbC6017UPS(eUPSMode := eSelUpsMode);
END_CASE

FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
IF astAxes[iAxes].stStatus.bAxisInitialized THEN
afbReadPositionBias[iAxes](Axis := GVL.astAxes[iAxes].Axis,
FOR iCnt := 1 TO GVL_APP.nAXIS_NUM DO
IF astAxes[iCnt].stStatus.bAxisInitialized THEN
afbReadPositionBias[iCnt](Axis := GVL.astAxes[iCnt].Axis,
Enable := TRUE,
ReadMode:= READMODE_CYCLIC,
ParameterNumber := E_AxisParameters.AxisEncoderOffset);
Expand All @@ -117,6 +123,27 @@ ELSIF eGlobalSUpsState <> eSUPS_PowerOK THEN
//Next cycles of powerfailure
//Skip regular code execution for the remaining cycles of the powerfailure/writing of persistent data/quick shutdown...
END_IF
]]></ST>
</Implementation>
</Action>
<Action Name="INIT" Id="{211fcb7f-ce8f-0752-27ee-b9ea8bd7e7c5}">
<Implementation>
<ST><![CDATA[//Get task index for initialization.
GVL.fbGetCurTaskIndex();

IF _TaskInfo[fbGetCurTaskIndex.index].FirstCycle THEN
FOR iCnt := 0 TO (SIZEOF(AMSNETID) - 1) DO
IF aEtherCATMasterNetId[iCnt] = 0 THEN
ADSLOGSTR(ADSLOG_MSGTYPE_ERROR,'Invalid Device 2 AmsNetID','');
EXIT;
END_IF

sEtherCATMasterNetId := CONCAT(sEtherCATMasterNetId, TO_STRING(aEtherCATMasterNetId[iCnt]));
IF iCnt < (SIZEOF(AMSNETID) - 1) THEN
sEtherCATMasterNetId := CONCAT(sEtherCATMasterNetId, '.');
END_IF
END_FOR
END_IF
]]></ST>
</Implementation>
</Action>
Expand All @@ -125,8 +152,8 @@ END_IF
<ST><![CDATA[fbReadPositionTimer(IN := bReadPosition, PT := tReadPosition);

IF fbReadPositionTimer.Q THEN
FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
afSavedPosition[iAxes] := GVL.astAxes[iAxes].Axis.NcToPlc.ActPos;
FOR iCnt := 1 TO GVL_APP.nAXIS_NUM DO
afSavedPosition[iCnt] := GVL.astAxes[iCnt].Axis.NcToPlc.ActPos;
END_FOR
bReadPosition := FALSE;
END_IF
Expand All @@ -147,10 +174,7 @@ END_IF
</Action>
<Action Name="PROG" Id="{5d03ebbb-2a47-4890-ad6d-e82daf72dc51}">
<Implementation>
<ST><![CDATA[//Get task index for Axes parameters initialization.
GVL.fbGetCurTaskIndex();

//Call the programs that are defined in the "Application Specific" folder.
<ST><![CDATA[//Call the programs that are defined in the "Application Specific" folder.
//Create as many programs in that folder as axes and applications you have or need

//Cabinet monitoring and pressure limits for pneumatics
Expand All @@ -162,7 +186,7 @@ Safety_Shutter();
//Pneumatics_Template();

//Application program calls
Cabinet_Monitoring();
Cabinet_Monitoring(sEtherCATMasterNetId:= sEtherCATMasterNetId);
Pneumatic_Box();
//Shutter_Operator_Panel();
//Slit_Template();
Expand Down Expand Up @@ -357,24 +381,24 @@ END_IF
</Action>
<Action Name="STORE_PERSISTENT" Id="{cb5c9254-2e5f-47b1-9baa-10e728a961b0}" FolderPath="POSITION_RECOVERY\">
<Implementation>
<ST><![CDATA[FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
<ST><![CDATA[FOR iCnt := 1 TO GVL_APP.nAXIS_NUM DO
//Store actual position at shutdown
astAxesPersistent[iAxes].fPositionAtShutdown := GVL.astAxes[iAxes].Axis.NcToPlc.ActPos;
astAxesPersistent[iCnt].fPositionAtShutdown := GVL.astAxes[iCnt].Axis.NcToPlc.ActPos;

//Store encoder position BIAS at shutdown
astAxesPersistent[iAxes].fEncoderBiasAtShutdown := afbReadPositionBias[iAxes].Value;
astAxesPersistent[iCnt].fEncoderBiasAtShutdown := afbReadPositionBias[iCnt].Value;


//Store axis status at shutdown
astAxesPersistent[iAxes].bInitializedAtShutdown := GVL.astAxes[iAxes].stStatus.bAxisInitialized;
astAxesPersistent[iAxes].bHomedAtShutdown := GVL.astAxes[iAxes].stStatus.bHomed;
astAxesPersistent[iAxes].fPositionDifferenceAtShutdown := ABS(afSavedPosition[iAxes] - astAxesPersistent[iAxes].fPositionAtShutdown);
astAxesPersistent[iCnt].bInitializedAtShutdown := GVL.astAxes[iCnt].stStatus.bAxisInitialized;
astAxesPersistent[iCnt].bHomedAtShutdown := GVL.astAxes[iCnt].stStatus.bHomed;
astAxesPersistent[iCnt].fPositionDifferenceAtShutdown := ABS(afSavedPosition[iCnt] - astAxesPersistent[iCnt].fPositionAtShutdown);

//Store value of moving at shutdown
IF astAxes[iAxes].Axis.Status.Disabled OR astAxesPersistent[iAxes].fPositionDifferenceAtShutdown < fPositionDifferenceLimit THEN
astAxesPersistent[iAxes].bMovingAtShutdown := FALSE;
IF astAxes[iCnt].Axis.Status.Disabled OR astAxesPersistent[iCnt].fPositionDifferenceAtShutdown < fPositionDifferenceLimit THEN
astAxesPersistent[iCnt].bMovingAtShutdown := FALSE;
ELSE
astAxesPersistent[iAxes].bMovingAtShutdown := TRUE;
astAxesPersistent[iCnt].bMovingAtShutdown := TRUE;
END_IF
END_FOR

Expand Down
Loading