WIP: Aktueller stand für fehlersuche Sensorrauschen

This commit is contained in:
Matthias Heisig
2024-05-22 17:43:26 +02:00
parent cf0d144987
commit 0d9a4d9c72
27 changed files with 1667 additions and 824 deletions

View File

@@ -291,10 +291,10 @@ VAR_GLOBAL PERSISTENT
// String fully charged voltage (Volt)
// 960 V -> 80 V per Unit
rStringFullyChargedVoltage : REAL := 950.0;
rStringFullyChargedVoltage : REAL := 960.0;
// String empty voltage (Volt) (617V is needed for the inverter to start up -> 51.4V per Segment)
rStringEmptyVoltage : REAL := 630.0;
// String empty voltage (Volt) (617V is needed for the inverter to start up -> 55.0V per Segment)
rStringEmptyVoltage : REAL := 660.0;
// Unit wait startup time
timUnitStartupTime : TIME := T#1M;

View File

@@ -97,6 +97,9 @@
<Compile Include="POUs\FB_String.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\FB_UMD705.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\FB_Unit.TcPOU">
<SubType>Code</SubType>
</Compile>
@@ -106,6 +109,21 @@
<Compile Include="POUs\Sunspec\FB_PowerSupplySunspec.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\Sunspec\ModelData\ST_SunspecInverterThreePhase.TcDUT">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\Sunspec\ModelData\ST_SunspecNameplateRatings.TcDUT">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\Sunspec\StatePattern\StateEvents\I_SunspecStateEvents.TcIO">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\Sunspec\StatePattern\States\FB_SunspecErrorState.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\Sunspec\StatePattern\States\FB_SunspecOffState.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\Sunspec\ST_SUNSPEC_CURRENT_VALUES.TcDUT">
<SubType>Code</SubType>
</Compile>
@@ -119,6 +137,12 @@
<Folder Include="DUTs\Modbus\HoldingRegisters" />
<Folder Include="GVLs" />
<Folder Include="POUs\Sunspec" />
<Folder Include="POUs\Sunspec\ModelData" />
<Folder Include="POUs\Sunspec\StatePattern">
<ExcludeFromBuild>true</ExcludeFromBuild>
</Folder>
<Folder Include="POUs\Sunspec\StatePattern\StateEvents" />
<Folder Include="POUs\Sunspec\StatePattern\States" />
<Folder Include="VISUs" />
<Folder Include="POUs" />
</ItemGroup>
@@ -185,7 +209,10 @@
<o>
<v n="Name">"{192FAD59-8248-4824-A8DE-9177C94C195A}"</v>
<d n="SubKeys" t="Hashtable" />
<d n="Values" t="Hashtable" />
<d n="Values" t="Hashtable" ckt="String" cvt="String">
<v>CurrentUmlCompilerVersion</v>
<v>4.2.1.0</v>
</d>
</o>
</d>
<d n="Values" t="Hashtable" />

File diff suppressed because one or more lines are too long

View File

@@ -44,6 +44,15 @@ VAR_INPUT
// Inverter enabled status
xInverterEnabled : BOOL;
// Leakage double segment 1/2
xLeakageSegments12 AT %I* : BOOL;
// Leakage double segment 3/4
xLeakageSegments34 AT %I* : BOOL;
// Leakage tank
xLeakageTank AT %I* : BOOL;
END_VAR
VAR_OUTPUT
// Module voltage
@@ -419,7 +428,10 @@ _fbUnit4.Name := CONCAT(_sName, 'Unit 4');
_fbUnitsOutOfBalanceAlarm.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.ModuleImbalance, bWithConfirmation := TRUE, 0);
// Create alarm message
_fbUnitsOutOfBalanceAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
_fbUnitsOutOfBalanceAlarm.ipArguments.Clear().AddString(_sName);
// Create leakage alarm messages
]]></ST>
</Implementation>
</Method>
<Property Name="Name" Id="{bc8bc990-5071-47c9-a928-a129c60c6f41}">
@@ -521,6 +533,9 @@ _fbUnitsOutOfBalanceAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
<LineId Id="19" Count="0" />
<LineId Id="18" Count="0" />
<LineId Id="20" Count="0" />
<LineId Id="42" Count="0" />
<LineId Id="41" Count="0" />
<LineId Id="43" Count="0" />
</LineIds>
<LineIds Name="FB_Module.Name.Get">
<LineId Id="2" Count="0" />

View File

