Overview

The UPS support will be configured differently depending on the operating system and the UPS hardware and software used. The UPS support can be configured either via the TwinCAT or the Windows UPS service. The TwinCAT UPS service offers support for the following devices:

  • 230V UPS devices on the serial interface (APC or Effekta) with basic signalling under Win NT;
  • Beckhoff IPCs with integrated 24V UPS at the CP9030 card under Win NT and Win 2000;
  • Beckhoff IPCs with integrated 24V UPS at the COM interface under Win NT;

The following sections describe the mode of operating and configuration of the different UPS types.

1. General information about the Windows UPS service

  • Basic signalling under NT 4.0 and ASCII communication under Win2K/XP

  • Different cable and signalling types;

2. APC

  • 2.1 APC configuration under NT4.0

  • 2.2 APC configuration under Win2K/XP

3. Integrated UPS of the Beckhoff IPCs

  • 3.1 24V UPS at the CP9030 card under NT4.0/Win2K/XP

  • 3.1.1 Configuration via Windows UPS service

  • 3.1.2 Configuraiton via TwinCAT UPS service

  • 3.1.3 Configuration via ActiveX control CP9090-S100

  • 3.2 24V UPS at the COM interface

  • 3.2.1 Configuration via TwinCAT UPS service under NT4.0

  • 3.2.2 Configuration via TwinCAT UPS service under Win2K/XP

  • 3.2.3 Configuration via NT4.0 UPS service

  • 3.2.4 Configuration via Win2K/XP UPS service

4. FAQ

  • 230 V UPS, Win 2000 and TwinCAT. Points to note.

  • 230 V UPS, Win NT and TwinCAT. Upgrading to Win 2000 with existing application. Points to note.

  • 230 V UPS, Win NT and TwinCAT. Upgrading to later TwinCAT version with existing application. Points to note.

  • 24 V UPS, Win 2000 and TwinCAT. Points to note.

  • 24 V UPS, Win NT and TwinCAT. Upgrading to Win 2000 with existing application. Points to note.

  • 24 V UPS, Win NT and TwinCAT. Upgrading to later TwinCAT version with existing application. Points to note.

  • After updating from Win NT to Win 2000, my visualisation hangs after a shutdown through the Win 2000 UPS service. This was not the case under NT 4.0.

  • After updating from Win NT to Win 2000, my visualisation hangs after a shutdown from the Start menu in the task bar. This was not the case under NT 4.0.


Basic signalling under NT4.0 and ASCII communication under Win2K/XP

The Windows UPS service communicates with the UPS equipment via the serial COM interface. Under Windows NT 4.0, the status of the UPS is detected through the signal levels at the pins of the serial interface. This type of communication with the UPS is also called basic signalling (or simple signalling). In case of supply voltage failure, the level of certain pins will be set to High or Low. The levels can be configured in the NT 4.0 UPS configuration dialogue. Whether the UPS has a High or Low pin signal level in the inactive state will vary from device to device. Details can be found in the device documentation.

Advanced signalling was introduced with Windows 2000. However, basic signalling will continue to be supported. With advanced signalling, the operating system can maintain ASCII communication with the UPS via a serial interface. This enables expanded UPS status information to be determined. Compared with basic signalling, ASCII communication has the following main advantages:

  • The user no longer has to configure the pin polarity;
  • The expected service life/capacity of the battery can easily be determined.

The following diagram shows the UPS status, the UPS signals transmitted to the operating system and the response of the operating system to UPS messages. The process is identical for basic and advanced mode:

In case of failure of the power supply, the UPS will send a Power fail signal to the operating system and switch to battery operation. The operating system can send messages (notifications) at configurable intervals to a user or a group of users. If the so-called Critical alarm is reached during battery operation (UPS reports Low battery or the configured On battery time has expired), a task (user application/batch file) may be called. Subsequently, a shutdown of the operating system is initiated. During initiation of the shutdown, the UPS may be configured in such a way that it will switch itself off after a certain delay (Remote OFF) in order to protect the battery.

