Modbus TCP Server - AOI Based Code For ControlLogix V 2.02.00
Modbus TCP Server - AOI Based Code For ControlLogix V 2.02.00
Modbus TCP Server Add-On Instruction (AOI) allows users to implement Modbus TCP Server
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.
Contents
Introduction .................................................................................................................................................. 1
Requirements................................................................................................................................................ 3
Hardware Requirements ........................................................................................................................... 3
Software Requirements ............................................................................................................................ 3
Memory Requirements ............................................................................................................................. 3
Functional Requirements and Description ................................................................................................... 4
Supported Modbus Function Codes ......................................................................................................... 4
Bit Level Commands.............................................................................................................................. 4
Word Level Commands ......................................................................................................................... 4
Data Format .......................................................................................................................................... 5
Implementation ............................................................................................................................................ 6
Modbus TCP Sever AOI implementation .................................................................................................. 6
Using Periodic Task ............................................................................................................................... 6
Rung Import and tag naming changes .................................................................................................. 6
Configure Operational Parameters ....................................................................................................... 9
Implementation Restrictions .................................................................................................................. 11
Monitoring Modbus TCP Server operations ............................................................................................... 12
Performance data ....................................................................................................................................... 14
Revision History .......................................................................................................................................... 15
Requirements
Hardware Requirements
The Modbus TCP Server 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 Server AOI code supports Logix controller revisions 20 and higher.
Memory Requirements
First instance of the Modbus TCP Server AOI uses about 123 Kbytes of memory.
Each additional AOI instance requires about 40 Kbytes of memory.
These estimates based on the ControlLogix 5570 family of controllers.
Please note that 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 Name Description Supported Modbus
Code Values Range
01 Read This function code is used by the Client to Start Address: 00001-02048
Coils read contiguous status of coils in a remote 0 to 2047
device (0xxxx addresses). The coils in the Length:
response message are packed as one coil 1 to 120 coils
per bit of the data field.
02 Read This function code is used by the Client to Start Address: 10001-12048
Discrete read contiguous status of discrete inputs in 0 to 2047
Inputs a remote device (1xxxx addresses). Length:
The inputs in the response message are 1 to 120 Inputs
packed as one coil per bit of the data field.
05 Write This function code is used by the Client to Start Address: 00001-02048
Single write a single coil. to either ON or OFF in a 0 to 2047
Coil remote device. (0xxxx addresses).
15 Write This function code is used by the Client to Start Address: 00001-02048
Multiple write one or more coils in a sequence of 0 to 2047
Coils coils to either ON or OFF in a remote Length:
device. (0xxxx addresses). 1 to 120 coils
The Modbus TCP Client AOI supports Modbus TCP standard format of big-endian protocol. This means
that the most significant byte of a 16-bit value is sent before the least significant byte.
Implementation
Modbus TCP Sever 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.
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.
5. You can leave final names as-is or change them to accommodate your application.
When Dialog opens, replace default name Server_01 with desired prefix, verify that Final Names
Box is checked then click Replace All
Modbus TCP Server requires a local EtherNet/IP module that supports Logix Sockets. See Requirements
section for details.
In this section we will link Modbus TCP Server 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 controllers 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 set the “.LocalSlot” to 0.
4. Leave Default Modbus TCP port at 502. This value is Modbus TCP protocol standard.
5. If you change any of these Parameters during operation be sure to reset and then set the AOI
Inp_Enable parameter tag.
2. Only one Server AOI is supported per CompactLogix controller (5370, 5380, 5480). ControlLogix
Controllers (1756) can have one server per each 1756-EN2T(R) module used, but each instance
must use own set of data tags.
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.
4. When implemented in ControlLogix Redundancy system, user should expect at least a 5 second
loss of Modbus communications after a controller switchover attributed to the Modbus TCP
Server AOI. There can be additional Modbus communications delays attributed to the behavior
of the exact Client device being used.
Monitoring Modbus TCP Server operations
This tag contains four separated 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.
Modbus Server performance can be affected by many factors including: periodic task rate, performance
of the Client device, speed of Server controller, how busy the Server controller is, network performance,
network card, number of Clients connected to the Server, the number of active transactions etc.
The Sever can affect the performance of the data delivery in the Client based on the following factors:
The Server can delay data delivery by as much as the following formula:
Example:
Assumptions:
(3 + 4) x 10 x 2 = 140msec
So in this example the Server can delay the actual data transmission by as much as 140 msec.
Revision History
1. Revision 1.02 – Initial Release in Ladder Program format. If you are currently using this code in an
existing application, you may continue to do so.
2. Server Revision 2.00.00 – Initial Release in Add-On Instruction format. This version is recommended
for use in all new applications.
2.1. Enhancements
2.1.1. Re-written code in Add-On instruction format
2.1.2. Reduced memory requirements
2.1.3. Simplified implementation and configuration