IBN changes

added sync units for cabinet temperature, changes in modbus interface to EMS (1.0.4 and 1.0.5), added error counter to modbus communication, lot of changes to kaco (faults, consecutive errors, bms error messages), isolation error ledge, allowed startbalancing when on shutdown, tower light integration
This commit is contained in:
Markus.Neukirch
2025-09-05 14:24:37 +02:00
parent 69749409a3
commit f0e6143997
33 changed files with 1321 additions and 955 deletions

View File

@@ -5,6 +5,8 @@
VAR
_xEmergencyStopOk AT %I* : BOOL;
_xShowAckEmergencyStop AT %Q* : BOOL;
xNAProtectionOK AT %I* : BOOL;
_xNAProtectionTripped : BOOL := FALSE;
_xReleaseErrors : BOOL := TRUE;
_xReleaseLimitsErrors : BOOL := TRUE;
_xConfirmAlarms : BOOL;
@@ -46,7 +48,7 @@ VAR
_tonStartupDelay : TON := (PT := T#10S);
// Small delay for inverter shutdown
_tonBeginShutdown : TON := (PT := T#30S);
_tonBeginShutdown : TON := (PT := T#10S);
// Not all strings in automatic mode
_fbNoAutomaticModeAlarm : FB_TcAlarm;
@@ -65,6 +67,9 @@ VAR
// EMS heartbeat alarm
_fbEMSHeartbeatAlarm : FB_TcAlarm;
// NA Protection Alarm
_fbNAProtectionAlarm : FB_TcAlarm;
// First cycle tag
_xFirstCycle : BOOL := TRUE;
@@ -114,6 +119,7 @@ VAR
_rtHardwareResetButton : R_TRIG;
_xErrorActive : BOOL;
_xWarningActive : BOOL;
// Battery in safety check mode
_xInSafetyCheckMode : BOOL;
@@ -188,6 +194,9 @@ VAR
_rPowerDH : REAL;
_fbTONDHCycleTime : TON := (PT := T#15M);
// tower light
_fbTowerLight : FB_TowerLight;
END_VAR
]]></Declaration>
<Implementation>
@@ -216,11 +225,16 @@ END_VAR
_afbStrings[1].Name := 'String 2';
_fbEMSHeartbeatAlarm.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.EMSHeartbeatTimeout, TRUE, 0);
_fbNAProtectionAlarm.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.NAProtectionTripped, TRUE, 0);
END_IF
// Reset error flag
_xErrorActive := FALSE;
// Reset warning flag
_xWarningActive := FALSE;
// Ack alarms from HMI
_xConfirmAlarms := GVL_SCADA.stAckAlarmsButton.xRequest;
IF GVL_SCADA.stAckAlarmsButton.xRequest THEN
@@ -298,6 +312,34 @@ END_IF
GVL_MODBUS.stBMSErrorReg.wBMSErrorActive.stBitmap.bEStop := (NOT _xEmergencyStopOk) OR _fbEStopNotOk.bRaised OR (_fbEStopNotOk.eConfirmationState <> TcEventConfirmationState.Confirmed);
// ===============================
// handle NA Protection
// ===============================
IF _xConfirmAlarms THEN
_xNAProtectionTripped := FALSE;
END_IF
IF NOT xNAProtectionOK THEN
_xNAProtectionTripped := TRUE;
IF NOT _fbNAProtectionAlarm.bRaised THEN
_fbNAProtectionAlarm.Raise();
END_IF
END_IF
IF _xNAProtectionTripped THEN
_xErrorActive := TRUE;
END_IF
IF xNAProtectionOK AND _fbNAProtectionAlarm.bRaised THEN
_fbNAProtectionAlarm.Clear(0, FALSE);
END_IF
IF _fbNAProtectionAlarm.eConfirmationState = TcEventConfirmationState.WaitForConfirmation AND _xConfirmAlarms THEN
_fbNAProtectionAlarm.Confirm(0);
END_IF
GVL_MODBUS.stBMSErrorReg.wBMSErrorActive.stBitmap.bNAProtectionTripped := _xNAProtectionTripped;
// ===============================
// Hardware reset button part 1
// ===============================
@@ -356,13 +398,17 @@ IF _fbTempCabinetBMS.xWarningHigh THEN
GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bTCabinetBMSHigh := TRUE;
END_IF
IF _fbTempCabinetBMS.xWarning THEN
_xWarningActive := TRUE;
END_IF
IF _fbTempCabinetBMS.xError THEN
_xErrorActive := TRUE;
END_IF
// Call string 1
_afbStrings[0](
xEnable := _xEnableString AND GVL_CONFIG.axStringEnabled[0],
xEnable := _xEnableString AND GVL_CONFIG.axStringEnabled[0] AND xNAProtectionOK,
xReleaseInverterPower := _xReleaseInverterPower,
uiStringNumber := 0,
eOperationMode := _eStringOpMode,
@@ -378,7 +424,12 @@ _afbStrings[0](
xReleaseManualMode := _xReleaseManualMode,
xConfirmAlarms:= _xConfirmAlarms,
xAllToManualMode := _xAllComponentsToManualMode,
xResetSafety := xSafetyResterTaster);
xResetSafety := xSafetyResterTaster,
refuStringErrorsModbus := GVL_MODBUS.stBMSErrorReg.wString1ErrorActive);
IF _afbStrings[0].xWarning THEN
_xWarningActive := TRUE;
END_IF
IF _afbStrings[0].xError THEN
_xErrorActive := TRUE;
@@ -396,6 +447,10 @@ _fbTempCabinetSCSString1(
xReleaseHardwareErrors:= _xReleaseErrors,
xConfirmAlarms:= _xConfirmAlarms,
stHMIInterface=> GVL_SCADA.stHMIInterface[0].stTempCabinetSCS);
IF _fbTempCabinetSCSString1.xWarning THEN
_xWarningActive := TRUE;
END_IF
IF _fbTempCabinetSCSString1.xError THEN
_xErrorActive := TRUE;
@@ -405,7 +460,7 @@ END_IF
// Handle string 1 modbus error and warning
GVL_MODBUS.stBMSErrorReg.wStringErrorActive.0 := _afbStrings[0].xError;
GVL_MODBUS.stBMSErrorReg.wStringWarningActive.0 := _afbStrings[0].xWarning;
GVL_MODBUS.stBMSErrorReg.wBMSErrorActive.stBitmap.bDCSwitchS1 := (NOT _afbStrings[0].xRepairSwitchOk);
GVL_MODBUS.stBMSErrorReg.wString1ErrorActive.stBitmap.bDCSwitch := (NOT _afbStrings[0].xRepairSwitchOk);
GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bSafetyIntlkString1 := (NOT _afbStrings[0].xSafetyIntlksOk);
GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bTCabinetString1Module1High := _afbStrings[0].xTempCabinetModule1Warning;
GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bTCabinetString1Module2High := _afbStrings[0].xTempCabinetModule2Warning;
@@ -415,7 +470,7 @@ GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bTCabinetSCSString1High := _
// Call string 2
_afbStrings[1](
xEnable := _xEnableString AND GVL_CONFIG.axStringEnabled[1],
xEnable := _xEnableString AND GVL_CONFIG.axStringEnabled[1] AND xNAProtectionOK,
xReleaseInverterPower := _xReleaseInverterPower,
uiStringNumber := 1,
eOperationMode := _eStringOpMode,
@@ -431,8 +486,13 @@ _afbStrings[1](
xReleaseManualMode := _xReleaseManualMode,
xConfirmAlarms:= _xConfirmAlarms,
xAllToManualMode := _xAllComponentsToManualMode,
xResetSafety := xSafetyResterTaster);
xResetSafety := xSafetyResterTaster,
refuStringErrorsModbus := GVL_MODBUS.stBMSErrorReg.wString2ErrorActive);
IF _afbStrings[1].xWarning THEN
_xWarningActive := TRUE;
END_IF
IF _afbStrings[1].xError THEN
_xErrorActive := TRUE;
END_IF
@@ -450,6 +510,10 @@ _fbTempCabinetSCSString2(
xConfirmAlarms:= _xConfirmAlarms,
stHMIInterface=> GVL_SCADA.stHMIInterface[1].stTempCabinetSCS);
IF _fbTempCabinetSCSString2.xWarning THEN
_xWarningActive := TRUE;
END_IF
IF _fbTempCabinetSCSString2.xError THEN
_xErrorActive := TRUE;
END_IF
@@ -457,7 +521,7 @@ END_IF
// Handle string 1 modbus error and warning
GVL_MODBUS.stBMSErrorReg.wStringErrorActive.1 := _afbStrings[1].xError;
GVL_MODBUS.stBMSErrorReg.wStringWarningActive.1 := _afbStrings[1].xWarning;
GVL_MODBUS.stBMSErrorReg.wBMSErrorActive.stBitmap.bDCSwitchS2 := (NOT _afbStrings[1].xRepairSwitchOk);
GVL_MODBUS.stBMSErrorReg.wString2ErrorActive.stBitmap.bDCSwitch := (NOT _afbStrings[1].xRepairSwitchOk);
GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bSafetyIntlkString2 := (NOT _afbStrings[1].xSafetyIntlksOk);
GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bTCabinetString2Module1High := _afbStrings[1].xTempCabinetModule1Warning;
GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bTCabinetString2Module2High := _afbStrings[1].xTempCabinetModule2Warning;
@@ -669,7 +733,6 @@ FOR _ui := 0 TO (GVL_CONFIG.uiNumberOfStrings-1) DO
GVL_MODBUS.stModbusEMSComm.stModbusReg11.diTotalACCurrentPhase3 := GVL_MODBUS.stModbusEMSComm.stModbusReg11.diTotalACCurrentPhase3 + REAL_TO_DINT(_afbStrings[_ui].stInverterData.rActtACPhaseCCurrent);
END_FOR
// Set Modbus mirror values
GVL_MODBUS.stModbusEMSComm.stModbusReg11.diSetpointActivePowerMirror := GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.rSetpointCosPhiMirror := GVL_MODBUS.stModbusEMSComm.stModbusReg12.rSetpointCosPhi;
@@ -887,7 +950,7 @@ END_IF
// Call safety fb
_fbSafety();
_fbSafety(refuStringErrorsModbus := GVL_MODBUS.stBMSErrorReg.wBMSErrorActive);
// Check if all modules are in auto mode
IF _xStringsInAutoMode AND _fbNoAutomaticModeAlarm.bRaised THEN
@@ -909,10 +972,19 @@ END_IF
IF _xConfirmAlarms OR _rtHardwareResetButton.Q THEN
GVL_MODBUS.stBMSErrorReg.wBMSErrorActive.wRegister := 0;
GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.wRegister := 0;
GVL_MODBUS.stBMSErrorReg.wString1ErrorActive.wRegister := 0;
GVL_MODBUS.stBMSErrorReg.wString2ErrorActive.wRegister := 0;
_xConfirmAlarms := FALSE;
END_IF
_fbPowerMeter24V();]]></ST>
_fbPowerMeter24V();
_fbTowerLight(
xAutoInStop := FALSE,
xWarningActive := FALSE,
xWarningConfirmPending := FALSE,
xErrorActive := _xErrorActive,
xErrorConfirmPending := FALSE);]]></ST>
</Implementation>
<Action Name="SM_AUTO" Id="{b5166e16-4fea-442b-9560-02c156f9a9ad}">
<Implementation>
@@ -924,7 +996,8 @@ _fbPowerMeter24V();]]></ST>
END_IF
// Wait for power command
IF (ABS(_rAutoPowerRequest) > DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) AND (NOT _xStringsErrorActive) AND _xStringsAllInAutomaticMode AND (NOT _xEMSHeartbeatNotOK) THEN
IF ((ABS(_rAutoPowerRequest) > DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) OR GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive)
AND (NOT _xStringsErrorActive) AND _xStringsAllInAutomaticMode AND (NOT _xEMSHeartbeatNotOK) THEN
_iState := 5;
_xReleaseInverterPower := FALSE;
_xCanChangeMode := FALSE;
@@ -932,8 +1005,8 @@ _fbPowerMeter24V();]]></ST>
END_IF
5: // Check if power command is within limits
IF _rAutoPowerRequest < DINT_TO_REAL(GVL_CONFIG.diMaxStringDischargePower)
AND _rAutoPowerRequest > DINT_TO_REAL(GVL_CONFIG.diMaxStringChargingPower) THEN
IF _rAutoPowerRequest <= DINT_TO_REAL(GVL_CONFIG.diMaxStringDischargePower)
AND _rAutoPowerRequest >= DINT_TO_REAL(GVL_CONFIG.diMaxStringChargingPower) THEN
_xEnableString := TRUE;
_xStartBalancing := FALSE;
_iState := 10;
@@ -981,7 +1054,7 @@ _fbPowerMeter24V();]]></ST>
_xReleaseInverterPower := TRUE;
// Check if the battery should still be active
IF (_rAutoPowerRequest = 0.0) THEN
IF (_rAutoPowerRequest = 0.0) AND NOT GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive THEN
_xNoPowerRequested := TRUE;
ELSE
_xNoPowerRequested := FALSE;