Professional Documents
Culture Documents
Objectives
Address Configuration
Address mapping is done in the Machine Edition Hardware Configuration of the CPU. All
Ethernet modules and daughter-boards in the PLC use Modbus-to-PLC address mapping
based on this one map. The Modbus/TCP Server does not use COMMREQs to configure
address mapping.
Each PLC memory area is mapped to an appropriate Modbus address space. On the Settings
tab, Modbus Address Space Mapping can be set to Standard Modbus Addressing or
Disabled. If Modbus Address Space Mapping is set to Standard, the Modbus/TCP Address
Map tab displays the standard references assignments.
Modbus/TCP Client
Communications to the Modbus/TCP Server are initiated by the Modbus/TCP client. The client
first opens a communication channel via a communications request (COMMREQ) written in
the client’s program. Once the communication channel has been opened the client reads or
writes data to/from the server via a second COMMREQ. When the client has finished reading
and/or writing data the communication channel is closed via another COMMREQ. All of the
COMMREQ’s are programmed in the client controller.
Structure of the Communications Request
The Communications Request is made up of the following elements:
• The COMMREQ Function Block (ladder instruction)
• The COMMREQ Command Block
• The Channel Command
• Status Data (COMMREQ Status word, LAN Interface Status and Channel Status bits)
• The logic program controlling execution of the COMMREQ Function Block
Status Data
There are several types of status available to the client application program.
LAN Interface Status Bits (LIS Bits): The LIS bits comprise bits 1–16 of the 80-bit status area.
The location of this 80-bit status area is assigned using the Configuration software. The LIS
bits contain information on the status of the Local Area Network (LAN) and the Ethernet
interface.
Channel Status Bits: The Channel Status bits comprise bits 17–80 (64 bits) of the 80-bit
status area. When used for Modbus/TCP channels, these bits consist of a connection open
bit and a unused bit, reserved for future use, for each of the 16 channels that can be
established.
Status bits for unused channels are always set to zero.
COMMREQ Status Word (CRS Word): The 16-bit CRS word will receive the initial status of the
communication request. The location of the CRS word is assigned for each COMMREQ
function in the COMMREQ Command Block.
FT Output of the COMMREQ Function Block: This output indicates that the PLC CPU
detected errors in the COMMREQ Function Block and/or Command Block and did not pass
the Command Block to the Ethernet interface.
Each of the inputs and outputs are discussed in detail below. It is important to understand
that the Command Block address points to the location in memory you have setup as the
Command Block.
Enable: Control logic for activating the COMMREQ Function Block. See Section 5 for tips on
developing your program.
IN: The location of the Command Block. It can be any valid address within a word-oriented
area of memory (%R, %AI, %AQ, %P, %L or %W for the Ethernet interface).
SYSID: A hexadecimal word value that gives the rack (high byte) and slot (low byte) location
of the Ethernet interface.
Figure 10-5. Hex Format of Rack and Slot Location of Ethernet Interface
TASK: For the RX3i and Rx7i ETM001 Ethernet interfaces TASK must always be set to zero.
For PACSystems CPU embedded Ethernet interface, TASK must be set to 65536 (0x10000) to
address the CPU’s Ethernet daughterboard.
FT Output: The FT output is set if the PLC CPU (rather than the Ethernet interface) detects
that the COMMREQ fails. In this case, the other status indicators are not updated for this
COMMREQ.
(Word 1) Data Block Length: This is the length in words of the Data Block portion of the
Command Block. The Data Block portion starts at Word 7 of the Command Block. The length
is measured from the beginning of the Data Block at Word 7, not from the beginning of the
Command Block. The correct value for each command, and the associated length of each
command, is specified in the next section.
(Word 2) WAIT/NOWAIT Flag: This flag must be set to zero for TCP/IP Ethernet
Communications.
COMMREQ Status Word: The Ethernet interface updates the CRS word to show success or
failure of the command. Command words 3 and 4 specify the PLC memory location of the
CRSW word.
(Word 3) COMMREQ Status Word Memory Type: This word specifies the memory type for
the CRS word. The memory types are listed in the table below:
(Word 4) COMMREQ Status Word Address Offset: This word contains the offset within the
memory type selected. The status word address offset is a zero-based number. For
example, if you want %R1 as the location of the CRS word, you must specify a zero for the
offset. The offset for %R100 would be 99 decimal. Note, however, that this is the only zero-
based field in the Channel commands.
(Word 5): Reserved. Set to zero.
(Word 6): Reserved. Set to zero.
(Words 7 and up) Data Block: The Data Block defines the Channel command to be
performed.
Dec (Hex)
Word 1 00002 (0002) Length of Channel command Data Block
Word 2 00000 (0000) Always 0 (no-wait mode request)
Word 3 00008 (0008) Memory type of CRS word (%R)
Word 4 00009 (0009) CRS word address minus 1 (%R10)
Word 5 00000 (0000) Reserved
Word 6 00000 (0000) Reserved
Word 7 03001 (0BB9) Close Modbus/TCP Client Connection
Word 8 00005 (0005) Channel number (5)
PC
Personal Server Client
Computer with RX3i Controller RX3i Controller
Machine Edition
IP Address: IP Address:
IP Address: 192.168.123.102 192.168.123.104
192.168.123.199
Server_QP Client_QP
QuickPanel View QuickPanel View
IP Address: IP Address:
192.168.123.101 192.168.123.103
4. Under the Settings tab you will see that this controller has been configured for Standard
Modbus Addressing.
5. Click on the tab labeled Modbus TCP Address Map. Here you will see how the Modbus
register memory has been mapped to the PAC Rx3i memory.
9. The ladder logic in the _MAIN program block has comments that describe what the first
2 rungs do.
12. Scroll through the logic in this block and read the comments that describe the operation
of the block.
15. Scroll through the logic in this block and read the comments that describe the operation
of the block.
16. Next you will need to download to each of the 4 targets in this project. Right-click on the
Client target and select Set as Active Target from the menu.
17. Now, right-click on the Client target and select Go Online from the menu, or press the
Online/Offline toolbar button .
18. Next, right-click and select the Online Commands, Set Programmer Mode menu, or
press the Toggle Online Mode toolbar button .
19. Next, select the Online Commands, Stop PLC menu, or press the Stop Active Target
toolbar button .
21. Right-click and select the Download to PLC menu, or press the F8 function key, or press
the Download Active Target toolbar button .
22. Check to make sure that the boxes are checked as shown below and then click OK.
23. Select the Online Commands, Start PLC menu, or press the Start Active Target toolbar
button .
25. Check the information displayed on the Status Bar to verify that the PACSystems
controller is in Run Mode, and that the Configuration and Logic are both Equal.
26. Right-click on the Client target and select Go Offline from the menu.
Once you have successfully downloaded and started the Client and Server controllers, you
will use the QuickPanels to exercise the application.
But first, you need to download both QuickPanel applications to the demo units.
28. Right-click on the Client_QP target and select Set as Active Target from the menu.
29. Right-click on the Client_QP target and select Download and Start from the menu, or
press the F9 function key, or press the Download and Start Active Target toolbar button
.
31. Now you will read and write some data using the QuickPanels on the PACSystems
demo units.
33. Touch the Numerical Data Entry box labeled Value_1 and enter a value between 0 and
32767 by using the pop-up keypad.
37. Touch the button labeled Read and the values that you entered on the Modbus/TCP
Server screen will be read from the Server PAC controller and displayed on the Client’s
QuickPanel screen as Value_1 and Value_2.
38. Next, enter a number for Value_3 and Value_4 from the Client screen.
39. Now touch the button labeled Write and these values will be written to the Server PAC
controller and displayed on the Server’s QuickPanel screen as Value_3 and Value_4.
40. Touching the button labeled Reset will clear the values on the Modbus/TCP Client
screen so that another Read/Write can be performed.
Review:
In this lab, you have been shown how:
• A PACSystems controller can be configured as a Modbus/TCP Server
• A PACSystems controller can act as a Modbus/TCP Client to read and write data
from/to a Modbus/TCP Server device
• The logic to perform the read/write is configured
• Reads/writes can be executed from a graphical interface