Modbus Server

From Wiki
Revision as of 14:23, 27 June 2022 by Mab (talk | contribs) (Added Modbus mapping spread sheet)

The Modbus protocol can be used for controlling robots among other devices from a central PLC to achieve a combined workflow. A register mapping defines sets of 1-bit and 16-bit registers that can be read for information or written to send parameters, change states or start actions.

The embedded robot control TinyCtrl supports Modbus TCP. This article gives a short overview of the features, a more in-depth explanation can be found in the user manual.

Programming blocks for Siemens S7-1200 and S7-1500 will be provided for easy integration of basic features.


Introduction Video

TitleScreenModbus small.JPG

Video Link: Modbus Interface Video on YouTube

Availability

The Modbus server is implemented in TinyCtrl version V980-12-018 and newer. Please upgrade your integrated robot control to the current version.

Using the Modbus server requires a license for each robot control. More information can be found on our shop.

Without a license the Modbus features can be tested for 30 minutes. Another test duration can be started by restarting the robot.

Documentation

The robot control user guide covers the Modbus Interface in a seperate chapter of 10 pages with alle necassary information. The latest version can be downloaded here: DocumentationEN

Here you can find the Modbus mapping as a spread sheet. Details on the data format is explained in the user guide.

This Wiki page contains the starting points and downloadable material, but for the complete depth of details please refer to the user guide.

Setting up the Modbus server

Modbus configuration via CPRog/iRC

By default the Modbus server is disabled. It can be enabled using CPRog/iRC.

  • Connect CPRog/iRC to the robot by clicking "Connect"
  • Click File -> Configure Interfaces -> Modbus.
  • Check the box "Enabled" to enable the server.
  • Change the port and maximum number of connections if necessary.
  • Click "Apply" or "Save Project" below the configuration to apply the changes. The Modbus server will start immediately.

PLC integration

As demonstration and example for operation with Siemens S7 1200/1500 a program block can be downloaded. The library contains a function block that covers the communication with the robot control. It is available here: CPR_ROBOTS_TiA_Lib_V01-06.zal16 If you are updating the block please also update the DataTypes in the block.

This block is generic and will not fit to every application. Therefore it provided with access to the code so that it can be adapted to the use case. The block covers most of the available data, this leads to longer communication times. If your application requires only few variables in low cycle times we recommend to adapt the function block to your needs, especially reduce the number of transferred variables.

The Modbus interface can also be used with different PLC types, the necessary information are found below and in the documentation.

Modbus mapping

The Modbus protocol defines 4 access types that generally refer to distinct sets of parameters:

  • Discrete inputs (1 bit, read only)
  • Coils (1 bit, read/write)
  • Input registers (16 bit, read only)
  • Holding registers (16 bit, read/write)

Our mapping uses these depending on what access type is appropriate for what information. Status information can be read from discrete inputs and input registers, states can be changed by writing to coils and holding registers, actions can be startet by writing to coils.

A complete mapping table can be found in the user manual.

To test whether the Modbus connection is successful the input registers on addresses 0-3 can be read: These contain the TinyCtrl version and mapping version, e.g. 980, 12, 20, 1.

Digital inputs and outputs

  • Digital inputs can be read on discrete inputs 300-363 and as bitsets on input registers 207-210.
  • Digital outputs can be read or changed on coils 300-363 and as bitsets on holding registers 207-210.

Program variables and global signals

The Modbus server enables communication with the robot program using global signals, number variables and position variables:

  • Global signals work similar to the digital outputs: They can be read or changed on coils 200-299 or as bit sets on holding registers 200-206.
  • The Modbus server defines 32 number variables (mb_num1 - mb_num32) which can be read or written as 16 bit integers on addresses 480-511
  • 32 position variables (mb_pos1 - mb_pos32) are defined as a combination of 16 registers each on addresses 512-1023. Please refer to the user manual for more information.

Moving Robots via Modbus

The Modbus server offers two approaches for moving the robot:

  • Position variables: Write your position as joint angles or cartesian position to a position variable, then use a robot program with a Join-by-Variable or Linear-by-Variable command to move to the position.
  • The mapping provides registers for motion target positions (joint angles or cartesian positions). By writing 1 to a specific coil address a cartesian, joint or relative motion can be started. Please refer to the mapping table in the user manual.

The article Moving Robots via Modbus gives a more in-depth explanation on how to move a robot.