FB_GetUPSStatus
![FB_GetUPSStatus 1:](Images/png/9007199314219659__Web.png)
Requirements:
- 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.
VAR_INPUT
VAR_INPUT
sNetId : T_AmsNetId;
nPort : T_AmsPort;(* 0 = Windows UPS service / Windows Battery Driver *)
bEnable : BOOL;
END_VAR
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.
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_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 |
---|---|
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. |
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.
Example:
Online data with status information of a UPS:
Requirements
Development environment | Target platform | UPS hardware | PLC libraries to be integrated (category group) |
---|---|---|---|
TwinCAT v3.1.0 | PC or CX (x86, x64, ARM) |
| Tc2_IoFunctions (IO) |