0% found this document useful (0 votes)
253 views19 pages

NX1P Modbus Solution V212

The document provides instructions for using an Omron NX1P Machine Automation Controller to communicate with Modbus RTU slave devices. It describes a pre-written Modbus RTU application that supports up to 100 read and 100 write items. It outlines how to configure read and write items, select an RS485 communication port, monitor errors and cycle time, and provides examples of using different Modbus functions to read and write data from devices.

Uploaded by

ma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
253 views19 pages

NX1P Modbus Solution V212

The document provides instructions for using an Omron NX1P Machine Automation Controller to communicate with Modbus RTU slave devices. It describes a pre-written Modbus RTU application that supports up to 100 read and 100 write items. It outlines how to configure read and write items, select an RS485 communication port, monitor errors and cycle time, and provides examples of using different Modbus functions to read and write data from devices.

Uploaded by

ma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

PNSPO!

!
NX1P
Modbus RTU Solution

Version 2.12
11/30/2016
Section 1. Overview
The Omron NX1P Machine Automation Controllers offer built in Function Blocks to
support the Modbus RTU protocol, which allows the NX1P to control and monitor
devices such as inverters, scales, temperature controllers, and other Modbus RTU
slave devices.
While the built in Function Blocks are powerful and easy to use for simple applications,
they require the user to develop a ladder program to feed data to and retrieve data
from the devices, controlling the sequencing and timing of the Modbus RTU
communications. This can be intimidating to a user in a larger application.
This Modbus Solution was developed to provide a pre-written Modbus RTU application,
supporting up to 100 Read Items and 100 Write Items. 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:

01: Read Coil Status (1-32 coils)


02: Read Input Status (1-32 coils)
03: Read Holding Registers (1 or 2 registers)
04: Read Input Registers (1 or 2 registers)
05: Force Single Coil (1 Coil)
06: Preset Single Register (1 Register)
0F: Force Multiple Coils (1 – 32 coils)
10: Preset Multiple Registers (1 or 2 registers)

The NA 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.
Section 2. Hardware Requirements
Machine Automation Controller to use the Modbus Solution

1 NX1P CPU

1 NX1W-CIF11 or NX1W-CIF12 Option Board


Or
1 NX-CIF105 mounted locally to the NX1P CPU Bus
Or
1 NX-CIF105 mounted to an NX EtherCAT bus coupler.

To use the NA Series HMI application

1 NA series HMI (project developed for 7 inch NA HMI).


1 Ethernet connection between the NA HMI and the NX1P CPU.
Section 3. Setup for the NX1W-CIF11 / CIF12 Option Boards
When using an Option Board, the NX1W-CIF11 or NX1W-CIF12 may be
mounted in the leftmost or rightmost option board mounting socket. This
application is written with the leftmost option board mounting socket as the
default. The right hand option board mounting socket or multiple NX-CIFxx
modules can be used, with modifications to the application code.

For RS-485 communications, set the DIP switches on the back of the NX1W-
CIF11 or CIF12 adapter as shown prior to installing in the NX1P.
The Port that is being used for Modbus communications will need to be
configured as shown. The Baud rate can be configured to match the attached
Modbus RTU slave devices.

Serial Communications Mode = Modbus-RTU Master


Baud Rate = match to slave devices
Data Length = 8 bits
Parity = None
Stop bit = 1
Section 4. Setup for the NX-CIF105

The NX-CIF105 can be used either mounted locally to the NX1P CPU Bus, or
attached through an EtherCAT bus coupler (NX-ECCxxx). An NX-CIF105
cannot be used on an EtherNet/IP bus coupler (NX-EICxxx).

The Port that is being used for Modbus communications will need to be
configured as shown. The Baud rate can be configured to match the attached
Modbus RTU slave devices.

Baud = match to slave devices


