676 lines
20 KiB
XML
676 lines
20 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
|
|
<POU Name="MAIN" Id="{bbd7302c-91ce-4697-9f4b-743f57ca5819}" SpecialFunc="None">
|
|
<Declaration><![CDATA[PROGRAM MAIN
|
|
VAR
|
|
_xEmergencyStopOk AT %I* : BOOL;
|
|
_xShowAckEmergencyStop AT %Q* : BOOL;
|
|
_xString1DCSafetyOk AT %I* : BOOL;
|
|
_xReleaseErrors : BOOL := TRUE;
|
|
_xReleaseLimitsErrors : BOOL := TRUE;
|
|
_xConfirmAlarms : BOOL;
|
|
_xEnableString : BOOL;
|
|
_xEnableInverter : BOOL;
|
|
|
|
_xCanChangeMode : BOOL := TRUE;
|
|
|
|
{attribute 'OPC.UA.DA' := '0'}
|
|
_afbStrings : ARRAY[0..1] OF FB_String[('String 1'), ('String 2')];
|
|
|
|
_fbInverter : FB_PowerSupplySunspec;
|
|
_stInverterData : ST_SUNSPEC_CURRENT_VALUES;
|
|
|
|
// Variable to detect charge status change
|
|
_eLastChargeStatus : E_CHARGE_STATUS;
|
|
// Variable to detect battery status change
|
|
_eLastBatteryStatus : E_BATTERY_STATUS;
|
|
|
|
// 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;
|
|
|
|
// Flag for zero power indication
|
|
_xNoPowerRequested : BOOL;
|
|
|
|
// Startup delay for error release during plc startup
|
|
_tonStartupDelay : TON := (PT := T#10S);
|
|
|
|
// Small delay for inverter shutdown
|
|
_tonBeginShutdown : TON := (PT := T#30S);
|
|
|
|
// Not all strings in automatic mode
|
|
_fbNoAutomaticModeAlarm : Fb_TcAlarm;
|
|
|
|
// First cycle tag
|
|
_xFirstCycle : BOOL := TRUE;
|
|
|
|
// ADS reader for modbus server data
|
|
_fbADSReader : ADSREAD;
|
|
|
|
// Timer for ADS read
|
|
_timADSReadTimer : TON;
|
|
|
|
// Release manual mode
|
|
_xReleaseManualMode : 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.AUTO_LOCAL;
|
|
|
|
// UPS
|
|
_fbUPS : FB_S_UPS_BAPI;
|
|
|
|
// Safety
|
|
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;
|
|
|
|
// Safety
|
|
_fbSafety : FB_Safety;
|
|
|
|
// DEBUG
|
|
_xRestart : BOOL;
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[// ===============================
|
|
// DEBUG
|
|
IF _xRestart AND (_iState = 1010) THEN
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower := 0;
|
|
_xConfirmAlarms := TRUE;
|
|
END_IF
|
|
|
|
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
|
|
// ===============================
|
|
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;
|
|
_afbStrings[0].Name := 'String 1';
|
|
_afbStrings[1].Name := 'String 2';
|
|
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
|
|
_afbStrings[0](
|
|
stStringModuleVoltageConfig := GVL_CONFIG.stString1VoltageConfig,
|
|
xEnable := _xEnableString,
|
|
xInSafetyCheckMode := _xInSafetyCheckMode,
|
|
stHMIInterface:= GVL_SCADA.stHMIInterface[0],
|
|
xEmergencyStopOk:= _xEmergencyStopOk,
|
|
xReleaseErrors:= _xReleaseErrors AND _tonStartupDelay.Q,
|
|
xReleaseLimitErrors:= _xReleaseLimitsErrors AND _tonStartupDelay.Q,
|
|
xReleaseManualMode := _xReleaseManualMode,
|
|
xConfirmAlarms:= _xConfirmAlarms,
|
|
xResetSafety := xSafetyResterTaster);
|
|
|
|
IF _afbStrings[0].xError THEN
|
|
_xErrorActive := TRUE;
|
|
END_IF
|
|
|
|
// ===============================
|
|
// Hardware reset button part 2
|
|
// ===============================
|
|
_xShowErrorOnButton := _xErrorActive;
|
|
|
|
// HMI Feedback
|
|
GVL_SCADA.stHMIInterface[0].rVoltage := _afbStrings[0].rCurrentVoltage;
|
|
IF _afbStrings[0].eStatus = E_COMPONENT_STATUS.ON THEN
|
|
IF _iState = 30 AND _rPowerInverter > 0 THEN
|
|
GVL_SCADA.stHMIInterface[0].eStatus := E_COMPONENT_STATUS.DISCHARGING;
|
|
ELSIF _iState = 30 AND _rPowerInverter < 0 THEN
|
|
GVL_SCADA.stHMIInterface[0].eStatus := E_COMPONENT_STATUS.CHARGING;
|
|
ELSE
|
|
GVL_SCADA.stHMIInterface[0].eStatus :=_afbStrings[0].eStatus;
|
|
END_IF
|
|
ELSE
|
|
GVL_SCADA.stHMIInterface[0].eStatus :=_afbStrings[0].eStatus;
|
|
END_IF
|
|
|
|
// DEACTIVATED FOR DEBUG REASONS !!!
|
|
// Call inverter
|
|
_fbInverter(
|
|
sInverterIPAddr:= GVL_CONFIG.sInverterIp,
|
|
xEnable:= _xEnableInverter,
|
|
rPower:= _rPowerInverter,
|
|
xReset:= _xConfirmAlarms,
|
|
rMaxBattPower:= DINT_TO_REAL(GVL_CONFIG.diMaxStringDischargePower),
|
|
stCurrentValues => _stInverterData);
|
|
|
|
|
|
// ===============================
|
|
// Read modbus request count
|
|
// ===============================
|
|
_timADSReadTimer(IN := NOT _fbADSReader.BUSY, PT := T#200MS);
|
|
_fbADSReader(
|
|
NETID:= '',
|
|
PORT:= 10500,
|
|
IDXGRP:= 16#2000,
|
|
IDXOFFS:= 1,
|
|
LEN:= 4,
|
|
DESTADDR:= ADR(GVL_MODBUS.stModbusEMSComm.stModbusReg11.udiLifeMessage),
|
|
READ:= _timADSReadTimer.Q,
|
|
TMOUT:= T#1S,
|
|
BUSY=> ,
|
|
ERR=> ,
|
|
ERRID=> );
|
|
|
|
|
|
// ===============================
|
|
// State machine
|
|
// ===============================
|
|
CASE _eBMSControlMode OF
|
|
E_BMS_CONTROL_MODE.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;
|
|
_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
|
|
|
|
GVL_SCADA.xCanChangeControlMode := _xCanChangeMode;
|
|
|
|
_fbSafety();
|
|
|
|
// Reset alarm confirmation
|
|
IF _xConfirmAlarms OR _rtHardwareResetButton.Q THEN
|
|
_xConfirmAlarms := FALSE;
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
<Action Name="SM_AUTO" Id="{b5166e16-4fea-442b-9560-02c156f9a9ad}">
|
|
<Implementation>
|
|
<ST><![CDATA[CASE _iState OF
|
|
0: // Idle
|
|
// Wait for power command
|
|
IF (ABS(_rAutoPowerRequest) > DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) AND _afbStrings[0].xSafetyIntlksOk AND (NOT _afbStrings[0].xError) AND _afbStrings[0].xAllModulesInAutoMode THEN
|
|
_iState := 5;
|
|
_xCanChangeMode := FALSE;
|
|
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
|
|
_xEnableString := TRUE;
|
|
_iState := 10;
|
|
ELSE
|
|
// Set error bitmap flag
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.lwErrorBitmap.0 := 1;
|
|
|
|
// Goto error state
|
|
_iState := 1000;
|
|
END_IF
|
|
|
|
10: // Wait for string to be ready
|
|
IF _afbStrings[0].xReady AND (NOT _afbStrings[0].xError) THEN
|
|
_rPowerInverter := 0.0;
|
|
_xEnableInverter := TRUE;
|
|
_iState := 20;
|
|
END_IF
|
|
|
|
IF _afbStrings[0].xError THEN
|
|
_xEnableInverter := FALSE;
|
|
_xEnableString := FALSE;
|
|
GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic := 0;
|
|
_iState := 45;
|
|
END_IF
|
|
|
|
IF (ABS(_rAutoPowerRequest) < DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) THEN
|
|
_xEnableString := FALSE;
|
|
_iState := 45;
|
|
END_IF
|
|
|
|
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;
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg10.uiActiveParallelMembers := 1;
|
|
_iState := 30;
|
|
END_IF
|
|
|
|
// Check for errors
|
|
IF _afbStrings[0].xError OR _fbInverter.xError THEN
|
|
_xEnableInverter := FALSE;
|
|
_xEnableString := FALSE;
|
|
GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic := 0;
|
|
_iState := 1000;
|
|
END_IF
|
|
|
|
30: // String and inverter enabled
|
|
// Set inverter power to modbus requested power
|
|
_rPowerInverter := _rAutoPowerRequest;//DINT_TO_REAL(GVL_MODBUS.stModbusEMSComm.stModbusReg12.diSetpointActivePower);
|
|
|
|
// Check if the battery should still be active
|
|
IF (_rAutoPowerRequest = 0.0) THEN
|
|
_xNoPowerRequested := TRUE;
|
|
ELSE
|
|
_xNoPowerRequested := FALSE;
|
|
END_IF
|
|
|
|
// Set battery status
|
|
IF _rAutoPowerRequest > 0 THEN
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.DISCHARGING;
|
|
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
|
|
|
|
// Add small delay before shutdown by EMS is detected
|
|
_tonBeginShutdown(IN := _xNoPowerRequested);
|
|
|
|
// shutdown triggered from EMS
|
|
IF _tonBeginShutdown.Q THEN
|
|
_tonBeginShutdown(In := FALSE);
|
|
|
|
// Set inverter to zero power
|
|
_rPowerInverter := 0.0;
|
|
|
|
// Start string shutdown
|
|
_xEnableString := FALSE;
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.UNDEFINED;
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg10.uiActiveParallelMembers := 0;
|
|
_iState := 35;
|
|
END_IF
|
|
|
|
// Shutdown triggered by battery fully charged
|
|
IF GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus = E_CHARGE_STATUS.CHARGING AND (_afbStrings[0].rCurrentVoltage >= GVL_CONFIG.rStringFullyChargedVoltage) THEN
|
|
_tonBeginShutdown(In := FALSE);
|
|
|
|
// Set inverter to zero power
|
|
_rPowerInverter := 0.0;
|
|
|
|
// Start string shutdown
|
|
_xEnableString := FALSE;
|
|
|
|
// Change battery status
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.FULL;
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg10.uiActiveParallelMembers := 0;
|
|
_iState := 35;
|
|
END_IF
|
|
|
|
// Shutdown triggered by battery empty
|
|
IF GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus = E_CHARGE_STATUS.DISCHARGING AND (_afbStrings[0].rCurrentVoltage <= GVL_CONFIG.rStringEmptyVoltage) THEN
|
|
_tonBeginShutdown(In := FALSE);
|
|
|
|
// Set inverter to zero power
|
|
_rPowerInverter := 0.0;
|
|
|
|
// Start string shutdown
|
|
_xEnableString := FALSE;
|
|
|
|
// Change battery status
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.EMPTY;
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg10.uiActiveParallelMembers := 0;
|
|
_iState := 35;
|
|
END_IF
|
|
|
|
// Check for errors
|
|
IF _afbStrings[0].xError OR (NOT _xString1DCSafetyOk) OR _fbInverter.xError THEN
|
|
_xEnableInverter := FALSE;
|
|
_xEnableString := FALSE;
|
|
_tonBeginShutdown(In := FALSE);
|
|
GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic := 0;
|
|
_iState := 45;
|
|
END_IF
|
|
|
|
35: // Wait for string to be in shutdown discharge mode
|
|
IF _afbStrings[0].xInShutdownDischargeMode THEN
|
|
// Check if we are allowed to discharge during shutdown with inverter
|
|
IF GVL_CONFIG.xShutdownDischargeWithInverter THEN
|
|
_iState := 40;
|
|
ELSE
|
|
_rPowerInverter := 0.0;
|
|
_xEnableInverter := FALSE;
|
|
_xEnableString := FALSE;
|
|
GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic := 0;
|
|
_iState := 45;
|
|
END_IF
|
|
END_IF
|
|
|
|
// Check for errors
|
|
IF _afbStrings[0].xError OR _fbInverter.xError THEN
|
|
_xEnableInverter := FALSE;
|
|
_iState := 1000;
|
|
END_IF
|
|
|
|
40: // Wait for inverter discharge done
|
|
IF _afbStrings[0].xShutdownDischargeAllowed THEN
|
|
_rPowerInverter := GVL_CONFIG.rAbsShutdownDischargePower;
|
|
ELSE
|
|
_rPowerInverter := 0.0;
|
|
GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic := 0;
|
|
_xEnableInverter := FALSE;
|
|
_xEnableString := FALSE;
|
|
_xCanChangeMode := TRUE;
|
|
_iState := 45;
|
|
END_IF
|
|
|
|
// Check for errors
|
|
IF _afbStrings[0].xError OR _fbInverter.xError THEN
|
|
_xEnableInverter := FALSE;
|
|
_iState := 1000;
|
|
END_IF
|
|
|
|
45: // Wait for shutdown of string to be done
|
|
IF (NOT _afbStrings[0].xInShutdownDischargeMode) AND _afbStrings[0].xOff THEN
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.OFF;
|
|
_iState := 0;
|
|
END_IF
|
|
|
|
// Restart if possible
|
|
IF (ABS(_rAutoPowerRequest) > DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) AND _afbStrings[0].xSafetyIntlksOk AND (NOT _afbStrings[0].xError) AND _afbStrings[0].xAllModulesInAutoMode THEN
|
|
_iState := 5;
|
|
END_IF
|
|
|
|
// Check for errors
|
|
// IF _afbStrings[0].xError OR _fbInverter.xError THEN
|
|
// _xEnableInverter := FALSE;
|
|
// _iState := 1000;
|
|
//END_IF
|
|
|
|
1000: // Error state
|
|
_xEnableString := FALSE;
|
|
_xEnableInverter := FALSE;
|
|
_rPowerInverter := 0.0;
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.ERROR;
|
|
_iState := 1010;
|
|
|
|
1010: // Wait for reset from error state
|
|
IF (_rAutoPowerRequest = 0.0) AND (NOT _afbStrings[0].xError) AND (NOT _fbInverter.xError) THEN
|
|
// Reset modbus error register
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.lwErrorBitmap := 0;
|
|
|
|
// Reset modbus error flag
|
|
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.OFF;
|
|
|
|
// Goto init state
|
|
_iState := 0;
|
|
|
|
_xCanChangeMode := TRUE;
|
|
END_IF
|
|
END_CASE]]></ST>
|
|
</Implementation>
|
|
</Action>
|
|
<Action Name="SM_CAPACITY_TEST" Id="{705978cf-2798-4a38-8f24-148e2ec1d46e}">
|
|
<Implementation>
|
|
<ST><![CDATA[]]></ST>
|
|
</Implementation>
|
|
</Action>
|
|
<Action Name="SM_MANUAL" Id="{ddef276e-9f4f-4258-b863-d254dd94b701}">
|
|
<Implementation>
|
|
<ST><![CDATA[_xCanChangeMode := _afbStrings[0].xAllModulesInAutoMode;]]></ST>
|
|
</Implementation>
|
|
</Action>
|
|
<Action Name="SM_SAFETY_CHECK" Id="{6d8e5993-cf32-4980-9ea3-c1fbfa4b8601}">
|
|
<Implementation>
|
|
<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
|
|
CASE _iStateSafetyCheck OF
|
|
0: // Idle
|
|
// Wait for power command
|
|
IF _xStartSafetyCheck AND _afbStrings[0].xAllModulesInAutoMode THEN
|
|
_xEnableString := TRUE;
|
|
_xEnableInverter := FALSE;
|
|
_iStateSafetyCheck := 10;
|
|
_xCanChangeMode := FALSE;
|
|
END_IF
|
|
|
|
10: // Wait for string to be ready
|
|
IF _afbStrings[0].xReady AND (NOT _afbStrings[0].xError) THEN
|
|
_iStateSafetyCheck := 30;
|
|
END_IF
|
|
|
|
IF NOT _xStartSafetyCheck THEN
|
|
_xEnableString := FALSE;
|
|
_iStateSafetyCheck := 0;
|
|
END_IF
|
|
|
|
// Check for errors
|
|
IF _afbStrings[0].xError THEN
|
|
_iStateSafetyCheck := 1000;
|
|
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;
|
|
_xCanChangeMode := TRUE;
|
|
END_IF
|
|
|
|
// Check for errors
|
|
IF _afbStrings[0].xError THEN
|
|
_iStateSafetyCheck := 1000;
|
|
END_IF
|
|
|
|
45: // Wait for shutdown of string to be done
|
|
IF _afbStrings[0].xOff THEN
|
|
_iStateSafetyCheck := 0;
|
|
END_IF
|
|
|
|
// Check for errors
|
|
IF _afbStrings[0].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 _afbStrings[0].xError) AND NOT _xStartSafetyCheck THEN
|
|
// Goto init state
|
|
_iStateSafetyCheck := 0;
|
|
|
|
_xCanChangeMode := TRUE;
|
|
END_IF
|
|
END_CASE]]></ST>
|
|
</Implementation>
|
|
</Action>
|
|
<LineIds Name="MAIN">
|
|
<LineId Id="2032" Count="54" />
|
|
<LineId Id="2197" Count="0" />
|
|
<LineId Id="2087" Count="12" />
|
|
<LineId Id="2287" Count="0" />
|
|
<LineId Id="2100" Count="91" />
|
|
<LineId Id="2383" Count="0" />
|
|
<LineId Id="2192" Count="0" />
|
|
<LineId Id="2388" Count="0" />
|
|
<LineId Id="2387" Count="0" />
|
|
<LineId Id="2193" Count="3" />
|
|
<LineId Id="25" Count="0" />
|
|
</LineIds>
|
|
<LineIds Name="MAIN.SM_AUTO">
|
|
<LineId Id="2" Count="4" />
|
|
<LineId Id="195" Count="0" />
|
|
<LineId Id="7" Count="16" />
|
|
<LineId Id="183" Count="1" />
|
|
<LineId Id="182" Count="0" />
|
|
<LineId Id="25" Count="0" />
|
|
<LineId Id="185" Count="1" />
|
|
<LineId Id="189" Count="0" />
|
|
<LineId Id="205" Count="0" />
|
|
<LineId Id="214" Count="0" />
|
|
<LineId Id="187" Count="1" />
|
|
<LineId Id="200" Count="1" />
|
|
<LineId Id="203" Count="1" />
|
|
<LineId Id="202" Count="0" />
|
|
<LineId Id="31" Count="10" />
|
|
<LineId Id="190" Count="0" />
|
|
<LineId Id="216" Count="0" />
|
|
<LineId Id="215" Count="0" />
|
|
<LineId Id="42" Count="18" />
|
|
<LineId Id="62" Count="54" />
|
|
<LineId Id="191" Count="0" />
|
|
<LineId Id="206" Count="0" />
|
|
<LineId Id="117" Count="0" />
|
|
<LineId Id="217" Count="0" />
|
|
<LineId Id="118" Count="10" />
|
|
<LineId Id="207" Count="0" />
|
|
<LineId Id="218" Count="0" />
|
|
<LineId Id="129" Count="5" />
|
|
<LineId Id="192" Count="0" />
|
|
<LineId Id="135" Count="7" />
|
|
<LineId Id="219" Count="0" />
|
|
<LineId Id="143" Count="0" />
|
|
<LineId Id="208" Count="0" />
|
|
<LineId Id="196" Count="0" />
|
|
<LineId Id="144" Count="4" />
|
|
<LineId Id="193" Count="0" />
|
|
<LineId Id="149" Count="7" />
|
|
<LineId Id="209" Count="0" />
|
|
<LineId Id="213" Count="0" />
|
|
<LineId Id="210" Count="2" />
|
|
<LineId Id="157" Count="2" />
|
|
<LineId Id="194" Count="0" />
|
|
<LineId Id="160" Count="19" />
|
|
<LineId Id="198" Count="1" />
|
|
<LineId Id="180" Count="0" />
|
|
<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="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="0" />
|
|
<LineId Id="216" Count="0" />
|
|
<LineId Id="25" Count="0" />
|
|
<LineId Id="39" Count="4" />
|
|
<LineId Id="206" Count="2" />
|
|
<LineId Id="210" Count="0" />
|
|
<LineId Id="209" Count="0" />
|
|
<LineId Id="211" Count="0" />
|
|
<LineId Id="213" Count="2" />
|
|
<LineId Id="212" Count="0" />
|
|
<LineId Id="62" Count="1" />
|
|
<LineId Id="67" Count="1" />
|
|
<LineId Id="202" Count="3" />
|
|
<LineId Id="201" Count="0" />
|
|
<LineId Id="217" 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="1" />
|
|
<LineId Id="218" Count="1" />
|
|
<LineId Id="197" Count="0" />
|
|
<LineId Id="19" Count="0" />
|
|
</LineIds>
|
|
</POU>
|
|
</TcPlcObject> |