Note:

  • With the switch from NT 4.0 to Windows 2000, the shutdown behaviour has changed. As a result, the UPS devices with basic signalling configured under Windows 2000 cannot be switched off after the shutdown (UPS Remote OFF not possible). For the UPS to be switched off in basic signalling mode, a certain level must be applied over several seconds to a serial interface pin. Under NT 4.0, some processes may continue to run with limited resources after a shutdown. This enables the UPS to be switched off via the serial interface some time after the shutdown. Under Windows 2000, all processes are interrupted at shutdown. This behaviour prevents the UPS being switched off via the serial interface. There is no solution to this problem. Some UPS devices have an internal timer, which is partly configurable. The UPS switches off, once the timer time has expired. For the Back UPS Pro "S" models, this timer may have the following values: 20, 120, 180, 300 or 600 seconds. Some models have a timer with a fixed value of 20 seconds. The timer is configured via the UPS service.


Different cable and signalling types

Some UPS manufacturers supply several connecting cables for supporting basic or advanced signalling. However, the type of signalling also depends on the firmware of the UPS device. If the UPS is configured under Windows 2000 and a device has been selected from the list of UPS devices, the connecting cable supplied should be used. The appropriate signalling type will then be selected automatically. NT 4.0 requires a connecting cable for basic signalling. Most UPS connecting cable are not standard RS-232 connecting cables. For APC, for example, the type will be printed on the connector.

Note:

  • If the UPS was configured under the Windows NT 4.0 UPS service, the configuration will not have to be changed after upgrading to Windows 2000. The settings will be transferred.
  • TwinCAT only supports basic signalling. Note that a suitable connecting cable must be used.

The following table shows the signals used by Windows NT 4.0 for basic signalling with the UPS:

RS-232 Signal | 9 Pin Connector Pin # | 25 Pin Connector Pin # | UPS Usage
CTS | 8 | 5 | Power failure
DCD | 1 | 8 | Low battery
DTR | 4 | 20 | UPS shutdown

Power fail and Low battery can be simulated under NT 4.0 with the following circuit (the pins for 25 pin connectors are shown in brackets):

Test:

Configure the switches: Switch1 and Switch2 in such a way that pins 8 and 1 are connected with pin 7. In the NT 4.0 configuration dialogue, set the options: Power fail signal and Low battery signal at... to a negative level. Start the UPS service. To simulate Power fail, change Switch1 (connect pin 8 with pin 3). Low battery can be simulated with Switch2 (connect pin 1 with pin 3).


APC NT4.0 Overview

TwinCAT UPS - Reference

APC configuration under NT 4.0

Since the NT 4.0 UPS service only supports basic signalling, the UPS device must support this communication type. A suitable connecting cable is also required. APC can supply different cables for the UPS devices as well as dedicated configuration software, PowerChute.The PowerChute software also enables ASCII communication with the UPS. The following table provides an overview of software suitable for different cable types. The type identifier for the APC cables can be found on the connectors.

Cable type | Configuration via NT4.0 UPS service | Configuration via TwinCAT | Configuration via PowerChute plus
940-0020B | Yes | No | No
940-0024C | No | No | Yes
940-0095A | No | Yes | Yes
940-0095B | No | Yes | Yes


APC NT4.0 TwinCAT Configuration

TwinCAT UPS - Reference

APC configuration via TwinCAT UPS service under NT 4.0

Example:

APC Back-UPS Pro 280 at COM1 should not be configured via TwinCAT. The UPS should shut down and switch off the PC after 10 seconds of battery operation. Once the supply voltage is available again, it should no longer be possible to abort the shutdown:

Cable: 940-0095A or 940-0095B, do not install PowerChute software!

1. Insert an I/O device in the TwinCAT System Manager:

2. Select the serial interface from the list of available devices and confirm with OK:

3. The serial interface is configured as follows:

If the checkbox No abort is selected, the shutdown will not be interrupted once the external power supply is available again.

From TwinCAT version 2.7 build 501, an additional option is available in the configuration dialogue: Delayed (NT4 only) . This option has to be selected to enable delayed UPS switch-off after the shutdown. If this option is not selected, the UPS will switch off too early (during shutdown).


APC NT4.0 UPS Service Configuration

