Pnspo!: Modbus Solution Cp1H / Cp1L / Cj1 / Cj2 / Cs1
Pnspo!: Modbus Solution Cp1H / Cp1L / Cj1 / Cj2 / Cs1
Pnspo!: Modbus Solution Cp1H / Cp1L / Cj1 / Cj2 / Cs1
!
Modbus Solution
CP1H / CP1L / CJ1 / CJ2 / CS1
Version 2.05
6/18/2009
Section 1. Overview
The Omron CP1H and CP1L PLCs offer a built in function called ‘Easy Modbus’, that
performs a Modbus RTU Master function, allowing the PLC to communicate with
devices that use the Modbus RTU protocol, such as inverters, scales, temperature
controllers, etc. The CJ1 / CJ2 / CS1 PLCs support Modbus through a Protocol Macro.
While the ‘Easy Modbus’ or ‘Protocol Macro’ functions are powerful functions, they
require the user to develop a ladder program to feed data to and retrieve data from the
‘Easy Modbus’ or ‘Protocol Macro’ function. This can be intimidating to a user.
This Modbus Solution was developed to provide a pre-written solution to Modbus RTU
applications, supporting up to 100 ‘items’ to read and 100 ‘items’ to write. An ‘item’ is
an individual data point on a device such as ‘present temperature of node 4’, or
‘frequency reference on node 7’.
The Modbus RTU function codes that are supported are:
The NS series HMI application that is provided is not necessary for the solution, but is
intended to assist in setup and monitoring of the Modbus Solution.
Memory Considerations:
The Modbus Solution uses ~ 1,500 steps of PLC User Memory for CP1H /
CP1L and ~1600 steps for CJ1 / CJ2 / CS1.
This represents the following amount for each PLC CPU type. Keep this
memory usage in mind when selecting a PLC CPU for an application.
The PLC must have an RS232 port (CP1H or CP1L-M type, or CJ1 / CJ2/ CS1)
1 CP1W-CIF01 for communications to the HMI from CP1H or CP1L
1 NS8 HMI
1 C200H-CN510-EU (or similar) PLC to NS cable
For RS-485 communications, set the DIP switches on the back of the CP1W-
CIF11 or CIF12 adapter as shown prior to installing in the PLC.
The Port that is being used for Modbus communications will need to be
configured as shown. Be certain to download the PLC settings to configure the
serial port, and make certain that the DIP Switch associated with the port is OFF.
This is DIP Switch 4 on CP1L-L, and DIP Switch 5 on CP1L-M and CP1H.
Section 3. Setup for CJ1 / CJ2 / CS1
The CJ1 / CJ2 / CS1 configuration for the Modbus Solution requires an SCU31 /
SCU41 module.
The built in ports on the PLC CPU cannot be used for this function. An SCB
(Serial Communications Board) on a CS1 cannot be used for this function.
The SCU module must be set for unit #F, and the top communications port is
used as shown. Set the 2/4 wire mode for 2 wire (RS485), and the Terminating
Resistance switch to ON.
The port must be configured through the I/O table of CX Programmer, and setup
as shown below.
The Protocol Macro must also be downloaded to the SCU module via CX
Protocol.
Section 4. Data Layout for Modbus RTU data exchange
To read and write data from and to a Modbus RTU capable device, the user simply
manipulates data in data tables in the PLCs DM (Data Memory) area. The Modbus
Solution automatically communicates to the Modbus devices based on the data tables.
To read from a Modbus Slave device: The user fills in the ‘Read Data’ Table as follows.
Item 1 is shown, but the data layout is the same for all items. Shaded items are set by
the user, non-shaded items are populated by the Modbus Solution.
The PLC program will cycle through the items in order. To mark the last item to read,
enter ‘F000’ in the ‘Last Item to Read’ memory location for the last ‘item’. Set ‘0000’ for
all but the last ‘item’. If there are no read items for the application, set D5009 to ‘E000’.
Address Setting
D5000 Modbus Slave Node Number In HEX
D5001 Modbus Function Code In HEX
D5002 Starting Modbus Address to Read In HEX
D5003 Number of Modbus Addresses to Read In HEX, 0 – 31 for coils, 0 or 1 for registers
D5004 First word of Response Data
D5005 Second word of Response Data Not used if < 16 coils or 1 register is read
D5006 Not used
D5007 Not used
D5008 Is the Data Valid? FFFF = invalid (ie error), 0000 = valid, F000 =
data not yet read (set on powerup)
D5009 Last Item to Read? Set to F000 if this is the last item to read
Example: To read the present frequency and current for an Omron 3G3JX inverter, the
Read Data Tables would be configured as follows:
The PLC program will cycle through the items in the read table, and write data to a
Modbus Slave only on Data Change. To mark the last item to write, enter ‘F00x’ in the
‘Last Item to Write’ memory location for the last ‘item’. Set ‘000x’ for all but the last
‘item’.
To set a particular write ‘item’ to FFFF after the data is written to the device, set
xxxA in the ‘Last Item’ field. This allows the same value to be written over and over
again in the Data register of the Modbus Solution, and the Modbus Solution will
correctly detect the changing data.
0000 = Not Last Write Item, do not detect same value write
000A = Not Last Write Item, detect same value write
F000 = Last Write Item, do not detect same value write
F00A = Last Write Item, detect same value write.
Address Setting
D6000 Modbus Slave Node Number In HEX
D6001 Modbus Function Code In HEX
D6002 Starting Modbus Address to Write In HEX
D6003 Number of Modbus Addresses to Write In HEX, 0 – 31 for coils, 0 or 1 for registers
D6004 First word of Write Data
D6005 Second word of Write Data Not used if < 16 coils or 1 register is read
D6006 Copy of last data sent first write word Used to detect ‘changed’ data
D6007 Copy of last data sent second write word Used to detect ‘changed’ data
D6008 Last Write Successful? FFFF = unsuccessful (ie error), 0000 = valid,
F000 = data not yet written (set on powerup)
D6009 Last Item to Write / Detect Same Data? 0000, 000A, F000, F00A as explained above
Example: To Write a Frequency Reference for Omron 3G3JX inverters at nodes 9 and
12, the Write Data Tables would be configured as follows:
Each Read / Write has a 3 retry on timeout setting. The timeout value is set in the PLC
port setup for CP1H / CP1L, and in the Protocol macro for CJ1 / CJ2 / CS1.
The Modbus Solution has an overall error log. The last 5 errors are logged as follows:
(W220 + W221 is the most recent error). Consult the Modbus specification for the
slave device to determine the cause and solution to the Modbus error.
There is also a complete copy of the Modbus string sent out the port, and received
back in the port for the last Modbus error. This is for CP1H / CP1L Only. For CJ1 /
CJ2 / CS1, use the Data Trace function in CX Protocol to analyze the Modbus strings.
W230 – W239 = Last sent Modbus Command that caused an error.
W240 – W249 = Last received Modbus command that contained an error.
The current polling cycle time can be viewed in W216 as xx.xx seconds as a BCD data
type. Example: W216 = 0140 means is takes 1.40 seconds to scan all the ‘items’ in
the read tables.
The CP1H / CP1L PLCs scan 10 ‘items’ in ~ 0.40 seconds (at 19,200 bps).
The CJ1 / CJ2 / CS1 PLCs scan 10 ‘items’ in ~ 1.30 seconds (at 19,200 bps).
The difference in these times is due to the overhead associated with Protocol Macros.
Section 7. Data Layout by Function
Note: For function code 3 or 4, when reading a single 2 register parameter (such as
Accel in a 3G3JX), the result is word swapped.
Note: For function code 10, when writing a single 2 register parameter (such as Accel
in a 3G3JX), the data needs to be presented in a word swapped format.
Section 8. Table Setup Example for 3G3JX Inverter
Read Item 1 = Read All Status Coils from node 1
Read Item 2 = Read Frequency and Current from Node 1
c. Plug in the inverter and wait ~ 30 seconds in case the inverter is set to
use Modbus for communications. This lets it timeout.
d. Set B84 to 01.
e. Press and hold the Mode and Decrement Keys simultaneously.
f. Press and Hold the Stop/Reset key until the display blinks.
g. Release all 3 keys and let the inverter go through its initialization.
3. Change the following Inverter Parameters using the Operator Keypad.
a. A001 = 03. Set Modbus as Frequency Reference Input
b. A002 = 03. Set Modbus as the Run/ Stop command reference
c. C070 = 03. Set Modbus as the input method (not keypad).
d. C071 = 06. Set 19,200 as the baud rate
When starting at Coil 1 (set in the read item as ‘0’ by Modbus) for a read or write,
the coil numbers are as follows for a 3G3JX. This example uses Read Item 1
(D5000) as the item for reading the coils.
Shaded = Read only