From offline to online configurations
This article explains how to convert a TwinCAT configuration, which has been created 'offline', via TwinCAT Automation Interface to an online configuration. The term "offline" means that no physical I/Os are present at the time of configuration creation and therefore the real address information is not available, e.g. for an EtherCAT Master . The following topics are part of this article:
- General information
- Creating an offline configuration
- Switching to an online configuration
General Information
Two scenarios are common when creating a TwinCAT configuration:
- Scenario 1: This scenario is based on the real physical device on which the TwinCAT configuration is to run later. For this reason, all I/Os are online , already available and connected to the device.
- Scenario 2: This scenario may involve creating the configuration offline (i.e. without any I/O connected to the device) and later switching to an online configuration once the I/Os are available. This scenario is the main focus of this article.
Both scenarios are possible with the TwinCAT Automation Interface. However, because important information about some of the I/Os is missing in the case of scenario 2, e.g. their physical addresses, the latter is somewhat more sophisticated because the required (address) information has to be passed later.
The familiar TwinCAT XAE functionality "Scan Devices" plays an important role in this use case because it scans all available I/O devices and automatically connects them to the configuration, along with any additional information required, e.g. the physical addresses.

In the case of a physical controller, this functionality can also be called up via the Automation Interface, in which case it returns an XML representation of all I/O devices found, including their corresponding address information.
If a TwinCAT configuration is to be activated on a controller, the required address information must be set for all I/O devices belonging to the configuration. This can be done by calling up the "Scan Devices" functionality via the Automation Interface and defining the address information of the I/O devices in the configuration. This will now be explained in more detail.
Creating an offline configuration
There are several articles which explain how to create an offline TwinCAT configuration. Please refer to our Product Description page to get an overview.
Switching to an online configuration
If you finally have created a TwinCAT configuration that should now be activated on the physical controller, the following steps need to be taken to ensure that all required address information is available before downloading the configuration:
- Step 1 [optional]: Connecting to the target device
- Step 2: Scanning the device for available I/Os
- Step 3: Iterating through XML and configuring address information of I/Os
- Step 4: Activating the configuration
Of course, you can also always create an online configuration directly by using the ScanDevices functionality. There is an own sample which shows you exactly how to do that.
Step 1 [optional]: Connecting to the target device
If the physical controller is not located on the same machine as the Automation Interface code runs on, you can use the ITcSysManager::SetTargetNetId() method to connect to the remote device and then continue with the next steps.
Step 2: Scanning the device for available I/Os
The "Scan Devices" functionality mentioned above can be triggered via Automation Interface by calling the ITcSmTreeItem::ProduceXml() method on the I/O devices node.
Code Snippet (C#):
ITcSmTreeItem ioDevices = systemManager.LookupTreeItem("TIID");
string foundDevices = ioDevices.ProduceXml();
Step 3: Iterating through XML and configuring address information of I/Os
In this example we want to update the address information of an EtherCAT device which is already part of our offline configuration. The ProduceXml() in step 2 has already returned the available I/O devices on the system, which is now available in the variable 'foundDevices'. We will identify the EtherCAT device in this XML via its item sub type (111) and then update the address information of the EtherCAT Master in our configuration.
Code Snippet (C#):
XmlDocument doc = new XmlDocument();
doc.LoadXml(foundDevices);
XmlNodeList devices = doc.SelectNodes("TreeItem/DeviceGrpDef/FoundDevices/Device");
foreach (XmlNode device in devices)
{
xmlNode typeNode = device.SelectSingleNode("ItemSubType");
int subType = int.Parse(typeNode.InnerText);
if (subType == 111)
{
XmlNode addressInfo = device.SelectSingleNode("AddressInfo");
ITcSmTreeItem deviceToUpdate = systemManager.LookupTreeItem("TIID^EtherCAT Master");
string xmlAddress = string.Format("<TreeItem><DeviceDef>{0}</DeviceDef></TreeItem>", addressInfo.OuterXml);
deviceToUpdate.ConsumeXml(xmlAddress);
}
}
Step 4: Activating the configuration
The last step only involves activating the configuration on the target device. Simply use the ITcSysManager::ActivateConfiguration() method to do that.
Code Snippet (C#):
sysManager.ActivateConfiguration();