TwinCAT UPS - Reference

APC configuration via NT 4.0 UPS service

Example:

APC Back-UPS Pro 280 at COM1 should be configured via the NT 4.0 service:

Cable: 940-0020B, do not install PowerChute software!

In order to avoid a complete discharge of the UPS battery during UPS shutdown, the NT 4.0 UPS service should be configured as follows:

If the option "Battery warning signal at least 2 minutes prior to shut down" is selected, the PC will run on battery power until the battery is nearly empty and the battery warning signal is sent by the UPS. Only then is the operating system shut down.

The operating system will calculate the expected battery lifetime via the battery charging time for one minute. This time (in our example 2 minutes) will only be reached if the PC operation time exceeds 200 minutes without voltage failure. If the expected battery lifetime is not reached, the shutdown will be initiated immediately.


APC W2K Overview

TwinCAT UPS - Reference

APC configuration under Win2K/XP

Under Windows 2000, the UPS service will terminate all running applications and processes without prior notification during shutdown. This means that none of the running applications are alerted about the shutdown procedure having been initiated. They are thus unable to respond appropriately (e.g. save unsaved projects, close application windows). This can lead to problems if applications establish the ADS connections but do not terminate or release them prior to shutdown. In this case, the shutdown procedure can take several minutes or "hang". The Windows 2000 UPS service offers the option to execute an application prior to the actual shutdown (Scheduled task). This task may also be a batch file calling further applications. This task can be used to notify the running applications that the shutdown was initiated. Applications that have established ADS connections are then able to respond appropriately and to release the connections. Because the ADS connections are automatically released when the application is terminated, the applications have to be instructed to terminate themselves. Subsequently, the TwinCAT system service can be stopped. The persistent data and the current configuration, for example, are saved on a data storage medium. During a shutdown via the Start menu in the task bar, Windows messages (WM_QUERYENDSESSION and WM_ENDSESSION) are sent to all running applications. The UPS service does not send messages, but terminates the running processes. This article presents a solution for avoiding excessive shutdown times.

APC configuration via Win2K/XP UPS service

APC configuration under Win2K/XP with TwinCAT UPS service


APC configuration under Win2K/XP with TwinCAT UPS service

Since delayed switch-off by TwinCAT of the APC UPS via the serial interface is not possible under Win2K/XP, the Win2K/XP UPS service has to be used for configuring the UPS.


APC configuration via Win2K/XP UPS service

Example configuration of a Back-UPS Pro 280 type APC UPS.

The connecting cable supplied has the following identifier: 940-0095A (grey). The UPS was connected to the second serial interface (COM2).

The configuration dialogue for the UPS can be found under Power Options in the Control Panel:

1. Open the dialogue and select the UPS tab. The UPS tab shows the current status of the UPS. However, in our case a UPS has not yet been configured.

2. Select the command Select...Select the manufacturer and the model in the dialog box and configure the COM port to which the UPS is connected. Close the dialogue. If the UPS is selected from the list of UPS devices, the connecting cable supplied by the manufacturer should always be used.

3. Select the command Configure...In the UPS configuration dialogue, the system behaviour in case of Power fail can be configured.

Enable all notifications: This option can be used to instruct the operating system to send messages to the user in case of Power fail.

Critical alarm: The alarm is triggered once the battery voltage has fallen to a certain level or once battery operation has exceeded a certain time limit.

Minutes on battery before critical alarm: This option can be used to specify the battery operation time in minutes until the Critical alarm is triggered. The shutdown of the operating system is only initiated once the alarm has been triggered. If the option has not been activated, the shutdown will only be initiated once the battery voltage has fallen to a critical level. This option should be selected in order to protect the battery.

The smallest On battery time is specified as 2 minutes. The time may be changed through an appropriate entry in the Windows registry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UPS\Config\ShutdownOnBatteryWait REG_DWORD = 0x00000000

When the alarm occurs, run this program: This option allows execution of an application during an alarm. In our example, a batch file: TCShutdownJob.bat with the following content is called.

net stop "TwinCAT System Service"

The TwinCAT system service can be stopped with net stop "TwinCAT system service" (net start "TwinCAT system service" will start the system).

