Configuring the PROFIBUS system
PROFIBUS masters and slaves are created under the I/O node using CreateChild. The SubType identifies the specific device. SubTypes 86 and 97 apply to the EtherCAT-based PROFIBUS cards EL6731 and EL6731-0010, respectively. After the device has been created, the desired hardware resource is selected using ClaimResources. ClaimResources assigns the physical adapter on which the fieldbus operates to the device.
Requirements
- A TwinCAT solution is open, and a DTE connection is active.
ITcSysManagerwas initialized as a COM object in an STA thread.- EL6731 (as the master) and EL6731-0010 (as the slave) are available in the ESI library.
C# sample
The master and slave are created under the I/O node TIID with CreateChild. ResourcesCount then returns the number of hardware resources found. The ClaimResources statement assigns a specific resource to the device.
ITcSmTreeItem devices = sysManager.LookupTreeItem("TIID");
// Create Profibus master (SubType 86 = EL6731)
ITcSmTreeItem profiMaster = devices.CreateChild("Profibus Master (EL6731)", 86, "", null);
// Check available resources and claim hardware resource
Console.WriteLine("Available masters: " + profiMaster.ResourcesCount);
profiMaster.ClaimResources(1); // Index 1 = first available resource
// Create Profibus slave (SubType 97 = EL6731-0010)
ITcSmTreeItem profiSlave = devices.CreateChild("Profibus Slave (EL6731-0010)", 97, "", null);
Console.WriteLine("Available slaves: " + profiSlave.ResourcesCount);
profiSlave.ClaimResources(1);
PowerShell sample
$devices = $sysManager.LookupTreeItem("TIID")
# Create Profibus master (SubType 86 = EL6731)
$profiMaster = $devices.CreateChild("Profibus Master (EL6731)", 86, "")
Write-Host "Available masters: $($profiMaster.ResourcesCount)"
$profiMaster.ClaimResources(1) # Index 1 = first available resource
# Create Profibus slave (SubType 97 = EL6731-0010)
$profiSlave = $devices.CreateChild("Profibus Slave (EL6731-0010)", 97, "")
Write-Host "Available slaves: $($profiSlave.ResourcesCount)"
$profiSlave.ClaimResources(1)
![]() | The index of |
Changing the fieldbus address
The fieldbus address of a PROFIBUS box is its station number on the bus. It is modified by calling ConsumeXml with the desired number as the value.
C#:
ITcSmTreeItem item = sysMan.LookupTreeItem("TIID^Device 1 (FC310x)^Box 1 (BK3100)");
item.ConsumeXml("44");PowerShell:
$item = $sysMan.LookupTreeItem("TIID^Device 1 (FC310x)^Box 1 (BK3100)")
$item.ConsumeXml("44")