@@ -30,6 +30,9 @@ VAR_INPUT
// All safetyinterlocks from safety plc are ok
xSafetyIntlksOk AT %I* : BOOL;
// Safety communication error
xSafetyComError AT %I* : BOOL;
// Release alarms
xReleaseErrors : BOOL;
@@ -173,6 +176,9 @@ VAR
// Start balancing internal signal
_xStartBalancing : BOOL;
// Internal SOC
_rSOC : REAL;
END_VAR
VAR PERSISTENT
@@ -432,7 +438,13 @@ _tonSafetyOkTimeout();
// of all units
// ===============================
rSmallestSegmentVoltage := MIN(_fbModule1.rSmallestSegmentVoltage, _fbModule2.rSmallestSegmentVoltage, _fbModule3.rSmallestSegmentVoltage);
rHighestSegmentVoltage := MAX(_fbModule1.rSmallestSegmentVoltage, _fbModule2.rSmallestSegmentVoltage, _fbModule3.rSmallestSegmentVoltage);
rHighestSegmentVoltage := MAX(_fbModule1.rHighestSegmentVoltage, _fbModule2.rHighestSegmentVoltage, _fbModule3.rHighestSegmentVoltage);
// Only recalculate SOC if all modules are ready
IF _xAllModulesReady THEN
_rSOC := ((100.0 * rSmallestSegmentVoltage ) / 24.0) - 229.17;
END_IF
// Call inverter
@@ -538,6 +550,8 @@ CASE _iState OF
_iState := 21;
END_IF
IF _tonErrorDCCBNotClosed.Q THEN
_xEnable := FALSE;
xCloseDCCB := FALSE;
_tonErrorDCCBNotClosed.IN := FALSE;
xError := TRUE;
xReady := FALSE;
@@ -565,7 +579,7 @@ CASE _iState OF
_iState := 31;
END_IF
// Inverter error or ttimeout for startup
// Inverter error or timeout for startup
IF _fbInverter.xError OR (NOT xRepairSwitchOk) THEN // _tonInverterStartupTimeout.Q
IF _tonInverterStartupTimeout.Q AND (NOT _fbInverterStartupTimeoutAlarm.bRaised) THEN
_fbInverterStartupTimeoutAlarm.Raise(0);
@@ -574,6 +588,7 @@ CASE _iState OF
_xEnableInverter := FALSE;
xError := TRUE;
xErrorInverter := TRUE;
_xEnable := FALSE;
_tonInverterStartupTimeout(IN := FALSE);
END_IF
@@ -593,9 +608,8 @@ CASE _iState OF
_rPowerInverterInternal := rPowerInverter;
END_IF
// Shutdown
IF NOT xEnable THEN
// _rPowerInverterInternal := 0.0;
// _xEnableInverter := FALSE;
_xEnable := FALSE;
_xReleaseLimitErrorsInternal := FALSE;
IF GVL_CONFIG.xShutdownDischargeWithInverter THEN
@@ -621,6 +635,12 @@ CASE _iState OF
_iState := 32;
END_IF
IF xError THEN
_rPowerInverterInternal := 0.0;
_xEnableInverter := FALSE;
_iState := 40;
END_IF
32: // Shutdown discharge mode
IF xShutdownDischargeAllowed AND GVL_CONFIG.xShutdownDischargeWithInverter AND xSafetyIntlksOk AND (stInverterData.rActDCVoltage > 620.0) THEN
_rPowerInverterInternal := GVL_CONFIG.rAbsShutdownDischargePower;
@@ -779,7 +799,26 @@ _fbSafetyInterlocksNotOkAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
</Set>
</Property>
<LineIds Name="FB_String">
<LineId Id="4873" Count="525" />
<LineId Id="4873" Count="251" />
<LineId Id="5776" Count="0" />
<LineId Id="5775" Count="0" />
<LineId Id="5773" Count="0" />
<LineId Id="5590" Count="0" />
<LineId Id="5125" Count="0" />
<LineId Id="5774" Count="0" />
<LineId Id="5777" Count="0" />
<LineId Id="5126" Count="103" />
<LineId Id="5962" Count="1" />
<LineId Id="5230" Count="35" />
<LineId Id="5964" Count="0" />
<LineId Id="5266" Count="18" />
<LineId Id="5772" Count="0" />
<LineId Id="5285" Count="0" />
<LineId Id="5288" Count="23" />
<LineId Id="5581" Count="2" />
<LineId Id="5585" Count="1" />
<LineId Id="5584" Count="0" />
<LineId Id="5312" Count="86" />
<LineId Id="527" Count="0" />
</LineIds>
<LineIds Name="FB_String.FB_init">