Finally, turn off the UPS:If the option is selected, the UPS is switched off after the shutdown (Power OFF) in order to protect the battery. In order to utilise the option it must support UPS ASCII communication. Devices that only support basic signalling cannot be switched off under Windows 2000.

Note:

Under Windows 2000, the UPS cannot be notified about completion of the shutdown. It is assumed that the shutdown is complete after 180 seconds, and that the PC can then be switched off. This time is permanently coded, but can be set in the Windows registry to any value between 0 and 180 (e.g. 5 seconds):

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UPS\Config\TurnUPSOffWait REG_DWORD = 0x00000005 (5)

4. Once the configuration has been completed successfully, the current UPS status information is displayed in the dialogue.


Beckhoff IPCs with integrated 24V UPS

The integrated 24V UPS of the Beckhoff IPCs can either be connected and configured with the serial COM interface or with the CP9030 card (Control Panel card). The first variant is used in IPCs that do not have a CP9030 card. For configuring the UPS via the CP9030 card, this card must be connected to the UPS electronics in an appropriate way. An internal counter on the CP9030 card is responsible for delayed switch-off of the UPS. The counter is configured via the software when the shutdown is initiated and immediately starts counting backwards. The UPS will switch off when zero is reached.


Configuration of the integrated CP9030 UPS via the TwinCAT UPS service under NT4.0/Win2K/XP

The following steps are required to configure the integrated UPS of the CP9030 card under TwinCAT:

1. Insert an I/O device in the TwinCAT System Manager:

2. Select the CP9030 card from the list of available devices and confirm with OK:

3. Configure the address area of the card via the CP9030 tab:

4. Configure the UPS tab:

If the checkbox No abort is selected, the shutdown will not be interrupted once the power supply is available again. Once the operating system has been shut down, the UPS is switched off after 5 seconds in order to protect the battery. This time cannot be configured. Save the configuration in the registry and start the TwinCAT system.


Configuration of the 24V IPC (CP903x Panel-Link) UPS via the NT4.0/Win2k/XP UPS service

The UPS cannot be configured via the Windows UPS service.


IPC 24V USV CP903x NT4.0 Win2K XP ActiveX Configuration

TwinCAT UPS - Reference

Configuration of the integrated CP903x UPS without TwinCAT via the CP9090-S100 ActiveX component under NT4.0/Win2K/XP

In order to utilise the UPS functionality of the PC, the UPS must be configured and activated appropriately. The CP9090-S100 ActiveX component enables access to the CP-Link card for PC without TwinCAT software. The following steps are required to configure the UPS from a Visual Basic application:

1. Install the CP9090-S100 ActiveX component:

2. Insert the component into the Visual Basic component palette:

3. Create a Visual Basic application with the ActiveX component. You can enable/disable the UPS or query its status via properties and methods.

A example application:

Here you can unpack the example application with complete sources. You will find a description of the ActiveX component methods and properties in the CP9090-S100 documentation. Information about shutting down the operating system can be found in the Win32 API. In the example application you will find several sources for executing a shutdown from a Visual Basic application. These can be used as starting points for your own implementation.

Enable UPS: activates or deactivates the UPS;

Enable Shutdown:if this option is selected, the operating system is shut down in case of failure of the external supply voltage.

Enable Delayed OFF: Activates delayed switch-off of the UPS. In the example application you may select delay times between 5 and 60 seconds; the delay time is configured via the UpsDelay property. As soon as this property has a value <>0, the internal counter starts counting backwards and switches the UPS off when 0 is reached. This process cannot be stopped once it has been initiated. Please ensure that an adequate delay time, e.g. for a shutdown, is configured. The current status of the charge controller and of the rechargeable battery and external supply voltage is displayed in the UPS state frame;

The VB program:

At program start-up, the address of the CP9030 card is assigned to the DeviceAddr property, and the communication port is opened.

