Mitsubishi Electric MELSEC iQ-R Series Reference Manual

Mitsubishi Electric MELSEC iQ-R Series Reference Manual

Modbus and modbus/tcp
Hide thumbs Also See for MELSEC iQ-R Series:
Table of Contents

Advertisement

MELSEC iQ-R MODBUS and MODBUS/TCP
Reference Manual
-RJ71C24
-RJ71C24-R2
-RJ71C24-R4
-RJ71EN71
-R04ENCPU
-R08ENCPU
-R16ENCPU
-R32ENCPU
-R120ENCPU

Advertisement

Table of Contents
loading

Summary of Contents for Mitsubishi Electric MELSEC iQ-R Series

  • Page 1 MELSEC iQ-R MODBUS and MODBUS/TCP Reference Manual -RJ71C24 -RJ71C24-R2 -RJ71C24-R4 -RJ71EN71 -R04ENCPU -R08ENCPU -R16ENCPU -R32ENCPU -R120ENCPU...
  • Page 3: Safety Precautions

    (Read these precautions before using this product.) Before using MELSEC iQ-R series programmable controllers, please read the manuals for the product and the relevant manuals introduced in those manuals carefully, and pay full attention to safety to handle the product correctly.
  • Page 4: Introduction

    MODBUS/TCP slave function of the following modules. Before using this product, please read this manual and the relevant manuals carefully and develop familiarity with the functions and performance of the MELSEC iQ-R series programmable controller to handle the product correctly. Relevant products...
  • Page 5: Table Of Contents

    CONTENTS SAFETY PRECAUTIONS ..............1 CONDITIONS OF USE FOR THE PRODUCT .
  • Page 6 3.16 Mask Write Register (FC: 16H) ............. 48 3.17 Read/Write Multiple Registers (FC: 17H).
  • Page 7: Relevant Manuals

    Reference Manual device to a module [BCN-P5999-1060] (this manual) e-Manual refers to the Mitsubishi Electric FA electronic book manuals that can be browsed using a dedicated tool. e-Manual has the following features: • Required information can be cross-searched in multiple manuals.
  • Page 8: Chapter 1 Frame Specifications

    FRAME SPECIFICATIONS MODBUS Protocol Frame Specifications This section describes the frame specifications of the MODBUS protocol. Address field Function code Data Error check Protocol data unit Area name Description Address field ■When request message is sent from the master to a slave •...
  • Page 9 If the least significant bit of the step 2 is '1', calculate the exclusive OR (XOR) from the result of step 3 and the generator polynomial (A001H). If the least significant bit is '0', do not calculate the exclusive OR (XOR), but shift it by 1 bit to the right. Repeat the step 3 and 4 until the bit is shifted up to 8 times.
  • Page 10: Ascii Mode

    CRC error checking procedure 16-bit register (MSB) Flag Shift by 1 bit to the right. Shift 1 0100 0000 1001 1100 Since the flag is '1', calculate the exclusive OR (XOR) from the Generator polynomial (A001H) 1010 0000 0000 0001 result in 'Shift 1' and generator polynomial (A001H).
  • Page 11 • Data (2 bytes): Start coil number specification (0000H), Number of read points (0008H) Error check procedure LRC in request message transmission Convert the ASCII codes within the error check range into the RTU format Address field (02H) 0000 0010 (binary).
  • Page 12: Modbus/Tcp Protocol Frame Specifications

    MODBUS/TCP Protocol Frame Specifications This section describes the frame specifications of the MODBUS/TCP protocol. Ethernet IP header TCP header Application data MODBUS/TCP frame (Error check) header MODBUS/TCP application data unit MODBUS application header Protocol data unit Transaction Protocol ID Message Module ID Function code Data...
  • Page 13: Protocol Data Unit Formats Grouped By Function

    Protocol Data Unit Formats Grouped by Function This section describes the protocol data unit formats of the MODBUS standard functions. When the device number is specified within the message When specifying the device number within the message, specify "device number - 1". However, this instruction is not applicable to the file number and the device number specified for reading or writing extended file register.
  • Page 14 (RTU mode) Function code Data Start coil number specification Number of read points (006EH) (003FH) Convert RTU mode to ASCII mode (ASCII mode) Function code Data Start coil number specification Number of read points (30H) (31H) (30H) (30H) (36H) (45H) (30H) (30H) (33H)
  • Page 15: Chapter 2 Modbus Standard Function List

    MODBUS STANDARD FUNCTION LIST This chapter lists the MODBUS standard functions and availability for modules when using the slave function. The modules are abbreviated as follows: • C24: RJ71C24, RJ71C24-R2, RJ71C24-R4 • E71: RJ71EN71, R04ENCPU, R08ENCPU, R16ENCPU, R32ENCPU, R120ENCPU : Available, : Not available Function code Sub code (SC) Function name...
  • Page 16: Chapter 3 Modbus Standard Function Details

    MODBUS STANDARD FUNCTION DETAILS This chapter describes protocol data unit formats. Read Coils (FC: 01H) Operation description Reads the status (ON/OFF) of one or multiple coils. Request message format (from master to slave) Function code Data Start coil number specification Number of read points (0000H to FFFFH) (0001H to 07D0H)
  • Page 17: Read Discrete Inputs (Fc: 02H)

    Read Discrete Inputs (FC: 02H) Operation description Reads the status (ON/OFF) of one or multiple inputs. Request message format (from master to slave) Function code Data Start input number specification Number of read points (0000H to FFFFH) (0001H to 07D0H) Response message format (from slave to master) ■...
  • Page 18: Read Holding Registers (Fc: 03H)

    Read Holding Registers (FC: 03H) Operation description Reads one or multiple holding register values. Request message format (from master to slave) Function code Data Start holding register number Number of read points specification (0000H to FFFFH) (0001H to 007DH) Response message format (from slave to master) ■...
  • Page 19: Read Input Registers (Fc: 04H)

    Read Input Registers (FC: 04H) Operation description Reads one or multiple input register values. Request message format (from master to slave) Function code Data Start input register number Number of read points specification (0000H to FFFFH) (0001H to 007DH) Response message format (from slave to master) ■...
  • Page 20: Write Single Coil (Fc: 05H)

    Write Single Coil (FC: 05H) Operation description Writes a value (ON/OFF) to one coil. Request message format (from master to slave) Function code Data Coil number specification ON/OFF specification FF00H: ON (0000H to FFFFH) 0000H: OFF Response message format (from slave to master) ■...
  • Page 21: Write Single Register (Fc: 06H)

    Write Single Register (FC: 06H) Operation description Writes a value to one holding register area. Request message format (from master to slave) Function code Data Holding register number Write data specification (0000H to FFFFH) (0000H to FFFFH) Response message format (from slave to master) ■...
  • Page 22: Read Exception Status (Fc: 07H)

    Read Exception Status (FC: 07H) Operation description Reads the error status. Request message format (from master to slave) Function code Response message format (from slave to master) ■ When completed successfully Function code Data Error information In the error information, the specified device data by "Specifying the error status" of the parameter is stored. MELSEC iQ-R Serial Communication Module User's Manual(Application) ■...
  • Page 23: Diagnostics (Fc: 08H)

    Diagnostics (FC: 08H) Executes the various diagnostics and checks the C24 status and communication status. In the diagnostics, a sub-function code is specified after a function code with a request message. Checking communication conditions using a diagnostic counter When using the MODBUS slave function, the number of error occurrences during communication is stored in a diagnostic counter.
  • Page 24: Return Query Data (Sub-Function Code: 00H)

    Return query data (sub-function code: 00H) Operation description Returns the contents of the request message without change. Used to check if the network or the target device is operating normally. (Loopback test) Request message format (from master to slave) Function code Sub-function code Data Arbitrary data...
  • Page 25: Restart Communications Option (Sub-Function Code: 01H)

    Restart communications option (sub-function code: 01H) Operation description Initializes the communication port of the receiving channel side and restarts the slave function. Restart is performed after returning the response message corresponding to a request message. The operation status returns to online mode when it was in the listen only mode. The following data are cleared when executing the restart communications option.
  • Page 26: Return Diagnostic Register (Sub-Function Code: 02H)

    Return diagnostic register (sub-function code: 02H) Operation description Reads out the detailed LED status of C24 to the master. Request message format (from master to slave) Function code Sub-function code Data (0002H) (0000H) Response message format (from slave to master) ■...
  • Page 27: Change Ascii Input Delimiter (Sub-Function Code: 03H)

    Change ASCII input delimiter (sub-function code: 03H) Operation description Changes the 2nd byte (LF(0AH)) of the end code in the ASCII mode to a specified data. Start Address field Function code Data Error check n x 2 characters CR + 2 characters 2 characters 2 characters...
  • Page 28: Force Listen Only Mode (Sub-Function Code: 04H)

    Force listen only mode (sub-function code: 04H) Operation description Places a slave into the offline mode. Used when disconnecting a slave from the network. When C24 is set in the listen only mode, the status is as follows: • Ignores all request messages except for those of restart communications option. (Page 23 Restart communications option (sub-function code: 01H)) •...
  • Page 29: Clear Counters And Diagnostic Register (Sub-Function Code: 0Ah)

    Clear counters and diagnostic register (sub-function code: 0AH) Operation description Clears counters (e.g. message count). Also, clears the diagnostic register and the error of the channel where the request message has been received. The following counters will be cleared. • Diagnostic counter (Page 21 Checking communication conditions using a diagnostic counter) •...
  • Page 30: Return Bus Message Count (Sub-Function Code: 0Bh)

    Return bus message count (sub-function code: 0BH) Operation description Reads out the number of messages detected on the line to the master. Request message format (from master to slave) Function code Sub-function code Data (000BH) (0000H) Response message format (from slave to master) ■...
  • Page 31: Return Bus Communication Error Count (Sub-Function Code: 0Ch)

    Return bus communication error count (sub-function code: 0CH) Operation description Reads out the number of error messages detected on the line to the master. Request message format (from master to slave) Function code Sub-function code Data (000CH) (0000H) Response message format (from slave to master) ■...
  • Page 32: Return Bus Exception Error Count (Sub-Function Code: 0Dh)

    Return bus exception error count (sub-function code: 0DH) Operation description Reads out the frequency of exception errors to the master. Request message format (from master to slave) Function code Sub-function code Data (000DH) (0000H) Response message format (from slave to master) ■...
  • Page 33: Return Slave Message Count (Sub-Function Code: 0Eh)

    Return slave message count (sub-function code: 0EH) Operation description Reads out the number of the slave message processing to the master (including receive of request messages from broadcast). Request message format (from master to slave) Function code Sub-function code Data (000EH) (0000H) Response message format (from slave to master)
  • Page 34: Return Slave No Response Count (Sub-Function Code: 0Fh)

    Return slave no response count (sub-function code: 0FH) Operation description Reads to out the number of broadcast request messages received to the master. Request message format (from master to slave) Function code Sub-function code Data (000FH) (0000H) Response message format (from slave to master) ■...
  • Page 35: Return Slave Nak Count (Sub-Function Code: 10H)

    Return slave NAK count (sub-function code: 10H) Operation description Reads out the number of NAK responses to the master. Request message format (from master to slave) Function code Sub-function code Data (0010H) (0000H) Response message format (from slave to master) ■...
  • Page 36: Return Slave Busy Count (Sub-Function Code: 11H)

    Return slave busy count (sub-function code: 11H) Operation description Reads out the number of busy responses to the master. Request message format (from master to slave) Function code Sub-function code Data (0011H) (0000H) Response message format (from slave to master) ■...
  • Page 37: Return Bus Character Overrun Count (Sub-Function Code: 12H)

    Return bus character overrun count (sub-function code: 12H) Operation description To the master, reads out the number of times the request message size exceeds the upper limit. Request message format (from master to slave) Function code Sub-function code Data (0012H) (0000H) Response message format (from slave to master) ■...
  • Page 38: Return Iop Overrun Error Count (Sub-Function Code: 13H)

    Return IOP overrun error count (sub-function code: 13H) Operation description Reads the IOP overrun error count value to the master. C24 returns to the master the number of times the request message size exceeds the upper limit. (Same as the Return bus character overrun count) Request message format (from master to slave) Function code...
  • Page 39: Clear Overrun Counter And Flag (Sub-Function Code: 14H)

    Clear overrun counter and flag (sub-function code: 14H) Operation description Clears the overrun error counter and flag. C24 clears the character overrun count value. Request message format (from master to slave) Function code Sub-function code Data (0014H) (0000H) Response message format (from slave to master) ■...
  • Page 40: Get Communications Event Counter (Fc: 0Bh)

    Get Communications Event Counter (FC: 0BH) Operation description Acquires the number of messages whose requested actions (read/write, diagnostics, etc.) have been normally completed. Whether the action corresponding to the request message is normally completed or not can be checked. Request message format (from master to slave) Function code Response message format (from slave to master) ■...
  • Page 41: Get Communications Event Log (Fc: 0Ch)

    3.10 Get Communications Event Log (FC: 0CH) Operation description Acquires the communications event log into the master. Request message format (from master to slave) Function code Response message format (from slave to master) ■ When completed successfully Function code Data Number of Program command status Communications event...
  • Page 42 Communications event log When the get communications event log (FC: 0CH) is received from the master, C24 returns the following data of the buffer memory. • 'Communications event log 1 to 64' (Un\G32544 to Un\G32575/Un\G32608 to Un\G32639) The number of communications event logs can be checked in the buffer memory 'Communications event log count' (Un\G32543/Un\G32607).
  • Page 43: Write Multiple Coils (Fc: 0Fh)

    3.11 Write Multiple Coils (FC: 0FH) Operation description Writes values (ON/OFF) to multiple coils. Request message format (from master to slave) Function code Data Start coil number specification Number of write points Number of bytes Device data 1 Device data n (0000H to FFFFH) (0001H to 07B0H) (01H to F6H)
  • Page 44: Write Multiple Registers (Fc: 10H)

    3.12 Write Multiple Registers (FC: 10H) Operation description Writes values to multiple holding register areas. Request message format (from master to slave) Function code Data Start holding register number Number of write points n Number of Device data 1 Device data n specification bytes n×2 (0000H to FFFFH)
  • Page 45: Report Slave Id (Fc: 11H)

    3.13 Report Slave ID (FC: 11H) Operation description Acquires the information of C24 mounted station into the master. Request message format (from master to slave) Function code Response message format (from slave to master) ■ When completed successfully Function code Data Number of Programmable...
  • Page 46 Module name Model Programmable controller CPU type returned to Master Process CPU R08PCPU R16PCPU R32PCPU R120PCPU SIL2 process CPU R08PSFCPU R16PSFCPU R32PSFCPU R120PSFCPU Safety CPU R08SFCPU R16SFCPU R32SFCPU R120SFCPU C Controller module R12CCPU-V Remote head module RJ72GF15-T2 RJ72GF15-T2(SR) RJ72GF15-T2(LR) 3 MODBUS STANDARD FUNCTION DETAILS 3.13 Report Slave ID (FC: 11H)
  • Page 47: Read File Record (Fc: 14H) (Sc: 06H)

    3.14 Read File Record (FC: 14H) (SC: 06H) Operation description Reads the values of multiple extended file register areas. Request message format (from master to slave) Function code Data Sub-request 1 Number of Reference File number specification Read start device number Number of read points n1 bytes m×7 number...
  • Page 48 Response message format (from slave to master) ■ When completed successfully N shown below is the total of the device data (n1 + ... + nm). Function code Data Sub-request 1 Number of Number of Reference Device data 1 Device data n1 response data read bytes number...
  • Page 49: Write File Record (Fc: 15H) (Sc: 06H)

    3.15 Write File Record (FC: 15H) (SC: 06H) Operation description Writes a value to one extended file register area or values to multiple extended file register areas. Request message format (from master to slave) N shown below is the total of the device data (n1 + ... + nm). Function code Data Sub-request 1...
  • Page 50: Mask Write Register (Fc: 16H)

    3.16 Mask Write Register (FC: 16H) Operation description Writes the masked value obtained by performing AND and OR operations on the value stored in one holding register area. The value is written to the holding register as shown below. Write value = (current value of target register  AND mask value)  (OR mask value  AND mask value) If the OR mask value is 0000H, only the AND processing of the AND mask value will be performed.
  • Page 51: Read/Write Multiple Registers (Fc: 17H)

    3.17 Read/Write Multiple Registers (FC: 17H) Operation description Reads/writes data from/to multiple holding register areas. During the processing, writing is performed first, followed by reading. Request message format (from master to slave) Function code Data Read start holding Number of read points Write start holding Number of write points Number of...
  • Page 52: Chapter 4 Exception Codes

    EXCEPTION CODES Exception codes are error codes that are common to the MODBUS protocol and are stored in the response message when a slave returns an abnormal response for the request message from the master. When the master receives an exception code from a slave, perform actions according to the description in this chapter. The response message format when processing completed with an error is shown below.
  • Page 53 Exception code list This section lists the exception codes that are stored in the lower byte of the response message format. Exception code Error name Error definition and cause Action Function code error The slave received an unsupported function Check the function codes that are supported by the code.
  • Page 54: Index

    INDEX ..50 Abnormal response function code list Descriptions of request message and response ..... . . 11 message formats .
  • Page 55 MEMO...
  • Page 56: Revisions

    Japanese manual number: BCN-P5999-1059-B This manual confers no industrial property rights of any other kind, nor does it confer any patent licenses. Mitsubishi Electric cannot be held responsible for any problems involving industrial property rights that may occur as a result of using the contents noted in this manual.
  • Page 57: Warranty

    WARRANTY Please confirm the following product warranty details before using this product. 1. Gratis Warranty Term and Gratis Warranty Range If any faults or defects (hereinafter "Failure") found to be the responsibility of Mitsubishi occurs during use of the product within the gratis warranty term, the product shall be repaired at no cost via the sales representative or Mitsubishi Service Company.
  • Page 58: Trademarks

    TRADEMARKS The company names, system names and product names mentioned in this manual are either registered trademarks or trademarks of their respective companies.   In some cases, trademark symbols such as ' ' or ' ' are not specified in this manual.
  • Page 60 BCN-P5999-1060-B(2010) HEAD OFFICE : TOKYO BUILDING, 2-7-3 MARUNOUCHI, CHIYODA-KU, TOKYO 100-8310, JAPAN NAGOYA WORKS : 1-14 , YADA-MINAMI 5-CHOME , HIGASHI-KU, NAGOYA , JAPAN When exported from Japan, this manual does not require application to the Ministry of Economy, Trade and Industry for service transaction permission. Specifications subject to change without notice.

Table of Contents