Modbus TCP Connectivity

ProtoTwin Connect supports the Modbus TCP protocol for connection to any PLC that can run a Modbus server (slave) over TCP. Note that the process is simplified if you are connecting to Schneider Modicon or Arduino PLC. Please refer to the specific documentation for those PLCs.

Server Configuration

Click the “Add Server” button in the “Servers” tab of the IO Browser and configure the server as follows:

  • Protocol: Select “Modbus/TCP” from the list.
  • Type: Select “Generic” from the list.
  • Name: Enter a (preferably) unique name, which will be used to identify the server.
  • Host: Enter the static IP address of the PLC.
  • Port: Enter the port number for the Modbus TCP server (typically 502).
  • Unit ID: Enter the unit/slave ID for the Modbus TCP server (typically 255).
  • Flags: Optionally enable any flags for features supported by the PLC.
  • Scan Rate: Enter the desired scan rate, which is the interval (in seconds) at which ProtoTwin Connect will read and write tag values.

Note that the scan rate is the desired interval at which tags are read and written. The actual rate will depend on the performance of the PLC and networking latency. You can set the scan rate to zero in order to read/write as fast as possible.

Save the configuration to add the server.

Areas

Modbus addresses are divided into the following areas:

  • Coils: Discrete bits (Read from PLC, Write to PLC)
  • Discrete Inputs: Discrete bits (Read from PLC)
  • Input Registers: 16 bit numbers (Read from PLC)
  • Holding Registers: 16 bit numbers (Read from PLC, Write to PLC)

Your PLC may not support all of these areas. Some PLCs support only coils. Others support only registers. Some support coils and holding registers. You should refer to the manual for your PLC in order to determine the areas supported. Note that although coils are divided into discrete bits, it is possible to read/write numeric values from/to coils. For example, a 32-bit integer can be stored using 32 coils. Similarly, it is possible to read/write boolean values from/to registers. You can address the specific bit of a register, which is detailed in the section below.

Addressing

Different PLCs use different addressing schemes. ProtoTwin uses the most common addressing scheme, but it may be necessary to convert from the addressing scheme used by the PLC to the addressing scheme used by ProtoTwin. This section describes the addressing scheme used by ProtoTwin. If you are connecting to a Schneider Modicon or Arduino PLC then you should refer to the specific documentation for those PLCs, since the address conversion is performed automatically.

Modbus addresses are represented by at least 6 digits. The first digit specifies the area. The area digits are listed below:

  • Coils: 0
  • Discrete Inputs: 1
  • Input Registers: 3
  • Holding Registers: 4

The next 5 digits specify the coil/register number. This number starts from 1 and has a maximum value of 65536, although your PLC may not support the maximum:

  • 000001: The first coil.
  • 065536: The 65536th coil.
  • 100001: The first discrete input.
  • 300001: The first input register.
  • 400001: The first holding register.

You may specify a bit index for a boolean tag in order to refer to a specific bit of a register:

  • 400001.0: The first bit of the first holding register.
  • 400001.15: The last bit of the first holding register.

It is possible to read/write 32-bit integers or floating point numbers from/to both coils and registers:

  • UINT32 at address 000001: The 32-bit unsigned integer is stored in the coils, occupying coils 1 to 32 inclusive.
  • INT32 at address 300016: The 32-bit signed integer is stored in the input registers, occupying registers 16 and 17.
  • FLOAT at address 400001: The 32-bit floating point number is stored in the holding registers, occupying registers 1 and 2.