Fixed some bugs and added inverter status to modbus register

- Safety now has a tof of 0,5s for Temp, Voltage and Pressure
- Doppelhöcker now switches powercommand during second phase
This commit is contained in:
Matthias Heisig
2025-09-24 10:10:37 +02:00
parent d882effb35
commit dd82744356
12 changed files with 343 additions and 260 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4026.8">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4026.12">
<DUT Name="ST_MODBUS_REG_11" Id="{7e772293-d4e3-4809-9da8-3d4e0412ede6}">
<Declaration><![CDATA[{attribute 'analysis' := '-33'}
{attribute 'pack_mode' := '1'}
@@ -102,6 +102,30 @@ STRUCT
// Addr: 11.044
lwErrorBitmap : LWORD;
// Addr: 11.048
eInverter1RequestedState : E_KACO_PCU_REQUESTED_STATE;
// Addr: 11.049
eInverter1CurrentState : E_KACO_CURRENT_STATE;
// Addr: 11.050
eInverter1PCUState : E_KACO_PCU_STATE;
// Addr: 11.051
eInverter1PCUError : E_KACO_PCU_ERROR;
// Addr: 11.052
eInverter2RequestedState : E_KACO_PCU_REQUESTED_STATE;
// Addr: 11.053
eInverter2CurrentState : E_KACO_CURRENT_STATE;
// Addr: 11.054
eInverter2PCUState : E_KACO_PCU_STATE;
// Addr: 11.055
eInverter2PCUError : E_KACO_PCU_ERROR;
END_STRUCT
END_TYPE
]]></Declaration>

View File

@@ -183,6 +183,9 @@
<Compile Include="POUs\Sunspec\Kaco\FB_PowerSupplyKaco.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\Sunspec\Kaco\ST_KACO_INFOS.TcDUT">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\Sunspec\Kaco\ST_KACU_PCU.TcDUT">
<SubType>Code</SubType>
</Compile>

File diff suppressed because one or more lines are too long

View File

@@ -496,7 +496,7 @@ END_IF
_fbBalanceNotOkSignal(
xSignal:= NOT _xBalanceOk,
xRelease:= xEnable AND _xAllUnitsReady,
timOnDelay:= T#10S,
timOnDelay:= T#5S,
timOffDelay:= T#5S,
xReleaseSignal=> );
@@ -523,7 +523,7 @@ END_IF
// ===============================
// Module ready validation check
// ===============================
IF _xAllUnitsReady AND _xBalanceOk THEN
IF _xAllUnitsReady AND (NOT _fbBalanceNotOkSignal.xReleaseSignal) THEN
xReady := TRUE;
ELSE
xReady := FALSE;

View File

@@ -129,6 +129,9 @@ VAR_OUTPUT
// Balancing done
xBalancingDone : BOOL;
// Inverter infos for EMS display
stInverterInfos : ST_KACO_INFOS;
END_VAR
VAR
_fbModule1 : FB_Module(CONCAT(Name,' - Module 1'));
@@ -390,7 +393,8 @@ _fbInverter(
rPower:= _rPowerInverterInternal,
xReset:= xConfirmAlarms,
rMaxBattPower:= DINT_TO_REAL(GVL_CONFIG.diMaxStringDischargePower),
stCurrentValues => stInverterData);
stCurrentValues => stInverterData,
stInverterInfos => stInverterInfos);
refuStringErrorsModbus.stBitmap.bInverterError := _fbInverter.xError;
@@ -679,7 +683,7 @@ CASE _iState OF
_iState := 40;
END_IF
ELSIF (NOT _xAllModulesReady) OR (NOT _xBalanceOk) OR (NOT xSafetyIntlksOk) OR (NOT xRepairSwitchOk) OR (_xErrorInternal) THEN
ELSIF (NOT _xAllModulesReady) OR (_fbBalanceNotOkSignal.xReleaseSignal) OR (NOT xSafetyIntlksOk) OR (NOT xRepairSwitchOk) OR (_xErrorInternal) THEN
xError := TRUE;
_xEnable := FALSE;
_rPowerInverterInternal := 0.0;
@@ -1079,8 +1083,8 @@ END_IF
_fbBalanceNotOkSignal(
xSignal:= NOT _xBalanceOk,
xRelease:= xEnable AND _xAllModulesReady,
timOnDelay:= T#10S,
timOffDelay:= T#10S,
timOnDelay:= T#5S,
timOffDelay:= T#5S,
xReleaseSignal=> );
// Signal an error if all units are ready and module is out of balance

View File