Private Sub Form_Load()
    BkCp9030W9x1.DeviceAddr = CPAddr_0xCC000 'The address of CP9030 card

    BkCp9030W9x1.DeviceOpen = True

    If Not BkCp9030W9x1.DeviceOpen Then 'Check if opened succesfully
        Call MsgBox("CP9030 not initialized! Check the CP9030 address.", vbCritical, "CP9090-S100 error")
        GoTo ErrorExit
    End If

    Timer1.Interval = 1000
    Timer1.Enabled = True
    Option1(1).Value = True

    'check if UPS already enabled
    chkEnableUPS.Value = IIf(BkCp9030W9x1.EnableUPS = True, vbChecked, vbUnchecked)

ErrorExit:
End Sub

When the program is terminated, the communication port is closed.

Private Sub Form_Unload(Cancel As Integer)
    BkCp9030W9x1.DeviceOpen = False
End Sub

The UPS is activated or deactivated via the EnableUSV property.

Private Sub chkEnableUPS_Click()
    BkCp9030W9x1.EnableUPS = IIf(chkEnableUPS.Value = vbChecked, True, False)
End Sub

The status of the UPS is cyclically checked via a Multimedia timer. In case of external voltage failure, a shutdown is initiated. The status of the UPS can be queried by polling the appropriate properties of the ActiveX component.

Private Sub Timer1_Timer()
    chkAkkuCharged = IIf(BkCp9030W9x1.AkkuCharged = True, vbChecked, vbUnchecked)
    chkAkkuCharging.Value = IIf(BkCp9030W9x1.AkkuCharging = True, vbChecked, vbUnchecked)
    chkAkkuNotPresent.Value = IIf(BkCp9030W9x1.AkkuNotPresent = True, vbChecked, vbUnchecked)
    chkAkkuVoltageOk.Value = IIf(BkCp9030W9x1.AkkuVoltageOk = True, vbChecked, vbUnchecked)
    chkAkkuWaiting.Value = IIf(BkCp9030W9x1.AkkuWaiting = True, vbChecked, vbUnchecked)
    chkExtVoltageOk.Value = IIf(BkCp9030W9x1.ExtVoltageOk = True, vbChecked, vbUnchecked)

    If chkExtVoltageOk.Value = vbUnchecked Then

        'set the delay time to turn OFF the UPS
        If chkDelayedOff.Value = vbChecked Then
            BkCp9030W9x1.UpsDelay = IIf(Option1(0).Value = True, CPUpsDelay_5, CPUpsDelay_60)
        Else
            BkCp9030W9x1.UpsDelay = CPUpsDelay_0
        End If

        If chkEnableShutdown.Value = vbChecked Then

         'E.g. perform shutdown or other tasks
    Call Shutdown

        End If

    End If

End Sub


Beckhoff IPC 24V UPS an COM TwinCAT Configuration

TwinCAT UPS - Reference

Configuration of the 24V IPC UPS (at the COM interface) under NT4.0 via the TwinCAT UPS service

1. Insert an I/O device in the TwinCAT System Manager:

2. Select the serial interface from the list of available devices and confirm with OK:

3. The serial interface can be configured as follows:

From TwinCAT version 2.7 build 501, an additional option is available in the configuration dialogue: Delayed (NT4 only) . This option has to be selected to enable delayed UPS switch-off after the shutdown. If this option is not selected, the UPS will switch off too early (during shutdown).


Configuration of the integrated Beckhoff 24V IPC UPS (at the COM interface) via the NT 4.0 UPS service

TwinCAT UPS - Reference

Configuration of the 24V IPC UPS (at the COM interface) via the NT 4.0 UPS service

The UPS cannot be configured via the NT 4.0 UPS service.


Configuration of 24V IPC UPS (at the COM interface) under Win2K/XP with TwinCAT UPS service

This UPS cannot be configured with TwinCAT UPS service. Whilst configuration under TwinCAT is possible, the UPS switches off too early (during shutdown). The reason: UPS switch-off cannot be delayed


Configuration of 24V IPC UPS (at the COM interface) via Win2K/XP UPS service

TwinCAT UPS - Reference

Configuration of 24V IPC UPS (at the COM interface) via the Win2K/XP UPS service

This UPS cannot be configured via the Win2K/XP UPS service.


FAQ

