Blog

Siemens S7 to TwinCAT Communication

Configuring Profinet I-Device Communication Between Siemens S7 and TwinCAT 3

When integrating large systems that span multiple controllers, it often is necessary to configure communication between different types of PLCs. With some PLCs, this can be challenging because they only communicate with their “native” protocol. For example, Allen-Bradley PLCs only support Ethernet/IP communication.

This is not an issue with Siemens S7 or Beckhoff TwinCAT PLCs. Siemens can communicate both with PROFINET and Ethernet/IP. TwinCAT can communicate with EtherCAT, PROFINET , Ethernet/IP and others. This simplifies integration of big systems in which different machine builders use different PLCs.

In this article, we’ll cover communication between an S7 PLC and a Beckhoff TwinCAT 3 PLC using I-Device. The TwinCAT PLC will be configured as the PROFINET Controller and the Siemens PLC the I-Device or PROFINET Device. There are other options for communication between S7 PLCs and TwinCAT PLCs, including S7 communication and using the TwinCAT PLC as the PROFINET Device. We typically choose I-Device over S7 communication due to increased security and support for PROFISAFE.  

Configuring I-Device on a Siemens S7-1500 PLC in TIA Portal

This setup works with both the S7-1200 and S7-1500 series PLCs. In this setup, we used an S7-1516 because we have one in our lab.

  1. Create a UDT for both directions of communication. Group similar variable types.

  2. Create an unoptimized DB with an instance for each direction of communication. Take note of the length of each of the structures.
  3. Create PLC tags of the UDT typesPLC Tags
  4. Add logic to copy the DB data into the tags.Copy UDT Logic
  5. Setup I-Device on the PROFINET interface using the lengths from step 2.S7-1500 I-Device Setup
  6. Export the GSDML file and save for the TwinCAT configuration.Export GSDML File.

Configuring a Beckhoff TwinCAT PLC as a PROFINET Controller in TwinCAT 3 XAE

A PROFINET controller can be implemented with any Beckhoff PLC using any one of the following ethernet adapters:

  • The built-in network adapter in the PLC
  • A PROFINET terminal, such as the EL6631
  • A CU2508 Multiport adapter

In addition, a TS6271 PROFINET Controller license is necessary unless an EL terminal is used.

  1. Copy the GSDML file exported from TIA into the Profinet IO device folder in the TwinCAT folder.SaveGSD
  2. Open TwinCAT XAE (or refresh IO Devices if already open) and create a new project
  3. Create a PROFINET I/O Controller
    1. Add a new device to the hardware configuration
    2. To use a network adapter on the PLC, select the (RT) version, to use a specific EL terminal select the card being used.Add Profinet IO Controller
    3. Select the network adapter. This will vary depending on the network adapter being used, but the process is the same as for EtherCAT adapters.Set Network Adapter
    4. Create a new sync task for the PROFINET controller. Typically, use 1ms to allow more granularity in configuration. Create Sync Task
    5.  Set the IP address in the same subnet as the Siemens S7 PLC.Set Siemens IP Address
  4. Add the Siemens IO Device.
    1. Add a new item to the PROFINET I/O Controller. Note that multiple IO Devices can be added to a single controller.Add PROFINET IO Controller to TwinCAT
    2. Select the GSDML that was exported from TIA and added to the IO folder in step 1.Select GSDML
    3. At this point, each of the Transfer Areas from TIA should show up in the API in TwinCAT. Confirm Profinet API
      1. Note: The data will always show up as a byte array in TwinCAT, even when different data types are configured in TIA.
    4. Set the StationName and IP address in TwinCAT to match TIA.PROFINET Name Configuration in TwinCAT
    5. Make sure the cycle time parameters are OK, otherwise adjust as requested.Profinet Cycle Times In TwinCAT
  5. Define structs in TwinCAT to match the UDTs in Siemens TIA Portal. The data types must match but the names do not matter. TwinCAT Structs to match Siemens
    1. Make sure to use the data type Bit instead of Bool to ensure efficient spacing.
    2. The Pack Mode attribute may need to be adjusted depending on the variable layout.
    3. Occasionally, a spacer bit may need to be added to make sure everything aligns.
  6. Instantiate the structs, then link the IO for both the inputs and outputs.Link TwinCAT IO for Profinet
  7. Activate Configuration and test.

Conclusion

The communication between Siemens S7 PLCs and Beckhoff TwinCAT 3 PLCs can easily be configured and allows integration of large complex systems.

 

Contact us to learn more about how we can help with integrations like this or other combinations of communication between different PLCs.

Share this post

Leave A Comment

Let's work together to solve your automation problem

Call 480-900-2170