TwinCAT Virtual Serial COM Driver

The TwinCAT-Virtual-Serial-COM-Driver creates serial ports ("COMx") for one or multiple E-Bus terminals EL6001 under Windows CE or Windows XP. With the System Manager one can configure individually for each terminal, if and on which host a serial port should be created. Access to such a serial port is provided through the standard Window API for serial communication. This allows to use existing Windows applications in order to receive data from devices with support for serial connections via an EL6001 terminal.

  • System Requirements
  • Installation on Windows XP
  • Installation on Windows CE
  • Architecture
  • Configuration with System Manager
  • Shared use of EL60xx bus terminal from PLC
  • Behavior on TwinCAT Stop and Start
  • Additional Remarks


Notes on the documentation

This description is only intended for the use of trained specialists in control and automation engineering who are familiar with the applicable national standards.
It is essential that the following notes and explanations are followed when installing and commissioning these components.

The responsible staff must ensure that the application or use of the products described satisfy all the requirements for safety, including all the relevant laws, regulations, guidelines and standards.

Disclaimer

The documentation has been prepared with care. The products described are, however, constantly under development.
For that reason the documentation is not in every case checked for consistency with performance data, standards or other characteristics.
In the event that it contains technical or editorial errors, we retain the right to make alterations at any time and without warning.
No claims for the modification of products that have already been supplied may be made on the basis of the data, diagrams and descriptions in this documentation.

Trademarks

Beckhoff®, TwinCAT®, EtherCAT®, Safety over EtherCAT®, TwinSAFE® and XFC® are registered trademarks of and licensed by Beckhoff Automation GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owners.

Patent Pending

The TwinCAT Technology is covered, including but not limited to the following patent applications and patents:
EP0851348, US6167425 with corresponding applications or registrations in various other countries.

Copyright

© Beckhoff Automation GmbH & Co. KG, Germany.
The reproduction, distribution and utilization of this document as well as the communication of its contents to others without express authorization are prohibited.
Offenders will be held liable for the payment of damages. All rights reserved in the event of the grant of a patent, utility model or design.


System Requirements

  • General requirement is TwinCAT 2.10 Build 1328 which is needed for virtual COM ports under Windows XP and for configuration
  • Virtual COM port under CE requires a Windows CE 6.0 Image version 306b or later


Installation on Windows XP System

For installation of TwinCAT Virtual Serial COM driver the setup program TcVirtualSerialCOMDrv.exe must be executed, which is located on the "Beckhoff Software Products" CD in subdirectory Supplement\TwinCAT_Virtual_Serial_COM_Driver\Install.

After successful installation the Windows Device Manager shows under entry "TwinCAT Virtual Serial COM" one single "TwinCAT Virtual Serial COM Device". If a previous version was installed, this version is replaced by the new driver.