56
PLC/POUs/FB_UMD705.TcPOU Normal file
View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<POU Name="FB_UMD705" Id="{e3557e0d-5497-476d-aba3-e3a1e4ffd057}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_UMD705
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
_xExecute : BOOL;
// FB for reading Modbus holding registers
_fbReadRegister : FB_MBReadRegs;
// FB for writing Modbus holding registers
_fbWriteRegister : FB_MBWriteRegs;
_diLastReset : DINT;
END_VAR
VAR CONSTANT
STATUS_REGISTER : WORD := 40108;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[_fbReadRegister(
sIPAddr:= sInverterIPAddr,
nTCPPort:= 502,
nUnitID:= 16#FF, // 16#FF for Modbus TCP
nQuantity:= 1,
nMBAddr:= STATUS_REGISTER,
cbLength:= SIZEOF(_uiInverterState),
pDestAddr:= ADR(_uiInverterState),
bExecute:= TRUE,
tTimeout:= T#5S,
bBusy=> ,
bError=> ,
nErrId=> ,
cbRead=> );
IF _xExecute THEN
_xExecute := FALSE;
END_IF]]></ST>
</Implementation>
<LineIds Name="FB_UMD705">
<LineId Id="21" Count="0" />
<LineId Id="24" Count="11" />
<LineId Id="23" Count="0" />
<LineId Id="22" Count="0" />
<LineId Id="17" Count="1" />
<LineId Id="9" Count="0" />
<LineId Id="19" Count="1" />
</LineIds>
</POU>
</TcPlcObject>

View File

@@ -402,7 +402,7 @@ _fbPressurePosolytSegmentInlet(
stEWConfig:= stUnitConfig.stEWLPosolytPressureSegmentInlet,
stEWDelayConfig:= stUnitConfig.stEWDPosolytPressureSegmentInlet,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors AND _fbPosolytPumpInlet.IsRunning AND _fbPosolytPumpInlet.xInTarget AND (NOT xStartBalancing),
xReleaseLimitErrors:= xReleaseLimitErrors AND _fbPosolytPumpInlet.IsRunning AND _fbPosolytPumpInlet.xInTarget AND (NOT xStartBalancing) AND (_fbPosolytPumpInlet.rSPautomatic > 40),
xReleaseHardwareErrors:= xReleaseErrors,
xConfirmAlarms:= xConfirmAlarms,
stHMIInterface => stHMIInterface.stP11);
@@ -426,7 +426,7 @@ _fbPressureNegolytSegmentInlet(
stEWConfig:= stUnitConfig.stEWLNegolytPressureSegmentInlet,
stEWDelayConfig:= stUnitConfig.stEWDNegolytPressureSegmentInlet,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors AND _fbNegolytPumpInlet.IsRunning AND _fbNegolytPumpInlet.xInTarget AND (NOT xStartBalancing),
xReleaseLimitErrors:= xReleaseLimitErrors AND _fbNegolytPumpInlet.IsRunning AND _fbNegolytPumpInlet.xInTarget AND (NOT xStartBalancing) AND (_fbNegolytPumpInlet.rSPautomatic > 40),
xReleaseHardwareErrors:= xReleaseErrors,
xConfirmAlarms:= xConfirmAlarms,
stHMIInterface => stHMIInterface.stP21);
@@ -823,6 +823,9 @@ CASE _iState OF
END_IF
35: // Unit in enabled state
_rSetpointNegolytPumpInlet := GVL_CONFIG.rPumpNegolytOnPower;
_rSetpointPosolytPumpInlet := GVL_CONFIG.rPumpPosolytOnPower;
IF (NOT xEnable) THEN
_iState := 40;
END_IF
@@ -1200,7 +1203,9 @@ END_CASE]]></ST>
<LineId Id="257" Count="0" />
<LineId Id="76" Count="0" />
<LineId Id="258" Count="1" />
<LineId Id="77" Count="25" />
<LineId Id="77" Count="13" />
<LineId Id="340" Count="2" />
<LineId Id="91" Count="11" />
<LineId Id="338" Count="0" />
<LineId Id="106" Count="4" />
<LineId Id="231" Count="2" />

View File

