Modbus TCP Client Add-On Instruction for ControlLogix and CompactLogix

Introduction

This document describes the application and use of the Modbus TCP Client Add-On Instruction.

Modbus TCP Client Add-On Instruction (AOI) allows users to implement Modbus TCP Client functionality into the Logix family of controllers. AOIs can be used standalone or can be added to an existing application following the directions outlined below.


                                     

Requirements

Hardware Requirements

The Modbus TCP Client code requires a ControlLogix or CompactLogix controller with an EtherNet/IP module that supports Logix Sockets functionality. See Knowledgebase technote 470690 for complete list of controllers and modules. https://rockwellautomation.custhelp.com/app/answers/detail/a_id/470690

 

Software Requirements

The Modbus TCP Client AOI code supports Logix controller revisions 20 and higher.

 

Memory Requirements

First instance of the Modbus TCP Client AOI uses about 93 Kbytes of memory. Each additional AOI instance requires about 20 Kbytes of memory. These estimates based on the ControlLogix 5570 family of controllers. Please note some Compactlogix controllers have a starting memory size as low as 384Kbytes. This code can take a significant amount of memory in smaller CompactLogix controllers.

 

Functional Requirements and Description

Supported Modbus Function Codes

Bit Level Commands

 

Function
Code
Name
Description
Supported
Values
Modbus Range
01
Read Coils
This function code is used to read contiguous status of coils in a remote device (0xxxx addresses). The coils in the response message are packed as one coil per bit of the data field.
Local Address: 0 to 1023
Server Address: 0 to 9999
Length:
1 to 256 coils
Local Address 00001-01024

Server Address 00001-09999
02
Read Discrete Inputs
This function code is used to read contiguous status of discrete inputs in a remote device (1xxxx addresses).
The inputs in the response message are packed as one coil per bit of the data field.
Local Address: 0 to 1023
Server Address: 0 to 9999
Length:
1 to 256 Inputs
Local Address 10001-11024

Server Address 10001-19999
05
Write Single Coil
This function code is used to write a single coil to either ON or OFF in a remote device (0xxxx addresses).
Local Address: 0 to 1023
Server Address: 0 to 9999
Local Address 00001-01024

Server Address 00001-09999
15
Write Multiple Coils
This function code is used to write to one or more coils in a sequence of coils to either ON or OFF in a remote device (0xxxx addresses).
Local Address: 0 to 1023
Server Address: 0 to 9999
Length:
1 to 256 coils
Local Address 00001-01024

Server Address 00001-09999

 

Word Level Commands

 

Function
Code
Name
Description
Supported
Values
Modbus Range
03
Read Holding Registers
This function code is used to read the contents of a contiguous block of holding registers (4xxxx addresses) in a remote device.
Local Address: 0 to 1023
Server Address: 0 to 9999
Length:
1 to 120 registers
Local Address 40001-
41024

Server Address 40001-49999
04
Read Input Registers
This function code is used to read the contents of a contiguous block of input registers (3xxxx addresses) in a remote device.
Local Address: 0 to 1023
Server Address: 0 to 9999
Length: 1 to 120
input registers
Local Address 30001-
31024

Server Address 30001-39999
06
Write a Single Holding Register
This function code is used to write to single holding register (4xxxx addresses) in a remote device
Local Address: 0 to 1023
Server Address: 0 to 9999
Local Address 40001-
41024

Server Address 40001-49999
16
Write Multiple Holding Registers
This function code is used to write to contiguous holding registers (4xxxx addresses) in a remote device.
Local Address: 0 to 1023
Server Address: 0 to 9999
Length:
1 to 120 registers
Local Address 40001-
41024

Server Address 40001-49999

 

Implementation

 

Modbus TCP Client AOI implementation

Using Periodic Task

It’s recommended to add AOIs into a Periodic task with Rate of 10ms (or higher). Slower rates will reduce controller load and reduce performance. Faster task rates will increase performance but will add a significant load to the controller.

Rung Import and tag naming changes

The pre-configured Add-On Instructions are supplied in a Rung format.

The Rung Import format must be used to implement the AOI.

Important: Use only the Rung Import process. Do not use Copy/Paste functionality or add these AOIs using Instructions tool bar. Doing this will remove configurations from pre-configured message instructions, making AOIs non-functional.

Rung Import process for Modbus TCP Client AOI

1. Open a Ladder Routine within your application
2. Right click on any empty area and select Import Rungs

                                             
3. Select raC_Opr_NetModbusTCPClient_Rung.L5X file and click Import
                                         
4. When Import Configuration Dialog opens, select Tags
                                            
5. You can leave final names as-is or change them to accommodate your application.
                       
6. To change Final Names click Find/Replace button
                                                                  
When Dialog opens, replace default name Client_01 with desired prefix, verify that Final Names Box is checked then click Replace All Close 

                             
Close Find/Replace dialog and verify Final Names

                                                            

7. Click Ok to finish the Import process The new rung should look like shown below without any errors 
               
8. Repeat Steps 2-7 if application requires additional Clients. DO NOT Copy/Paste.

 

