FB_S_UPS

FB_S_UPS 1:

The function block FB_S_UPS can be used on CX50x0 Embedded PCs with 1-second UPS, in order to control the 1-second UPS from the PLC. In the event of a power failure, this enables the persistent data to be saved and/or a quick shutdown to be executed, depending on the selected mode. The default input values of the FB_S_UPS should be retained.

The 1-second UPS does not have sufficient capacity for bridging power failures. Only the Compact Flash card can be used for data storage, in view of the fact that the UPS capacity is not sufficient for operating a hard disk.

The 1-second UPS can be used only for a few seconds in the event of a power failure in order, 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. Make sure you configure adequate router memory for saving the persistent data.

Irrespective of the mode and irrespective of whether data were saved or the quick shutdown was executed, the 1-second UPS switches off the mainboard after the discharging of the capacitors.

Note

Loss of data

If other applications or the PLC keep further files open or write to them, file errors may occur if the 1-second UPS switches off the controller.

Function block modes

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 eSUPS_ImmediateShutdown mode a quick shutdown 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 function block only switches back to the PowerOK state after the expiry of tRecoverTime (10s).

Application under Windows Embedded Standard 7P

To protect Windows XP Embedded files on devices with 1-second UPS, either the Enhanced Write Filter (EWF) or the File Based Write Filter (FBWF) must be enabled.

Beckhoff EBWF Manager:

FB_S_UPS 2:

FB_S_UPS 3: Inputs

VAR_INPUT
    sNetID          : T_AmsNetId:= ''; (* '' = local netid *)
    iPLCPort        : UINT; (* 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

Name

Type

Description

sNetID

T_AmsNetId

AmsNetId of the controller

iPLCPort

UINT

Port number of the PLC runtime system (851 for the first PLC runtime system, 852 for the second PLC runtime system, etc.). If you do not specify a port number, the function block then automatically determines the port of the PLC runtime system.

iUPSPort

UINT

Port number through which the UPS status is read. The default value is 16#4A8.

tTimeout

TIME

Timeout for writing the persistent data or the quick shutdown.

eUpsMode

E_S_UPS_Mode

Defines whether persistent data are to be written and whether a quick shutdown is to be executed. The default value is eSUPS_WrPersistData_Shutdown, i.e. a quick shutdown is executed automatically once the persistent data have been saved.

ePersistentMode

E_PersistentMode

Mode for writing the persistent data. Default value is SPDM_2PASS.

tRecoverTime

TIME

Time after which the UPS returns to the PowerOK state in UPS modes without quick shutdown. The tRecoverTime must be greater than the maximum charging time for the UPS, otherwise the UPS may discharge too much in the event of short, consecutive power failures, which could result in its charge being insufficient for storing the persistent data.

FB_S_UPS 4: Outputs

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

Name

Type

Description

bPowerFailDetect  

BOOL

TRUE during power failure. FALSE if the supply voltage is present.

eState

E_S_UPS_State

Internal state of the function block

Requirements

Development environment

Target platform

Hardware

PLC libraries to include

TwinCAT v3.1 B4016

CX50x0

1-second UPS

Tc2_SUPS