Receive Instruction: MODBUS TCP

Topic: CL213

Description

The Receive instruction allows you to use Com Port 1 (Ethernet), 2 or 3 (if available) on the CLICK CPU modules as a network master and read data from external devices. The CLICK CPU modules support the MODBUS RTU, MODBUS TCP and ASCII protocols. This help topic covers the MODBUS TCP protocol. Please refer to the help topic Receive Instruction: MODBUS RTU for the MODBUS RTU protocol or Receive Instruction: ASCII for the ASCII protocol.

If you use Com Port 1 (Ethernet) on the CLICK CPU modules as a MODBUS TCP server (slave), you don’t need to use this instruction.

If you need more detailed information about the MODBUS protocol, we recommend to visit the following web site: www.MODBUS.org

1 COM Port: Select Port 1 to use the Ethernet port.

2 Protocol:COM Port 1 only supports the MODBUS TCP protocol.

3 COM Port Setup: Click on this button to open the Com Port Setup window.

4 Server (Slave) IP Address: Enter the IP Address of the target server.

5 Server Port Number: Enter the Port Number of the target server. ‘502’ is the default.

6 Slave ID of Serial Device: Typically used for Modbus TCP to Modbus RTU gateways but some server devices may require a certain value. This value may be either a number or a DS Address.

7 MODBUS Function Code: Select one of the following MODBUS function codes:
01 – Read Coil Status
02 – Read Input Status
03 – Read Holding Registers
04 – Read Input Registers

8 Addressing Type: Select one of the following MODBUS Addressing Types:

Addressing Type

Description

MODBUS 984

Addressing

This Addressing is patterned after the Modicon PLC addressing, which many devices support.

0***** are Coils (Read/Write).

1***** are Input Bits (Read only).

3***** are Input Registers (Read Only)

4***** are Holding Registers (Read/Write)

MODBUS Hex

Addressing

This Addressing is patterned after what the MODBUS protocol actually requests, which is simply a Function Code + an Offset.

CLICK Addressing

If the MODBUS slave is the CLICK PLC, we recommend to use this CLICK Addressing because you can use the Address Picker to select the Starting Slave Address.

9 Starting Slave Address: Enter the Slave Address to start reading data from. The table below shows the valid Slave Addresses.  If CLICK Addressingis selected, you can use the Address Picker by clicking the icon.

MODBUS

Addressing

Function Code

01

02

03

04

MODBUS 984

1 to 65535

100001 to 165535

400001 to 465535

300001 to 365535

MODBUS Hex

0h to FFFEh

0h to FFFEh

0h to FFFEh

0h to FFFEh

CLICK

X, Y, C, T, CT and SC

X, Y, C, T, CT and SC

CTD, DS, DD, DH, DF, SD, TD, YD and TXT

CTD, DS, DD, DH, DF, SD, TD, YD and TXT

10 Starting Master Address:  Enter the Starting Memory Address of the Master CLICK CPU module to save the read data from the MODBUS slave. You can use the Address Picker by clicking the icon.

Function Code

01

02

03

04

Y and C

Y and C

CTD, DS, DD, DH, DF, SD, TD, YD and TXT

CTD, DS, DD, DH, DF, TD, SD, YD and TXT

11 Number of Bits: Enter the size of the data to read from the MODBUS slave.

12 Word Swap: This option is only available when the Starting Master Address is a DD or DFMemory Address. These Memory Addresses have 32 bit data length, so they can store the data read from two registers in the MODBUS slave. You can swap the order of the data to be stored in the DD or DF Memory Address.

13 Character Order: This option is not available with the current Firmware Version.

14 Receiving: Assign a C bit as the Receiving flag. This C bit turns ON when the Com Port is sending a read request to a MODBUS slave with this instruction. Please refer to the Timing Chart shown below.

Note: This Receiving flag is OFF when another Receive instruction is requesting data from the MODBUS slave.

15 Success: Assign a C bit as the Success flag.  This C bit turns ON after the Com Port received data from the MODBUS slave successfully.  It stays ON until the instruction is re-enabled. Please refer to the Timing Chart shown below.

16 Error: Assign a C bit as the Error flag. This C bit turns ON after the Com Port could not receive data from the MODBUS slave successfully. It stays ON until the instruction is re-enabled. Please refer to the Timing Chart shown below.

17 Exception Response (Error Code): Assign a DS or DD Memory Address to store the Exception Response from the MODBUS slave.

Note: Each MODBUS slave connected to the CLICK PLC would support a different set of the Exception Response.  Please refer to the User Manual/Specifications of each MODBUS Slave. If you are using a CLICK PLC as a MODBUS Slave, please refer to this topic for the Exception Response that the CLICK PLC supports.

18 About Error Flag: If the Slave ID Is outside the range of 0 to 255, SC43: Out of Range will be set TRUE.

Timing Charts

Read Data from a MODBUS Slave Once

Read Data from a MODBUS Slave Continuously

Related Topics Link IconRelated Topics