Serial COM Ports

The TwinCAT can use the PC’s serial COM ports. There are two operating modes available:

  1. Uninterruptible power supply (UPS)
  2. COM port operation

COM port operation is divided into the following sub-operating modes:

  1. Connection of serial Bus Couplers (BK8xx0)
  2. General data interface (simulation of a KL6xx1)

”Serial interface” tab

Serial COM Ports 1:
Serial COM Ports 2:

Operating mode: UPS

In the UPS operating mode, an external UPS is connected to the serial interface and controlled by the TwinCAT. Currently supports pin configurations APC and EFFEKTA.

In contrast to the UPS service provided with Windows NT, the TwinCAT-controlled UPS behaviour rather resembles that required for machine control. The NT service seeks to supply power to the PC for as long as possible and the computer only stops when the battery fails.

When the TwinCAT is controlling the UPS (the NT service must be disabled), the computer is shut down after a (user-) specified waiting period.

Operation mode: COM – BK8xx0

Serial bus couplers can be added under the I/O device and the couplers themselves can be fitted with terminals as required.

Serial COM Ports 3:

Intelligent interface card required

To operate RS485 (BK80x0) you require an intelligent interface card which independently monitors the RTS/CTS leads (send and receive).

Operating mode: COM - KL6xx1

The type KL6xx1 terminals allow serial communication, e.g. of the PLC via a fieldbus - Bus Coupler and - the terminal to an external serial device (e.g. a barcode reader). The data bytes are exchanged via the terminal process image and the required handshake is controlled.

These functions can be replicated for the serial interfaces in the PC. A significantly greater data throughput can be achieved because on the one hand the baud rate can be set higher and on the other more data bytes can be transferred per cycle (maximum five for KL6xx1).

Data Bytes:

Serial COM Ports 4:

The maximum number of transferable data bytes can be set to between 16 and 4096. In addition, the internal buffer size can be adjusted, which is particularly important for the reception of data bytes (between 4096 and 65535).

The handshake is processed via the Ctrl and Status words. These words are structured in a very similar way to the Ctrl and Status bytes of the KL6xx1, with the difference that the data length to be specified is twelve, rather than three bits (maximum 4096).

TA / TR

A status change from TR has the effect of loading the nOut data number (maximum 4096 bytes) from Data0-DataN into the send buffer. The interface signals the execution of this command via TA.

RA / RR

Via a status change from RR the controller interface indicates that the displayed nIn data number is in Data0-DataN. The reception of data is acknowledged in the control word using RA. Only then is new data transmitted from the interface to the controller.

IA / IR

If IR is high, the interface carries out an initialization. The send and receive functions are disabled, the FIFO indicators are reset. The execution of initialization is acknowledged by the interface with IA.

BUF_F

The receive buffer is full. Data received now will be lost.

Extended Ctrl/Status:

From TwinCAT v2.10 Build >= 1313 (CE image v2.16(x86), v2.17(ARM) and higher). This option is only supported by the standard PC interfaces COMx. If this option is selected, an additional word of process output data (ExtCtrl) and process input data (ExtStatus) is displayed to the existing data. Via these process data the following RS232 control lines can be set or requested.

ExtCtrl Bits:
0x0001 = DTR
0x0002 = RTS
If the according bit is set/reset the concerning RS232 control line is set/reset. All other bits are reserved.

ExtStatus Bits:
0x0001 = CTS
0x0002 = DSR
0x0004 = RI
0x0008 = DCD
0x8000 = TX buffer empty (this bit is set if all send buffer are empty (inclusive hardware Fifo).
The state of the rs232 control lines can be requested by masking the bits. All other bits are reserved.

Sync Mode

In Sync mode, communication with the interface hardware is synchronized with the communication task. This setting usually offers benefits at high baud rates, as long the cycle time of the communication task is short enough. At 115 kBaud, for example, 12 characters are received each millisecond. The interface therefore has to be operated with a maximum cycle time of 1 ms, in order to avoid overflow of the 16-byte hardware FIFO. If the cycle times are too long, there is a risk of buffer overflow.

If Sync mode is switched off, the interface is served via the Windows timer interrupt every millisecond, irrespective of the task cycle time. This mode is not real-time capable, and with high computer utilisation longer operating intervals may be experienced. In this case, with very high baud rates there is also a risk of buffer overflow.

It is recommended to activate Sync mode and to adjust the cycle time of the communication task to the baud rate in such a way that overflow of the 16-byte hardware buffer is avoided. For smaller baud rates and with a slower communication task, Sync mode may perhaps be deactivated.