Vai al contenuto

Generic Modbus Slave

After inserting a Generic Modbus node under the Ethernet node, you can click it to show:
  • Inside the main window, the General tab and the Parametrization tab.
  • Inside the catalog window, the list of all the available Modbus commands.
Generic Modbus Slave-image_0The General tab allows you to set:
  • Name: the name of the slave node
  • IP address: the IP address of the slave node
  • Modbus address: the Modbus address of the slave node inside the RTU network
  • Node number: a value used for diagnostic purpose to identify the slave node
The Parameterization tab lets you define a series of Modbus objects to be sent to the slave node at each PLC restart.The list of objects to be sent is built with the Add and Remove buttons that appear on the Tab. Generic Modbus Slave-image_0Once an object (a row of the table) is added, you have to set:
  • Address: Modbus address of the object to be written
  • Type: type of the object to be written
  • Value: value assigned to the object to be written
  • TimeOut: value of maximum time (in milliseconds) after which the operation is consid- ered failed (default is 200 ms)
Always by dragging or adding from the catalog window, you can also assign to the slave device node, one or more Modbus commands (you may not see always all of this commands):
  • Modbus FC-01(Read Coils): reading of one or more RW bits by slave node
  • Modbus FC-02(Read Discrete Inputs): reading of one or more RO bits by slave node
  • Modbus FC-03(Read Holding Registers): reading of one or more RW registers by slave node
  • Modbus FC-04(Read Input Registers): reading of one or more RO registers by slave node
  • Modbus FC-05(Write Single Coil): writing of a single RW bit on slave node
  • Modbus FC-06(Write Single Register): writing of a single RW register on slave node
  • Modbus FC-15(Write Multiple Coils): writing of one or more RW bits on slave node
  • Modbus FC-16(Write Multiple registers): writing of one or more RW registers on slave node
Let’s suppose we add a Modbus FC-01(Read Coils) command, selecting it from the project tree, you’ll see a new window in the main window with a General tab and a Coils tab (the tabs depends on the command, if it was a Modbus FC-16 (Write Multiple registers) command, you would have seen a General tab and a Multiple Regs. tab). Generic Modbus Slave-image_0In the General tab, you can set:
  • Start address: Modbus address of the first object (coil) to be read
  • Polling time: minimum interval of time (in milliseconds) to wait before executing again the command; if set to 0, the time between two commands execution depends on the PLC idle
  • Timeout: value of maximum time (in milliseconds) after which the operation is considered failed (default is 1000 ms)
  • Wait before send: waiting time before each command execution, doesn’t count PLC idle time. This time is added to Polling time value. (Default 0)
  • One shot variable: you can specify a BOOL variable that is used to trigger the sending ofthe command. When this variable is set to TRUE the command is sent, then, when the command is actually served, the variable is automatically reset by Modbus RTU master.
On the Coils tab, you can decide how many objects (coils) read with every command execution, starting from the Start address set on the General tab. Generic Modbus Slave-image_0You have to assign a variable to each element (row of the table), using one of the following modes:
  • usign the Assign button, choose one of the variables previously declared on the PLC (for coils only booleans are allowed). The variable will be mapped as a datablock.
  • directly declare a new variable in the Label column, the variable will be mapped as a datablock boolean variable.