@@ -207,6 +207,7 @@ VAR
_xGetPowerMeterData : BOOL;
_rPowerDH : REAL;
_xDHActive : BOOL;
_fbTONDHCycleTime : TON := (PT := T#15M);
// tower light
@@ -486,6 +487,11 @@ GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bTCabinetString1Module2High
GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bTCabinetString1Module3High := _afbStrings[0].xTempCabinetModule3Warning;
GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bTCabinetSCSString1High := _fbTempCabinetSCSString1.xWarningHigh;
// Copy inverter data to Modbus registers
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eInverter1CurrentState := _afbStrings[0].stInverterInfos.eCurrentState;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eInverter1RequestedState := _afbStrings[0].stInverterInfos.eRequestedState;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eInverter1PCUState := _afbStrings[0].stInverterInfos.ePCUState;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eInverter1PCUError := _afbStrings[0].stInverterInfos.ePCUError;
// Call string 2
_afbStrings[1](
@@ -548,6 +554,12 @@ GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bTCabinetString2Module2High
GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bTCabinetString2Module3High := _afbStrings[1].xTempCabinetModule3Warning;
GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bTCabinetSCSString2High := _fbTempCabinetSCSString2.xWarningHigh;
// Copy inverter data to Modbus registers
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eInverter2CurrentState := _afbStrings[1].stInverterInfos.eCurrentState;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eInverter2RequestedState := _afbStrings[1].stInverterInfos.eRequestedState;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eInverter2PCUState := _afbStrings[1].stInverterInfos.ePCUState;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eInverter2PCUError := _afbStrings[1].stInverterInfos.ePCUError;
// ===============================
// Get global string status information
@@ -880,14 +892,21 @@ CASE _eBMSControlMode OF
// Goto error state if a string has an error
IF _xStringsErrorActive THEN
_xDHActive := FALSE;
_iStateDH := 1000;
END_IF
CASE _iStateDH OF
0: // Idle, wait for command
_rAutoPowerRequest := DINT_TO_REAL(GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic);
IF (ABS(_rAutoPowerRequest) > 100.0) THEN
_rPowerDH := _rAutoPowerRequest;
_rPowerDH := DINT_TO_REAL(GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic);
IF (ABS(_rPowerDH) > 100.0) THEN
_xDHActive := TRUE;
_iStateDH := 5;
END_IF
5: // Wait for pre startup
IF _xBatteryActive THEN
_rAutoPowerRequest := _rPowerDH;
_fbTONDHCycleTime(IN := TRUE);
_iStateDH := 10;
END_IF
@@ -904,7 +923,7 @@ CASE _eBMSControlMode OF
20: // First pause
_fbTONDHCycleTime(IN := TRUE);
IF _fbTONDHCycleTime.Q THEN
_rAutoPowerRequest := _rPowerDH;
_rAutoPowerRequest := _rPowerDH * -1;
GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic := REAL_TO_DINT(_rAutoPowerRequest);
_fbTONDHCycleTime(IN := FALSE);
_iStateDH := 30;
@@ -916,6 +935,7 @@ CASE _eBMSControlMode OF
_rAutoPowerRequest := 0;
GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic := 0;
_fbTONDHCycleTime(IN := FALSE);
_xDHActive := FALSE;
_iStateDH := 0;
END_IF
@@ -1019,7 +1039,7 @@ _fbTowerLight(
END_IF
// Wait for power command
IF ((ABS(_rAutoPowerRequest) > DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) OR GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive)
IF ((ABS(_rAutoPowerRequest) > DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) OR GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive OR _xDHActive)
AND (NOT _xStringsErrorActive) AND _xStringsAllInAutomaticMode AND (NOT _xEMSHeartbeatNotOK) THEN
_iState := 5;
_xReleaseInverterPower := FALSE;
@@ -1065,7 +1085,7 @@ _fbTowerLight(
END_IF
IF ((ABS(_rAutoPowerRequest) < DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) OR _xEMSHeartbeatNotOK) AND (NOT GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive) THEN
IF ((ABS(_rAutoPowerRequest) < DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) OR _xEMSHeartbeatNotOK) AND (NOT GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive) AND (NOT _xDHActive) THEN
_fbStringReadyTimeout(IN := FALSE);
_xEnableString := FALSE;
_xCanChangeMode := TRUE;
@@ -1080,7 +1100,7 @@ _fbTowerLight(
_xBatteryActive := TRUE;
// Check if the battery should still be active
IF (_rAutoPowerRequest = 0.0) AND NOT GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive THEN
IF (_rAutoPowerRequest = 0.0) AND ((NOT GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive) OR (NOT _xDHActive)) THEN
_xNoPowerRequested := TRUE;
ELSE
_xNoPowerRequested := FALSE;
@@ -1248,6 +1268,7 @@ _fbTowerLight(
END_IF
45: // Wait for shutdown of string to be done
_xCanChangeMode := TRUE;
IF (NOT _xStringsInSchutdownDischargeMode) AND _xStringsOff THEN
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.OFF;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.UNDEFINED;
@@ -1256,7 +1277,7 @@ _fbTowerLight(
END_IF
// Restart if possible
IF ((ABS(_rAutoPowerRequest) > DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) OR GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive)
IF ((ABS(_rAutoPowerRequest) > DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) OR GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive OR _xDHActive)
AND (NOT _xStringsErrorActive) AND _xStringsAllInAutomaticMode THEN
_xCanChangeMode := FALSE;
IF (_rAutoPowerRequest < 0 OR GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive) AND GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus <> E_CHARGE_STATUS.FULL THEN
@@ -1267,6 +1288,10 @@ _fbTowerLight(
_iState := 0;
END_IF
IF _xDHActive THEN
_iState := 0;
END_IF
IF (_rAutoPowerRequest <> 0 OR GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive) THEN
IF (_rAutoPowerRequest <= 0 AND (GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus <> E_CHARGE_STATUS.FULL))
OR (_rAutoPowerRequest >= 0) AND (GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus <> E_CHARGE_STATUS.EMPTY) THEN

View File

@@ -22,6 +22,9 @@ VAR_OUTPUT
// Current inverter values
stCurrentValues : ST_SUNSPEC_CURRENT_VALUES;
// Inverter infos for EMS display
stInverterInfos : ST_KACO_INFOS;
END_VAR
VAR
// Battery limits
@@ -247,6 +250,13 @@ END_IF
HandleCyclicData();
// Copy inverter states to output
stInverterInfos.eRequestedState := _eRequestedState;
stInverterInfos.eCurrentState := _eCurrentState;
stInverterInfos.ePCUState := _stPCUState.ePCUState;
stInverterInfos.ePCUError := _stPCUState.ePCUError;
// Run state machine
CASE _iState OF
0: // Pre-init phase (no battery limits set)
_fbTONSetBatteryLimits(IN := TRUE);

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4026.12">
<DUT Name="ST_KACO_INFOS" Id="{8a89bb74-fd34-4e8d-a03d-9fc814aadf52}">
<Declaration><![CDATA[TYPE ST_KACO_INFOS :
STRUCT
eRequestedState : E_KACO_PCU_REQUESTED_STATE;
eCurrentState : E_KACO_CURRENT_STATE;
ePCUState : E_KACO_PCU_STATE;
ePCUError : E_KACO_PCU_ERROR;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TargetSystemConfig Crc="518712921" Version="1.5">
<TargetSystemConfig Crc="2395715113" Version="1.5">
<TargetSystemType>HSafetyPLC</TargetSystemType>
<TargetSystemSubType>EL2912</TargetSystemSubType>
<IsExternalDevice>false</IsExternalDevice>
@@ -7,7 +7,7 @@
<TargetSystemObjectName>=STRNG01-15K1 (EL2912)</TargetSystemObjectName>
<SoftwareVersion>01 (V01.04) </SoftwareVersion>
<SerialNumber>4210722</SerialNumber>
<ProjectCRC>48933</ProjectCRC>
<ProjectCRC>31493</ProjectCRC>
<MapProjectCRC>false</MapProjectCRC>
<MapSerialNumber>false</MapSerialNumber>
<VersionNumber>1</VersionNumber>
@@ -19,4 +19,7 @@
<TakeOverSafetyAliasDeviceNamesInProcessImage>true</TakeOverSafetyAliasDeviceNamesInProcessImage>
<TakeOverStandardAliasDeviceNamesInProcessImage>true</TakeOverStandardAliasDeviceNamesInProcessImage>
<BackupRestore Needed="0" Activated="false" RestoreUserAdministration="false" />
<Customizing>
<Group Id="87605930-f4c2-4c12-816d-f0103cb2103d" Value="2" />
</Customizing>
</TargetSystemConfig>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<safetyApplication Crc="2744339254" xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.5.0.0" Id="ff73f95d-f766-4a11-ae64-a777e602935b" name="" mapState="false" mapDiag="false" groupOrderId="2" passificationAllowed="false" temporaryDeactivationAllowed="true" permamentDeactivationAllowed="true" xmlid="0" analogFBOutputReplacementValues="Zero" verifyAnalogFBInputsIfStart="false" userFbId="00000000-0000-0000-0000-000000000000" xmlns="http://schemas.microsoft.com/dsltools/SafetyApplicationLanguage">
<safetyApplication Crc="2261407596" xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.5.0.0" Id="ff73f95d-f766-4a11-ae64-a777e602935b" name="" mapState="false" mapDiag="false" groupOrderId="2" passificationAllowed="false" temporaryDeactivationAllowed="true" permamentDeactivationAllowed="true" xmlid="0" analogFBOutputReplacementValues="Zero" verifyAnalogFBInputsIfStart="false" userFbId="00000000-0000-0000-0000-000000000000" xmlns="http://schemas.microsoft.com/dsltools/SafetyApplicationLanguage">
<networks>
<safetyApplicationHasNetworks Id="45bf57f5-e212-45c3-b2ae-b56f389355ac">
<Network Id="26c2246b-bba3-4c4b-ab9b-0ae03bc71b34" name="Network1" networkName="Network1" intId="1" networkOrderId="0">
@@ -321,7 +321,7 @@
</inPorts>
<outPorts>
<functionBlockHasOutPorts Id="66238260-1e54-470d-a6e5-7ead2b1ea587">
<outPort Id="a0805043-5c56-4913-817c-3f43efb32a17" name="TofOut" portName="TofOut" portNum="4" objectIndex="1" varId="4" filter="6" portDataType="1" replacementValue="0">
<outPort Id="a0805043-5c56-4913-817c-3f43efb32a17" name="TofOut" portName="TofOut" portNum="4" objectIndex="1" varId="4" filter="6" portDataType="1" replacementValue="1">
<fbPortGlobalVariableReferences>
<functionBlockPortHasFbPortGlobalVariableReferences Id="4d9db7c2-97a2-445c-9ab7-b94f3f84773b">
<fbPortGlobalVariableReference Id="e230eea8-d76f-42e9-a102-6263ce922507" variableId="22c6bbd9-e70f-41fa-baec-6d281eb53a94" lastKnownPath="GVL1.xTempOk" />

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<safetyApplication Crc="4008380785" xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.5.0.0" Id="87605930-f4c2-4c12-816d-f0103cb2103d" name="" mapState="false" mapDiag="false" groupOrderId="0" passificationAllowed="false" temporaryDeactivationAllowed="true" permamentDeactivationAllowed="true" xmlid="0" analogFBOutputReplacementValues="Zero" verifyAnalogFBInputsIfStart="false" userFbId="00000000-0000-0000-0000-000000000000" xmlns="http://schemas.microsoft.com/dsltools/SafetyApplicationLanguage">
<safetyApplication Crc="4179604175" xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.5.0.0" Id="87605930-f4c2-4c12-816d-f0103cb2103d" name="" mapState="false" mapDiag="false" groupOrderId="0" passificationAllowed="false" temporaryDeactivationAllowed="true" permamentDeactivationAllowed="true" xmlid="0" analogFBOutputReplacementValues="Zero" verifyAnalogFBInputsIfStart="false" userFbId="00000000-0000-0000-0000-000000000000" xmlns="http://schemas.microsoft.com/dsltools/SafetyApplicationLanguage">
<networks>
<safetyApplicationHasNetworks Id="441dd36d-89fa-47c9-80b9-44936b1aca22">
<Network Id="7e322be9-60c8-4483-9173-14be8a768464" name="Network1" networkName="Network1" intId="1" networkOrderId="0">
@@ -291,7 +291,7 @@
</inPorts>
<outPorts>
<functionBlockHasOutPorts Id="39f7ef71-b5fb-492f-94d7-8126e87ff3eb">
<outPort Id="1de57bce-7cfa-4016-9d8c-8857fff990b2" name="TofOut" portName="TofOut" portNum="4" objectIndex="1" varId="4" filter="6" portDataType="1" replacementValue="0">
<outPort Id="1de57bce-7cfa-4016-9d8c-8857fff990b2" name="TofOut" portName="TofOut" portNum="4" objectIndex="1" varId="4" filter="6" portDataType="1" replacementValue="1">
<fbPortGlobalVariableReferences>
<functionBlockPortHasFbPortGlobalVariableReferences Id="a6937e68-a9fd-4f79-92c9-8fff0515b4fe">
<fbPortGlobalVariableReference Id="ad292a88-2281-4281-9762-41cc07a2fec6" variableId="94a2e745-de6b-4604-bf45-a58bb35b124e" lastKnownPath="GVL1.xVoltageOK" />

View File

@@ -263,7 +263,7 @@
</System>
<Plc>
<Project GUID="{9AE64910-5EB2-4866-93FD-EFE059C38C36}" Name="PLC" PrjFilePath="PLC\PLC.plcproj" TmcFilePath="PLC\PLC.tmc" ReloadTmc="true" AmsPort="851" FileArchiveSettings="#x000e" CopyTmcToTarget="true" CopyTpyToTarget="false" SymbolicMapping="true">
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcHash="{A12F560C-1648-A72A-B399-409FD1F42B6E}" TmcPath="PLC\PLC.tmc">
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcHash="{6789674A-C83D-5D1A-BF00-40D98F100E42}" TmcPath="PLC\PLC.tmc">
<Name>PLC Instance</Name>
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
<Vars VarGrpType="2" AreaNo="1">