FB_GetUPSStatus

Requirements:
a) The Beckhoff UPS software components are installed.
- Windows 10, Windows 7, Windows Embedded Standard 7 und höher: Configuration dialog under "Start->Programs->Beckhoff->UPS Software Components";
- NT4, Win2K, WinXP, WinXP embedded: Additional tab under "Control Panel->Energy Options->Beckhoff UPS Configuration" or under "Control Panel->Energy Options->UPS";
- Beckhoff CE devices with 24V UPS service are delivered with a special Beckhoff Battery Driver for Windows CE. The driver is included in the standard CE Image;
b) The UPS has been activated and configured. Further information about the UPS activation and configuration can be found in the considering device and UPS software documentation.
- Windows 7, Windows Embedded Standard 7 : Configuration dialog under "Start->Programs->Beckhoff->UPS Software Components";
- NT4, Win2K, WinXP, WinXP embedded: Configuration dialog under "Control Panel->Energy Options->Beckhoff UPS Configuration" or "Control Panel->Energy Options->UPS";
- Windows CE: At delivery time the UPS function is deactivated. The activation is done by execution of RegFiles. Newer images include configuration dialog under "Start->Control Panel->BECKHOFF UPS Configuration".
With the FB_GetUPSStatus function block the PLC can read the status of a UPS hardware. The block is level triggered, which means that the status information 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.
VAR_INPUT
VAR_INPUT
sNetId :T_AmsNetId;
nPort :T_AmsPort; (* 0 = Windows UPS service / Windows Battery driver *)
bEnable :BOOL;
END_VAR
sNetId: It is possible here to provide the AmsNetId of the TwinCAT computer on which the function to be executed. If it is to be run on the local computer, an empty string can be entered.
nPort: ADS port number. Set this value to zero. Other port numbers are reserved for applications in future.
bEnable: If the input is set, the UPS status is read cyclically.
VAR_OUTPUT
VAR_OUTPUT
bValid :BOOL;
bError :BOOL;
nErrId :UDINT;
stStatus :ST_UPSStatus;
END_VAR
bValid: if this output is set, the data in the ST_UPS status 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.
stStatus: structure with the status information of the UPS.
Error Codes | Error description |
---|---|
0x0000 | No error |
0x8001 | UPS configuration error. It is possible that the UPS is not configured correctly or that no UPS is configured at all. |
0x8002 | Communication error. Communication with the UPS was interrupted. |
0x8003 | Error during the reading of the status data. |
![]() | Not every UPS device can supply all the status information. Some devices, for example, cannot supply the BatteryLifeTime or BatteryReplace status. |
Example for a call in FBD:
Online data with status information of UPS:

Requirements
UPS hardware | Target system type | Development environment | PLC libraries to include |
---|---|---|---|
| PC or CX | TwinCAT v2.8.0, Build > 745 TwinCAT v2.9.0, Build > 945 | TcIoFunctions.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically ) |
TwinCAT v3.0 and above | Tc2_IoFunctions |