EtherNet/IP?
In Normal, Siemens families are using Profinet for real-time communication,but you can also use other industrial protocols in the same channel.For Example EthernetIP.
EthernetIP is an IEE802.3 base Protocol and is integrated with TCP and UDP technology.
EthernetIP is managed by the ODVA Community.
There are two types of devices named Scanner and Adapter.
Scanner is the device to scan all the devices in the network, and collect or write the device to the Adapter.
Adapter is the device that provides
After the connection between Scanner and Adapter is established, they will use UDP to exchange the IO Data.
Originator:The device for initiating the connection.
Target:The device to accept the connections.
Siemens provided a Function Block named “LCCF_EnetAdapter” to implement the adapter function for the Siemens CPU.This time we will use the S7-1200 as Adapter.
The Example from Siemens’s Manaul, uses other Siemens PLC in Adapter Side and Scanner. But in this Example I will configure the Scanner as with TwinCAT3+TF6281 as a Scanner.
Topology Setup
Line Topology
This is the most simple onn but not good for Network debugging.
Star Topology
Star Topology is implemented by a network switch and we can use wireshark/Port Mirroring/Port spawning in this configuration.
Library
- Download the Library.
- Download the Example with your TIA Version
- Download the Library with your TIA Version
- Download the S7-1200,S7-1500 EDS File.
Unzip your library.
Open your TIA Software and import your library by Global libraries>Right click>Open library.
Choose the Files of type as Compressed libraries.
Select LCCF_EnetAdapter.zal1x and Open it.
Choose the directory that you would like to extract.
You can see the library shown in the TIA Global libraries.
Function Block
Input
enable | bool | Pulse Up Edge=Start Pulse Down Edge=Stop |
interface | HW_ANY | The CPU interface that communicates with Scanner |
endianness | bool | True=BigEndianFalse=Little Endian |
inputAssembly | Uint | T->O Assembly ID Default=101 |
outputAssembly | Uint | O->T Assembly IDDefault=102 |
configAssembly | Uint | O->TAssembly IDDefault=104 |
adapterName | String[32] | Adapter Name’s Name |
adapterIPAddr | IP_V4 | Adapter’s IP |
InOut
inputs | variant | ScannerのInput Area |
outputs | variant | ScannerのOutput Area |
configuration | variant |
Output
valid | bool | 1=Communicating |
busy | bool | 1=Busy |
error | bool | 1=Error |
status | word | Current status of Block |
actUpdIntervalOut | time | The Cycle time that receives data from the Scanner. |
actUpdIntervalIn | time | The Cycle time that sends data to the Scanner. |
diagnostics | LCCF_typeAdaptDiag | Error information |
TIA Side
Import the Function Block
Open your Global libraries >S71200 and choose LCCF_EnetAdapter.
Add a Cyclic interrupt OB30 inside your program and set the update time as 100ms.
Drop the Function Block inside OB30.
Create a DB instance for this function block.
Finished!
You can see a small icon in the Function Block
While the icon is clicked, the hidden parameters are shown.
DB Insert
Now we need to Add the DB for data exchange.
Define 3 arrays with 64 bytes.
Assignment
Assign the variables defined before in the DB to the parameters Inputs/outputs/configuration.
And Also the Enable signal.
TwinCAT Side
Now we need to configure the TwinCAT Side.Please reference the follow link to configure TwinCAT as a IP Scanner.
EDS
Import the EDS Files that were downloaded from Siemens Website before, and import to TwinCAT.
Insert the Variables
As mentioned before, TwinCAT will not update the variable value until you assign and use it in the user program.
Implement
We configured the network lke this.
Test
Download the project on both TwinCAT and Siemens.
Click the State in the TwinCAT.
0x0000 is displayed while communication is OK.
TIA Output
Let’s input 123 into a register.
You can see 123 is transferred from Siemens CPU.
TwinCAT Output
This time we will input some values from TwinCAT.
Siemens can receive the data from TwinCAT.