Difference between revisions of "Modbus Server"

From Wiki
m (Added S7 usage example)
 
(26 intermediate revisions by 3 users not shown)
Line 8: Line 8:
 
= Introduction Video =
 
= Introduction Video =
  
[[file:TitleScreenModbus_small.JPG|200px|link=https://www.youtube.com/watch?v=GGD7pND2IAU]]
+
[[file:TitleScreenModbus_small.JPG|600px|link=https://www.youtube.com/watch?v=GGD7pND2IAU]]
 
 
  
 
Video Link: [https://www.youtube.com/watch?v=GGD7pND2IAU Modbus Interface Video on YouTube]
 
Video Link: [https://www.youtube.com/watch?v=GGD7pND2IAU Modbus Interface Video on YouTube]
  
 
= Availability =
 
= Availability =
The Modbus server is implemented in TinyCtrl version V980-12-XXX (to be released in September 2021). Please upgrade your software to the current version.
+
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. More information can be found [https://shop.cpr-robots.com/?product=modbus-tcp-ip-schnittstelle on our shop].
+
In versions 12 and 13 using the Modbus server requires a license for each robot control. More information can be found [https://rbtx.com/de/components/software/modbus-tcpip on RBTX]. Since version 14 it can be used without a license.
  
 
Without a license the Modbus features can be tested for 30 minutes. Another test duration can be started by restarting the robot.
 
Without a license the Modbus features can be tested for 30 minutes. Another test duration can be started by restarting the robot.
  
= Setting up the Modbus server =
+
= 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: [[IgusRobotControl-Release13-EN | DocumentationEN]]
  
By default the Modbus server is disabled. In order to enable it the project configuration file of the embedded control must be changed. It can either be accessed via CPRog/iRC or an SFTP client:
+
[[Media:Modbus_Mapping.pdf|Here you can find the Modbus mapping as a spread sheet.]] Details on the data format is explained in the user guide.
* via CPRog/iRC
 
** Connect CPRog/iRC to the robot
 
** Click File -> Access Remote Configuration
 
** Find the project configuration section and click Load
 
** After changing the file using a text editor click Write and select the changed file.
 
* via a SFTP client
 
** Please refer to sections 1 and 2 of this guide: [[FTP and putty Access]]
 
** Find the file /home/robot/TinyCtrl/Data/Projects/EmbeddedCtrl.prj
 
** Edit it with a text editor, then save it and make sure it is written back to the robot control
 
  
Once you opened the project file in a text editor find the section <Environment>. In that section try to find a line starting with <ModbusServer. If it does not exist create it as follows. Change the port and connection count if necessary.
+
This Wiki page contains the starting points and downloadable material, but for the complete depth of details please refer to the user guide.
  
<ModbusServer Active="true" Port="502" MaxConnections="5"/>
+
= Setting up the Modbus server =
 +
[[File:ModbusConfigurationCPRog.PNG|thumb|Modbus configuration via CPRog/iRC]]
  
After changing the configuration file save it, write it back to the robot control and restart it by powering it down and up.
+
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 =
 
= PLC integration =
  
To be written...
+
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:
 +
[https://www.cpr-robots.com/download/CPRog/CPR_ROBOTS_TiA_Lib_V01-06.zal16 CPR_ROBOTS_TiA_Lib_V01-06.zal16]
 +
You will need TiA version 16 or newer. [https://www.cpr-robots.com/download/CPRog/ModbusTest.zap16 ModbusTest.zap16] contains usage examples.
 +
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 =
 
= Modbus mapping =
Line 58: Line 62:
  
 
= Digital inputs and outputs =
 
= Digital inputs and outputs =
* Digital inputs can be read on discrete inputs 300-363 and as bitsets on input registers 207-210.
+
* Digital inputs can be read on discrete inputs 364-427 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.
+
* Digital outputs can be read and changed on coils 300-363 and as bitsets on holding registers 207-210.
 +
* Global signals can be read and changed on coils 200-299 and as bitsets on input registers 200-206.
 +
 
 +
= Communicating with Robot Programs =
 +
 
 +
To communicate with the robot program a PLC can use the following mechanisms:
 +
* Global signals - boolean values similar to digital inputs / outputs
 +
* Number variables - 16 bit integer values
 +
* Position variables - a set of joint angles and cartesian position
 +
 
 +
== Global Signals ==
 +
Global signals can be read or changed via coils 200 (GSig1) - 299 (GSig100). You can also access global signals as 16 bit fields via holding registers 200 - 206.
 +
 
 +
== Number Variables ==
 +
Number variables exchange 16 bit integer values. Read and write directions are split: there are 16 variables that can be read by the PLC (mb_num_r1 - mb_num_r16 in input registers 440 - 455) and 16 that can be written (mb_num_w1 - mb_num_w16 in holding registers 440 - 455).
 +
 
 +
== Position Variables ==
 +
Position variables consist 16 succeeding register containing 6 robot axis values, 3 external axis values, cartesian XYZ coordinate and ABC orientation. Like the number variables there are 16 for reading (mb_pos_r1 - mb_pos_r16 in input registers 456 - 711) and 16 for writing (mb_pos_w1 - mb_pos_w16 in holding registers 456 - 711).
  
= Program variables and global signals =
+
The register order for each position variable is the following (example register numbers for position variable 1, the next variable follows directly after):
The Modbus server enables communication with the robot program using global signals, number variables and position variables:
+
* robot axes 1 - 6 (456 - 461)
* 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.
+
* external axes 1 - 3 (462 - 464)
* 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
+
* X, Y, Z (465 - 467)
* 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.
+
* A, B, C (468 - 470)
  
= Moving robots via Modbus =
+
Each register value has precision 0.1, e.g. a register value of 1234 means value 123.4 degrees or mm.
 +
 
 +
= Moving Robots via Modbus =
 
The Modbus server offers two approaches for moving the robot:
 
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.
 
* 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 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.
  
[[Category:TinyCtrl]]
+
The article [[Moving Robots via Modbus]] gives a more in-depth explanation on how to move a robot.
 +
 
 +
[[Category:Configuration]][[Category:TinyCtrl]][[Category:Modbus]]

Latest revision as of 09:28, 17 May 2024

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.

In versions 12 and 13 using the Modbus server requires a license for each robot control. More information can be found on RBTX. Since version 14 it can be used without a license.

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 You will need TiA version 16 or newer. ModbusTest.zap16 contains usage examples. 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 364-427 and as bitsets on input registers 207-210.
  • Digital outputs can be read and changed on coils 300-363 and as bitsets on holding registers 207-210.
  • Global signals can be read and changed on coils 200-299 and as bitsets on input registers 200-206.

Communicating with Robot Programs

To communicate with the robot program a PLC can use the following mechanisms:

  • Global signals - boolean values similar to digital inputs / outputs
  • Number variables - 16 bit integer values
  • Position variables - a set of joint angles and cartesian position

Global Signals

Global signals can be read or changed via coils 200 (GSig1) - 299 (GSig100). You can also access global signals as 16 bit fields via holding registers 200 - 206.

Number Variables

Number variables exchange 16 bit integer values. Read and write directions are split: there are 16 variables that can be read by the PLC (mb_num_r1 - mb_num_r16 in input registers 440 - 455) and 16 that can be written (mb_num_w1 - mb_num_w16 in holding registers 440 - 455).

Position Variables

Position variables consist 16 succeeding register containing 6 robot axis values, 3 external axis values, cartesian XYZ coordinate and ABC orientation. Like the number variables there are 16 for reading (mb_pos_r1 - mb_pos_r16 in input registers 456 - 711) and 16 for writing (mb_pos_w1 - mb_pos_w16 in holding registers 456 - 711).

The register order for each position variable is the following (example register numbers for position variable 1, the next variable follows directly after):

  • robot axes 1 - 6 (456 - 461)
  • external axes 1 - 3 (462 - 464)
  • X, Y, Z (465 - 467)
  • A, B, C (468 - 470)

Each register value has precision 0.1, e.g. a register value of 1234 means value 123.4 degrees or mm.

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.