Configure Local Operational Parameters


Modbus TCP Client requires a local EtherNet/IP module that supports Logix Sockets.

In this section we will link Modbus TCP Client AOI to this EtherNet/IP module.

1. Right Click on the tag attached to the Ref_Connection parameter and select Monitor “…”
                   
2. Expand Parameters tag. Specify the slot of the Local EtherNet/IP module.
                   
For 1756 ControlLogix processors specify the actual slot of desired 1756-EN2T(R) module. For 1756-L8xE controllers using the built in Ethernet port specify the 1756-L8xE controller slot. For CompactLogix 5370, 5380, 5480 controllers leave .LocalSlot at 0.

3. Specify the .LocalAddress of the EtherNet/IP module.
                     
For CompactLogix 5380 and 5480 in Dual IP Mode only, specify the IP Address of the Local Ethernet connection used for Modbus TCP communications. Leave this field blank for all other cases.

4. Specify Ethernet IP Address of the Modbus Server device. This address must be specified and cannot remain blank.
                     
5. Leave Default Modbus TCP port at 502. This value is Modbus TCP protocol standard.
6. If you change any of these Parameters during operation be sure to reset and then set the AOI Inp_Enable parameter tag.

Configure Data Transactions

1. Expand Transactions tags to expose Transaction 0 member tags

             
2. Set Polling Interval value in milliseconds.
Default value is 1000 (1 second). Minimum value is 80 msec. Any transaction with polling rate below 80ms will be polled at 1 second rate

            
3. Set Modbus Function code in TransType tag. See Supported Modbus Function Codes section for the list of supported commands.
              
4. Set BeginAddress tag. The value represents the beginning address in remote device (Modbus TCP Server) to read from or write to. Depending on the function used above, values 0…9998 represent Modbus addresses 00001-09999, 10001-19999, 30001-39999, 40001-49999 respectively.
              
5. Set Count tag. The value represents the number of items in remote device (Modbus TCP Server) to read from or write to.
            
6. Set LocalAddress tag. The value represents the beginning address in this programs' "_Data" arrays.
                                                   
                    
7. Start Modbus TCP Client by setting tag attached to Inp_Enable parameter to 1.
                                   


Implementation Restrictions

1. Implementation must be done using Import Rung function only to preserve Message instruction configurations. Do not use Copy/Paste as it will not bring complete Message instruction configurations and tags. Do not use Search/Replace tags once rung is implemented. All replacement can be done only during rung import.

2. Multiple instances of Client AOI are supported per controller. Each instance must use own set of backing and Message tags, however “…_Data” tag structure can be shared between AOIs.

3. Modbus TCP Server and Modbus TCP Client AOIs can reside in the same program. However Server applications may cause a temporary Client disconnection due to the shared Logix Sockets object.

Monitoring Modbus TCP Server operations


 1. Modbus Tags are located under Ref_ModbusData parameter tag.
                                       
This tag contains four separate data areas for coils (0xxxx), discrete inputs (1xxxx), input registers (3xxxx) and holding registers (4xxxx). These tag values can be read and populated by the user application without any restrictions.
                                   
2. Modbus TCP AOI Status Bits
                               
  • Sts_EN output indicates that Modbus TCP Client functionality is enabled.
  • Sts_Connected output indicates that Client connection request was accepted by the Server. It does not indicate the active data flow. The status of individual transactions should be checked to verify the data exchange.
  • Sts_Faulted output indicates that one of the message instructions is faulted.
  • Sts_Overlap output indicates that one or more transaction is not completing before next trigger
  • Sts_Overload output indicates excessive Overlaps in one or more transactions.

3. Individual Transaction status information. These tags exist for each of the 5 built in transactions. Transaction 0-4).

TransComplete bit is set when requested transaction was completed. It’s cleared by the
program when next transaction is requested.
TransStatus value indicates the current status of transaction. 0 = success, 1 = in process, 2 = retry, -1 = exception


                                      
4. Transaction Diagnostic data structure provides internal dynamic information while the transaction is active. Do not write to these tags.
      

Performance data


 Modbus Client performance can be affected by many factors including: periodic task rate, performance of the Server device, speed of Client controller, how busy the Client controller is, network performance, network card, number of Clients in the controller, the number of active transactions etc.

Below are typical performance expectations when using an L7x Controller with a 10ms periodic task:




Number of Transaction Enabled
Recommended Minimum
PollInterval for all Transactions
1
80 mS
2
130 mS
3
220 mS
4
300 mS
5
380 mS

When using the recommended PollInterval settings or greater, you can expect the actual data delivery to be very close to the PollInterval.
NOTE:
If selected PollInterval settings are marginally too fast you will likely see occasional Sts_Overlap errors and your system should work reasonably well.

If selected PollInterval settings are extremely out of line, you will see both Sts_Overlap and Sts_Overload errors and your system will not work reliably. If you are getting Sts_Overload errors, you must make adjustments to your PollInterval settings.
 
  Sample AOI Download

 Credits to RockwellAutomation
.

Popular Posts