Function blocks

FUNCTION_BLOCK FB_S_UPS_CX80xx

Function blocks 1:

The FB_S_UPS function block can be used on the CX80xx with the seconds UPS in order to activate the seconds UPS from the PLC. This allows the persistent data to be saved and a quick shutdown to be performed in the event of a power failure. If possible the default values of the INPUTs of the FB_S_UPS should be retained.

Notice

Loss of data

The seconds UPS can be used only for a few seconds in the event of a power failure in order, for example, to save persistent data. The data must be saved in the fast persistent mode "SPDM_2PASS", even though this can lead to real-time violations. Sufficient router memory must be configured for the storage of the persistent data!

The second UPS does not have sufficient capacity for bridging power failures. Saving can take place only on Micro SD cards.

A QuickShutdown is performed automatically in the eSUPS_WrPersistData_Shutdown mode (standard setting) after the storage of the persistent data.

In the eSUPS_WrPersistData_NoShutdown mode only the persistent data are saved, no QuickShutdown is performed.

In the eSUPS_ImmediateShutdown mode a QuickShutdown is executed immediately without saving data.

In the eSUPS_CheckPowerStatus mode only a check is performed as to whether a power failure has occurred. If this is the case, the module only switches back to the PowerOK state after the expiry of tRecoverTime (10s).

Independent of the mode and thus independent of the saving or the shutting down of the controller, the UPS switches the main board off after the capacitors have discharged, even if the voltage has returned in the meantime.

Notice

Caution when using files:

If other applications or the PLC keep other files open or write to them, this can lead to faulty files if the UPS switches off the controller.

VAR_INPUT

VAR_INPUT
    sNetID      : T_AmsNetId := '';           (* '' = local netid *)
    iPLCPort    : UINT := AMSPORT_R0_PLC_RTS1;    (* PLC Runtime System for writing persistent data *)
    iUPSPort    : UINT := 16#4A8;         (* Port for reading Power State of UPS, dafault 16#4A8 *)
    tTimeout    : TIME := DEFAULT_ADS_TIMEOUT;    (* ADS Timeout *)
    eUpsMode    : E_S_UPS_Mode := eSUPS_WrPersistData_Shutdown; (* UPS mode (w/wo writing persistent data, w/wo shutdown) *)
    ePersistentMode : E_PersistentMode := SPDM_2PASS; (* mode for writing persistent data *)
    tRecoverTime    : TIME := T#10s;          (* ON time to recover from short power failure in mode eSUPS_WrPersistData_NoShutdown/eSUPS_CheckPowerStatus *)
END_VAR

E_S_UPS_Mode

sNetID                        : AmsNetID of the controller.

iPLCPort                    : Port number of the PLC runtime system (AMSPORT_R0_PLC_RTS1 = 801, AMSPORT_R0_PLC_RTS2 = 811, AMSPORT_R0_PLC_RTS3 = 821, AMSPORT_R0_PLC_RTS4 = 831).

iUPSPort                    : Port number via which the UPS status is read (standard value is 16#4A8).

tTimeout                    : Timeout for the execution of the QuickShutdown.

eUpsMode                 : The eUpsMode defines whether persistent data are to be written and whether a QuickShutdown is to be performed.
                                       Standard value is eSUPS_WrPersistData_Shutdown, i.e. with writing of the persistent data and then QuickShutdown. See E_S_UPS_Mode.

ePersistentMode     : Mode for the writing of the persistent data. Standard value is SPDM_2PASS.
                                       SPDM_2PASS, all persistent data are saved at once, which can lead to the cycle time being exceeded.
                                       SPDM_VAR_BOOST, here, each persistent variable is written separately; if there is a large amount of persistent data this can accordingly take many cycles. This is not recommended as some data may be lost if the time of the seconds UPS is not sufficient.     

tRecoverTime           : Time after which the UPS reverts to the PowerOK status in the case of UPS modes without shutdown.
                                        The tRecoverTime must be somewhat longer than the maximum holding time of the UPS, since the UPS switches off even when the voltage returns.

VAR_OUTPUT

VAR_OUTPUT
    bPowerFailDetect    : BOOL;        (* TRUE while powerfailure is detected *)
    eState      : E_S_UPS_State;   (* current ups state *)
END_VAR

E_S_UPS_State

bPowerFailDetect  : True during the power failure; False if the supply voltage is present.

eState                       : Internal state of the function block, for values see E_S_UPS_State.

VAR_GLOBAL

VAR_GLOBAL
    eGlobalSUpsState : E_S_UPS_State;    (* current ups state *)
END_VAR

E_S_UPS_State

eGlobalUpsState      : Internal state of the function block as a global copy of the VAR_OUTPUT eState; for values see E_S_UPS_State.

Prerequisites

Development environment

Target platform

Hardware

PLC libraries to be linked

TwinCAT v2.11.0 build 2220 or higher (R3)

ARM

Seconds UPS

TcSystemCX80xx.lib