Signal Wire = 2-wire
Data Bit Length = 8 bits
Parity = No parity
Stop bit = 1 bit
Number of Characters to Determine the End = 35 (x 0.1 characters)
Section 5. Wiring
Shown below are the connection points to use for Modbus RTU
Communications.
When using the NX-CIF105, place a jumper between A3 and B3 as shown.

An Omron E5DC temperature controller is used as an example Modbus RTU


device.
Section 6. Read Item Configuration
To read data from Modbus RTU slave devices, the user simply manipulates data in
Global Variables in the NX1P. The Modbus Solution automatically communicates to
the Modbus devices based on this data.

To read from a Modbus Slave device: The user fills in the Read_Item variable
members as follows. Read Item 0 is shown, but the data layout is the same for all
Read Items. Non-shaded members are set by the user, shaded members are
populated by the Modbus Solution.

The NX1P program will cycle through the Read Items in order, until it finds the End
marker of -4096 decimal (F000 Hex) in the End_Code member of a Read Item.
Set ‘0000’ for the End_Code member for all but the last Read Item. No items below
the read Item with -4096 set in the End_Code member will be read.
If there are no Read Items for the application, set Read_Item[0].End_Code to -8192
decimal (E000 Hex). This disables all Modbus RTU reading from the slave devices.

Example: To read the present value from 2 different Omron E5DC temperature
controllers at Modbus Node Numbers 1 and 2, using Function Code 3, reading 1
register starting at register 2000 Hex, the user would configure the following:
Section 7. Write Item Configuration
To write to a Modbus Slave device, the user fills in the Write_Item members as follows.
Write Item 0 is shown, but the data layout is the same for all items. Non-shaded
members are set by the user, shaded members are populated by the Modbus Solution.

The NX1P program will scan through Write Items each program scan until the
Write_Item with End_Code -4096 decimal (F000 Hex) is found. Each program scan,
the NX1P will look for a change of value in Write_Data_1 or Write_Data_2 members
for a particular Write Item. If a change is found (with respect to the last time the Item
was scanned), it is pushed onto a stack, and written to the device.
Set ‘0000’ for the End_Code member for all but the last Write Item. No items below
the Write Item with the value -4096 set in the End_Code member will be scanned.

Example: To write the set point to 2 different Omron E5DC temperature controllers at
Modbus Node Numbers 1 and 2, using Function Code 16 (10 Hex), writing 1 register
starting at register 8451(2103 Hex), the user would configure the following:
Section 8. Selecting the RS485 Port Location
The NX1P Machine Automation Controller has 4 possible locations for the RS485 port
that can be used with this solution:

NX1W-CIF11 or CIF12 mounted in the leftmost option board socket


NX1W-CIF11 or CIF12 mounted in the rightmost option board socket
NX-CIF105 mounted locally on the NX1P CPU Bus
NX-CIF105 connected by EtherCAT using an NX-ECCxxx bus coupler.

To use this solution, the NX1P program needs to be configured to use one of these
locations. The default for this application is an NX1W-CIF12 mounted in the leftmost
option board socket.

The location of the RS485 port is configured by making 2 settings:

1. The assignment of a Global Variable to the IO Port Location parameter for the
physical location of the RS485 port on the IO Map. 2 different variables are
provided, as they have slightly different data types. Make one of the following
settings (see the note below regarding how to make this setting).

a. Port_1_Option_Board_Node_Location is the variable used when the


device is an NX1W-CIF11 or NX1W-CIF12. Use OptionBoard1 or
OptionBoard2 depending on where the NX1W-CIF11 or NX1W-CIF12 is
mounted.

b. Port_1_NX_Node_Location is the variable used when the device is an


NX-CIF105.
.