@@ -51,6 +51,16 @@ VAR
// Emergency stop not ok alarm
_fbEStopNotOk : FB_TcAlarm;
// String 1 Error Mssage
_fbEtherCATErrorString1 : FB_TcAlarm;
_stECString1ErrSI : FB_TcSourceInfo;
// String 2 Error Mssage
_fbEtherCATErrorString2 : FB_TcAlarm;
_stECString2ErrSI : FB_TcSourceInfo;
// First cycle tag
_xFirstCycle : BOOL := TRUE;
@@ -104,12 +114,18 @@ VAR
// Safety
_fbSafety : FB_Safety;
// String EtherCAT state
_uiEtherCATState AT%I* : UINT;
_wEtherCATState : WORD;
_xEtherCatString1Ok : BOOL;
_xEtherCatString2Ok : BOOL;
// DEBUG
_xRestart : BOOL;
_xDebug : BOOL;
_uiDebugCurrentString : UINT := 1;
_uiDebugCurrentString : UINT := 0;
_ModbusDebugTest : ST_MODBUS_REG_11;
@@ -140,9 +156,21 @@ IF _xFirstCycle THEN
_fbBatteryEmptyMessage.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.BatteryEmpty, 0);
_fbEStopNotOk.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.EmergencyStopNotOk, TRUE, 0);
_stECString1ErrSI.Clear();
_stECString1ErrSI.nId := 1;
_stECString1ErrSI.sName := 'MAIN';
_fbEtherCATErrorString1.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.EthercatStringError, TRUE, _stECString1ErrSI);
_fbEtherCATErrorString1.ipArguments.Clear().AddString('1');
_stECString2ErrSI.Clear();
_stECString2ErrSI.nId := 2;
_stECString2ErrSI.sName := 'MAIN';
_fbEtherCATErrorString2.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.EthercatStringError, TRUE, _stECString2ErrSI);
_fbEtherCATErrorString2.ipArguments.Clear().AddString('2');
END_IF
// Reset error flag
_xErrorActive := FALSE;
// Ack alarms from HMI
@@ -151,6 +179,40 @@ IF GVL_SCADA.stAckAlarmsButton.xRequest THEN
GVL_SCADA.stAckAlarmsButton.xRequest := FALSE;
END_IF
// ===============================
// EtherCAT communication error
// ===============================
_wEtherCATState := UINT_TO_WORD(_uiEtherCATState);
_xEtherCatString1Ok := (_wEtherCATState AND 16#8000) = 0;
_xEtherCatString2Ok := (_wEtherCATState AND 16#2000) = 0;
// String 1 on X1 = Port D = 0x8000
IF (NOT _xEtherCatString1Ok) AND (NOT _fbEtherCATErrorString1.bRaised) THEN
_fbEtherCATErrorString1.Raise(0);
END_IF
IF _fbEtherCATErrorString1.bRaised AND (_xEtherCatString1Ok) THEN
_fbEtherCATErrorString1.Clear(0, FALSE);
END_IF
IF _fbEtherCATErrorString1.eConfirmationState = TcEventConfirmationState.WaitForConfirmation AND _xConfirmAlarms THEN
_fbEtherCATErrorString1.Confirm(0);
END_IF
// String 2 on X2 = Port B = 0x2000
IF (NOT _xEtherCatString2Ok) AND (NOT _fbEtherCATErrorString2.bRaised) THEN
_fbEtherCATErrorString2.Raise(0);
END_IF
IF _fbEtherCATErrorString2.bRaised AND _xEtherCatString2Ok THEN
_fbEtherCATErrorString2.Clear(0, FALSE);
END_IF
IF _fbEtherCATErrorString2.eConfirmationState = TcEventConfirmationState.WaitForConfirmation AND _xConfirmAlarms THEN
_fbEtherCATErrorString2.Confirm(0);
END_IF
// ===============================
// Safety
// ===============================
@@ -212,14 +274,14 @@ _tonStartupDelay(IN := TRUE);
// Call string 1
_afbStrings[0](
stStringModuleVoltageConfig := GVL_CONFIG.stString1VoltageConfig,
xEnable := _xEnableString AND GVL_CONFIG.xDummy,
xStartBalancing := _xStartBalancing AND GVL_CONFIG.xDummy,
xEnable := _xEnableString, //AND GVL_CONFIG.xDummy,
xStartBalancing := _xStartBalancing, // AND GVL_CONFIG.xDummy,
sInverterIP := GVL_CONFIG.sInverterIpString1,
rPowerInverter := _rPowerInverter,
xInSafetyCheckMode := _xInSafetyCheckMode,
stHMIInterface:= GVL_SCADA.stHMIInterface[0],
xEmergencyStopOk:= _xEmergencyStopOk,
xReleaseErrors:= _xReleaseErrors AND _tonStartupDelay.Q AND GVL_CONFIG.xDummy,
xReleaseErrors:= _xReleaseErrors AND _tonStartupDelay.Q AND _xEtherCatString1Ok,
xReleaseLimitErrors:= _xReleaseLimitsErrors AND _tonStartupDelay.Q,
xReleaseManualMode := _xReleaseManualMode,
xConfirmAlarms:= _xConfirmAlarms,
@@ -239,7 +301,7 @@ _afbStrings[1](
xInSafetyCheckMode := _xInSafetyCheckMode,
stHMIInterface:= GVL_SCADA.stHMIInterface[1],
xEmergencyStopOk:= _xEmergencyStopOk,
xReleaseErrors:= _xReleaseErrors AND _tonStartupDelay.Q,
xReleaseErrors:= _xReleaseErrors AND _tonStartupDelay.Q AND _xEtherCatString2Ok,
xReleaseLimitErrors:= _xReleaseLimitsErrors AND _tonStartupDelay.Q,
xReleaseManualMode := _xReleaseManualMode,
xConfirmAlarms:= _xConfirmAlarms,
@@ -443,6 +505,7 @@ END_IF]]></ST>
IF (ABS(_rAutoPowerRequest) < DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) THEN
_xEnableString := FALSE;
_xCanChangeMode := TRUE;
_iState := 45;
END_IF
@@ -479,7 +542,7 @@ END_IF]]></ST>
// Start string shutdown
_xEnableString := FALSE;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.UNDEFINED;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.DISCHARGING;
GVL_MODBUS.stModbusEMSComm.stModbusReg10.uiActiveParallelMembers := 0;
_iState := 35;
END_IF
@@ -533,6 +596,7 @@ END_IF]]></ST>
_xEnableString := FALSE;
_tonBeginShutdown(In := FALSE);
GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic := 0;
_xCanChangeMode := TRUE;
_iState := 45;
END_IF
@@ -579,6 +643,7 @@ END_IF]]></ST>
45: // Wait for shutdown of string to be done
IF (NOT _afbStrings[_uiDebugCurrentString].xInShutdownDischargeMode) AND _afbStrings[_uiDebugCurrentString].xOff THEN
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.OFF;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.UNDEFINED;
_iState := 0;
END_IF
@@ -679,10 +744,13 @@ IF GVL_SCADA.stAutomaticModeHMI.stStartAutoButton.xRequest THEN
END_IF
END_IF
// Sto pif stop button pressed
IF GVL_SCADA.stAutomaticModeHMI.stStopAutoButton.xRequest THEN
_xStartSafetyCheck := FALSE;
END_IF
// State machine
CASE _iStateSafetyCheck OF
0: // Idle
// Wait for start command
@@ -698,6 +766,7 @@ CASE _iStateSafetyCheck OF
_iStateSafetyCheck := 30;
END_IF
// Shutdown
IF NOT _xStartSafetyCheck THEN
_xEnableString := FALSE;
_iStateSafetyCheck := 0;
@@ -739,6 +808,7 @@ CASE _iStateSafetyCheck OF
1000: // Error state
_xEnableString := FALSE;
_rPowerInverter := 0.0;
_xCanChangeMode := TRUE;
_iStateSafetyCheck := 1010;
1010: // Wait for reset from error state
@@ -758,11 +828,31 @@ END_CASE]]></ST>
<LineId Id="2808" Count="0" />
<LineId Id="2813" Count="1" />
<LineId Id="2917" Count="1" />
<LineId Id="3257" Count="0" />
<LineId Id="3442" Count="0" />
<LineId Id="3306" Count="1" />
<LineId Id="3258" Count="0" />
<LineId Id="3260" Count="1" />
<LineId Id="3443" Count="0" />
<LineId Id="3308" Count="1" />
<LineId Id="3259" Count="0" />
<LineId Id="3262" Count="0" />
<LineId Id="2807" Count="0" />
<LineId Id="2805" Count="0" />
<LineId Id="2802" Count="0" />
<LineId Id="2045" Count="0" />
<LineId Id="2932" Count="4" />
<LineId Id="3445" Count="7" />
<LineId Id="3444" Count="0" />
<LineId Id="3264" Count="3" />
<LineId Id="3272" Count="0" />
<LineId Id="3298" Count="1" />
<LineId Id="3282" Count="0" />
<LineId Id="3277" Count="0" />
<LineId Id="3268" Count="2" />
<LineId Id="3274" Count="0" />
<LineId Id="3273" Count="0" />
<LineId Id="3275" Count="1" />
<LineId Id="3279" Count="2" />
<LineId Id="3278" Count="0" />
<LineId Id="3284" Count="11" />
<LineId Id="3283" Count="0" />
<LineId Id="2931" Count="0" />
<LineId Id="2046" Count="5" />
<LineId Id="2920" Count="0" />
@@ -875,7 +965,9 @@ END_CASE]]></ST>
<LineId Id="214" Count="0" />
<LineId Id="187" Count="1" />
<LineId Id="200" Count="1" />
<LineId Id="203" Count="1" />
<LineId Id="203" Count="0" />
<LineId Id="246" Count="0" />
<LineId Id="204" Count="0" />
<LineId Id="202" Count="0" />
<LineId Id="220" Count="0" />
<LineId Id="44" Count="16" />
@@ -890,6 +982,7 @@ END_CASE]]></ST>
<LineId Id="206" Count="0" />
<LineId Id="117" Count="0" />
<LineId Id="217" Count="0" />
<LineId Id="245" Count="0" />
<LineId Id="118" Count="9" />
<LineId Id="207" Count="0" />
<LineId Id="218" Count="0" />
@@ -902,7 +995,9 @@ END_CASE]]></ST>
<LineId Id="225" Count="0" />
<LineId Id="227" Count="2" />
<LineId Id="226" Count="0" />
<LineId Id="151" Count="5" />
<LineId Id="151" Count="3" />
<LineId Id="244" Count="0" />
<LineId Id="155" Count="1" />
<LineId Id="209" Count="0" />
<LineId Id="213" Count="0" />
<LineId Id="210" Count="2" />
@@ -952,7 +1047,11 @@ END_CASE]]></ST>
<LineId Id="242" Count="0" />
<LineId Id="236" Count="0" />
<LineId Id="243" Count="0" />
<LineId Id="237" Count="4" />
<LineId Id="237" Count="0" />
<LineId Id="252" Count="0" />
<LineId Id="249" Count="0" />
<LineId Id="239" Count="2" />
<LineId Id="253" Count="1" />
<LineId Id="17" Count="0" />
<LineId Id="20" Count="3" />
<LineId Id="198" Count="0" />
@@ -961,7 +1060,9 @@ END_CASE]]></ST>
<LineId Id="216" Count="0" />
<LineId Id="25" Count="0" />
<LineId Id="39" Count="4" />
<LineId Id="206" Count="2" />
<LineId Id="206" Count="0" />
<LineId Id="246" Count="0" />
<LineId Id="207" Count="1" />
<LineId Id="210" Count="0" />
<LineId Id="209" Count="0" />
<LineId Id="211" Count="0" />
@@ -981,6 +1082,7 @@ END_CASE]]></ST>
<LineId Id="222" Count="0" />
<LineId Id="177" Count="4" />
<LineId Id="183" Count="0" />
<LineId Id="247" Count="0" />
<LineId Id="185" Count="3" />
<LineId Id="195" Count="1" />
<LineId Id="218" Count="1" />