The CE driver CAB files are stored within the TwinCAT system directory (default is "c:\TwinCAT\CE\Virtual Serial COM Driver CE\").

Note, that virtual serial ports created by the Virtual Serial COM driver are not visible in the Windows Device Manager.

Starting with version 1.16 the setup installs the TwinCAT Server TcEL60xxStartSync. TwinCAT is stopped and the TwinCAT Server is added to "Default.tps". TcEL60xxStartSync synchronizes TwinCAT system start with the start of the TwinCAT Virtual Serial COM driver. This ensures that the TwinCAT System is not started until the driver has been completely initialized.

TwinCAT Storage Editor ("TcStgEditor.exe" in TwinCAT directory) can be used to open "Default.tps" and shows currently installed TwinCAT Servers. The following figure shows the state after a successful installation.

TwinCAT Storage Manager with TcEL60xxStartSync entry


Installation on CE System

The CE driver CAB files are stored within the TwinCAT system directory (default is "c:\TwinCAT\CE\Virtual Serial COM Driver CE\"). Installation is identical to all other CE Supplement products (see Supplement Installation)

After installation it is necessary to reboot the CE device by selecting the reset/suspend function within the start menu to activate the driver.


TcEL60xx Architecture

TS6360 | TwinCAT Virtual Serial COM Driver

Architecture

Considering a conventional serial port the driver communicates with the UART chip through an internal hardware bus. In case of the TwinCAT-Virtual-Serial-COM-Driver this communication is implemented using ADS and EtherCAT protocol.

When the driver is installed on a computer, it instantiates an ADS server with fixed port number, the so-called TcEL60xx-AdsServer. This ADS server provides an ADS interface to create serial COM ports. Within the TcIO driver EtherCAT slave objects are the clients of the TcEL60xx-AdsServer. TcIo has a special class of EtherCAT slave objects that are created for each EL60xx bus terminal on TwinCAT start. They have the capability to transmit data packets from the TwinCAT-Virtual-Serial-COM-Driver to the bus terminal, and to receive data from the bus terminal which is in turn forwarded to the driver. The driver will forward it to a Windows application which has a pending read on the respective serial port.

The following image illustrates the architecture for the Windows XP driver variant.


Configuration with System Manager

Parameter of virtual COM port

The System Manager provides the EL60xx configuration tab for bus terminals of type EL6001 and EL6021. Figure XX shows this tab. For EL60xx terminals with checked "Virtual Com Port" check box TwinCAT creates on configuration activation a virtual serial COM port. The number of the COM port is defined in edit field "Com Port". Note, that a com port number must be unique within a computer. The computer on which the virtual com port should be created must not have a com port with this number. System manager starts with com port number 6. The com port number must be less than 65536.

Edit field "Host Ams NetId" determines the computer on which the virtual com port should be created. By default the local computer is used, which is the one where the configuration is activated and with which the bus terminal is connected. It is also possible to create the virtual com port on another computer just by changing the "Host Ams NetId" respectively. Note, that the TwinCAT-Virtual-Serial-COM-Driver has to be installed on this computer.

Within "Com Port Settings" panel one can change the common parameters of a com port, i.e. baud rate, parity, data bits, stop bits, and also flow control settings as RTS/CTS, Tx XON/XOFF, and Rx XON/XOFF. The bus terminal is initialized with the configured parameters on TwinCAT activation. However, usually applications that open a com port will also reconfigure it with their own particular default settings overriding the settings from system manager.

Not all possible combinations of parity, data bit count and stop bit count are valid. The following table lists the allowed combinations:

7 data bits, even parity, 1 stop bit
7 data bits, even parity, 2 stop bits
7 data bits, odd parity, 1 stop bit
7 data bits, odd parity, 2 stop bits
8 data bits, no parity, 1 stop bit
8 data bits, no parity, 2 stop bits
8 data bits, even parity, 1 stop bit
8 data bits, even parity, 2 stop bits
8 data bits, odd parity, 1 stop bit
8 data bits, odd parity, 2 stop bits

In addition to common parameters there are some proprietary settings for an EL60xx bus terminal, i.e. "Transfer Rate Optimization" and "Fifo threshold". With enabled "Transfer Rate Optimization" the bus terminal first collects enough data to fill the available space in the process image before it is sent to the TcIo driver. With disabled "Transfer Rate Optimization" the data is sent as soon as possible to the TcIo driver. The "Fifo Threshold" setting determines when the bus terminal indicates "Fifo Full" state.

Parameters of the EL6021 bus terminal are somewhat different. Therefore the configuration dialog differs:

The EL6021 does not support RTS/CTS handshake. It does support a half duplex mode and it can be configured for point to point connections.

For more details on the special settings refer to bus terminal documentation of EL6001 and EL6021.

Dummy Task

The TwinCAT IO driver only processes data from bus terminals, if at least one input variable is linked to a Task variable. Otherwise, the data is ignored. Therefore, a dummy Task with one variable for each bus terminal that is used as virtual com port is needed. E.g. link the input status word of the bus terminal to a respective Task variable as shown in the screen shot below.

Make sure to configure the task with "Auto start" enabled. The "Cycle Ticks" settings controls the update frequency for the variables. In order to get the full data transfer rate through a virtual COM port, the cycle time should be about 1ms.


Behaviour on TwinCAT Start and Stop

General

On TwinCAT stop all virtual COM ports created by the TcEL60xx driver on this computer are removed. A TwinCAT start creates the virtual COM port defined by the current configuration. An Application, which uses one of the virtual COM ports, must close this port before the TwinCAT stop, because in general it is undefined how an application will handle the removal of an open COM port.

Virtual COM Port on Remote Computer

Suppose that a EL60xx bus terminal is connected to computer A, while the associated virtual COM port is created on computer B. The driver handles TwinCAT start and stop as follows:

TwinCAT stop on computer A breaks the connection to the bus terminal while the virtual COM port on computer B persists. Read and write request for the virtual COM port on computer B would fail. A successive TwinCAT start on computer A again creates the virtual COM on computer B. Using the AMS address the EL60xx driver on computer B checks, if a virtual COM port for this address exists and removes it respectively. Then the virtual COM port is created, possibly with another number, which could be changed within System Manager.

TwinCAT Stop on computer B removes all virtual COM ports on this computer. After TwinCAT start on computer B virtual COM ports can be created again. However, the virtual COM port, which was created from computer A, will not be available. Not until the TwinCAT on computer A has been restarted the virtual COM port on computer B is created again.

As the TwinCAT on computer B will not be notified when the TwinCAT on computer A is stopped, it is not possible to remove the virtual COM port. If the configuration on computer A is changed, e.g. such that no virtual COM port is created, then an orphaned virtual COM port on computer B persists until the next TwinCAT stop on this computer.


Shared use of EL60xx bus terminal from PLC

If an EL60xx bus terminal is utilized from PLC and also as virtual COM port, then access to the bus terminal must be coordinated by a superior mechanism. On opening the respective virtual COM port, accesses by PLC are blocked as long as the virtual COM port is open. When the virtual COM port is closed, PLC can access the bus terminal again. However, the driver will not regard any running transfers. It will also not restore the bus terminal configuration like baud rate, or stop bit settings, even if it has been modified by an application which used it through an virtual COM port.


Limits with respect to normal COM ports

  • Interval Timeout
    The virtual COM port for an EL60xx bus terminal does not support interval timeouts, because the driver has no access to the required information.
  • DSR/DTR Handshake
    EL6001 and EL6021 do not have DSR/DTR lines
  • Explicit Setting of RTS/CTS lines
    The explicit setting of RTS and CTS lines is not supported.
  • XON/XOFF char cannot be changed
    The EL6001/EL6021 has fixed values for XON and XOFF characters, i.e. 0x11 and 0x13, respectively. These cannot be changed.

Known Issues

  • Remote virtual serial port for EL60xx bus terminal on CE Device
    A EL60xx bus terminal, connected to computer A, can be used via a virtual serial port on a CE device B, which is connected to computer A via network. However, currently the driver is only activated on a CE device if a bus terminal directly connected to the CE device is used via a virtual serial port. To solve this issue, one can manually activate the driver with an additional entry in the section <Drivers> ... </Drivers> of the CurrentConfig.xml:

    <Drivers>
    <Driver>
    <Type>1</Type>
    <ServiceName>TCEL60XX</ServiceName>
    </Driver>
    ...
    </Drivers>

Solved Issues

Starting with software version 03 (last two digits of the bus terminal serial number) the following issues with bus terminals EL6001 and EL6021 are solved. (Note, that software version 03 contains the firmware version 00.04)

  • Diagnostic bits (solved with new EL60xx firmware, V00.xx)
    Diagnostic bits (Parity, dataframe, buffer overflow) of bus terminal cannot be provided by the driver.
  • Spurious XON characters (0x11) (solved with new EL60xx firmware, V00.xx)
    If the "XON/XOFF support for Rx" feature of the EL6001 is enabled, then it sends an XON character every time a configuration parameter is written to the bus terminal. For instance, when a virtual COM port is opened, then the current default settings are sent to the bus terminal leading to 10 XON characters being transmitted. As long as the connected COM port is configured with "XON/XOFF support for Tx" enabled, the spurious XON chars should not affect a data transmission.