Interfacing PROFINET

This article provides a general concept of interfacing PROFINET from Linux and all basic guidelines that ROS user needs to know for appropriate configuration and usage of this package. Reading this article is recomended for better understanding of following tutorials.

(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Introduction to siemens_cp1616

Description: Driver installation and instuctions for basic usage of ROS-PROFINET wrappers

Keywords: SIEMENS, PROFINET, CP1616,

Tutorial Level: INTERMEDIATE

cp1616.jpg

Driver installation

To use CP1616 with latest Linux distribution the driver v2.6.2 is necessary.

Extract archive cd_v_02_06_02/V2.6.2/DK16xx/linux-sw/host-2-6.2.tar.gz to your home directory

Login as a root:

$ sudo su

Change directory to /home/username/host_linx folder:

# cd host_linx

Build and install the driver:

# make | make install

Test if new driver works properly:

# make load

Driver should respond:

load cp1604 cp1616 example driver...done

NOTE: You need to make load the driver each time you boot in to the system.

Configuration

If driver loads properly, you can start configuring your project. The main part of PROFINET configuration is usually bounded with STEP7, TIA Portal or other industrial software tool, so creating project, setting Ethernet addresses, network topologies and data to be transmitted, traditionally happens outside ROS.

After downloading the configuration to CP1616, the Linux CP driver automatically detects and leverages on the existing setup. The only information that needs to be additionally passed into ROS application is the configuration of data transmissions (modules/slots/transfer areas). In order to provide such an information .yaml files are used within this package.

YAML files

User defined .yaml file keeps an information about existing STEP7 hardware configuration. It is also important to notice that .yaml configuration files are not the same for IO Controller and IO Device - see following examples:

.yaml file for communication with S7-1200 PLC using 2 modules (CP1616 in IO Controller mode)

- label: CP_input_byte
  type: input
  size: 1
  starting_address: 4116
  topic: cp_input_byte_topic

- label: CP_output_byte
  type: output
  size: 1
  starting_address: 4120
  topic: cp_output_byte_topic

.yaml file for communication with S7-1200 PLC using 2 modules (CP1616 in IO Device mode)

- label: PLC_output_byte
  type: output
  size: 1
  slot: 2
  modId: 0x22
  subslotId: 0x01
  topic: plc_output_byte_topic

- label: PLC_input_byte
  type: input
  size: 1
  slot: 3
  modId: 0x21
  subslotId: 0x01
  topic: plc_input_byte_topic

PROFINET CONVENTION: "type" (input/output) is always assessed from an IO Controller point of view.

Launch files

The next step is to prepare launch file to launch both wrapper and user node as well as load filepath to .yaml config to ROS Parameter server

example .launch file for an IO Controller mode:

  <!--   Load yaml config filepath on rosparam server -->
  <param name="filepath" value="$(find siemens_cp1616_io_controller_tutorial)/config/test_io_controller_config.yaml"/>

  <!--   Wrapper node  -->
  <node
    name="siemens_cp1616_io_controller_wrapper"
    pkg="siemens_cp1616"
    type="siemens_cp1616_io_controller_wrapper"
    output="screen" />

  <!--   User node -->
  <node
    name="siemens_cp1616_io_controller_tutorial"
    pkg="siemens_cp1616_io_controller_tutorial"
    type="siemens_cp1616_io_controller_tutorial_node"
    output="screen" />

</launch>

example .launch file for an IO Device mode:

  <!--   Load yaml config filepath on rosparam server -->
  <param name="filepath" value="$(find siemens_cp1616_io_device_tutorial)/config/test_io_device_config.yaml"/>

  <!--   Wrapper node  -->
  <node
    name="siemens_cp1616_io_device_wrapper"
    pkg="siemens_cp1616"
    type="siemens_cp1616_io_device_wrapper"
    output="screen" />

  <!--   User node -->
  <node
    name="siemens_cp1616_io_device_tutorial_node"
    pkg="siemens_cp1616_io_device_tutorial"
    type="siemens_cp1616_io_device_tutorial_node"
    output="screen" />

</launch>

Usage

Load the CP1616 driver

The CP Linux driver needs to be loaded manually

$ sudo su
# cd host_linx
# make load

If everything is OK, driver should respond:

load cp1604 cp1616 example driver...and all submodules separately.
done

Launch siemens_cp1616 package

Before launching siemens_cp1616 package, make sure that selected CP mode (IO Controller/ IO Device) as well as filepath to .yaml file are correct and all the data in .yaml configuration meets existing hardware setup.

$ roslaunch siemens_cp1616 test_io_controller.launch

$ roslaunch siemens_cp1616 test_io_device.launch

Topics

After all modules/slots/transfer_areas from .yaml configuration were initializes successfully, cyclic data transmissions should start immediately. Sometimes (especially in IO Device mode) it is difficult to figure out which topics are intended for publishing and which are for subscribing. To handle these assignments, keep in mind that data direction are always assessed from IO Controller point of view so:

If CP1616 is in IO Controller mode, then:

- for module configured as "input", data received from PROFINET are published to input module topic.

- for module configured as "output", data subscribed from the output module topic are transmitted to PROFINET.

If CP1616 is in IO Device mode, (with PLC as an IO Controller for example), then:

- for module configured as "input", data subscribed from the input module topic are transmitted to PROFINET.

- for module configured as "output", data received from PROFINET are published to output module topic.

Cycle times for data transmission between CP1616 and particular PROFINET device which are defined directly in (STEP7 or other) project usually reach 1-2ms. From ROS user point of view, data to be published or subscribed from topics are red from/written to CP buffers every 10ms (default). Adjustment of this period is possible directly in siemens_cp1616 code.

All topics use the same message type -std_msg::UInt8MultiArray, hence providing basic byte transfers between ROS application and PROFINET network. To see particular examples how to interface CP topics directly from code check out the following tutorials.

Services

If CP1616 is in IO Device mode, following alarm services are available:

- set_alarm - this service sends a diagnostic alarm to the IO Controller and sets IO Device state to "ERROR".

- reset_alarm - this service resets diagnostic alarm and sets IO Device state to "OPERATE"

To see particular examples how to interface CP services directly from code check out the CP1616 - IO Device tutorial.

Available tutorials

See theTutorials page for an overview of the available tutorials.

Wiki: siemens_cp1616/Tutorials/Introduction to siemens_cp1616 (last edited 2016-08-23 12:59:03 by FrantisekDurovsky)