230 V UPS, Win 2000 and TwinCAT. Points to note.

The UPS must be configured via the Win 2000 UPS service. The UPS service will not inform the running applications that a shutdown has been initiated. A task (application) may be called from the shutdown service. This application may, for example, close other applications, save data, stop the TwinCAT system etc. The UPS can only be switched off if it supports ASCII communication and has an internal timer enabling delayed switch-off (POWER OFF). Whilst configuration via the TwinCAT UPS service is possible, the UPS cannot be switched off by TwinCAT, or it will switch off too early. Cause: unlike under NT, access to the COM interface after the shutdown is not possible.

230 V UPS, Win NT and TwinCAT. Upgrading to Win 2000 with existing application. Points to note.

The TwinCAT UPS service should not be used under Win 2000. The UPS cannot be switched off by TwinCAT under Win 2000, or it will switch off too early (during the shutdown procedure). Under Win 2000, the UPS has to be configured via the Win 2000 UPS service. The UPS should have an internal timer for delayed switch-off and should support ASCII communication. Applications using ADS communication may "hang" during the shutdown. The shutdown can thus take 10 minutes or more. The reason is that any open ADS connections are not released. During UPS shutdown, the applications are not terminated with WM_QUERYENDSESSION. Existing applications may have to be changed in order to respond correctly to the shutdown.

230 V UPS, Win NT and TwinCAT. Upgrading to later TwinCAT version with existing application. Points to note.

An upgrade to a later TwinCAT version within the same operating system is possible at any time. No particular measures (changes in configuration) are required.

24 V UPS, Win 2000 and TwinCAT. Points to note.

24V UPS at the CP9030:

The UPS should be configured with TwinCAT. If a CP9030 card with older firmware is used, it must be updated to the latest firmware version. Delayed switch-off (POWER OFF) of the UPS is implemented in the latest firmware (version 1.73xxx and above).

24V UPS at the COM interface:

Currently, whilst the UPS can be configured via the TwinCAT UPS service under Win 2000, it cannot be switched off properly. The UPS will switch off too early or not at all. Delayed switch-off is not possible for this UPS. Currently, another UPS type should be used under Win 2000. This UPS cannot be configured via the Win 2000 UPS service. The Win 2000 UPS service only supports APC pin assignment. The UPS, however, has EFFEKTA pin assignment.

24 V UPS, Win NT and TwinCAT. Upgrading to Win 2000 with existing application. Points to note.

24V UPS at the CP9030:

No changes in the configuration are required. If a CP9030 card with older firmware is used, it must be updated to the latest firmware version. Delayed switch-off (POWER OFF) of the UPS is implemented in the latest firmware (version 1.73xxx and above).

24V UPS at the COM interface:

Currently, whilst the UPS can be configured via the TwinCAT UPS service under Win 2000, it cannot be switched off properly. The UPS will switch off too early or not at all. Delayed switch-off is not possible for this UPS. Currently, another UPS type should be used under Win 2000. This UPS cannot be configured via the Win 2000 UPS service. The Win 2000 UPS service only supports APC pin assignment. The UPS, however, has EFFEKTA pin assignment.

24 V UPS, Win NT and TwinCAT. Upgrading to later TwinCAT version with existing application. Points to note.

An upgrade to a later TwinCAT version within the same operating system is possible at any time. No particular measures (changes in configuration) are required.

After updating from Win NT to Win 2000, my visualisation hangs after a shutdown through the Win 2000 UPS service. This was not the case under NT 4.0.

The open ADS ports prevent the shutdown. Configure a shutdown task via the Win 2000 UPS service that automatically closes the open ADS interfaces.

In our example, a batch file: TCShutdownJob.bat with the following content is called:

net stop "TwinCAT System Service"

The TwinCAT system service can be stopped with net stop "TwinCAT system service" (net start "TwinCAT system service" will start the system).

After updating from Win NT to Win 2000, my visualisation hangs after a shutdown from the Start menu in the task bar. This was not the case under NT 4.0.

In the application, the Windows message: WM_ENDSESSION should be trapped, and any open ADS interfaces should be closed when the message occurs. The open ADS ports prevent the shutdown.