Hallo and in this tutorial I will explain how to use TwinCAT TF6271 as a Profinet RT Controller and Using Codesys runtime as a Profinet Device.
Let’s Do it!
System Requirment
Configuration
Insert Controller
Go to I/O and right click Devices>Add New Item.
Choose Profinet > Profinet I/O Controller(RT) and press OK.
And then you need to choose the Network Interface Card.
Profinet Controller is inserted into your project.
Insert Device
Now is the time to configure the Profinet Devices inside your Profinet Network.
PNController>Add New Item.
Choose Miscellaneous>Profinet IO Device.
This time I will use Codesys as the Profinet Devices, choose the GSDML file and press OK.
Profinet Device is inserted.Now you need to configure how many bytes that will be exchanged with this device.
Insert Slot
PN-Device>API>Add New Item.
The below popup is shown.Choose InOut64bytes and drop into slot1.
FInished.
Term 2 with inout 64 bytes is configured.
Device Name・IP Setup
Device Name and IP Address are necessary in the Profinet Network. Click the pn-device.
Configure your station name and IP.
Task Cycle Time Setting
The PNIO-Controller Cycle Time must be a power of 2! is shown after compiled, please modify your task cycle time.を修正する必要があります。
Click the PNController1.
Open the Sync task tab and enter the Cycle ticks with power of 2.
Insert PLC
PLC > Add New Items to insert a PLC.
POUs>MAIN.
define the variable.
Activate Configuration.
If the below popup is shown, please Link the variable to your Profinet IO.
Links to Variable
Go to Pn-Device>API>Subterm>Inputs.
Right Click the Input Data and Change Link.
Choose the variables that you defined before.
Codesys-Device側設定
Please reference the previous post to configure a Codesys Profinet runtime.
And do not forget the IO Mapping.
While using WireShark
After TwinCAT is started up, WireShark is not available to use. Here is an option to allow WireShark.
Click the PNController.
Go to the Adapter, and Check the Promiscuous Mode(Use with WireShark Only).