Configuring the PROFINET system
PROFINET devices are created under the I/O node using CreateChild. The path to the device's GSDML file is passed as the vInfo parameter. The GSDML file describes the modules available on a device. Modules are created later under the API node of the PROFINET box, with the SubType determining their position in the GSDML module list.
Requirements
- A TwinCAT solution is open, and a DTE connection is active.
ITcSysManagerwas initialized as a COM object in an STA thread.- A PROFINET controller is included in the solution.
- A GSDML file for the PROFINET device is available.
SubType overview for PROFINET controllers and devices
To create PROFINET I/O devices – that is, controllers and devices – you can use the CreateChild() method. The SubType specifies the actual device type.
Name | SubType |
|---|---|
PROFINET controller (RT) | 113 |
PROFINET controller CCAT (RT) | 140 |
PROFINET controller EL6631 (RT, EtherCAT) | 119 |
PROFINET controller EL6632 (RT + IRT, EtherCAT) | 126 |
PROFINET device (RT) | 115 |
PROFINET device CCAT (RT) | 142 |
PROFINET device CCAT (RT + IRT) | 143 |
PROFINET device EL6631 (RT, EtherCAT) | 118 |
SubType overview for PROFINET boxes
Beckhoff's own PROFINET fieldbus couplers require the following SubTypes:
Device | SubType |
|---|---|
BK9102 | 9125 |
BK9300 | 9128 |
BK6631 / EL6631 | 9130 |
C# sample
First, the PROFINET controller is created under the I/O node TIID. Below that is the PROFINET box, whose GSDML path – with the DAP ModId suffix #0x3 – is passed as vInfo. The box's API node is created automatically and accessed via LookupChild("API"). The modules are listed below it along with their slot numbers.
ITcSmTreeItem io = sysManager.LookupTreeItem("TIID");
// Create ProfiNET controller (SubType 113)
ITcSmTreeItem profinetCtrl = io.CreateChild("Profinet Controller", 113, null, null);
// Create ProfiNET box: vInfo = path to GSDML file with DAP-ModId suffix (#0x3)
// Note: Since TC 4026 the default TwinCAT installation path has changed.
// Verify the GSDML path on the target system before use.
ITcSmTreeItem profinetEL6631 = profinetCtrl.CreateChild("EL6631", 9130, null,
@"C:\TwinCAT\3.1\Config\Io\Profinet\GSDML-V2.31-beckhoff-EL6631-20140508.xml#0x3");
// Look up API node (created automatically)
ITcSmTreeItem api = profinetEL6631.LookupChild("API");
// Remove existing modules (optional: reset configuration)
foreach (ITcSmTreeItem module in api)
api.DeleteChild(module.Name);
// Add modules with slot number
// SubType = index in <ModuleList> of the GSDML file
// vInfo = slot number as string
ITcSmTreeItem module1 = api.CreateChild("Module_1", 2, "", "2"); // SubType 2, Slot 2
ITcSmTreeItem module2 = api.CreateChild("Module_10", 7, "", "10"); // SubType 7, Slot 10
GSDML path format and BoxFlags
The vInfo parameter when creating a PROFINET box supports an extended format with BoxFlags:
GSDML-Pfad#DAP-ModId#BoxFlags#DAP-Nr
Sample:C:\TwinCAT\Io\Profinet\GSDML-V2.3-beckhoff-TCPNDevice-20130723.xml#0x01#0#0x03
The following BoxFlags are evaluated:
Name | Value | Description |
|---|---|---|
GENERATE_NAME_FROM_PAB | 0x0004 | The PROFINET name is generated based on the process image. |
GET_STATIONNAME | 0x0400 | The PROFINET name from the TwinCAT configuration is used (Tree Item name). |
SET_NOT_IP_TO_OS | 0x4000 | CE only: PROFINET IP is not registered in the operating system. |
Adding PROFINET submodules
PROFINET submodules can be added below a “PROFINET Modular Module”:
ITcSmTreeItem profinetModularModule = profinetEL6631api.CreateChild("", 98, null, null); // SubType 98 = Modular
ITcSmTreeItem modularModule1 = profinetModularModule.CreateChild("", 12, null, null); // SubType 12 = 8 Byte In-Out
ITcSmTreeItem modularModule2 = profinetModularModule.CreateChild("", 14, null, null); // SubType 14 = 16 Byte Out
ITcSmTreeItem modularModule3 = profinetModularModule.CreateChild("", 31, null, null); // SubType 31 = 8 Word In
![]() | GSDML files must not contain any spaces or comments in the ModuleList. Otherwise, parsing will fail. |