View File

@@ -886,7 +886,7 @@ CASE _iState OF
sIPAddr:= sInverterIPAddr,
nTCPPort:= 502,
nUnitID:= 16#FF, // 16#FF for Modbus TCP
nQuantity:= 10,
nQuantity:= 22,
nMBAddr:= AC_VALUES_START_REGISTER,
cbLength:= SIZEOF(_awCurrentACValues),
pDestAddr:= ADR(_awCurrentACValues),
@@ -903,11 +903,15 @@ CASE _iState OF
IF NOT _fbReadRegister.bError THEN
// Go back to polling state
_iState := 90;
stCurrentValues.rActACPower := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[0]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[1])));
stCurrentValues.rActACFreq := LREAL_TO_REAL(WORD_TO_UINT(_awCurrentACValues[2]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[3])));
stCurrentValues.rActApparentPower := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[4]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[5])));
stCurrentValues.rActReactivePower := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[6]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[7])));
stCurrentValues.rActPowerFactor := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[8]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[9])));
stCurrentValues.rActACCurrent := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[0]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[4])));
stCurrentValues.rActtACPhaseACurrent := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[1]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[4])));
stCurrentValues.rActtACPhaseBCurrent := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[2]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[4])));
stCurrentValues.rActtACPhaseCCurrent := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[3]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[4])));
stCurrentValues.rActACPower := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[12]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[13])));
stCurrentValues.rActACFreq := LREAL_TO_REAL(WORD_TO_UINT(_awCurrentACValues[14]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[15])));
stCurrentValues.rActApparentPower := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[16]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[17])));
stCurrentValues.rActReactivePower := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[18]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[19])));
stCurrentValues.rActPowerFactor := LREAL_TO_REAL(WORD_TO_INT(_awCurrentACValues[20]) * EXPT(10,WORD_TO_INT(_awCurrentACValues[21])));
ELSE
// Read error register
_iState := 1000;
@@ -1334,9 +1338,9 @@ _fbErrorInverterAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
<LineId Id="1737" Count="0" />
<LineId Id="1739" Count="19" />
<LineId Id="1781" Count="0" />
<LineId Id="1759" Count="2" />
<LineId Id="1774" Count="0" />
<LineId Id="1776" Count="1" />
<LineId Id="1759" Count="0" />
<LineId Id="4066" Count="7" />
<LineId Id="1777" Count="0" />
<LineId Id="1762" Count="4" />
<LineId Id="1738" Count="0" />
<LineId Id="3213" Count="0" />

