FUNCTION_BLOCK FB_GetUPSStatus
Requirements:
a) The Beckhoff UPS software components are installed.
- Windows 10, Windows 7, Windows Embedded Standard 7 and higher: 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 and higher: 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_UPSStatus structure are valid (no error occurs at the last read cycle).
bError: This output is set if an error occurs by execution of the function.
nErrId: Supplies the Ads error number or a command specific error code (table) when bError output is set.
stStatus: Structure with the status information of UPS.
Error codes | Error description |
---|---|
0x0000 | no error |
0x8001 | UPS configuration error. Perhaps the UPS is not configured correctly, or no UPS is configured. |
0x8002 | Communication error. The communication to the UPS has been interrupted. |
0x8003 | Error by reading the status data. |
Not all UPS devices are able to deliver status infomation. Some devices can´t deliver e.g BatteryLifeTime or BatteryReplace-Status |
Example for a call in FBD:
Online data with status information of UPS:
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 |