WIP: Inbetriebnahme vorladen

This commit is contained in:
Matthias Heisig
2024-04-11 19:06:45 +02:00
parent ef26159a4f
commit 9ce3522a70
48 changed files with 23544 additions and 3474 deletions

View File

@@ -4,6 +4,7 @@
<Declaration><![CDATA[PROGRAM MAIN
VAR
_xEmergencyStopOk AT %I* : BOOL;
_xShowAckEmergencyStop AT %Q* : BOOL;
_xReleaseErrors : BOOL := TRUE;
_xReleaseLimitsErrors : BOOL := TRUE;
_xConfirmAlarms : BOOL;
@@ -23,6 +24,13 @@ VAR
// State machine state
_iState : INT;
_iStateSafetyCheck : INT;
// Start safety check mode
_xStartSafetyCheck : BOOL;
// Auto remote and auto local power request
_rAutoPowerRequest : REAL;
// Internal inverter power
_rPowerInverter : REAL;
@@ -64,8 +72,20 @@ VAR
_fbUPS : FB_S_UPS_BAPI;
// Safety
xSafetyRun AT %Q* : BOOL;
xSafetyRun AT %Q* : BOOL := TRUE;
xSafetyErrAck AT %Q* : BOOL;
xSafetyResterTaster AT %I* : BOOL;
// Hardware reset button
_xHarwareResetButton AT %I* : BOOL;
_xShowErrorOnButton AT %Q* : BOOL;
_tonHardwareResetButton : TON := (PT := T#1S);
_rtHardwareResetButton : R_TRIG;
_xErrorActive : BOOL;
// Battery in safety check mode
_xInSafetyCheckMode : BOOL;
// DEBUG
_xRestart : BOOL;
@@ -83,10 +103,22 @@ IF _xRestart AND (_iState = 0) THEN
_xRestart := FALSE;
GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower := 1000;
END_IF
// DEBUG
// ===============================
_xErrorActive := FALSE;
// ===============================
// Safety
// ===============================
xSafetyErrAck := xSafetyResterTaster;
_xShowAckEmergencyStop := NOT _xEmergencyStopOk;
// ===============================
// Hardware reset button part 1
// ===============================
_tonHardwareResetButton(IN := _xHarwareResetButton);
_rtHardwareResetButton(CLK := _tonHardwareResetButton.Q);
_xConfirmAlarms := TRUE;
// ===============================
// Handle Manual mode release
@@ -129,12 +161,23 @@ END_IF
// Call string 1
_fbString(
xEnable := _xEnableString,
xInSafetyCheckMode := _xInSafetyCheckMode,
stHMIInterface:= GVL_SCADA.stHMIInterface,
xEmergencyStopOk:= _xEmergencyStopOk,
xReleaseErrors:= _xReleaseErrors AND _tonStartupDelay.Q,
xReleaseLimitErrors:= _xReleaseLimitsErrors AND _tonStartupDelay.Q,
xReleaseManualMode := _xReleaseManualMode,
xConfirmAlarms:= _xConfirmAlarms);
xConfirmAlarms:= _xConfirmAlarms,
xResetSafety := xSafetyResterTaster);
IF _fbString.xError THEN
_xErrorActive := TRUE;
END_IF
// ===============================
// Hardware reset button part 2
// ===============================
_xShowErrorOnButton := _xErrorActive;
// HMI Feedback
GVL_SCADA.stHMIInterface.rVoltage := _fbString.rCurrentVoltage;
@@ -184,48 +227,50 @@ _fbADSReader(
// ===============================
CASE _eBMSControlMode OF
E_BMS_CONTROL_MODE.AUTO_REMOTE:
SM_AUTO_REMOTE();
_xInSafetyCheckMode := FALSE;
_rAutoPowerRequest := DINT_TO_REAL(GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower);
SM_AUTO();
E_BMS_CONTROL_MODE.AUTO_LOCAL:
_xInSafetyCheckMode := FALSE;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.TESTING;
SM_AUTO_LOCAL();
_rAutoPowerRequest := DINT_TO_REAL(GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic);
SM_AUTO();
E_BMS_CONTROL_MODE.MANUAL:
_xInSafetyCheckMode := FALSE;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.MAINTENANCE;
SM_MANUAL();
E_BMS_CONTROL_MODE.SAFETY_CHECK:
_xInSafetyCheckMode := TRUE;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.MAINTENANCE;
SM_SAFETY_CHECK();
E_BMS_CONTROL_MODE.CAPACITY_TEST:
_xInSafetyCheckMode := FALSE;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.TESTING;
SM_CAPACITY_TEST();
END_CASE
// Reset alarm confirmation
IF _xConfirmAlarms THEN
IF _xConfirmAlarms OR _rtHardwareResetButton.Q 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}">
<Action Name="SM_AUTO" 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
IF (ABS(_rAutoPowerRequest) > DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) AND _fbString.xSafetyIntlksOk AND (NOT _fbString.xError) AND _fbString.xAllModulesInAutoMode THEN
_iState := 5;
END_IF
5: // Check if power command is within limits
IF GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower < GVL_CONFIG.diMaxStringDischargePower
AND GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower > GVL_CONFIG.diMaxStringChargingPower THEN
IF _rAutoPowerRequest < DINT_TO_REAL(GVL_CONFIG.diMaxStringDischargePower)
AND _rAutoPowerRequest > DINT_TO_REAL(GVL_CONFIG.diMaxStringChargingPower) THEN
_xEnableString := TRUE;
_iState := 10;
ELSE
@@ -238,15 +283,12 @@ END_IF]]></ST>
10: // Wait for string to be ready
IF _fbString.xReady AND (NOT _fbString.xError) THEN
_rPowerInverter := 0.0;
_xEnableInverter := TRUE;
_iState := 20;
END_IF
20: // Start main inverter with zero power
_rPowerInverter := 0.0;
_xEnableInverter := TRUE;
_iState := 25;
25: // Wait for inverter to be ready
20: // Wait for inverter to be ready
IF _fbInverter.xActive AND (NOT _fbInverter.xError) THEN
// Set battery status for modbus
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.ACTIVE;
@@ -261,21 +303,20 @@ END_IF]]></ST>
30: // String and inverter enabled
// Set inverter power to modbus requested power
_rPowerInverter := DINT_TO_REAL(GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower);//DINT_TO_REAL(GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower);
_rPowerInverter := _rAutoPowerRequest;//DINT_TO_REAL(GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower);
// Check if the battery should still be active
IF (GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower = 0) THEN
IF (_rAutoPowerRequest = 0.0) THEN
_xNoPowerRequested := TRUE;
ELSE
_xNoPowerRequested := FALSE;
END_IF
// Set battery status
IF GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower > 0 THEN
IF _rAutoPowerRequest > 0 THEN
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.DISCHARGING;
ELSIF GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower < 0 THEN
ELSIF _rAutoPowerRequest < 0 THEN
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.CHARGING;
ELSE
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.UNDEFINED;
END_IF
@@ -385,7 +426,7 @@ END_IF]]></ST>
_iState := 1010;
1010: // Wait for reset from error state
IF (GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower = 0) AND (NOT _fbString.xError) AND (NOT _fbInverter.xError) THEN
IF (_rAutoPowerRequest = 0.0) AND (NOT _fbString.xError) AND (NOT _fbInverter.xError) THEN
// Reset modbus error register
GVL_MODBUS.stModbusEMSComm.stModbusReg11.lwErrorBitmap := 0;
@@ -410,106 +451,115 @@ END_CASE]]></ST>
</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
<ST><![CDATA[// 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>
// stop pumps
CASE _iStateSafetyCheck OF
0: // Idle
// Wait for power command
IF _xStartSafetyCheck THEN
_xEnableString := TRUE;
_xEnableInverter := FALSE;
_iStateSafetyCheck := 10;
END_IF
10: // Wait for string to be ready
IF _fbString.xReady AND (NOT _fbString.xError) THEN
_iStateSafetyCheck := 30;
END_IF
IF NOT _xStartSafetyCheck THEN
_xEnableString := FALSE;
_iStateSafetyCheck := 0;
END_IF
30: // String enabled and dc circuit breaker closed
// Check if the battery should still be active
IF (NOT _xStartSafetyCheck) THEN
// Start string shutdown
_xEnableString := FALSE;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.UNDEFINED;
GVL_MODBUS.stModbusEMSComm.stModbusReg10.uiActiveParallelMembers := 0;
_iStateSafetyCheck := 45;
END_IF
// Check for errors
IF _fbString.xError THEN
_iStateSafetyCheck := 1000;
END_IF
45: // Wait for shutdown of string to be done
IF _fbString.xOff THEN
_iStateSafetyCheck := 0;
END_IF
// Check for errors
IF _fbString.xError THEN
_iStateSafetyCheck := 1000;
END_IF
1000: // Error state
_xEnableString := FALSE;
_xEnableInverter := FALSE;
_rPowerInverter := 0.0;
_iStateSafetyCheck := 1010;
1010: // Wait for reset from error state
IF (NOT _fbString.xError) AND NOT _xStartSafetyCheck THEN
// Goto init state
_iStateSafetyCheck := 0;
END_IF
END_CASE]]></ST>
</Implementation>
</Action>
<LineIds Name="MAIN">
<LineId Id="405" Count="0" />
<LineId Id="395" Count="0" />
<LineId Id="400" Count="0" />
<LineId Id="402" Count="1" />
<LineId Id="399" Count="0" />
<LineId Id="407" Count="0" />
<LineId Id="406" Count="0" />
<LineId Id="408" Count="0" />
<LineId Id="410" Count="0" />
<LineId Id="409" Count="0" />
<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="477" Count="0" />
<LineId Id="397" Count="0" />
<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="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="1426" Count="10" />
<LineId Id="1438" Count="1" />
<LineId Id="1752" Count="0" />
<LineId Id="1723" Count="0" />
<LineId Id="1722" Count="0" />
<LineId Id="1724" Count="1" />
<LineId Id="1728" Count="0" />
<LineId Id="1726" Count="0" />
<LineId Id="1440" Count="0" />
<LineId Id="1737" Count="0" />
<LineId Id="1741" Count="1" />
<LineId Id="1739" Count="0" />
<LineId Id="1738" Count="0" />
<LineId Id="1740" Count="0" />
<LineId Id="1441" Count="41" />
<LineId Id="1853" Count="0" />
<LineId Id="1483" Count="5" />
<LineId Id="1844" Count="0" />
<LineId Id="1747" Count="3" />
<LineId Id="1754" Count="3" />
<LineId Id="1753" Count="0" />
<LineId Id="1489" Count="48" />
<LineId Id="1848" Count="0" />
<LineId Id="1538" Count="3" />
<LineId Id="1849" Count="0" />
<LineId Id="1542" Count="0" />
<LineId Id="1562" Count="0" />
<LineId Id="1543" Count="2" />
<LineId Id="1850" Count="0" />
<LineId Id="1546" Count="3" />
<LineId Id="1851" Count="0" />
<LineId Id="1550" Count="3" />
<LineId Id="1852" Count="0" />
<LineId Id="1554" Count="7" />
<LineId Id="25" Count="0" />
</LineIds>
<LineIds Name="MAIN.SM_AUTO_LOCAL">
<LineId Id="1" Count="0" />
</LineIds>
<LineIds Name="MAIN.SM_AUTO_REMOTE">
<LineId Id="2" Count="178" />
<LineIds Name="MAIN.SM_AUTO">
<LineId Id="2" Count="21" />
<LineId Id="183" Count="1" />
<LineId Id="182" Count="0" />
<LineId Id="25" Count="0" />
<LineId Id="31" Count="29" />
<LineId Id="62" Count="118" />
<LineId Id="1" Count="0" />
</LineIds>
<LineIds Name="MAIN.SM_CAPACITY_TEST">
@@ -519,20 +569,31 @@ END_CASE]]></ST>
<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" />
<LineId Id="20" Count="3" />
<LineId Id="198" Count="1" />
<LineId Id="24" Count="1" />
<LineId Id="39" Count="4" />
<LineId Id="206" Count="2" />
<LineId Id="210" Count="0" />
<LineId Id="209" Count="0" />
<LineId Id="62" Count="1" />
<LineId Id="67" Count="1" />
<LineId Id="202" Count="3" />
<LineId Id="201" Count="0" />
<LineId Id="72" Count="0" />
<LineId Id="131" Count="2" />
<LineId Id="135" Count="1" />
<LineId Id="168" Count="2" />
<LineId Id="172" Count="11" />
<LineId Id="185" Count="3" />
<LineId Id="195" Count="2" />
<LineId Id="19" Count="0" />
</LineIds>
</POU>
</TcPlcObject>