1. Hardware Configuration
In the CPU Settings, set Port 2 Configuration to Ethernet.
Note:
Sequence Number and Command Data addresses should not overlap or conflict with any other variables used in the logic.
2. Telnet Configuration
a. Connect the PLC with Port 2 to the Ethernet Option
Module in the network.
Sample Modbus/TCP to RTU Bridge Setup 1) Network/IP Settings: IP Address <x.x.x.x> Default Gateway ............ <x.x.x.x> Netmask ..................... <x.x.x.x> SNMP is enabled 2) Serial & Mode Settings: Protocol ...............Modbus/RTU,Slave(s) attached Modbus/TCP Client .......... disabled Serial Interface .......... 175000,8,O,1 4) Advanced Modbus Protocol settings: Slave Addr/Unit Id Source: Modbus/TCP header Modbus Serial Broadcasts ... .................................Disabled (Id=0 auto-mapped to 1) MB/TCP Exception Codes ..... ........................................ Yes (return 00AH and 00BH) Char, Message Timeout ...... .............................................. 00050msec, 05000msec D)efault settings, S)ave, Q)uit without save Select Command or parameter set (1..4) to change:...2 Attached Device (1=Slave 2=Master) ..........................1 Modbus/TCP Client Enabled (N) ................................ Y Close Idle TCP sockets after (3-60 sec, 0=leave open) ..............................................................10 Press Enter Serial Protocol (1=Modbus/RTU 2=Modbus/ASCII).....1 Press Enter Enter serial parameters (38400,8,0,1) ..... 175000,8,O,1
Modbus/TCP to RTU Bridge Setup After entering all the values, the Modbus/TCP to RTU Bridge Setup screen appears showing the configured values. To save the parameters, press S. 1) Network/IP Settings: IP Address ......................................... 3.212.218.12 Default Gateway .......................... 003.212.218.001 Netmask ...................................... 255.000.000.000 SNMP is enabled
Parameters of MODBUS_TCP_RW
Parameter Inputs ???? DWord, R Control word. Requires two bytes in %R memory. Do not write or clear this memory during operation of the MODBUS_TCP_RW function. When the function is enabled, the operation is performed. Execute. A low to high transition starts command processing. Channel number on which the request will be processed. Should be 1. Function code. Modbus RTU function to be carried out. See page 3 for valid function codes. Segment selector for Local reference memory type. Destination memory type for a Read operation; Source memory type for a Write operation. Data Type, Memory Area Description
Description
Enable output. Complete. Set when the read or write operation has been successfully completed. Busy. Set when the read or write process is in operation and has not been completed. Error. Set when an error is identified during operation. Status. May include the following: Remote Server exceptions Function block parameter errors Client application errors For a list of status/error codes, refer to page 4.
BUSY
Enable EX CH
Flow Flow Word, Constant Word, AI, AQ, R, Constant Word, AI, AQ, R, Constant
ERR STS
FC
LMR
LMR Value 18 72 8
Description %Q discrete output memory (Byte mode) %Q discrete output memory (Bit mode) %R register memory (Word mode)
Read Coils Read Input Discrete Read Multiple Registers Read Analog Input Registers Write Coil Write Single Register Read Exception Status Write Multiple coils Write Multiple Registers
1 2
Read up to 2,000 bits Read up to 2,000 bits Read up to 125 words Read up to 125 words
Register (16-bit word) Register (16-bit word) Bit Register (16-bit word) Byte
LMO
Local PLC reference memory address for Modbus/TCP Client devices location. Destination for a read operation; Source for a write operation. Remote PLC reference memory address for Modbus/TCP Server devices location. Source for a read operation this memory; Destination for a write operation. For valid lengths refer to the comments in the table Modbus/TCP Function Codes Supported by VMNM PLCs on page 3. IP Start address. This is the IP Address of the Server device. Starting from this address, four words would contain four octets of the IP. Unit Identifier. A control code used in a Modbus/TCP message. This value is 1 for most Modbus/TCP devices except for an Ethernet to Serial bridge used to multi-drop to Modbus RTU devices. Valid values: 0255
5 6
RMO
-NA-
DL
15
Coil
Bit
IP
16
Register
UI
Status/Error Codes
Status codes are reported in the following format:
00 00
Error Description Slave Device Failure. An unrecoverable error occurred while the server was attempting to perform the requested action. Slave Device Busy. Server service request queue full. MODBUS exception code 06. Negative Acknowledge. Internal server error occurred. MODBUS exception code 07
0691H 0791H
Minor Status Codes for Major Status B0H Major Status Codes
Error Status (Hex) 01H 91H Major Status Description Successful completion. No minor status code (value can be ignored.) Modbus TCP Status codes at the server. An error was detected at the Modbus TCP server. See the table on page 4 for the associated Minor Status Codes. Client Application Error. See the table on page 4 for the associated Minor Status Codes. Serial link error codes between Micro and Ethernet Module. See the table on page 5 for the associated Minor Status Codes. 88B0H 8BB0H
The following table lists minor status codes that can be reported for status code B0H, Client Application Error.
Error Status (Hex) 85B0H 86B0H Error Description Client device not yet ready to send the request. Server unit data size of zero is not allowed. The data unit size for read/write operations should be greater than zero. Server unit data size is too large. The data unit size for read/write operations should not cross the maximum value. Example: If the data length specified for Read/Write coil is greater than 1, this error code is returned. Invalid Channel Number This error will be triggered when the server reference memory address is zero, which is not allowed. Invalid Client Memory Type. This error is triggered when the specified client reference memory type is invalid. Refer to page 3 for valid memory types. Invalid IP address integer. All four octets of the IP address should be in the range 0 to 255. Invalid IP address class. Insufficient TCP connection resources to perform request. Zero local starting address is not allowed, The starting address of the client PLC memory location should be greater than zero. Internal Error. This problem may occur due to the Ethernet Interface being asked to perform beyond its capacity. Underlying TCP connection aborted (reset) by server end point. The server is not responding within the timeout value. Underlying TCP connection aborted (reset) by Client end point. Invalid frame format. Data response did not arrive in a proper order. Data response had unexpected size. For example received more data than expected. Invalid Client PLC Memory reference address.
B0H
87B0H
B1H
8CB0H
8EB0H
95B0H
96B0H
0391H
Error Description Unrecognized Function code. The Client device does not support the function code or operation. Invalid Unit Identifier. Invalid Server Reference Memory Address. Failed to update the Micro reference memory. Ethernet Module was unable to write to the Client memory specified in the command data. Unable to connect to remote device after successful channel establishment. An attempt to establish a TCP connection with a remote server failed. This error can be caused by the following conditions: Server is not turned on Cables are not properly connected If using a switch, switch is not turned on This error can occur while establishing the connection with the server device.
A7B0H AAB0H
ACB0H
A protocol error occurred while communicating with the local PLC. This error can occur when a break in the frame or check sum error occurred. A TCP timeout occurred while communicating with the remote PLC.
04B1H 05B1H
ADB0H
1. The IP address is stored as integer values in the four words starting at %R1001.
4. When %I00488 is on, the MODBUS_TCP_RW function block is executed on the rising transition of %T0001. For parameter definitions, refer to page 3.
Function Reading Coils (FC=1) Reads a coil at offset 10 (RMO=10) in the remote Modbus TCP server and store the value at the location %Q10 (LMR=72, LMO=10). Sample Rung
Reading Discrete Inputs (FC=2) Read nine discrete inputs from offset 5 (RMO=5) in the remote Modbus TCP server and store the values in bit mode at %Q3 (LMR=72, LMO=3).
Function Reading Multiple Registers (FC=3) Read 125 registers from the remote server device. The Remote server reference address is %R0101 (LMR=8, LMO=101). The Client or Local PLC reference memory address is %R5001 (LMR=8, RMO=5001).
Sample Rung
Reading Analog Inputs (FC=4) Read nine analog input registers at offset 200 (RMO=200) in the remote Modbus TCP device and store the values in the Client PLC memory location %R0020 (LMR=8, LMO=20).
Function Writing a Coil (FC=5) Write the value at %Q4 (LMR=72, LMO=4) in the Client PLC memory location to coil %Q5 (RMO=5) in the remote Modbus TCP device.
Sample Rung
Writing a Single Register (FC=6) Write one register from %R10 (LMR=8, LMO=10) to a holding register at offset 200 (RMO=200) in the remote Modbus TCP server.
Function Reading Status (FC=7) Read the Status from the remote Modbus TCP server and store the Status data in bit mode at location %Q4 (LMR=72, LMO=4).
Sample Rung
Writing Multiple Coils (FC=15) Write the eight values starting from %Q1 (LMR=72, LMO=1) in the Client reference memory to eight coils starting at offset 1 (RMO=1) in the Remote Modbus TCP device.
Function Writing Multiple Registers (FC=16) Write 100 registers from the Client reference memory address %R5001 (LMR=8, LMO=5001) to the remote server reference address %R101 (RMO=101).
Sample Rung
10
11