Note: This tutorial assumes you have completed previous tutorial siemens_cp1616/Tutorials/CP1616 in IO Controller mode - User Node.
(!) 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.

CP1616 in IO Controller mode - Runtime

Description: This tutorial teaches you how to run IO Controller wrapper and check the results

Keywords: SIEMENS, CP1616, PROFINET, IO Controller, Runtime

Tutorial Level: INTERMEDIATE

Next Tutorial: siemens_cp1616/Tutorials/CP1616 in IO Controller mode - Using IRT

This tutorial teaches you how to run IO Controller wrapper in comination with User Node, monitor and check the results. We recommend using additional computer connected to second PN port of PLC for easier monitoring and testing of PROFINET communication.

Run the launch file

If you have completed all configuration steps as described in previous tutorials it is time to run existing launch file:

roslaunch siemens_cp1616_io_controller_tutorial siemens_cp1616_io_controller_tutorial.launch

If initialization succeded, you should notice red error indicators on both PLC and CP1616 turn off and, and see the following terminal output:

[ INFO]: CP1616: Number of input modules: 3
[ INFO]: CP1616: Number of output modules: 3
[ INFO]: Input Data Array: [Total size: 13 bytes]
[ INFO]: I4116-4116 cp_input_byte_topic [1 byte]
[ INFO]: I4124-4127 cp_input_real_topic [4 bytes]
[ INFO]: I4132-4139 cp_input_byte_array_topic [8 bytes]
[ INFO]: Output Data Array: [Total size: 13 byte]
[ INFO]: Q4120-4120 cp_output_byte_topic [1 bytes]
[ INFO]: Q4128-4131 cp_output_real_topic [4 bytes]
[ INFO]: Q4136-4143 cp_output_byte_array_topic [8 bytes]
[ INFO]: Openning CP1616 in IO_controller mode: done
[ INFO]: IO_controller mode change request-> OPERATE:
[ INFO]: Changing IO_controller mode: done
[ INFO]: IO Controller ready, communication started

NOTE: If initialization fails and return errors, please check if yaml config file meets the hardware configuration (addresses, sizes). If nevertheless errors still occurs please refer to original siemens cp1616 documentation.

Check CP1616 Webserver

If you have configured webserver in TIA Portal project, you can connect to CP1616 LAN Port and monitor CP state through Webserver interface. If initialization succedded, CP1616 should report "OPERATE".

IO_controller_webserver.jpg

Monitor topics

First use rostopic list command line tool to get the list of all active topics:

$ rostopic list

For this tutorial example, rostopic list should return:

/cp_input_byte_array_topic
/cp_input_byte_topic
/cp_input_real_topic
/cp_output_byte_array_topic
/cp_output_byte_topic
/cp_output_real_topic
/rosout
/rosout_agg

With default configuration, CP buffers are updated and synchronized with data on topics every 10ms. Using rostopic hz command line tool check if "cp_input" topics are updated regularly.

$ rostopic hz /cp_input_byte_topic

For this tutorial example, rostopic hz should return similar results:

average rate: 99.983
        min: 0.009s max: 0.010s std dev: 0.00042s window: 99
average rate: 99.999
        min: 0.009s max: 0.010s std dev: 0.00043s window: 199
average rate: 99.996
        min: 0.009s max: 0.010s std dev: 0.00043s window: 299

Average rate of cp_output topics in this example is approximately 2, since our tutorial node publishes data every 0.5 second. But synchronization with CP buffers still happens every 10ms.

Use Watch and Force tables

Using separate computers allows you to monitor and force values while running CP1616 application on the Linux side. To monitor data transmitted from CP1616 into PLC, you can use TIA Portal "Watch tables":

IO_controller_watch_tbl.jpg

To monitor and test opposite data direction you can use TIA Portal "Force tables".

IO_controller_force_tbl.jpg

For example after forcing "CP_input_byte" to 10, you should see updated value on "cp_input_byte_topic":

$ rostopic echo /cp_input_byte_topic

Should provide following output:

layout:
  dim:
    -
      label: CP_input_byte
      size: 1
      stride: 0
  data_offset: 0
data: [10]

Testing on single computer

In case when only single computer is available, use HMI or PLC Inputs/Outputs or other tools to monitor and change variables being transmitted over PROFINET.

Wiki: siemens_cp1616/Tutorials/CP1616 in IO Controller mode - Runtime (last edited 2015-11-09 20:07:47 by FrantisekDurovsky)