Note: The IO Port Location parameter is not visible by default in the IO Map. To
enable the IO Port Location, right click on the device (NX1W-CIF11, NX1W-CIF12, or
NX-CIF105), and select Display Node Location Port. Once this is visible, the correct
variable can be assigned.
2. The Device Type and Node Location assignments in the Initialization section of
the ladder program, in Rung 1. If using an NX-CIF105 module, change the line
of code circled below to ‘RS485_Port_is_NX_CIF_Module:=True;’.
Section 9. Error Logging and Cycle Time Monitoring
The Modbus Solution has build in error detection. Each read ‘item’ and write ‘item’ has
its own status area. For each item, this is the Result member. 0 (0 Hex) = last read or
write operation successful, 1 (1 Hex) = this item has not been read or written yet, -1
(FFFF Hex) = last read or write operation unsuccessful. For Read Items, use the
Result member to determine if the data is valid data, and for Write Items, use the
Result member to determine if the last write was successful or unsuccessful.

Each Read / Write function will retry 2 times if it is unsuccessful. This can be adjusted
in the Initialization section of the ladder code, by changing the
Communications_Options.Retry variable in rung 1.

The Modbus Solution keeps track of the last Read Item and last Write Item that did not
complete successfully. This data is available in the Global Variables
Port_1_Last_Error_Read_Item_Number and
Port_1_Last_Error_Write_Item_Number.

The current polling cycle time can be viewed in the Global Variable
Port_1_Polling_Cycle_ms, and represents the time that it took to read all of the Read
Items 1 time, in units of ms.
Section 10. Examples for each Modbus RTU Function
Function 01: To read 5 Coils starting at Coil 19 Hex (25 Decimal) from Modbus RTU
Node 1B Hex (27 Decimal) configure the members as shown.
The response data shown in Read_Data_1 (23 Decimal, 17 Hex) represents the
following Coil Data. 17 Hex = 10111 Binary.

Coil 25: On
Coil 26: On
Coil 27: On
Coil 28: Off
Coil 29: On

Global Variable Member Value


Port_1_Read_Item[0] Node_Number 27 (Decimal)
Function_Code 01 (Decimal)
Starting_Address 25 (Decimal)
Number_of_Items 05 (Decimal)
Read_Data_1 23 (Decimal)
Read_Data_2 00 (Decimal)

Function 02: To read 10 Inputs starting at Input 0 Hex (0 Decimal) from Modbus RTU
Node 1 Hex (1 Decimal) configure the members as shown.
The response data shown in Read_Data_1 (987 Decimal, 3DB Hex) represents the
following Coil Data. 3DB Hex = 1111011011 Binary.

Input 0: On
Input 1: On
Input 2: Off
Input 3: On
Input 4: On
Input 5: Off
Input 6: On
Input 7: On
Input 8: On
Input 9: On

Global Variable Member Value


Port_1_Read_Item[0] Node_Number 01 (Decimal)
Function_Code 02 (Decimal)
Starting_Address 00 (Decimal)
Number_of_Items 10 (Decimal)
Read_Data_1 987 (Decimal)
Read_Data_2 0 (Decimal)
Function 03: To read 1 Holding Register at Register C8 Hex (200 Decimal) from
Modbus RTU Node 0F Hex (15 Decimal) configure the members as shown.
The response data shown in Read_Data_1 (4660 Decimal) represents 1234 (Hex)
stored in the register in the Modbus RTU slave device.

Global Variable Member Value


Port_1_Read_Item[0] Node_Number 15 (Decimal)
Function_Code 03 (Decimal)
Starting_Address 200 (Decimal)
Number_of_Items 01 (Decimal)
Read_Data_1 4660 (Decimal)
Read_Data_2 00 (Decimal)

Function 04: To read 2 Input Registers at Register 32 Hex (50 decimal) from Modbus
RTU Node 04 Hex (04 decimal) configure the members as shown.
The response data shown in Read_Data_1 (4369 Decimal) represents 1111 (Hex)
stored in register 50 (decimal) and the response data shown in Read_Data_2 (8738
Decimal) represents 2222 (Hex) stored in register 51 (decimal) of the Modbus RTU
slave device.

Global Variable Member Value


