Added safety program pre comissioning and started implementing different modes
This commit is contained in:
17
PLC/DUTs/E_BMS_CONTROL_MODE.TcDUT
Normal file
17
PLC/DUTs/E_BMS_CONTROL_MODE.TcDUT
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
|
||||
<DUT Name="E_BMS_CONTROL_MODE" Id="{ab000a04-c252-420d-ac1e-2bf611fa911a}">
|
||||
<Declaration><![CDATA[{attribute 'qualified_only'}
|
||||
{attribute 'strict'}
|
||||
TYPE E_BMS_CONTROL_MODE :
|
||||
(
|
||||
AUTO_REMOTE := 1,
|
||||
AUTO_LOCAL := 2,
|
||||
SAFETY_CHECK := 3,
|
||||
CAPACITY_TEST := 4,
|
||||
MANUAL := 5
|
||||
);
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
18
PLC/DUTs/E_COMPONENT_STATUS.TcDUT
Normal file
18
PLC/DUTs/E_COMPONENT_STATUS.TcDUT
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
|
||||
<DUT Name="E_COMPONENT_STATUS" Id="{cff71c34-33b2-4724-933e-1a2c018acdb7}">
|
||||
<Declaration><![CDATA[{attribute 'qualified_only'}
|
||||
{attribute 'strict'}
|
||||
{attribute 'to_string'}
|
||||
TYPE E_COMPONENT_STATUS :
|
||||
(
|
||||
OFF := 0,
|
||||
ON := 1,
|
||||
CHARGING := 2,
|
||||
DISCHARGING := 3,
|
||||
ERROR := 4
|
||||
);
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
13
PLC/DUTs/ST_AUTO_HMI_INTERFACE.TcDUT
Normal file
13
PLC/DUTs/ST_AUTO_HMI_INTERFACE.TcDUT
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
|
||||
<DUT Name="ST_AUTO_HMI_INTERFACE" Id="{2b90c47c-9132-4aec-a172-6289a0ff4dc3}">
|
||||
<Declaration><![CDATA[TYPE ST_AUTO_HMI_INTERFACE :
|
||||
STRUCT
|
||||
stStartAutoButton : ST_HMI_CONTROL_BUTTON := (xRelease := TRUE);
|
||||
stStopAutoButton : ST_HMI_CONTROL_BUTTON := (xRelease := TRUE);
|
||||
diSetpointAutomatic : DINT;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
@@ -7,6 +7,14 @@ STRUCT
|
||||
stHMIInterfaceUnit2 : ST_UNIT_HMI_INTERFACE;
|
||||
stHMIInterfaceUnit3 : ST_UNIT_HMI_INTERFACE;
|
||||
stHMIInterfaceUnit4 : ST_UNIT_HMI_INTERFACE;
|
||||
|
||||
// Current voltage for HMI
|
||||
// ==============================
|
||||
rVoltage : REAL;
|
||||
|
||||
// Current status
|
||||
// ====================================
|
||||
eStatus : E_COMPONENT_STATUS;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
|
||||
@@ -6,6 +6,14 @@ STRUCT
|
||||
stHMIInterfaceModule1 : ST_MODULE_HMI_INTERFACE;
|
||||
stHMIInterfaceModule2 : ST_MODULE_HMI_INTERFACE;
|
||||
stHMIInterfaceModule3 : ST_MODULE_HMI_INTERFACE;
|
||||
|
||||
// Current voltage for HMI
|
||||
// ==============================
|
||||
rVoltage : REAL;
|
||||
|
||||
// Current status
|
||||
// ====================================
|
||||
eStatus : E_COMPONENT_STATUS;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
|
||||
@@ -50,6 +50,15 @@ STRUCT
|
||||
stVoltageSegment : ST_HMI_ANALOG_VALUE;
|
||||
|
||||
|
||||
// Current voltage for HMI
|
||||
// ==============================
|
||||
rVoltage : REAL;
|
||||
|
||||
// Current status
|
||||
// ====================================
|
||||
eStatus : E_COMPONENT_STATUS;
|
||||
|
||||
|
||||
// Aknowledge all alarms button
|
||||
// ===================================
|
||||
stButtonAckAlarms : ST_HMI_CONTROL_BUTTON;
|
||||
|
||||
@@ -77,7 +77,7 @@ VAR_GLOBAL
|
||||
),
|
||||
|
||||
// Pressure posolyt tank inlet
|
||||
stConfigPosolytPressureTankInlet := (iAIMax := 32767, iAIMin := 0, rPVMax := 1500, rPVMin := -1000, sUnit := 'mbar'),
|
||||
stConfigPosolytPressureTankInlet := (iAIMax := 32767, iAIMin := 0, rPVMax := 2000, rPVMin := 0, sUnit := 'mbar'),
|
||||
stEWLPosolytPressureTankInlet := (rErrorMin := -100, rWarningMin := -50, rWarningMax := 100, rErrorMax := 120),
|
||||
stEWDPosolytPressureTankInlet :=
|
||||
(
|
||||
@@ -173,11 +173,15 @@ VAR_GLOBAL
|
||||
rPumpPosolytOnPower : REAL := 70.0;
|
||||
rPumpNegolytOnPower : REAL := 70.0;
|
||||
|
||||
// Pump discharge segment without inverter power (%)
|
||||
rPumpPosolytDisChrgPower : REAL := 35.0;
|
||||
rPumpNegolytDisChrgPower : REAL := 35.0;
|
||||
|
||||
// Unit voltage pumps shutoff threshold (Volt)
|
||||
rPumpshutoffThreshold : REAL := 15.0;
|
||||
|
||||
// Minimum unit voltage required for inverter startup (Volt)
|
||||
rMinimumUnitVoltage : REAL := 49.0;
|
||||
rMinimumUnitVoltage : REAL := 50.0;
|
||||
|
||||
// Delta value to minimum unit voltage for shutdown discharge (Volt)
|
||||
rDeltaUnitVoltageShutdownDischarge : REAL := 5.0;
|
||||
@@ -193,26 +197,31 @@ VAR_GLOBAL
|
||||
// Minimum absolute power command to enable battery (Watt)
|
||||
diMinimumAbsPowerForEnable : DINT := 100;
|
||||
|
||||
// Maximum allowed charging power (Watt)
|
||||
diMaxStringChargingPower : DINT := -30_000;
|
||||
// Maximum allowed charging power (Watt) per String
|
||||
// 60.000 W -> 5.000 W per Unit
|
||||
diMaxStringChargingPower : DINT := -60_000;
|
||||
|
||||
// Maximum allowed discharging power (Watt)
|
||||
diMaxStringDischargePower : DINT := 30_000;
|
||||
// Maximum allowed discharging power (Watt) per String
|
||||
// 60.000 W -> 5.000 W per Unit
|
||||
diMaxStringDischargePower : DINT := 60_000;
|
||||
|
||||
// Inverter ip address
|
||||
sInverterIp : STRING := '192.168.42.11';
|
||||
|
||||
// Absolute shutdown discharge power (Watt)
|
||||
rAbsShutdownDischargePower : REAL := 5_000;
|
||||
// 12.000 W -> 1.000 W per unit
|
||||
rAbsShutdownDischargePower : REAL := 12_000;
|
||||
|
||||
// Allow inverter fast shutdown discharge
|
||||
xShutdownDischargeWithInverter : BOOL := TRUE;
|
||||
xShutdownDischargeWithInverter : BOOL := FALSE;
|
||||
|
||||
// String fully charged voltage (Volt)
|
||||
rStringFullyChargedVoltage : REAL := 888.0;
|
||||
// 960 V -> 80 V per Unit
|
||||
rStringFullyChargedVoltage : REAL := 960.0;
|
||||
|
||||
// String empty voltage (Volt)
|
||||
rStringEmptyVoltage : REAL := 672.0;
|
||||
// String empty voltage (Volt) (585V is needed for the inverter to start up -> 50V per Segment)
|
||||
// 600 V -> 50 V per Unit
|
||||
rStringEmptyVoltage : REAL := 600.0;
|
||||
|
||||
// Unit wait startup time
|
||||
timUnitStartupTime : TIME := T#5S;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<Declaration><![CDATA[{attribute 'qualified_only'}
|
||||
VAR_GLOBAL
|
||||
// Mqtt brocker ip address
|
||||
sMQTTBrokerAddr : STRING := '127.0.0.1';
|
||||
sMQTTBrokerAddr : STRING := '10.103.32.10';
|
||||
|
||||
// Mqtt keep alive (s)
|
||||
uiMQTTKeepAlive : UINT := 60;
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
<GVL Name="GVL_SCADA" Id="{8186ff04-764f-4b24-8a6b-d0a44d528e6f}">
|
||||
<Declaration><![CDATA[{attribute 'qualified_only'}
|
||||
VAR_GLOBAL
|
||||
stHMIInterfaces : ARRAY [0..3] OF ST_UNIT_HMI_INTERFACE;
|
||||
stHMIInterface : ST_STRING_HMI_INTERFACE;
|
||||
|
||||
stAckAlarmsButton : ST_HMI_CONTROL_BUTTON := (xRelease := TRUE);
|
||||
|
||||
stAutomaticModeHMI : ST_AUTO_HMI_INTERFACE;
|
||||
END_VAR]]></Declaration>
|
||||
</GVL>
|
||||
</TcPlcObject>
|
||||
@@ -21,12 +21,18 @@
|
||||
<Compile Include="DUTs\E_BATTERY_STATUS.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DUTs\E_BMS_CONTROL_MODE.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DUTs\E_CHARGE_STATUS.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DUTs\E_REACTIVE_POWER_TYPE.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DUTs\E_COMPONENT_STATUS.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DUTs\Modbus\HoldingRegisters\ST_MODBUS_REG_10.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -39,6 +45,9 @@
|
||||
<Compile Include="DUTs\Modbus\ST_EMS_MODBUS_INTERFACE.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DUTs\ST_AUTO_HMI_INTERFACE.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DUTs\ST_MODULE_HMI_INTERFACE.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -114,21 +123,22 @@
|
||||
<DefaultResolution>Tc2_Standard, * (Beckhoff Automation GmbH)</DefaultResolution>
|
||||
<Namespace>Tc2_Standard</Namespace>
|
||||
</PlaceholderReference>
|
||||
<PlaceholderReference Include="Tc2_SUPS">
|
||||
<DefaultResolution>Tc2_SUPS, * (Beckhoff Automation GmbH)</DefaultResolution>
|
||||
<Namespace>Tc2_SUPS</Namespace>
|
||||
</PlaceholderReference>
|
||||
<PlaceholderReference Include="Tc2_System">
|
||||
<DefaultResolution>Tc2_System, * (Beckhoff Automation GmbH)</DefaultResolution>
|
||||
<Namespace>Tc2_System</Namespace>
|
||||
</PlaceholderReference>
|
||||
<PlaceholderReference Include="Tc2_Utilities">
|
||||
<DefaultResolution>Tc2_Utilities, * (Beckhoff Automation GmbH)</DefaultResolution>
|
||||
<Namespace>Tc2_Utilities</Namespace>
|
||||
</PlaceholderReference>
|
||||
<PlaceholderReference Include="Tc3_EventLogger">
|
||||
<DefaultResolution>Tc3_EventLogger, * (Beckhoff Automation GmbH)</DefaultResolution>
|
||||
<Namespace>Tc3_EventLogger</Namespace>
|
||||
</PlaceholderReference>
|
||||
<PlaceholderReference Include="Tc3_IotBase">
|
||||
<DefaultResolution>Tc3_IotBase, * (Beckhoff Automation GmbH)</DefaultResolution>
|
||||
<Namespace>Tc3_IotBase</Namespace>
|
||||
</PlaceholderReference>
|
||||
<PlaceholderReference Include="Tc3_Module">
|
||||
<DefaultResolution>Tc3_Module, * (Beckhoff Automation GmbH)</DefaultResolution>
|
||||
<Namespace>Tc3_Module</Namespace>
|
||||
@@ -139,6 +149,11 @@
|
||||
<SubType>Content</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PlaceholderResolution Include="BaseLib">
|
||||
<Resolution>BaseLib, * (cmblu)</Resolution>
|
||||
</PlaceholderResolution>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<PlcProjectOptions>
|
||||
<XmlArchive>
|
||||
|
||||
314
PLC/PLC.tmc
314
PLC/PLC.tmc
File diff suppressed because one or more lines are too long
@@ -24,6 +24,9 @@ VAR_INPUT
|
||||
// Release analog io limit errors
|
||||
xReleaseLimitErrors : BOOL;
|
||||
|
||||
// Release manual mode
|
||||
xReleaseManualMode : BOOL;
|
||||
|
||||
// Input to confirm all errors
|
||||
xConfirmAlarms : BOOL;
|
||||
END_VAR
|
||||
@@ -86,7 +89,8 @@ _fbUnit1(
|
||||
rSetpointNegolytPumpInlet:= GVL_CONFIG.rPumpNegolytOnPower,
|
||||
xReleaseErrors:= xReleaseErrors,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors,
|
||||
xConfirmAlarms:= xConfirmAlarms,
|
||||
xConfirmAlarms:= xConfirmAlarms,
|
||||
xReleaseManualMode := xReleaseManualMode,
|
||||
_xWarningConfirmPending=> );
|
||||
|
||||
IF _fbUnit1.xWarning THEN
|
||||
@@ -114,7 +118,8 @@ _fbUnit2(
|
||||
rSetpointNegolytPumpInlet:= GVL_CONFIG.rPumpNegolytOnPower,
|
||||
xReleaseErrors:= xReleaseErrors,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors,
|
||||
xConfirmAlarms:= xConfirmAlarms,
|
||||
xConfirmAlarms:= xConfirmAlarms,
|
||||
xReleaseManualMode := xReleaseManualMode,
|
||||
_xWarningConfirmPending=> );
|
||||
|
||||
IF _fbUnit2.xWarning THEN
|
||||
@@ -142,7 +147,8 @@ _fbUnit3(
|
||||
rSetpointNegolytPumpInlet:= GVL_CONFIG.rPumpNegolytOnPower,
|
||||
xReleaseErrors:= xReleaseErrors,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors,
|
||||
xConfirmAlarms:= xConfirmAlarms,
|
||||
xConfirmAlarms:= xConfirmAlarms,
|
||||
xReleaseManualMode := xReleaseManualMode,
|
||||
_xWarningConfirmPending=> );
|
||||
|
||||
IF _fbUnit3.xWarning THEN
|
||||
@@ -170,7 +176,8 @@ _fbUnit4(
|
||||
rSetpointNegolytPumpInlet:= GVL_CONFIG.rPumpNegolytOnPower,
|
||||
xReleaseErrors:= xReleaseErrors,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors,
|
||||
xConfirmAlarms:= xConfirmAlarms,
|
||||
xConfirmAlarms:= xConfirmAlarms,
|
||||
xReleaseManualMode := xReleaseManualMode,
|
||||
_xWarningConfirmPending=> );
|
||||
|
||||
IF _fbUnit4.xWarning THEN
|
||||
@@ -213,6 +220,7 @@ xOff := _fbUnit1.xOff AND _fbUnit2.xOff AND _fbUnit3.xOff AND _fbUnit4.xOff;
|
||||
// Calculate module voltage
|
||||
// ===============================
|
||||
rCurrentVoltage := _fbUnit1.rCurrentVoltage + _fbUnit2.rCurrentVoltage + _fbUnit3.rCurrentVoltage + _fbUnit4.rCurrentVoltage;
|
||||
stHMIInterface.rVoltage := rCurrentVoltage;
|
||||
|
||||
|
||||
// ===============================
|
||||
@@ -278,6 +286,21 @@ IF _xAllUnitsReady AND _xBalanceOk THEN
|
||||
xReady := TRUE;
|
||||
ELSE
|
||||
xReady := FALSE;
|
||||
END_IF
|
||||
|
||||
// ===============================
|
||||
// Module status sum
|
||||
// ===============================
|
||||
IF xOff THEN
|
||||
stHMIInterface.eStatus := E_COMPONENT_STATUS.OFF;
|
||||
END_IF
|
||||
|
||||
IF xReady THEN
|
||||
stHMIInterface.eStatus := E_COMPONENT_STATUS.ON;
|
||||
END_IF
|
||||
|
||||
IF xError THEN
|
||||
stHMIInterface.eStatus := E_COMPONENT_STATUS.ERROR;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="FB_init" Id="{369c1d27-76e4-45f8-9dbe-03524d3389df}">
|
||||
@@ -340,25 +363,33 @@ _fbUnitsOutOfBalanceAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
|
||||
<LineId Id="575" Count="0" />
|
||||
<LineId Id="251" Count="4" />
|
||||
<LineId Id="456" Count="0" />
|
||||
<LineId Id="256" Count="16" />
|
||||
<LineId Id="256" Count="7" />
|
||||
<LineId Id="742" Count="0" />
|
||||
<LineId Id="264" Count="8" />
|
||||
<LineId Id="560" Count="0" />
|
||||
<LineId Id="559" Count="0" />
|
||||
<LineId Id="561" Count="1" />
|
||||
<LineId Id="273" Count="5" />
|
||||
<LineId Id="457" Count="0" />
|
||||
<LineId Id="279" Count="16" />
|
||||
<LineId Id="279" Count="7" />
|
||||
<LineId Id="743" Count="0" />
|
||||
<LineId Id="287" Count="8" />
|
||||
<LineId Id="563" Count="2" />
|
||||
<LineId Id="296" Count="0" />
|
||||
<LineId Id="574" Count="0" />
|
||||
<LineId Id="297" Count="4" />
|
||||
<LineId Id="458" Count="0" />
|
||||
<LineId Id="302" Count="16" />
|
||||
<LineId Id="302" Count="7" />
|
||||
<LineId Id="744" Count="0" />
|
||||
<LineId Id="310" Count="8" />
|
||||
<LineId Id="566" Count="2" />
|
||||
<LineId Id="319" Count="0" />
|
||||
<LineId Id="573" Count="0" />
|
||||
<LineId Id="320" Count="4" />
|
||||
<LineId Id="459" Count="0" />
|
||||
<LineId Id="325" Count="15" />
|
||||
<LineId Id="325" Count="7" />
|
||||
<LineId Id="745" Count="0" />
|
||||
<LineId Id="333" Count="7" />
|
||||
<LineId Id="188" Count="0" />
|
||||
<LineId Id="569" Count="2" />
|
||||
<LineId Id="441" Count="0" />
|
||||
@@ -385,6 +416,7 @@ _fbUnitsOutOfBalanceAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
|
||||
<LineId Id="446" Count="1" />
|
||||
<LineId Id="445" Count="0" />
|
||||
<LineId Id="442" Count="0" />
|
||||
<LineId Id="659" Count="0" />
|
||||
<LineId Id="440" Count="0" />
|
||||
<LineId Id="378" Count="3" />
|
||||
<LineId Id="387" Count="0" />
|
||||
@@ -434,6 +466,16 @@ _fbUnitsOutOfBalanceAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
|
||||
<LineId Id="463" Count="0" />
|
||||
<LineId Id="462" Count="0" />
|
||||
<LineId Id="455" Count="0" />
|
||||
<LineId Id="661" Count="0" />
|
||||
<LineId Id="660" Count="0" />
|
||||
<LineId Id="662" Count="4" />
|
||||
<LineId Id="668" Count="0" />
|
||||
<LineId Id="667" Count="0" />
|
||||
<LineId Id="669" Count="1" />
|
||||
<LineId Id="672" Count="0" />
|
||||
<LineId Id="671" Count="0" />
|
||||
<LineId Id="675" Count="0" />
|
||||
<LineId Id="674" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_Module.FB_init">
|
||||
<LineId Id="7" Count="0" />
|
||||
|
||||
@@ -7,7 +7,7 @@ VAR_INPUT
|
||||
xEnable : BOOL;
|
||||
|
||||
// Module 1 HMI interface
|
||||
stHMIInterface : ST_STRING_HMI_INTERFACE;
|
||||
stHMIInterface : REFERENCE TO ST_STRING_HMI_INTERFACE;
|
||||
|
||||
// Emergency stop ok
|
||||
xEmergencyStopOk : BOOL;
|
||||
@@ -18,6 +18,9 @@ VAR_INPUT
|
||||
// Release analog io limit errors
|
||||
xReleaseLimitErrors : BOOL;
|
||||
|
||||
// Release manual mode
|
||||
xReleaseManualMode : BOOL;
|
||||
|
||||
// Input to confirm all errors
|
||||
xConfirmAlarms : BOOL;
|
||||
END_VAR
|
||||
@@ -42,6 +45,8 @@ VAR_OUTPUT
|
||||
|
||||
xError : BOOL;
|
||||
xWarning : BOOL;
|
||||
|
||||
eStatus : E_COMPONENT_STATUS;
|
||||
END_VAR
|
||||
VAR
|
||||
_fbModule1 : FB_Module('Module 1');
|
||||
@@ -82,7 +87,8 @@ _fbModule1(
|
||||
xEmergencyStopOk:= xEmergencyStopOk,
|
||||
stHMIInterface:= stHMIInterface.stHMIInterfaceModule1,
|
||||
xReleaseErrors:= xReleaseErrors,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors,
|
||||
xReleaseManualMode := xReleaseManualMode,
|
||||
xConfirmAlarms:= xConfirmAlarms);
|
||||
|
||||
IF _fbModule1.xWarning THEN
|
||||
@@ -106,7 +112,8 @@ _fbModule2(
|
||||
xEmergencyStopOk:= xEmergencyStopOk,
|
||||
stHMIInterface:= stHMIInterface.stHMIInterfaceModule2,
|
||||
xReleaseErrors:= xReleaseErrors,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors,
|
||||
xReleaseManualMode := xReleaseManualMode,
|
||||
xConfirmAlarms:= xConfirmAlarms);
|
||||
|
||||
IF _fbModule2.xWarning THEN
|
||||
@@ -130,7 +137,8 @@ _fbModule3(
|
||||
xEmergencyStopOk:= xEmergencyStopOk,
|
||||
stHMIInterface:= stHMIInterface.stHMIInterfaceModule3,
|
||||
xReleaseErrors:= xReleaseErrors,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors,
|
||||
xReleaseManualMode := xReleaseManualMode,
|
||||
xConfirmAlarms:= xConfirmAlarms);
|
||||
|
||||
IF _fbModule3.xWarning THEN
|
||||
@@ -181,12 +189,11 @@ xShutdownDischargeAllowed := _fbModule1.xShutdownDischargeAllowed AND _fbModule2
|
||||
// ===============================
|
||||
xOff := _fbModule1.xOff AND _fbModule2.xOff AND _fbModule3.xOff;
|
||||
|
||||
|
||||
// ===============================
|
||||
// Calculate module voltage
|
||||
// Calculate string voltage
|
||||
// ===============================
|
||||
rCurrentVoltage := _fbModule1.rCurrentVoltage + _fbModule2.rCurrentVoltage + _fbModule3.rCurrentVoltage;
|
||||
|
||||
stHMIInterface.rVoltage := rCurrentVoltage;
|
||||
|
||||
// ===============================
|
||||
// String balance check
|
||||
@@ -237,6 +244,21 @@ IF _xAllModulesReady AND _xBalanceOk THEN
|
||||
xReady := TRUE;
|
||||
ELSE
|
||||
xReady := FALSE;
|
||||
END_IF
|
||||
|
||||
// ===============================
|
||||
// String status sum
|
||||
// ===============================
|
||||
IF xOff THEN
|
||||
eStatus := E_COMPONENT_STATUS.OFF;
|
||||
END_IF
|
||||
|
||||
IF xReady THEN
|
||||
eStatus := E_COMPONENT_STATUS.ON;
|
||||
END_IF
|
||||
|
||||
IF xError THEN
|
||||
eStatus := E_COMPONENT_STATUS.ERROR;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="FB_init" Id="{9e8494eb-1b40-4be9-91c8-810ecbdf7f0c}">
|
||||
@@ -305,7 +327,9 @@ _fbSafetyInterlocksNotOkAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
|
||||
<LineId Id="47" Count="0" />
|
||||
<LineId Id="140" Count="0" />
|
||||
<LineId Id="48" Count="0" />
|
||||
<LineId Id="50" Count="3" />
|
||||
<LineId Id="50" Count="2" />
|
||||
<LineId Id="600" Count="0" />
|
||||
<LineId Id="53" Count="0" />
|
||||
<LineId Id="58" Count="0" />
|
||||
<LineId Id="62" Count="0" />
|
||||
<LineId Id="64" Count="0" />
|
||||
@@ -317,13 +341,17 @@ _fbSafetyInterlocksNotOkAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
|
||||
<LineId Id="339" Count="1" />
|
||||
<LineId Id="71" Count="5" />
|
||||
<LineId Id="141" Count="0" />
|
||||
<LineId Id="77" Count="11" />
|
||||
<LineId Id="77" Count="3" />
|
||||
<LineId Id="601" Count="0" />
|
||||
<LineId Id="81" Count="7" />
|
||||
<LineId Id="70" Count="0" />
|
||||
<LineId Id="342" Count="2" />
|
||||
<LineId Id="341" Count="0" />
|
||||
<LineId Id="90" Count="5" />
|
||||
<LineId Id="142" Count="0" />
|
||||
<LineId Id="96" Count="11" />
|
||||
<LineId Id="96" Count="3" />
|
||||
<LineId Id="602" Count="0" />
|
||||
<LineId Id="100" Count="7" />
|
||||
<LineId Id="89" Count="0" />
|
||||
<LineId Id="346" Count="2" />
|
||||
<LineId Id="345" Count="0" />
|
||||
@@ -339,7 +367,6 @@ _fbSafetyInterlocksNotOkAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
|
||||
<LineId Id="260" Count="0" />
|
||||
<LineId Id="270" Count="4" />
|
||||
<LineId Id="269" Count="0" />
|
||||
<LineId Id="197" Count="0" />
|
||||
<LineId Id="190" Count="3" />
|
||||
<LineId Id="182" Count="0" />
|
||||
<LineId Id="199" Count="5" />
|
||||
@@ -362,6 +389,15 @@ _fbSafetyInterlocksNotOkAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
|
||||
<LineId Id="221" Count="5" />
|
||||
<LineId Id="239" Count="1" />
|
||||
<LineId Id="214" Count="0" />
|
||||
<LineId Id="512" Count="0" />
|
||||
<LineId Id="511" Count="0" />
|
||||
<LineId Id="513" Count="4" />
|
||||
<LineId Id="521" Count="0" />
|
||||
<LineId Id="520" Count="0" />
|
||||
<LineId Id="522" Count="1" />
|
||||
<LineId Id="525" Count="0" />
|
||||
<LineId Id="524" Count="0" />
|
||||
<LineId Id="526" Count="1" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_String.FB_init">
|
||||
<LineId Id="7" Count="0" />
|
||||
|
||||
@@ -27,6 +27,9 @@ VAR_INPUT
|
||||
// Release analog io limit errors
|
||||
xReleaseLimitErrors : BOOL;
|
||||
|
||||
// Release manual mode
|
||||
xReleaseManualMode : BOOL;
|
||||
|
||||
// Input to confirm all errors
|
||||
xConfirmAlarms : BOOL;
|
||||
END_VAR
|
||||
@@ -107,13 +110,13 @@ VAR
|
||||
|
||||
// Pump posolyt inlet interlocks
|
||||
_stPosolytPumpInletPIntlk : T_INTERLOCK;
|
||||
_stPosolytPumpInletPIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0001;
|
||||
_stPosolytPumpInletPIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0000;
|
||||
_stPosolytPumpInletSIntlk : T_INTERLOCK;
|
||||
_stPosolytPumpInletSIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0001;
|
||||
|
||||
// Pump negolyt inlet interlocks
|
||||
_stNegolytPumpInletPIntlk : T_INTERLOCK;
|
||||
_stNegolytPumpInletPIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0001;
|
||||
_stNegolytPumpInletPIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0000;
|
||||
_stNegolytPumpInletSIntlk : T_INTERLOCK;
|
||||
_stNegolytPumpInletSIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0001;
|
||||
|
||||
@@ -158,6 +161,9 @@ _xWarningActive := FALSE;
|
||||
// Reset safety interlocks flag
|
||||
xSafetyIntlksOk := TRUE;
|
||||
|
||||
// Copy release manual mode
|
||||
_xReleaseManualMode := xReleaseManualMode;
|
||||
|
||||
// ===============================
|
||||
// Valve posolyt tank outlet
|
||||
// ===============================
|
||||
@@ -229,8 +235,8 @@ stHMIInterface.stPosolytPump.stInterlock.asSafetyINTLKName[0] := 'Emergency stop
|
||||
_stPosolytPumpInletSIntlk.0 := xEmergencyStopOk;
|
||||
|
||||
// Process interlocks
|
||||
stHMIInterface.stPosolytPump.stInterlock.asProcessINTLKName[0] := 'At least one valve is open';
|
||||
_stPosolytPumpInletPIntlk.0 := _fbPosolytValveTankOutlet.IsOpen;
|
||||
// stHMIInterface.stPosolytPump.stInterlock.asProcessINTLKName[0] := 'At least one valve is open';
|
||||
//_stPosolytPumpInletPIntlk.0 := _fbPosolytValveTankOutlet.IsOpen;
|
||||
|
||||
|
||||
// Valve fb
|
||||
@@ -273,8 +279,8 @@ stHMIInterface.stNegolytPump.stInterlock.asSafetyINTLKName[0] := 'Emergency stop
|
||||
_stNegolytPumpInletSIntlk.0 := xEmergencyStopOk;
|
||||
|
||||
// Process interlocks
|
||||
stHMIInterface.stNegolytPump.stInterlock.asProcessINTLKName[0] := 'At least one valve is open';
|
||||
_stNegolytPumpInletPIntlk.0 := _fbNegolytValveTankOutlet.IsOpen;
|
||||
//stHMIInterface.stNegolytPump.stInterlock.asProcessINTLKName[0] := 'At least one valve is open';
|
||||
//_stNegolytPumpInletPIntlk.0 := _fbNegolytValveTankOutlet.IsOpen;
|
||||
|
||||
|
||||
// Valve fb
|
||||
@@ -364,7 +370,7 @@ _fbPressurePosolytTankInlet(
|
||||
stEWConfig:= stUnitConfig.stEWLPosolytPressureTankInlet,
|
||||
stEWDelayConfig:= stUnitConfig.stEWDPosolytPressureTankInlet,
|
||||
xReleaseErrors:= xReleaseErrors,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors AND _fbPosolytPumpInlet.IsRunning AND _fbPosolytPumpInlet.xInTarget,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors,
|
||||
xReleaseHardwareErrors:= xReleaseErrors,
|
||||
xConfirmAlarms:= xConfirmAlarms,
|
||||
stHMIInterface => stHMIInterface.stPosolytPressureTankInlet);
|
||||
@@ -388,7 +394,7 @@ _fbPressureNegolytTankInlet(
|
||||
stEWConfig:= stUnitConfig.stEWLNegolytPressureTankInlet,
|
||||
stEWDelayConfig:= stUnitConfig.stEWDNegolytPressureTankInlet,
|
||||
xReleaseErrors:= xReleaseErrors,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors AND _fbNegolytPumpInlet.IsRunning AND _fbNegolytPumpInlet.xInTarget,
|
||||
xReleaseLimitErrors:= xReleaseLimitErrors,
|
||||
xReleaseHardwareErrors:= xReleaseErrors,
|
||||
xConfirmAlarms:= xConfirmAlarms,
|
||||
stHMIInterface => stHMIInterface.stNegolytPressureTankInlet);
|
||||
@@ -706,6 +712,9 @@ _fbNotAllAutomaticAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
|
||||
<LineId Id="4232" Count="4" />
|
||||
<LineId Id="5406" Count="1" />
|
||||
<LineId Id="5405" Count="0" />
|
||||
<LineId Id="5592" Count="0" />
|
||||
<LineId Id="5591" Count="0" />
|
||||
<LineId Id="5593" Count="0" />
|
||||
<LineId Id="4237" Count="24" />
|
||||
<LineId Id="5408" Count="0" />
|
||||
<LineId Id="4584" Count="0" />
|
||||
|
||||
@@ -9,7 +9,10 @@ VAR
|
||||
_xConfirmAlarms : BOOL;
|
||||
_xEnableString : BOOL;
|
||||
_xEnableInverter : BOOL;
|
||||
|
||||
{attribute 'OPC.UA.DA' := '0'}
|
||||
_fbString : FB_String('String 1');
|
||||
|
||||
_fbInverter : FB_PowerSupplySunspec;
|
||||
_stInverterData : ST_SUNSPEC_CURRENT_VALUES;
|
||||
|
||||
@@ -18,9 +21,7 @@ VAR
|
||||
// Variable to detect battery status change
|
||||
_eLastBatteryStatus : E_BATTERY_STATUS;
|
||||
|
||||
// Variable to detect any battery status change
|
||||
_xBatteryStatusChange : BOOL;
|
||||
|
||||
// State machine state
|
||||
_iState : INT;
|
||||
|
||||
// Internal inverter power
|
||||
@@ -33,7 +34,7 @@ VAR
|
||||
_tonStartupDelay : TON := (PT := T#10S);
|
||||
|
||||
// Small delay for inverter shutdown
|
||||
_tonBeginShutdown : TON := (PT := T#10S);
|
||||
_tonBeginShutdown : TON := (PT := T#30S);
|
||||
|
||||
// Not all strings in automatic mode
|
||||
_fbNoAutomaticModeAlarm : Fb_TcAlarm;
|
||||
@@ -47,11 +48,24 @@ VAR
|
||||
// Timer for ADS read
|
||||
_timADSReadTimer : TON;
|
||||
|
||||
// MQTT client
|
||||
_fbMQTTClient : FB_IotMqttClient;
|
||||
// Release manual mode
|
||||
_xReleaseManualMode : BOOL;
|
||||
|
||||
// connect to mqtt broker
|
||||
_xConnectToMQTTBrocker : BOOL;
|
||||
// Current internal set inverter power value
|
||||
_diInternalPowerSetpoint : DINT;
|
||||
|
||||
_diSetpointActivePower : DINT;
|
||||
|
||||
// Current BMS control mode (Auto local, Auto remote, etc...)
|
||||
// On restart star in manual mode (so the ems can not directly start the bms)
|
||||
_eBMSControlMode : E_BMS_CONTROL_MODE := E_BMS_CONTROL_MODE.MANUAL;
|
||||
|
||||
// UPS
|
||||
_fbUPS : FB_S_UPS_BAPI;
|
||||
|
||||
// Safety
|
||||
xSafetyRun AT %Q* : BOOL;
|
||||
xSafetyErrAck AT %Q* : BOOL;
|
||||
|
||||
// DEBUG
|
||||
_xRestart : BOOL;
|
||||
@@ -73,24 +87,69 @@ END_IF
|
||||
// DEBUG
|
||||
// ===============================
|
||||
|
||||
|
||||
// ===============================
|
||||
// Handle Manual mode release
|
||||
// ===============================
|
||||
IF _iState = 0 THEN
|
||||
_xReleaseManualMode := TRUE;
|
||||
ELSE
|
||||
_xReleaseManualMode := FALSE;
|
||||
END_IF
|
||||
|
||||
|
||||
// ===============================
|
||||
// Handle UPS events
|
||||
// ===============================
|
||||
_fbUPS(
|
||||
sNetID:= '',
|
||||
iPLCPort:= 851,
|
||||
tTimeout:= DEFAULT_ADS_TIMEOUT,
|
||||
eUpsMode:= eSUPS_WrPersistData_Shutdown,
|
||||
ePersistentMode:= SPDM_2PASS,
|
||||
tRecoverTime:= T#10S,
|
||||
bPowerFailDetect=> ,
|
||||
eState=> );
|
||||
|
||||
|
||||
IF _xFirstCycle THEN
|
||||
_xFirstCycle := FALSE;
|
||||
_fbString.Name := 'String 1';
|
||||
_xConnectToMQTTBrocker := TRUE;
|
||||
END_IF
|
||||
|
||||
// Dely release of errors during PLC startup phase
|
||||
_tonStartupDelay(IN := TRUE);
|
||||
|
||||
// Ack alarms from HMI
|
||||
_xConfirmAlarms := GVL_SCADA.stAckAlarmsButton.xRequest;
|
||||
IF GVL_SCADA.stAckAlarmsButton.xRequest THEN
|
||||
GVL_SCADA.stAckAlarmsButton.xRequest := FALSE;
|
||||
END_IF
|
||||
|
||||
// Call string 1
|
||||
_fbString(
|
||||
xEnable := _xEnableString,
|
||||
stHMIInterface:= ,
|
||||
stHMIInterface:= GVL_SCADA.stHMIInterface,
|
||||
xEmergencyStopOk:= _xEmergencyStopOk,
|
||||
xReleaseErrors:= _xReleaseErrors AND _tonStartupDelay.Q,
|
||||
xReleaseLimitErrors:= _xReleaseLimitsErrors AND _tonStartupDelay.Q,
|
||||
xReleaseLimitErrors:= _xReleaseLimitsErrors AND _tonStartupDelay.Q,
|
||||
xReleaseManualMode := _xReleaseManualMode,
|
||||
xConfirmAlarms:= _xConfirmAlarms);
|
||||
|
||||
// HMI Feedback
|
||||
GVL_SCADA.stHMIInterface.rVoltage := _fbString.rCurrentVoltage;
|
||||
IF _fbString.eStatus = E_COMPONENT_STATUS.ON THEN
|
||||
IF _iState = 30 AND _rPowerInverter > 0 THEN
|
||||
GVL_SCADA.stHMIInterface.eStatus := E_COMPONENT_STATUS.DISCHARGING;
|
||||
ELSIF _iState = 30 AND _rPowerInverter < 0 THEN
|
||||
GVL_SCADA.stHMIInterface.eStatus := E_COMPONENT_STATUS.CHARGING;
|
||||
ELSE
|
||||
GVL_SCADA.stHMIInterface.eStatus :=_fbString.eStatus;
|
||||
END_IF
|
||||
ELSE
|
||||
GVL_SCADA.stHMIInterface.eStatus :=_fbString.eStatus;
|
||||
END_IF
|
||||
|
||||
// DEACTIVATED FOR DEBUG REASONS !!!
|
||||
// Call inverter
|
||||
//_fbInverter(
|
||||
@@ -118,18 +177,46 @@ _fbADSReader(
|
||||
BUSY=> ,
|
||||
ERR=> ,
|
||||
ERRID=> );
|
||||
|
||||
// ===============================
|
||||
// MQTT cummunication
|
||||
// ===============================
|
||||
// Handle connection to broker
|
||||
_fbMQTTClient.Execute(_xConnectToMQTTBrocker);
|
||||
|
||||
|
||||
|
||||
// ===============================
|
||||
// State machine
|
||||
// ===============================
|
||||
CASE _iState OF
|
||||
CASE _eBMSControlMode OF
|
||||
E_BMS_CONTROL_MODE.AUTO_REMOTE:
|
||||
SM_AUTO_REMOTE();
|
||||
|
||||
E_BMS_CONTROL_MODE.AUTO_LOCAL:
|
||||
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.TESTING;
|
||||
SM_AUTO_LOCAL();
|
||||
|
||||
E_BMS_CONTROL_MODE.MANUAL:
|
||||
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.MAINTENANCE;
|
||||
SM_MANUAL();
|
||||
|
||||
E_BMS_CONTROL_MODE.SAFETY_CHECK:
|
||||
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.MAINTENANCE;
|
||||
SM_SAFETY_CHECK();
|
||||
|
||||
E_BMS_CONTROL_MODE.CAPACITY_TEST:
|
||||
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.TESTING;
|
||||
SM_CAPACITY_TEST();
|
||||
END_CASE
|
||||
|
||||
|
||||
// Reset alarm confirmation
|
||||
IF _xConfirmAlarms THEN
|
||||
_xConfirmAlarms := FALSE;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
<Action Name="SM_AUTO_LOCAL" Id="{def23375-eebc-4fdc-90a2-71266ffc4850}">
|
||||
<Implementation>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
</Action>
|
||||
<Action Name="SM_AUTO_REMOTE" Id="{b5166e16-4fea-442b-9560-02c156f9a9ad}">
|
||||
<Implementation>
|
||||
<ST><![CDATA[CASE _iState OF
|
||||
0: // Idle
|
||||
// Wait for power command
|
||||
IF (ABS(GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower) > GVL_CONFIG.diMinimumAbsPowerForEnable) AND _fbString.xSafetyIntlksOk AND (NOT _fbString.xError) THEN
|
||||
@@ -174,7 +261,7 @@ CASE _iState OF
|
||||
|
||||
30: // String and inverter enabled
|
||||
// Set inverter power to modbus requested power
|
||||
_rPowerInverter := DINT_TO_REAL(GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower);
|
||||
_rPowerInverter := DINT_TO_REAL(GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower);//DINT_TO_REAL(GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower);
|
||||
|
||||
// Check if the battery should still be active
|
||||
IF (GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower = 0) THEN
|
||||
@@ -205,6 +292,7 @@ CASE _iState OF
|
||||
|
||||
// Start string shutdown
|
||||
_xEnableString := FALSE;
|
||||
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.UNDEFINED;
|
||||
GVL_MODBUS.stModbusEMSComm.stModbusReg10.uiActiveParallelMembers := 0;
|
||||
_iState := 35;
|
||||
END_IF
|
||||
@@ -236,7 +324,7 @@ CASE _iState OF
|
||||
_xEnableString := FALSE;
|
||||
|
||||
// Change battery status
|
||||
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.FULL;
|
||||
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.EMPTY;
|
||||
GVL_MODBUS.stModbusEMSComm.stModbusReg10.uiActiveParallelMembers := 0;
|
||||
_iState := 35;
|
||||
END_IF
|
||||
@@ -307,71 +395,36 @@ CASE _iState OF
|
||||
// Goto init state
|
||||
_iState := 0;
|
||||
END_IF
|
||||
END_CASE
|
||||
|
||||
// Send MQTT battery status
|
||||
_xBatteryStatusChange := FALSE;
|
||||
|
||||
IF GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus <> _eLastBatteryStatus THEN
|
||||
_xBatteryStatusChange := TRUE;
|
||||
END_IF
|
||||
_eLastBatteryStatus := GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus;
|
||||
|
||||
IF GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus <> _eLastChargeStatus THEN
|
||||
_xBatteryStatusChange := TRUE;
|
||||
END_IF
|
||||
_eLastChargeStatus := GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus;
|
||||
|
||||
IF _xBatteryStatusChange THEN
|
||||
SendBatteryStatus();
|
||||
END_IF
|
||||
|
||||
// Reset alarm confirmation
|
||||
IF _xConfirmAlarms THEN
|
||||
_xConfirmAlarms := FALSE;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="SendBatteryStatus" Id="{d5a8daa9-6942-4419-a57d-7958e56f7e71}">
|
||||
<Declaration><![CDATA[METHOD SendBatteryStatus
|
||||
VAR
|
||||
_sJSONString : T_MaxString;
|
||||
_fbFormatString : FB_FormatString;
|
||||
_sBatteryStatus : T_MaxString;
|
||||
_sChargeStatus : T_MaxString;
|
||||
_sBMSVersion : T_MaxString;
|
||||
END_VAR
|
||||
VAR CONSTANT
|
||||
_sTemplateString : STRING := '{"batteryStatus": "%s", "chargeStatus": "%s", "bmsVersion": "%s"}';
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Temp strings because string format needs write access to these variables
|
||||
_sBatteryStatus := TO_STRING(GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus);
|
||||
_sChargeStatus := TO_STRING(GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus);
|
||||
_sBMSVersion := GVL_MODBUS.stModbusEMSComm.stModbusReg10.sBMSVersion;
|
||||
|
||||
// Build JSON string
|
||||
_fbFormatString(
|
||||
sFormat:= _sTemplateString,
|
||||
arg1:= F_STRING(_sBatteryStatus),
|
||||
arg2:= F_STRING(_sChargeStatus),
|
||||
arg3:= F_STRINg(_sBMSVersion),
|
||||
sOut=> _sJSONString);
|
||||
|
||||
// Send message if connected and no formatting error occured
|
||||
IF NOT _fbFormatString.bError AND _fbMQTTClient.bConnected THEN
|
||||
_fbMQTTClient.Publish('status', ADR(_sJSONString), INT_TO_UDINT(LEN(_sJSONString)), GVL_MQTT.eMQTTQoS, FALSE, FALSE);
|
||||
END_IF]]></ST>
|
||||
END_CASE]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Action Name="SetMQTTParameter" Id="{f5ef2661-7fa1-4c9b-aa13-fba0d7bff32a}">
|
||||
</Action>
|
||||
<Action Name="SM_CAPACITY_TEST" Id="{705978cf-2798-4a38-8f24-148e2ec1d46e}">
|
||||
<Implementation>
|
||||
<ST><![CDATA[//_fbMQTTClient.sClientId:= '';
|
||||
_fbMQTTClient.sHostName:= GVL_MQTT.sMQTTBrokerAddr;
|
||||
_fbMQTTClient.nHostPort:= 1883;
|
||||
//_fbMQTTClient.sTopicPrefix := '';
|
||||
_fbMQTTClient.nKeepAlive:= GVL_MQTT.uiMQTTKeepAlive;
|
||||
// _fbMQTTClient.ipMessageQueue := ;]]></ST>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
</Action>
|
||||
<Action Name="SM_MANUAL" Id="{ddef276e-9f4f-4258-b863-d254dd94b701}">
|
||||
<Implementation>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
</Action>
|
||||
<Action Name="SM_SAFETY_CHECK" Id="{6d8e5993-cf32-4980-9ea3-c1fbfa4b8601}">
|
||||
<Implementation>
|
||||
<ST><![CDATA[// start pumps
|
||||
|
||||
// open valves
|
||||
|
||||
// wait for equilibrium and voltage in range
|
||||
|
||||
// engange dc breakers
|
||||
|
||||
// wait for stop or error
|
||||
|
||||
// on stop: open dc circuit breakers and close valves
|
||||
|
||||
// wait for voltage to drop below xx volts
|
||||
|
||||
// stop pumps]]></ST>
|
||||
</Implementation>
|
||||
</Action>
|
||||
<LineIds Name="MAIN">
|
||||
@@ -388,144 +441,98 @@ _fbMQTTClient.nKeepAlive:= GVL_MQTT.uiMQTTKeepAlive;
|
||||
<LineId Id="534" Count="0" />
|
||||
<LineId Id="398" Count="0" />
|
||||
<LineId Id="404" Count="0" />
|
||||
<LineId Id="1187" Count="0" />
|
||||
<LineId Id="1185" Count="0" />
|
||||
<LineId Id="1179" Count="0" />
|
||||
<LineId Id="1178" Count="0" />
|
||||
<LineId Id="1186" Count="0" />
|
||||
<LineId Id="1180" Count="1" />
|
||||
<LineId Id="1183" Count="1" />
|
||||
<LineId Id="1182" Count="0" />
|
||||
<LineId Id="1188" Count="0" />
|
||||
<LineId Id="1029" Count="0" />
|
||||
<LineId Id="1028" Count="0" />
|
||||
<LineId Id="1030" Count="1" />
|
||||
<LineId Id="1037" Count="2" />
|
||||
<LineId Id="1041" Count="4" />
|
||||
<LineId Id="1033" Count="0" />
|
||||
<LineId Id="1032" Count="0" />
|
||||
<LineId Id="475" Count="0" />
|
||||
<LineId Id="396" Count="0" />
|
||||
<LineId Id="476" Count="0" />
|
||||
<LineId Id="478" Count="0" />
|
||||
<LineId Id="624" Count="0" />
|
||||
<LineId Id="477" Count="0" />
|
||||
<LineId Id="397" Count="0" />
|
||||
<LineId Id="126" Count="19" />
|
||||
<LineId Id="126" Count="1" />
|
||||
<LineId Id="971" Count="1" />
|
||||
<LineId Id="970" Count="0" />
|
||||
<LineId Id="974" Count="0" />
|
||||
<LineId Id="973" Count="0" />
|
||||
<LineId Id="975" Count="0" />
|
||||
<LineId Id="128" Count="7" />
|
||||
<LineId Id="1189" Count="0" />
|
||||
<LineId Id="136" Count="0" />
|
||||
<LineId Id="1101" Count="2" />
|
||||
<LineId Id="1105" Count="0" />
|
||||
<LineId Id="1109" Count="2" />
|
||||
<LineId Id="1114" Count="0" />
|
||||
<LineId Id="1118" Count="1" />
|
||||
<LineId Id="1115" Count="2" />
|
||||
<LineId Id="1108" Count="0" />
|
||||
<LineId Id="137" Count="8" />
|
||||
<LineId Id="147" Count="0" />
|
||||
<LineId Id="784" Count="3" />
|
||||
<LineId Id="598" Count="0" />
|
||||
<LineId Id="808" Count="0" />
|
||||
<LineId Id="793" Count="10" />
|
||||
<LineId Id="789" Count="0" />
|
||||
<LineId Id="599" Count="0" />
|
||||
<LineId Id="463" Count="0" />
|
||||
<LineId Id="601" Count="0" />
|
||||
<LineId Id="600" Count="0" />
|
||||
<LineId Id="626" Count="0" />
|
||||
<LineId Id="617" Count="0" />
|
||||
<LineId Id="724" Count="0" />
|
||||
<LineId Id="152" Count="29" />
|
||||
<LineId Id="218" Count="0" />
|
||||
<LineId Id="182" Count="0" />
|
||||
<LineId Id="304" Count="0" />
|
||||
<LineId Id="207" Count="2" />
|
||||
<LineId Id="628" Count="0" />
|
||||
<LineId Id="314" Count="0" />
|
||||
<LineId Id="782" Count="0" />
|
||||
<LineId Id="210" Count="2" />
|
||||
<LineId Id="305" Count="1" />
|
||||
<LineId Id="308" Count="0" />
|
||||
<LineId Id="215" Count="0" />
|
||||
<LineId Id="219" Count="1" />
|
||||
<LineId Id="222" Count="0" />
|
||||
<LineId Id="221" Count="0" />
|
||||
<LineId Id="223" Count="1" />
|
||||
<LineId Id="234" Count="1" />
|
||||
<LineId Id="237" Count="1" />
|
||||
<LineId Id="236" Count="0" />
|
||||
<LineId Id="309" Count="3" />
|
||||
<LineId Id="315" Count="1" />
|
||||
<LineId Id="632" Count="0" />
|
||||
<LineId Id="360" Count="1" />
|
||||
<LineId Id="313" Count="0" />
|
||||
<LineId Id="317" Count="0" />
|
||||
<LineId Id="241" Count="0" />
|
||||
<LineId Id="240" Count="0" />
|
||||
<LineId Id="239" Count="0" />
|
||||
<LineId Id="327" Count="0" />
|
||||
<LineId Id="242" Count="1" />
|
||||
<LineId Id="262" Count="0" />
|
||||
<LineId Id="264" Count="0" />
|
||||
<LineId Id="261" Count="0" />
|
||||
<LineId Id="263" Count="0" />
|
||||
<LineId Id="265" Count="0" />
|
||||
<LineId Id="260" Count="0" />
|
||||
<LineId Id="783" Count="0" />
|
||||
<LineId Id="245" Count="0" />
|
||||
<LineId Id="244" Count="0" />
|
||||
<LineId Id="328" Count="0" />
|
||||
<LineId Id="330" Count="2" />
|
||||
<LineId Id="339" Count="0" />
|
||||
<LineId Id="338" Count="0" />
|
||||
<LineId Id="333" Count="3" />
|
||||
<LineId Id="340" Count="3" />
|
||||
<LineId Id="337" Count="0" />
|
||||
<LineId Id="329" Count="0" />
|
||||
<LineId Id="344" Count="1" />
|
||||
<LineId Id="347" Count="12" />
|
||||
<LineId Id="346" Count="0" />
|
||||
<LineId Id="246" Count="2" />
|
||||
<LineId Id="251" Count="0" />
|
||||
<LineId Id="249" Count="1" />
|
||||
<LineId Id="256" Count="1" />
|
||||
<LineId Id="266" Count="0" />
|
||||
<LineId Id="296" Count="0" />
|
||||
<LineId Id="290" Count="0" />
|
||||
<LineId Id="267" Count="0" />
|
||||
<LineId Id="291" Count="0" />
|
||||
<LineId Id="294" Count="1" />
|
||||
<LineId Id="292" Count="1" />
|
||||
<LineId Id="268" Count="0" />
|
||||
<LineId Id="258" Count="0" />
|
||||
<LineId Id="269" Count="1" />
|
||||
<LineId Id="272" Count="0" />
|
||||
<LineId Id="259" Count="0" />
|
||||
<LineId Id="273" Count="3" />
|
||||
<LineId Id="278" Count="3" />
|
||||
<LineId Id="277" Count="0" />
|
||||
<LineId Id="285" Count="0" />
|
||||
<LineId Id="287" Count="2" />
|
||||
<LineId Id="286" Count="0" />
|
||||
<LineId Id="282" Count="1" />
|
||||
<LineId Id="300" Count="0" />
|
||||
<LineId Id="666" Count="0" />
|
||||
<LineId Id="302" Count="1" />
|
||||
<LineId Id="301" Count="0" />
|
||||
<LineId Id="297" Count="2" />
|
||||
<LineId Id="284" Count="0" />
|
||||
<LineId Id="183" Count="2" />
|
||||
<LineId Id="216" Count="1" />
|
||||
<LineId Id="186" Count="6" />
|
||||
<LineId Id="252" Count="1" />
|
||||
<LineId Id="255" Count="0" />
|
||||
<LineId Id="254" Count="0" />
|
||||
<LineId Id="193" Count="2" />
|
||||
<LineId Id="197" Count="0" />
|
||||
<LineId Id="647" Count="0" />
|
||||
<LineId Id="646" Count="0" />
|
||||
<LineId Id="654" Count="0" />
|
||||
<LineId Id="659" Count="0" />
|
||||
<LineId Id="648" Count="2" />
|
||||
<LineId Id="664" Count="0" />
|
||||
<LineId Id="656" Count="0" />
|
||||
<LineId Id="655" Count="0" />
|
||||
<LineId Id="657" Count="1" />
|
||||
<LineId Id="665" Count="0" />
|
||||
<LineId Id="661" Count="0" />
|
||||
<LineId Id="660" Count="0" />
|
||||
<LineId Id="662" Count="1" />
|
||||
<LineId Id="958" Count="0" />
|
||||
<LineId Id="152" Count="3" />
|
||||
<LineId Id="1257" Count="1" />
|
||||
<LineId Id="1262" Count="2" />
|
||||
<LineId Id="1341" Count="0" />
|
||||
<LineId Id="1265" Count="0" />
|
||||
<LineId Id="1337" Count="1" />
|
||||
<LineId Id="1342" Count="0" />
|
||||
<LineId Id="1339" Count="0" />
|
||||
<LineId Id="1266" Count="1" />
|
||||
<LineId Id="1343" Count="0" />
|
||||
<LineId Id="1268" Count="2" />
|
||||
<LineId Id="1344" Count="0" />
|
||||
<LineId Id="1271" Count="0" />
|
||||
<LineId Id="1259" Count="0" />
|
||||
<LineId Id="663" Count="0" />
|
||||
<LineId Id="199" Count="3" />
|
||||
<LineId Id="25" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="MAIN.SendBatteryStatus">
|
||||
<LineId Id="27" Count="0" />
|
||||
<LineId Id="29" Count="1" />
|
||||
<LineId Id="28" Count="0" />
|
||||
<LineId Id="32" Count="0" />
|
||||
<LineId Id="31" Count="0" />
|
||||
<LineId Id="14" Count="4" />
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="23" Count="0" />
|
||||
<LineId Id="19" Count="3" />
|
||||
</LineIds>
|
||||
<LineIds Name="MAIN.SetMQTTParameter">
|
||||
<LineId Id="2" Count="4" />
|
||||
<LineIds Name="MAIN.SM_AUTO_LOCAL">
|
||||
<LineId Id="1" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="MAIN.SM_AUTO_REMOTE">
|
||||
<LineId Id="2" Count="178" />
|
||||
<LineId Id="1" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="MAIN.SM_CAPACITY_TEST">
|
||||
<LineId Id="1" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="MAIN.SM_MANUAL">
|
||||
<LineId Id="1" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="MAIN.SM_SAFETY_CHECK">
|
||||
<LineId Id="1" Count="0" />
|
||||
<LineId Id="3" Count="0" />
|
||||
<LineId Id="2" Count="0" />
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="4" Count="0" />
|
||||
<LineId Id="7" Count="0" />
|
||||
<LineId Id="6" Count="0" />
|
||||
<LineId Id="9" Count="0" />
|
||||
<LineId Id="8" Count="0" />
|
||||
<LineId Id="15" Count="1" />
|
||||
<LineId Id="13" Count="0" />
|
||||
<LineId Id="12" Count="0" />
|
||||
<LineId Id="18" Count="0" />
|
||||
<LineId Id="17" Count="0" />
|
||||
</LineIds>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
@@ -6,6 +6,7 @@ VAR_INPUT
|
||||
sInverterIPAddr : STRING;
|
||||
xEnable : BOOL;
|
||||
rPower : REAL;
|
||||
rReactivePower : REAL := 0.0;
|
||||
xReset : BOOL;
|
||||
rMaxBattPower : REAL := 24_000; // 24kW
|
||||
END_VAR
|
||||
@@ -47,6 +48,9 @@ VAR
|
||||
// Unscaled limit for converter power
|
||||
_iWMaxLimPct : INT;
|
||||
|
||||
// Scaling factor for reactive power percent value
|
||||
_iVarPctSF : INT;
|
||||
|
||||
// Reread set power limit
|
||||
_iWMaxLimPctRead : INT;
|
||||
_iWMaxLimPctReadScaled : REAL;
|
||||
@@ -72,6 +76,12 @@ VAR
|
||||
// Value for commanding the target state of the inverter
|
||||
_uiPCSSetOperation : UINT;
|
||||
|
||||
// Maximum reactive power
|
||||
_iMaxPowerVar : INT := 0;
|
||||
|
||||
// Enable max reactive power percent controller
|
||||
_iMaxVarPct : INt := 1;
|
||||
|
||||
// Holds the state number in which an error occured
|
||||
_iErrorInState : INT;
|
||||
|
||||
@@ -143,6 +153,26 @@ VAR CONSTANT
|
||||
// SIZE 10
|
||||
AC_VALUES_START_REGISTER : WORD := 40084;
|
||||
|
||||
// Power factor register in cosine of angle
|
||||
// Size 1, int16 (Range = -32767 .. 32767, Not implemented 0x8000)
|
||||
//OUT_PF_SET : WORD := 40192;
|
||||
|
||||
// Enable power factor controller
|
||||
// Size 1, enum16 (Range = 0 .. 65534, Not implemented = 0xFFFF)
|
||||
//OUT_PF_SET_ENA : WORD := 40196;
|
||||
|
||||
// Reactive power in percent of W_Max
|
||||
// Size 1, int16 (Range = -32767 .. 32767, Not implemented 0x8000)
|
||||
VAR_W_MAX_PCT : WORD := 40197;
|
||||
|
||||
// Enable percent limited var controller
|
||||
// Size 1, enum16 (Range = 0 .. 65534, Not implemented = 0xFFFF)
|
||||
VAR_PCT_ENA : WORD := 40204;
|
||||
|
||||
// Register for reactive power percent scaling factor
|
||||
// Size 1, sunssf (int16) (Range = -10 .. 10, Not implemented 0x8000)
|
||||
VAR_PCT_SF : WORD := 40207;
|
||||
|
||||
// Error bits register
|
||||
// Size 2
|
||||
EVT_1_REGISTER : WORD := 40110;
|
||||
@@ -289,6 +319,42 @@ CASE _iState OF
|
||||
_fbReadRegister(bExecute := FALSE);
|
||||
END_IF
|
||||
|
||||
26: // Read inverter scaling factor for reactive power
|
||||
_iErrorInState := _iState;
|
||||
_fbReadRegister(
|
||||
sIPAddr:= sInverterIPAddr,
|
||||
nTCPPort:= 502,
|
||||
nUnitID:= 16#FF, // 16#FF for Modbus TCP
|
||||
nQuantity:= 1,
|
||||
nMBAddr:= VAR_PCT_SF,
|
||||
cbLength:= SIZEOF(_iVarPctSF),
|
||||
pDestAddr:= ADR(_iVarPctSF),
|
||||
bExecute:= TRUE,
|
||||
tTimeout:= T#5S,
|
||||
bBusy=> ,
|
||||
bError=> ,
|
||||
nErrId=> ,
|
||||
cbRead=> );
|
||||
|
||||
// Check if reading mudbus register is done
|
||||
IF NOT _fbReadRegister.bBusy THEN
|
||||
// If there was no error then continue
|
||||
IF NOT _fbReadRegister.bError THEN
|
||||
_iState := 30;
|
||||
// Check for valid value
|
||||
IF (_iVarPctSF < -10) OR (_iVarPctSF > 10) OR (_iVarPctSF = 16#8000) THEN
|
||||
// Goto error state
|
||||
_iState := 1000;
|
||||
END_IF
|
||||
ELSE
|
||||
xError := TRUE;
|
||||
// Goto error state
|
||||
_iState := 1000;
|
||||
END_IF
|
||||
_fbReadRegister(bExecute := FALSE);
|
||||
END_IF
|
||||
|
||||
|
||||
30: // Read inverter max power
|
||||
_iErrorInState := _iState;
|
||||
_fbReadRegister(
|
||||
@@ -347,6 +413,8 @@ CASE _iState OF
|
||||
_iState := 50;
|
||||
_rOldPower := rPower;
|
||||
_uiMaxLimEn := 1;
|
||||
// Calculate reactive power setting
|
||||
_iMaxPowerVar := LREAL_TO_INT((rReactivePower*100)/(_iMaxPowerVar * EXPT(10,_iVarPctSF)));
|
||||
ELSE
|
||||
xError := TRUE;
|
||||
// Goto error state
|
||||
@@ -355,6 +423,66 @@ CASE _iState OF
|
||||
_fbWriteRegister(bExecute := FALSE);
|
||||
END_IF
|
||||
|
||||
|
||||
41: // Set max reactive power in percent
|
||||
_iErrorInState := _iState;
|
||||
_fbWriteRegister(
|
||||
sIPAddr:= sInverterIPAddr,
|
||||
nTCPPort:= 502,
|
||||
nUnitID:= 16#FF, // 16#FF for Modbus TCP
|
||||
nQuantity:= 1,
|
||||
nMBAddr:= VAR_W_MAX_PCT,
|
||||
cbLength:= SIZEOF(_iMaxPowerVar),
|
||||
pSrcAddr:= ADR(_iMaxPowerVar),
|
||||
bExecute:= TRUE,
|
||||
tTimeout:= T#5S,
|
||||
bBusy=> ,
|
||||
bError=> ,
|
||||
nErrId=> );
|
||||
|
||||
// If writing modbus register is done
|
||||
IF NOT _fbWriteRegister.bBusy THEN
|
||||
// And there is no error, then continue
|
||||
IF NOT _fbWriteRegister.bError THEN
|
||||
_iState := 42;
|
||||
ELSE
|
||||
xError := TRUE;
|
||||
// Goto error state
|
||||
_iState := 1000;
|
||||
END_IF
|
||||
_fbWriteRegister(bExecute := FALSE);
|
||||
END_IF
|
||||
|
||||
42: // Enable reactive power percent limiting
|
||||
_iErrorInState := _iState;
|
||||
_fbWriteRegister(
|
||||
sIPAddr:= sInverterIPAddr,
|
||||
nTCPPort:= 502,
|
||||
nUnitID:= 16#FF, // 16#FF for Modbus TCP
|
||||
nQuantity:= 1,
|
||||
nMBAddr:= VAR_PCT_ENA,
|
||||
cbLength:= SIZEOF(_iMaxVarPct),
|
||||
pSrcAddr:= ADR(_iMaxVarPct),
|
||||
bExecute:= TRUE,
|
||||
tTimeout:= T#5S,
|
||||
bBusy=> ,
|
||||
bError=> ,
|
||||
nErrId=> );
|
||||
|
||||
// If writing modbus register is done
|
||||
IF NOT _fbWriteRegister.bBusy THEN
|
||||
// And there is no error, then continue
|
||||
IF NOT _fbWriteRegister.bError THEN
|
||||
_iState := 50;
|
||||
ELSE
|
||||
xError := TRUE;
|
||||
// Goto error state
|
||||
_iState := 1000;
|
||||
END_IF
|
||||
_fbWriteRegister(bExecute := FALSE);
|
||||
END_IF
|
||||
|
||||
|
||||
// 45: // Read set power
|
||||
// _fbReadRegister(
|
||||
// sIPAddr:= sInverterIPAddr,
|
||||
@@ -704,11 +832,30 @@ END_CASE]]></ST>
|
||||
<LineId Id="1171" Count="0" />
|
||||
<LineId Id="845" Count="33" />
|
||||
<LineId Id="1172" Count="0" />
|
||||
<LineId Id="879" Count="33" />
|
||||
<LineId Id="879" Count="4" />
|
||||
<LineId Id="1981" Count="1" />
|
||||
<LineId Id="1991" Count="0" />
|
||||
<LineId Id="1993" Count="12" />
|
||||
<LineId Id="1992" Count="0" />
|
||||
<LineId Id="2006" Count="0" />
|
||||
<LineId Id="2008" Count="15" />
|
||||
<LineId Id="2007" Count="0" />
|
||||
<LineId Id="1983" Count="0" />
|
||||
<LineId Id="884" Count="28" />
|
||||
<LineId Id="1173" Count="0" />
|
||||
<LineId Id="913" Count="29" />
|
||||
<LineId Id="913" Count="28" />
|
||||
<LineId Id="2024" Count="1" />
|
||||
<LineId Id="942" Count="0" />
|
||||
<LineId Id="1174" Count="0" />
|
||||
<LineId Id="943" Count="4" />
|
||||
<LineId Id="1928" Count="3" />
|
||||
<LineId Id="1934" Count="18" />
|
||||
<LineId Id="1955" Count="5" />
|
||||
<LineId Id="1933" Count="0" />
|
||||
<LineId Id="2030" Count="1" />
|
||||
<LineId Id="2033" Count="25" />
|
||||
<LineId Id="2032" Count="0" />
|
||||
<LineId Id="1932" Count="0" />
|
||||
<LineId Id="1520" Count="0" />
|
||||
<LineId Id="1522" Count="17" />
|
||||
<LineId Id="1541" Count="0" />
|
||||
|
||||
Reference in New Issue
Block a user