Add pressure scaling method and variables to Cabinet_Configuration program

Add getting the scaled values of the cabinet pressure groups as part of the
Cabinet_Configuration program. To later link those values for the alarms in
PILS

modified:   solution/_Config/PLC/tc_project_app.xti
modified:   solution/tc_project_app/POUs/Application_Specific/Applications/Cabinet_Configuration.TcPOU
modified:   solution/tc_project_app/POUs/MAIN.TcPOU
This commit is contained in:
Federico Rojas
2025-04-02 12:16:59 +02:00
parent 6f3184712f
commit b21d984ce0
3 changed files with 47 additions and 11 deletions

View File

@@ -1,9 +1,22 @@
<?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.56" ClassName="CNestedPlcProjDef">
<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">
<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="{83792354-8B16-F471-93AE-C957C3918E0A}">
<Instance Id="#x08502040" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="tc_project_app\tc_project_app.tmc" TmcHash="{6DABFE35-762D-6BDB-AC11-EBB8BC5AE2B1}">
<Name>tc_project_app Instance</Name>
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
<Vars VarGrpType="1">
<Name>PlcTask Inputs</Name>
<Var>
<Name>GVL.nAirPressureSensorGroup1</Name>
<Comment><![CDATA[Raw value from analog air pressure sensor for pneumatic axes group 1]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>GVL.nAirPressureSensorGroup2</Name>
<Comment><![CDATA[Raw value from analog air pressure sensor for pneumatic axes group 2]]></Comment>
<Type>INT</Type>
</Var>
</Vars>
<Contexts>
<Context>
<Id>0</Id>

View File

@@ -4,10 +4,13 @@
<Declaration><![CDATA[PROGRAM Cabinet_Configuration
VAR
//fbCabinetMonitoring: FB_ESSMonitoringMCU5001a; FB_ESSMonitoringMCU5001b; FB_ESSMonitoringMCU6001a; FB_ESSMonitoringMCU6001b; FB_ESSMonitoringMCU5002; FB_ESSMonitoringMCU5003;
fScaledAirPressureGroup1: REAL;
fScaledAirPressureGroup2: REAL;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[(*fbCabinetMonitoring(
<ST><![CDATA[//Cabinet monitoring
(*fbCabinetMonitoring(
nEcMasterNetId:= ,
aErrorID=> ,
aErrorMsg=> ,
@@ -17,14 +20,34 @@ END_VAR
nAlarmGrpBitNumber=> );
*)
//Define pressure limits for pneumatic pressure group 1
GVL.fHighLimitAirPressureGroup1 := 0.0;
GVL.fLowLimitAirPressureGroup1 := 0.0;
//Define pressure limits for pneumatic pressure group 2
GVL.fHighLimitAirPressureGroup2 := 0.0;
GVL.fLowLimitAirPressureGroup2 := 0.0;
//Scale pressure sensor group 1 and 2
fScaledAirPressureGroup1 := mScaledPressureValue(nRawValue:=GVL.nAirPressureSensorGroup1);
fScaledAirPressureGroup2 := mScaledPressureValue(nRawValue:=GVL.nAirPressureSensorGroup2);
]]></ST>
</Implementation>
<Method Name="mScaledPressureValue" Id="{3a9ac7a5-453e-098d-2143-f7d60168bb86}">
<Declaration><![CDATA[METHOD PUBLIC mScaledPressureValue : REAL
VAR_INPUT
nRawValue: INT; //Raw value from the Terminal
END_VAR
VAR
rGradient: REAL; //Internal variable to calculate gradient of the slope
rOffset: REAL; //Internal variable to calculate the offset value
fRawHigh: REAL := 30518.0; //Highest value for the Raw value
fRawLow: REAL := 0.0; //Lowest value for the Raw value
fScaledHigh: REAL := 10.0; //Highest value for the Scaled value 10 bar
fScaledLow: REAL := 0.0; //Lowest value for the Scaled value 0 bar
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[rGradient:= (fScaledHigh - fScaledLow)/(fRawHigh - fRawLow);
rOffset:= fScaledHigh - rGradient * fRawHigh;
mScaledPressureValue:= rGradient * nRawValue + rOffset;
]]></ST>
</Implementation>
</Method>
</POU>
</TcPlcObject>

View File

@@ -120,7 +120,6 @@ END_IF
<Implementation>
<ST><![CDATA[//Get task index for Axes parameters initialization.
GVL.fbGetCurTaskIndex();
Cabinet_Configuration();
//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
@@ -130,6 +129,7 @@ Axis_Template();
//Pneumatics_Template();
//Application program calls
Cabinet_Configuration();
Application_Template();
]]></ST>
</Implementation>