View File

@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<DUT Name="ST_SunspecInverterThreePhase" Id="{f9acf95c-14fe-4c1e-9c73-dff4af6d43b5}">
<Declaration><![CDATA[// Sunspec register 40.070 - 40.120 (Size 52)
TYPE ST_SunspecInverterThreePhase :
STRUCT
// Model value
uiID : UINT;
// Model length
uiL : UINT;
// AC current. Sum of active phases
iA : INT;
// AC current. Phase A
iAphA : INT;
// AC current. Phase B
iAphB : INT;
// AC current. Phase C
iAphC : INT;
// AC current scaling factor
iASF : INT;
// Phase voltage AB
uiPPVphAB : UINT;
// Phase voltage BC
uiPPVphBC : UINT;
// Phase voltage CA
uiPPVphCA : UINT;
// Phase voltage AN
uiPhVphA : UINT;
// Phase voltage BN
uiPhVphB : UINT;
// Phase voltage CN
uiPhVphC : UINT;
// Phase voltage scaling factor
iVSF : INT;
// AC Power
iW : INT;
// AC power scaling factor
iWSF : INT;
// Line frequency
uiHz : UINT;
// Line frequency scaling factor
iHzSF : INT;
// AC apparent power
iVA : INT;
// AC apparent power scaling factor
iVASF : INT;
// AC reactive power
iVAr : INT;
// AC reactive power scaling factor
iVArSF : INT;
// AC power factor
iPF : INT;
// AC power factor scaling factor
iPFSF : INT;
// AC Energy
udiWH : UDINT;
// AC Energy scaling factor
iWHSF : INT;
// DC current
uiDCA : UINT;
// DC current scaling factor
iDCASF : INT;
// DC voltage
uiDCV : UINT;
// DC voltage scaling factor
iDCVSF : INT;
// DC power
iDCW : INT;
// DC power scaling factor
iDCWSF : INT;
// Cabinet temperature
iTmpCab : INT;
// Heat sink temperature
iTmpSnk : INT;
// Transformer temperature
iTmpTrns : INT;
// Other temperature
iTmpOt : INT;
// Temperature scaling factor
iTmpSF : INT;
// Operating state
wSt : WORD;
// Vendor specific operating state
wStVnd : WORD;
// Bitmask value. Event fields.
dwEvt1 : DWORD;
// Reserved for future use
dwEvt2 : DWORD;
// Vendor defined events 1
dwEvtVnd1 : DWORD;
// Vendor defined events 2
dwEvtVnd2 : DWORD;
// Vendor defined events 3
dwEvtVnd3 : DWORD;
// Vendor defined events 4
dwEvtVnd4 : DWORD;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>

View File

@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<DUT Name="ST_SunspecNameplateRatings" Id="{d43d4b8b-dd50-4ed8-ac51-53563f3eb7b3}">
<Declaration><![CDATA[// Sunspec register 40.122 - 40.149 (Size 28)
TYPE ST_SunspecNameplateRatings :
STRUCT
// Model value
uiID : UINT;
// Model length
uiL : UINT;
// Type of DER device
wDERTyp : WORD;
// Continuous power output capability of the inverter
uiWRtg : UINT;
// Continuous power output capability of the inverter scaling factor
uiWRtgSF : INT;
// Continuous volt-ampere output capability of the inverter
uiVARtg : UINT;
// Continuous volt-ampere output capability of the inverter scaling factor
uiVARtgSF : INT;
// Continuous VAR capability of the inverter in quadrant 1
iVArRtgQ1 : INT;
// Continuous VAR capability of the inverter in quadrant 2
iVArRtgQ2 : INT;
// Continuous VAR capability of the inverter in quadrant 3
iVArRtgQ3 : INT;
// Continuous VAR capability of the inverter in quadrant 4
iVArRtgQ4 : INT;
// Continuous VAR capability of the inverter in quadrant 1-4 scaling factor
iVArRtgSF : INT;
// Maximum RMS AC current level capability of the inverter
uiARtg : UINT;
// Maximum RMS AC current level capability of the inverter scaling factor
uiARtgSF : INT;
// Minimum power factor capability of the inverter in quadrant 1
iPFRtgQ1 : INT;
// Minimum power factor capability of the inverter in quadrant 2
iPFRtgQ2 : INT;
// Minimum power factor capability of the inverter in quadrant 3
iPFRtgQ3 : INT;
// Minimum power factor capability of the inverter in quadrant 4
iPFRtgQ4 : INT;
// Minimum power factor capability of the inverter in quadrant 1-4 scaling factor
iPFRtgSF : INT;
// Nominal energy rating of storage device
uiWHRtg : UINT;
// Nominal energy rating of storage device scaling factor
uiWHRtgSF : INT;
// The usable capacity of the battery
uiAhrRtg : UINT;
// The usable capacity of the battery scaling factor
uiAhrRtgSF : INT;
// Maximum rate of energy transfer into the storage device
uiMaxChaRte : UINT;
// Maximum rate of energy transfer into the storage device scaling factor
uiMaxChaRteSF : INT;
// Maximum rate of energy transfer out of the storage device
uiMaxDisChaRte : UINT;
// Maximum rate of energy transfer out of the storage device scaling factor
uiMaxDisChaRteSF : INT;
// Padding register
wPad : WORD;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<Itf Name="I_SunspecStateEvents" Id="{9f2878c1-5bc9-4cdb-9e46-4b259f381081}">
<Declaration><![CDATA[INTERFACE I_SunspecStateEvents
]]></Declaration>
<Method Name="Error" Id="{506b8d17-6aa9-4aab-bfd8-11f2ebedfcfc}">
<Declaration><![CDATA[METHOD Error : BOOL
VAR_INPUT
END_VAR
]]></Declaration>
</Method>
<Method Name="PowerSetpointChanged" Id="{3dcaeb52-d0ac-4f7e-99ba-b5f155953486}">
<Declaration><![CDATA[METHOD PowerSetpointChanged : BOOL
VAR_INPUT
END_VAR
]]></Declaration>
</Method>
<Property Name="sDescription" Id="{330ef48f-f9ea-4ee7-a639-0ea32e088efd}">
<Declaration><![CDATA[PROPERTY sDescription : STRING]]></Declaration>
<Get Name="Get" Id="{2bcfde01-0834-4a30-8867-40b073885fa2}">
<Declaration><![CDATA[]]></Declaration>
</Get>
</Property>
<Method Name="Start" Id="{f29f72f2-1d04-48a4-8608-368ea20f3369}">
<Declaration><![CDATA[METHOD Start : BOOL
VAR_INPUT
END_VAR
]]></Declaration>
</Method>
</Itf>
</TcPlcObject>

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<POU Name="FB_SunspecErrorState" Id="{32768020-5348-440d-ba86-8c22b89748ca}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_SunspecErrorState IMPLEMENTS I_SunspecStateEvents
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
<Method Name="Error" Id="{179954d6-9aec-4f12-920f-8ebcc939e9f0}">
<Declaration><![CDATA[{warning 'Methodenimplementierung hinzufügen'}
METHOD Error : BOOL
]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
</Method>
<Method Name="PowerSetpointChanged" Id="{13d718a0-4c83-4300-bbaa-e213ad7aa8af}">
<Declaration><![CDATA[{warning 'Methodenimplementierung hinzufügen'}
METHOD PowerSetpointChanged : BOOL
]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
</Method>
<Property Name="sDescription" Id="{d53971e2-a389-4522-ba1a-c5ff9ecf2f10}">
<Declaration><![CDATA[{warning 'Eigenschaftenimplementierung hinzufügen'}
PROPERTY sDescription : STRING
]]></Declaration>
<Get Name="Get" Id="{de420402-9047-4ee6-9fc9-cc905acb4d0f}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[sDescription := 'Inverter has error']]></ST>
</Implementation>
</Get>
</Property>
<Method Name="Start" Id="{2cda83e0-be11-442b-bf87-a7ac125ff2e7}">
<Declaration><![CDATA[{warning 'Methodenimplementierung hinzufügen'}
METHOD Start : BOOL
]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
</Method>
<LineIds Name="FB_SunspecErrorState">
<LineId Id="9" Count="0" />
</LineIds>
<LineIds Name="FB_SunspecErrorState.Error">
<LineId Id="4" Count="0" />
</LineIds>
<LineIds Name="FB_SunspecErrorState.PowerSetpointChanged">
<LineId Id="4" Count="0" />
</LineIds>
<LineIds Name="FB_SunspecErrorState.sDescription.Get">
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="FB_SunspecErrorState.Start">
<LineId Id="4" Count="0" />
</LineIds>
</POU>
</TcPlcObject>

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<POU Name="FB_SunspecOffState" Id="{e011d22f-f815-46e1-94fd-3c9f3920043c}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_SunspecOffState IMPLEMENTS I_SunspecStateEvents
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
<Method Name="Error" Id="{d664cadd-ac2b-4ff0-bcb2-b0337fcba29b}">
<Declaration><![CDATA[{warning 'Methodenimplementierung hinzufügen'}
METHOD Error : BOOL
]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
</Method>
<Method Name="PowerSetpointChanged" Id="{381d5fe1-608f-4100-85b9-2a00e88d6ec8}">
<Declaration><![CDATA[{warning 'Methodenimplementierung hinzufügen'}
METHOD PowerSetpointChanged : BOOL
]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
</Method>
<Property Name="sDescription" Id="{6bb22c27-a09d-421c-ba72-b88d70f45bf4}">
<Declaration><![CDATA[{warning 'Eigenschaftenimplementierung hinzufügen'}
PROPERTY sDescription : STRING
]]></Declaration>
<Get Name="Get" Id="{8e1a3f8b-86f3-43a4-b3ca-5e780a9a61e0}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[sDescription := 'Inverter off']]></ST>
</Implementation>
</Get>
</Property>
<Method Name="Start" Id="{6bd7c404-10c1-4936-a0c8-70f2c38a5fbf}">
<Declaration><![CDATA[{warning 'Methodenimplementierung hinzufügen'}
METHOD Start : BOOL
]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
</Method>
<LineIds Name="FB_SunspecOffState">
<LineId Id="9" Count="0" />
</LineIds>
<LineIds Name="FB_SunspecOffState.Error">
<LineId Id="4" Count="0" />
</LineIds>
<LineIds Name="FB_SunspecOffState.PowerSetpointChanged">
<LineId Id="4" Count="0" />
</LineIds>
<LineIds Name="FB_SunspecOffState.sDescription.Get">
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="FB_SunspecOffState.Start">
<LineId Id="4" Count="0" />
</LineIds>
</POU>
</TcPlcObject>