Port_1_Read_Item[0] Node_Number 04 (Decimal)
Function_Code 04 (Decimal)
Starting_Address 50 (Decimal)
Number_of_Items 02 (Decimal)
Read_Data_1 4369 (Decimal)
Read_Data_2 8739 (Decimal)

Function 05: To force a single Coil On at Coil 200 Hex (512 decimal) on Modbus RTU
Node 17 Hex (23 Decimal), configure the members as shown. -256 (Decimal) in
Write_Data_1 represents FF00 Hex, which is the Modbus value for a single forced coil.

Global Variable Member Value


Port_1_Write_Item[0] Node_Number 23 (Decimal)
Function_Code 05 (Decimal)
Starting_Address 512 (Decimal)
Number_of_Items 01 (Decimal)
Write_Data_1 -256 (Decimal)
Write_Write_2 00 (Decimal)
Function 06: To preset a single Register at Register 95 Hex (149 Decimal) on
Modbus RTU Node 9 Hex (9 Decimal), configure the members as shown. 1234
(Decimal) in Write_Data_1 would write 04D2 (Hex) into the Modbus RTU slave device.

Global Variable Member Value


Port_1_Write_Item[0] Node_Number 09 (Decimal)
Function_Code 06 (Decimal)
Starting_Address 149 (Decimal)
Number_of_Items 01 (Decimal)
Write_Data_1 1234 (Decimal)
Write_Write_2 00 (Decimal)

Function 0F: To force 5 coils starting at Coil 22 Hex (34 Decimal) on Modbus RTU
Node 2 Hex (2 Decimal), configure the members as shown. 21 (Decimal) in
Write_Data_1 would write the coil pattern shown below into the Modbus RTU slave
device. 21 Decimal = 15 Hex = 10101 Binary.

Coil 22: On
Coil 23: Off
Coil 24: On
Coil 25: Off
Coil 26: On

Global Variable Member Value


Port_1_Write_Item[0] Node_Number 02 (Decimal)
Function_Code 15 (Decimal)
Starting_Address 34 (Decimal)
Number_of_Items 05 (Decimal)
Write_Data_1 21 (Decimal)
Write_Write_2 00 (Decimal)
Function 10: To preset 2 registers starting at Register 22 Hex (34 Decimal) on
Modbus RTU Node 1 Hex (1 Decimal), configure the members as shown. 4660
(Decimal) in Write_Data_1 would write 1234 Hex into Register 22 Hex in the Modbus
RTU slave device, and 22136 (Decimal) in Write_Data_2 would write 5678 Hex into
Register 23 Hex in the Modbus RTU slave device.

Global Variable Member Value


Port_1_Write_Item[0] Node_Number 01 (Decimal)
Function_Code 16 (Decimal)
Starting_Address 34 (Decimal)
Number_of_Items 02(Decimal)
Write_Data_1 4660 (Decimal)
Write_Write_2 22136 (Decimal)
Section 11. Merging this application into an existing Project

Follow the steps below to merge the Modbus RTU Solution into an existing project, or
to add a second port to a project.

1. Copy and paste the 2 Structures from the Modbus RTU Solution into the
new or existing project.

2. Remove the Port_1_Option_Board_Node_Location variable and / or the


Port_1_NX_Node_Location variable(s) from the IO Map in the Modbus RTU
Solution.

3. If adding a second RS485 port to an application, follow parts a and b


in this step. Otherwise skip to step 4.

a. Modify the names of all the Global Variables (Port_1 to Port_2


shown in the example below), using the Variable Manager (Edit
Menu). Change each item one at a time, and after each change,
click Yes to make the change to the entire program.
b. Change the name of the Program from Port_1_Modbus_RTU to
Port_2_Modbus_RTU, or something relevant to the application.

4. Copy / Paste the Global Variables from the Modbus RTU Solution into
the new or existing project.

5. Copy / paste the Program from the Modbus RTU Solution into the new or
existing project.

6. Assign the port location, as shown in Section 8.


Revision History
Date Notes Version
11/27/2016 Original Document for NX1P 2.12

You might also like