CP1L / CP1H / CJ2M Modbus/TCP Adapter Application and Setup Guide
CP1L / CP1H / CJ2M Modbus/TCP Adapter Application and Setup Guide
net
Omron CP1W-MODTCP61
CP1L / CP1H / CJ2M Modbus/TCP Adapter
Application and Setup Guide
Revision 2.00a
7/29/2011
www.infoPLC.net
Section 1: Introduction
This document explains the theory, operation, and setup of the Omron CP1W-
MODTCP61 Modbus/TCP adapter.
The CP1W- MODTCP61 is an adapter that allows a CP1L or CP1H PLC to operate in 1
of 2 modes, but not both at the same time. For clarity, the discussion of the setup and
operation of each of these 2 modes is handled in separate sections of this document.
The adapter also allows a CJ2M-CPU3 series PLC to operate in Slave mode only.
Mode 1: Modbus TCP Slave / Server. In this mode, the adapter functions as a slave
device, allowing other Modbus TCP Master devices to send commands to and receive
responses from the adapter using the Modbus TCP protocol.
Mode 2: Modbus TCP Master / Client. In this mode, the adapter functions as a
master device, sending Modbus TCP commands to and receiving responses from other
slave devices, such as IO blocks, inverters, PLCs, etc. Note: this mode is not
applicable to CJ2M-CPU3 series PLCs.
CP1 Series: The adapter mounts in the Option Board Slot on the front of a CP1L or
CP1H PLC, and can be used in all CP1L / CP1H PLCs with an available Option Board
Slot. A CP1L or CP1H PLC with 2 option board slots can use 2 CP1W-MODTCP61
adapters, with 1 functioning as a Modbus TCP Master / Client and 1 functioning as a
Modbus TCP Slave / Server.
CJ2M Series: The adapter mounts in the Option Board Slot on the front of a CJ2M-
CPU3 PLC. When used in a CJ2M-CPU3 series PLC, the adapter will only function
as a Modbus TCP Slave / Server. The adapter is not applicable for CJ2M-CPU1
series PLCs.
2
www.infoPLC.net
Section 2 - Modbus TCP Slave / Server
2.1 Modbus TCP Slave / Server Overview
When configured for Modbus TCP Slave / Server mode, the adapter functions as a
slave node, allowing other Modbus TCP Master / Client devices to send commands to
and receive responses from the adapter. These master devices include PCs with
software that uses the Modbus TCP protocol, as well as PLCs and other hardware
devices functioning as Modbus TCP masters.
The adapter uses the standard Modbus/TCP port 502, and supports the following
Modbus function codes:
3
www.infoPLC.net
2.2 Modbus Addressing in the PLC
When addressing the PLC memory map using the Modbus TCP protocol, D1000 is
considered the first register, and CIO 1000.00 is considered the first coil.
To determine the Modbus TCP register number for a PLC address, simply subtract
1000 from the PLC Data Memory location.
Register Examples:
To determine the Modbus TCP coil for a PLC bit, subtract 1000 from the CIO Channel
number, multiply by 16, and add the bit number.
Coil Examples:
4
www.infoPLC.net
2.4 Modbus TCP Slave / Server Applications
The CP1W- MODTCP61 allows Omron CP1L, CP1H, and CJ2M-CPU3 PLCs to
function as programmable I/O modules. The CP1W-MODTCP61 will not function in a
CP1E PLC in Modbus TCP Slave / Server mode.
The adapter is a Modbus/TCP slave device, meaning the adapter cannot establish a
connection to another device. A device, such as a PC or PLC, functioning as
Modbus/TCP Master, must be the device used to establish the TCP connection, and
control the communications to the CP1W- MODTCP61.
When using the adapter in Modbus TCP Slave/Server mode, the adapter will also
function as a FINS slave device, allowing the use of an NS Series HMI and / or CX-
Programmer programming software.
Up to 2 Modbus TCP Master / Client devices can communicate simultaneously with the
adapter, in addition to 2 FINS devices.
When using Modbus TCP clients to connect to the PLC through the CP1W-MODTCP61,
the client will be automatically disconnected after 30 seconds of inactivity to allow other
clients to connect. To maintain a TCP connection from a client, send at least 1
command at intervals of less than 30 seconds.
5
www.infoPLC.net
2.5 Modbus TCP Slave / Server Setup
6
www.infoPLC.net
2.6 Modbus TCP Slave / Server PLC Setup
CP1L / CP1H
The CP1W- MODTCP61 adapter uses the Toolbus (high speed binary) protocol when
operating in the Slave / Server mode. To configure the PLC port, simply turn ON the
appropriate DIP switch on the CP1L or CP1H PLC. For CP1L PLCs with 1 Option
Board, use DIP Switch 4. For CP1L PLCs with 2 Option Board Slots, or CP1H PLCs,
use DIP Switch 4 for Slot 1, and DIP Switch 5 for Slot 2.
CJ2M –CPU3x
For CJ2M-CPU3x PLCs, turn on DIP switch 5 (located under the flip up cover).
7
www.infoPLC.net
To maximize the throughput of the CP1W- MODTCP61, the amount of time per PLC
scan that is allowed for servicing communications ports should be increased. This is
accessed through the PLC Settings in CX-Programmer. On the Peripheral Service tab,
uncheck the ‘default’ option, and enter 50 (5.0 ms). Transfer these settings to the PLC
and cycle power to apply the changes.
D1201 3rd and 4th Octets in Hexadecimal: Ex. D1201 = 0119 = 1.25
This feature is only available with the CP1W-MODTCP61 is configured in Modbus TCP
Slave / Server Mode.
8
www.infoPLC.net
Section 3 - Modbus TCP Master / Client
3.1 Modbus TCP Master / Client Overview
When configured for Modbus TCP Master / Client mode, the adapter functions as a
master device, controlling the communications with other slave devices such as IO
blocks, inverters, PLCs, etc. The adapter sends Modbus TCP commands to and
receives Modbus TCP responses from the slave devices.
The CP1W- MODTCP61 allows Omron CP1L and CP1H PLCs (but not the CJ2M-
CPU3 PLCs) to function as control devices for remote IO slaves that use the Modbus
TCP protocol. The adapter is a Modbus TCP master device, meaning the adapter will
not respond to Modbus TCP commands issued from another Modbus TCP master
device. The Easy Modbus function of the PLC is used to send Modbus RTU commands
to the adapter, which are converted to Modbus TCP commands and delivered to the
remote device. The Modbus RTU Node Number is automatically used as the last octet
of the IP address of the destination device, with the first 3 octets of IP address of the
adapter used as the first 3 octets of the destination device.
Note: Unlike the Modbus TCP Slave / Server mode, the FINS protocol is not available
when using the adapter as a Modbus TCP Master / Client. If an NS HMI is required,
connect via a serial connection, or via a CP1W-ETN61 FINS Ethernet adapter.
9
www.infoPLC.net
3.3 Modbus TCP Master / Client Setup
10
www.infoPLC.net
3.4 Modbus TCP Master / Client PLC Setup
CP1L / CP1H
Before configuring the PLC port below, turn OFF the appropriate DIP switch on the
CP1L or CP1H PLC. For CP1L PLCs with 1 Option Board, use DIP Switch 4. For
CP1L PLCs with 2 Option Board Slots, or CP1H PLCs, use DIP Switch 4 for Slot 1, and
DIP Switch 5 for Slot 2.
The CP1W- MODTCP61 adapter uses the Serial Gateway function of the PLC when
operating in the Master / Client mode. The CP1W- MODTCP61 adapter uses 115,200,
8,1,N as the communications parameters for the interface to the PLC. Configure the
socket that is being used for the CP1W- MODTCP61 (Serial Port 1 = Socket 1, Serial
Port 2 = Socket 2) as shown. Be certain to set the Response Timeout value to 20 x
100ms (2 seconds) to optimize communications recovery when a timeout occurs. This
is configured through the Settings of CX-Programmer on the Serial Port 1 or Serial Port
2 tab.
Although the adapter can be used in either Socket 1 or Socket 2, Modbus RTU Master
Ladder code is available from Omron to make Modbus TCP Master / Client
communications easier, and this code uses Socket 1 in PLCs with only 1 socket, and
Socket 2 in PLCs that have 2 sockets.
11
www.infoPLC.net
To maximize the throughput of the CP1W- MODTCP61, the amount of time per PLC
scan that is allowed for servicing communications ports should be increased. This is
accessed through the PLC Settings in CX Programmer. On the Peripheral Service tab,
uncheck the ‘default’ option, and enter 50 (5.0 ms). Transfer these settings to the PLC
and cycle power to apply the changes.
12
www.infoPLC.net
Section 4: Command Examples – Modbus TCP Server / Slave
Example: Reading 10 Coils starting at CIO 1002.00 (CIO 1002.00 – CIO 1002.09)
Command Response
Function Code 01 Function Code 01
Starting Address Hi 00 Byte Count 02
Starting Address Lo 20 Coils 0 -7 32
Number of Coils Hi 00 Coils 8 - 9 00
Number of Coils Low 0A
Command Response
Function Code 03 Function Code 03
Starting Address Hi 00 Byte Count 08
Starting Address Lo 32 Register Hi D1050 12
Number of Registers Hi 00 Register Lo D1050 34
Number of Registers Low 04 Register Hi D1051 56
Register Lo D1051 78
Register Hi D1052 90
Register Lo D1052 AB
Register Hi D1053 CD
Register Lo D1053 EF
13
www.infoPLC.net
Function Code 05: Write Single Coil.
To turn a bit ON, set the Output Value to FF00. To turn a bit OFF, set the Output Value
to 0000.
Command Response
Function Code 05 Function Code 05
Starting Address Hi 02 Starting Address Hi 02
Starting Address Lo 85 Starting Address Lo 85
Output Value Hi FF Output Value Hi FF
Output Value Lo 00 Output Value Lo 00
Command Response
Function Code 06 Function Code 06
Starting Address Hi 00 Starting Address Hi 00
Starting Address Lo 63 Starting Address Lo 63
Register Value Hi 14 Register Value Hi 14
Register Value Lo 67 Register Value Lo 67
Example: Set the values of CIO 1045.11 – 1045.00 to 011110000011 (hex 783)
Command Response
Function Code 0F Function Code 0F
Starting Address Hi 02 Starting Address Hi 02
Starting Address Lo D0 Starting Address Lo D0
Number of Coils Hi 00 Number of Coils Hi 00
Number of Coils Lo 0C Number of Coils Lo 0C
Byte Count 02
Output Value Hi 83
Output Value Lo 07
14
www.infoPLC.net
Function Code 10: Write Multiple Registers.
Command Response
Function Code 10 Function Code 10
Starting Address Hi 00 Starting Address Hi 00
Starting Address Lo 7D Starting Address Lo 7D
Number of Registers Hi 00 Number of Registers Hi 00
Number of Registers Lo 03 Number of Registers Lo 03
Byte Count 06
Register Value Hi (D1125) FE
Register Value Lo (D1125) ED
Register Value Hi (D1126) DE
Register Value Lo (D1126) AD
Register Value Hi (D1127) BE
Register Value Lo (D1127) EF
15
www.infoPLC.net
Section 5: Additional Literature
16
www.infoPLC.net
OMRON ELECTRONICS DE MEXICO • SALES OFFICE OTHER OMRON LATIN AMERICA SALES
Apodaca, N.L. • 52.81.11.56.99.20 • 001.800.556.6766 • [email protected] 54.11.4783.5300
Omron Europe B.V. • Wegalaan 67-69, NL-2132 JD, Hoofddorp, The Netherlands. • Tel: +31 (0) 23 568 13 00
Fax: +31 (0) 23 568 13 88 • www.industrial.omron.eu
Cat. No. SG_CP1_MODTCP 07/11 Note: Specifications are subject to change. © 2011 Omron Electronics LLC Printed in U.S.A.