FB_GetUPSStatus 1:


  • Beckhoff UPS software components have been installed:
    • Windows 7, Windows Embedded Standard 7 and higher: Configuration dialog under "Start->Programs->Beckhoff->UPS Software Components".
    • NT4, Win2K, WinXP, WinXP embedded: Additional tabs under "Control Panel->Power Options->Beckhoff UPS Configuration" or "Control Panel->Power Options->UPS".
    • Beckhoff CE devices with 24V UPS support are delivered with a special Beckhoff Battery Driver for Windows CE. In these devices the driver is included in the standard CE image.
  • The UPS has been activated and configured. You can find more information about UPS configuration in the corresponding advanced UPS software and device documentation.
    • Windows 7, Windows Embedded Standard 7 and higher: Configuration dialog under "Start->Programs->Beckhoff->UPS Software Components".
    • NT4, Win2K, WinXP, WinXP embedded: Configuration dialog under "Control Panel->Power Options->Beckhoff UPS Configuration".
    • Windows CE: By default the UPS function is disabled and must be enabled via a RegFile. Newer images have a configuration dialog under "Start->Control Panel->BECKHOFF UPS Configuration".


The function block FB_GetUPSStatus reads the status of the UPS hardware from the PLC. The function block is level triggered, which means that the status information of the UPS is only cyclically read while the bEnable input is set. To maintain system loading at a low level, the status information is only read approximately every 4.5 s. When the bValid output is set, the most recently read data is valid. The most recent read cycle was, in other words, executed without error. If an error occurs, the read cycle is repeated, and the error signal is automatically reset as soon as the cause of the error (e.g. no communication with the UPS) has been corrected.


    sNetId : T_AmsNetId;
    nPort  : T_AmsPort;(* 0 = Windows UPS service / Windows Battery Driver *)
 bEnable   : BOOL;

sNetId: A string with the network address of the TwinCAT computer whose UPS status is to be read can be entered here (type: T_AmsNetID). If it is to be run on the local computer, an empty string can be entered.

nPort: The ADS port number (type: T_AmsPort). Set this value to zero. Other port numbers are reserved for future applications.

bEnable: The UPS status is read cyclically if this input is set.


    bValid     :BOOL;
    bError     :BOOL;
    nErrId     :UDINT;
    stStatus   :ST_UPSStatus;

bValid: If this output is set, the data in the ST_UPSstatus structure are valid (no error occurred during the last reading cycle).

bError: This output is set if an error occurred when executing the function.

nErrId: Supplies the ADS error number or the command-specific error code (table) when the bError output is set.

Error Codes

Error description


No error


UPS configuration error. It is possible that the UPS is not configured correctly or that no UPS is configured at all.


Communication error. Communication with the UPS was interrupted.


Error during the reading of the status data.

stStatus: Structure with the status information of the UPS (type: ST_UPSStatus).


Not every UPS device can supply all the status information. Some devices, for example, cannot supply the BatteryLifeTime or BatteryReplace status.


Online data with status information of a UPS:

FB_GetUPSStatus 2:



Development environment

Target platform

UPS hardware

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

  • Beckhoff BAPI v1;
  • Beckhoff P24Vxxxx;
  • Beckhoff CP903x card (PCI/ISA);
  • Beckhoff CX2100-09x4 models (e.g. CX2100-0904 or CX2100-0914 + "Smart Battery" CX2900-0192);
  • The APC devices that come supplied with Beckhoff Industrial PC support the Smart protocol and can be configured with the Windows UPS service.

Tc2_IoFunctions (IO)