Added Kaco cyclic data exchange change
- Power will now only be written if the requested power changed
This commit is contained in:
@@ -1041,7 +1041,7 @@ _fbTowerLight(
|
||||
END_IF
|
||||
|
||||
|
||||
IF (ABS(_rAutoPowerRequest) < DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) OR _xEMSHeartbeatNotOK THEN
|
||||
IF ((ABS(_rAutoPowerRequest) < DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) OR _xEMSHeartbeatNotOK) AND (NOT GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive) THEN
|
||||
_fbStringReadyTimeout(IN := FALSE);
|
||||
_xEnableString := FALSE;
|
||||
_xCanChangeMode := TRUE;
|
||||
@@ -1231,17 +1231,25 @@ _fbTowerLight(
|
||||
END_IF
|
||||
|
||||
// Restart if possible
|
||||
IF (ABS(_rAutoPowerRequest) > DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) AND (NOT _xStringsErrorActive) AND _xStringsAllInAutomaticMode THEN
|
||||
IF ((ABS(_rAutoPowerRequest) > DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) OR GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive)
|
||||
AND (NOT _xStringsErrorActive) AND _xStringsAllInAutomaticMode THEN
|
||||
_xCanChangeMode := FALSE;
|
||||
IF _rAutoPowerRequest < 0 AND GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus <> E_CHARGE_STATUS.FULL THEN
|
||||
IF (_rAutoPowerRequest < 0 OR GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive) AND GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus <> E_CHARGE_STATUS.FULL THEN
|
||||
_iState := 0;
|
||||
// TODO: Meldung ausgeben, dass Batterie schon voll ist
|
||||
END_IF
|
||||
|
||||
IF _rAutoPowerRequest > 0 AND GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus <> E_CHARGE_STATUS.EMPTY THEN
|
||||
IF (_rAutoPowerRequest > 0 OR GVL_MODBUS.stModbusEMSComm.stModbusReg12.wBMSControlsRegister.stBitmap.bScheduleActive) AND GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus <> E_CHARGE_STATUS.EMPTY THEN
|
||||
_iState := 0;
|
||||
// TODO: Meldung ausgeben, dass Batterie schon leer ist.
|
||||
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
|
||||
_iState := 0;
|
||||
END_IF
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
// Check for errors
|
||||
|
||||
@@ -47,6 +47,7 @@ VAR
|
||||
|
||||
// Internal power command
|
||||
_rPowerInternal : REAL := 0;
|
||||
_rLastPowerInternal : REAL := 0;
|
||||
|
||||
// Enum for requested state
|
||||
_eRequestedState : E_KACO_PCU_REQUESTED_STATE := E_KACO_PCU_REQUESTED_STATE.OFF;
|
||||
@@ -466,7 +467,7 @@ CASE _iStateCyclicData OF
|
||||
IF _eRequestedState <> _eLastRequestedState THEN
|
||||
_iStateCyclicData := 10;
|
||||
ELSE
|
||||
_iStateCyclicData := 20;
|
||||
_iStateCyclicData := 12;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
@@ -500,7 +501,14 @@ CASE _iStateCyclicData OF
|
||||
_tonPollingTimer(IN := TRUE, PT := _timPollingDelay);
|
||||
IF _tonPollingTimer.Q THEN
|
||||
_tonPollingTimer(IN := FALSE);
|
||||
_iStateCyclicData := 12;
|
||||
END_IF
|
||||
|
||||
12: // Check if powercommand changed
|
||||
IF _rPowerInternal <> _rLastPowerInternal THEN
|
||||
_iStateCyclicData := 20;
|
||||
ELSE
|
||||
_iStateCyclicData := 21;
|
||||
END_IF
|
||||
|
||||
20: // Write current power command
|
||||
@@ -526,6 +534,7 @@ CASE _iStateCyclicData OF
|
||||
_iErrorCountWPC := _iErrorCountWPC + 1;
|
||||
_iErrorIDWPC := _fbWritePowerCommand.nErrId;
|
||||
ELSE
|
||||
_rLastPowerInternal := _rPowerInternal;
|
||||
_iCurrentErrorCountWPC := 0;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
Reference in New Issue
Block a user