melsec iq-r modbus/tcp reference manual · thank you for purchasing the mitsubishi electric melsec...

32
MELSEC iQ-R MODBUS/TCP Reference Manual

Upload: others

Post on 05-Nov-2019

20 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

MELSEC iQ-R MODBUS/TCP Reference Manual

Page 2: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications
Page 3: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

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.

Make sure that the end users read this manual and then keep the manual in a safe place for future reference.

CONDITIONS OF USE FOR THE PRODUCT(1) Mitsubishi programmable controller ("the PRODUCT") shall be used in conditions;

i) where any problem, fault or failure occurring in the PRODUCT, if any, shall not lead to any major or serious accident; and ii) where the backup and fail-safe function are systematically or automatically provided outside of the PRODUCT for the case of any problem, fault or failure occurring in the PRODUCT.

(2) The PRODUCT has been designed and manufactured for the purpose of being used in general industries.MITSUBISHI SHALL HAVE NO RESPONSIBILITY OR LIABILITY (INCLUDING, BUT NOT LIMITED TO ANY AND ALL RESPONSIBILITY OR LIABILITY BASED ON CONTRACT, WARRANTY, TORT, PRODUCT LIABILITY) FOR ANY INJURY OR DEATH TO PERSONS OR LOSS OR DAMAGE TO PROPERTY CAUSED BY the PRODUCT THAT ARE OPERATED OR USED IN APPLICATION NOT INTENDED OR EXCLUDED BY INSTRUCTIONS, PRECAUTIONS, OR WARNING CONTAINED IN MITSUBISHI'S USER, INSTRUCTION AND/OR SAFETY MANUALS, TECHNICAL BULLETINS AND GUIDELINES FOR the PRODUCT. ("Prohibited Application")Prohibited Applications include, but not limited to, the use of the PRODUCT in;• Nuclear Power Plants and any other power plants operated by Power companies, and/or any other cases in which the

public could be affected if any problem or fault occurs in the PRODUCT.• Railway companies or Public service purposes, and/or any other cases in which establishment of a special quality

assurance system is required by the Purchaser or End User.• Aircraft or Aerospace, Medical applications, Train equipment, transport equipment such as Elevator and Escalator,

Incineration and Fuel devices, Vehicles, Manned transportation, Equipment for Recreation and Amusement, and Safety devices, handling of Nuclear or Hazardous Materials or Chemicals, Mining and Drilling, and/or other applications where there is a significant risk of injury to the public or property.

Notwithstanding the above restrictions, Mitsubishi may in its sole discretion, authorize use of the PRODUCT in one or more of the Prohibited Applications, provided that the usage of the PRODUCT is limited only for the specific applications agreed to by Mitsubishi and provided further that no special quality assurance or fail-safe, redundant or other safety features which exceed the general specifications of the PRODUCTs are required. For details, please contact the Mitsubishi representative in your region.

1

Page 4: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

2

INTRODUCTIONThank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers.

This manual describes the frame specifications and MODBUS standard functions of MODBUS/TCP.

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.

Page 5: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

3

CO

NT

EN

TS

CONTENTSSAFETY PRECAUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1

CONDITIONS OF USE FOR THE PRODUCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1

INTRODUCTION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2

TERMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4

CHAPTER 1 MODBUS/TCP PROTOCOL FRAME SPECIFICATIONS 5

1.1 Frame Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.2 Protocol Data Unit Formats Grouped by Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

CHAPTER 2 MODBUS STANDARD FUNCTIONS 7

2.1 MODBUS Standard Function List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2 MODBUS Standard Function Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Coil reading (FC: 01H). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Input reading (FC: 02H). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Holding register reading (FC: 03H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Input register reading (FC: 04H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

One coil writing (FC: 05H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

One register writing (FC: 06H). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Multiple coil writing (FC: 0FH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Multiple register writing (FC: 10H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Extended file register reading (FC: 14H) (SC: 06H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Extended file register writing (FC: 15H) (SC: 06H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Holding register mask writing (FC: 16H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Multiple register reading/writing (FC: 17H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

CHAPTER 3 ABNORMAL RESPONSE CODES 21

INDEX 24

REVISIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26

WARRANTY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27

TRADEMARKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28

Page 6: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

4

TERMSUnless otherwise specified, this manual uses the following terms.

Term Description

FC An abbreviation of function code

Master A name for the side that requests function execution

MODBUS device A device used in communications via the MODBUS protocol

Request message A message that requests function execution to slaves.

In the MODBUS protocol, the master requests function execution to the slaves.

Response message A message that returns execution results of functions from a slave to the master

SC An abbreviation of sub code

Slave A name for the side that processes execution requests from the master and returns the execution results

Slave function A function that communicates with the MODBUS-compliant master device as the MODBUS slave

Page 7: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

1

1 MODBUS/TCP PROTOCOL FRAME

SPECIFICATIONS

1.1 Frame SpecificationsThis section describes the frame specifications of the MODBUS/TCP protocol.

Area name Area size Description

MODBUS application header Communication ID 2 bytes Used by the master to match response messages from slaves.

Protocol ID 2 bytes Indicates the protocol of the protocol data unit.

For MODBUS/TCP, 0 is stored.

Message length 2 bytes Stores the message size in bytes.

The stored message length indicates the length of the message in

areas subsequent to this area.

Module ID 1 byte Used when specifying slaves connected to other lines, such as with

the MODBUS Serial protocol.

Protocol data unit Function code 1 byte Specifies the content of the processing instructed from the master to a

slave.

Data 1 to 252 bytes ■When request message is sent from the master to a slave

Stores the request content of the processing.

■When response message is sent from a slave to the master

Stores the execution result of the processing.

FCSEthernetheader

Application dataIP header TCP header(Error check)MODBUS/TCP frame

MODBUS/TCP application data unit

MODBUS application header

Transaction ID

Protocol ID Message length

Module ID Function code Data

Protocol data unit

1 MODBUS/TCP PROTOCOL FRAME SPECIFICATIONS1.1 Frame Specifications 5

Page 8: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

6

1.2 Protocol Data Unit Formats Grouped by FunctionThis section describes the protocol data unit formats of the MODBUS standard functions.

When the device number is specified within the messageWhen 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.

Ex.

When the status of input 32 (100032) is read by input reading (function code: 02H)

The device number stored in the response message is "the device number of the device that actually performed reading/

writing - 1".

Descriptions of request message and response message formatsThis section describes descriptions of the request message and response message formats of the MODBUS standard

functions.

■Response message formatThe format of the response message sent from a slave to the master varies depending on whether the processing performed

by the slave completed successfully or completed with an error.

In the MODBUS standard function, the formats when completed successfully and completed with an error are described in the

response message format.

Storage locations of abnormal response code and error codeWhen processing on a slave is completed with an error, an abnormal response code is sent to the master.

For details on abnormal response codes, refer to the following.

Page 21 ABNORMAL RESPONSE CODES

Abnormal response codes are also stored in the buffer memory of Ethernet-equipped modules.

The detailed cause is detected as an error by Ethernet-equipped modules.

For details on the buffer memory and errors of Ethernet-equipped modules, refer to the following.

MELSEC iQ-R Ethernet User's Manual (Application)

(1) When reading the status of input 32 (100032), specify 31 (001FH) for the start input number.

(1) Area name

(2) Frame description

(3) For request message format: Setting range

For response message format: Value stored in the response message

(4) When one piece of data consists of two bytes, the upper byte (eight bits) is (H) and the lower byte (eight bits) is (L).

(H) (L)

(1)

(H) (L)02H 001FH 0001H

Start input number specification

Data

Number of read points

Function code

(H) (L) (H) (L)01H

(1)

(2)

(3)

(4)

Start coil number specification

Data

Number of read points

Function code

1 byte(8 bits)

1 byte(8 bits)

(0000H to FFFFH) (0001H to 07D0H)

1 MODBUS/TCP PROTOCOL FRAME SPECIFICATIONS1.2 Protocol Data Unit Formats Grouped by Function

Page 9: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

2

2 MODBUS STANDARD FUNCTIONS

This chapter describes the MODBUS standard functions supported by Ethernet-equipped modules.

2.1 MODBUS Standard Function ListThis section lists the MODBUS standard functions.

Function code (FC) Sub code (SC) Function name Reference

01H Coil reading Page 8 Coil reading (FC: 01H)

02H Input reading Page 9 Input reading (FC: 02H)

03H Holding register reading Page 10 Holding register reading (FC: 03H)

04H Input register reading Page 11 Input register reading (FC: 04H)

05H One coil writing Page 12 One coil writing (FC: 05H)

06H One register writing Page 13 One register writing (FC: 06H)

0FH Multiple coil writing Page 14 Multiple coil writing (FC: 0FH)

10H Multiple register writing Page 15 Multiple register writing (FC: 10H)

14H 06H Extended file register reading Page 16 Extended file register reading (FC: 14H) (SC: 06H)

15H 06H Extended file register writing Page 18 Extended file register writing (FC: 15H) (SC: 06H)

16H Holding register mask writing Page 19 Holding register mask writing (FC: 16H)

17H Multiple register reading/writing Page 20 Multiple register reading/writing (FC: 17H)

2 MODBUS STANDARD FUNCTIONS2.1 MODBUS Standard Function List 7

Page 10: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

8

2.2 MODBUS Standard Function Details

Coil reading (FC: 01H)

Operation descriptionReads the status (ON/OFF) of one or multiple coils.

Request message format (from master to slave)

Response message format (from slave to master)

■When completed successfully

• Device data 1 to n

■When completed with an error

• The read coil status is stored in the order of lower bit higher bit.

• If the number of read points is not a multiple of eight, the remaining bits are all set to 0.

(H) (L) (H) (L)01H

Data

Number of read pointsStart coil number specification

Function code

(0000H to FFFFH) (0001H to 07D0H)

01H

DataFunction code

Number of readbytes n

Device data 1 Device data n

Number of read bytes n

b0b1b2b3b4b5b6b7

0: OFF1: ON

Device data 1

Device data n

Bit device storage order

81H

Data

Exception code

Function code

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details

Page 11: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

2

Input reading (FC: 02H)

Operation descriptionReads the status (ON/OFF) of one or multiple inputs.

Request message format (from master to slave)

Response message format (from slave to master)

■When completed successfully

• Device data 1 to n

■When completed with an error

• The read input status is stored in the order of lower bit higher bit.

• If the number of read points is not a multiple of eight, the remaining bits are all set to 0.

(H) (L) (H) (L)02H

Start input number specification

Data

Number of read points

Function code

(0000H to FFFFH) (0001H to 07D0H)

02H

DataFunction code

Number of readbytes n

Device data 1 Device data n

Number of read bytes n

b0b1b2b3b4b5b6b7

0: OFF1: ON

Device data 1

Device data n

Bit device storage order

82H

Data

Exception code

Function code

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details 9

Page 12: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

10

Holding register reading (FC: 03H)

Operation descriptionReads one or multiple holding register values.

Request message format (from master to slave)

Response message format (from slave to master)

■When completed successfully

■When completed with an error

• For example, when n = 4, the number of read bytes is 4 2 = 8.

(H) (L) (H) (L)03H

Start holding register number specification

Data

Number of read points

Function code

(0000H to FFFFH) (0001H to 007DH)

03H(H) (L) (H) (L)

DataFunction code

Number of readbytes n×2

Device data 1 Device data n

Number of read bytes n×2

83H

Data

Exception code

Function code

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details

Page 13: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

2

Input register reading (FC: 04H)

Operation descriptionReads one or multiple input register values.

Request message format (from master to slave)

Response message format (from slave to master)

■When completed successfully

■When completed with an error

• For example, when n = 4, the number of read bytes is 4 2 = 8.

(H) (L) (H) (L)04H

Data

Number of read pointsStart input register numberspecification

Function code

(0000H to FFFFH) (0001H to 007DH)

04H(H) (L) (H) (L)

DataFunction code

Number of readbytes n×2

Device data 1 Device data n

Number of read bytes n×2

84H

Data

Exception code

Function code

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details 11

Page 14: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

12

One coil writing (FC: 05H)

Operation descriptionWrites a value (ON/OFF) to one coil.

Request message format (from master to slave)

Response message format (from slave to master)

■When completed successfullyThe slave returns the request message received from the master as-is.

■When completed with an error

(H) (L) (H) (L)05H

FF00H: ON0000H: OFF

Coil number specification

Data

ON/OFF specification

Function code

(0000H to FFFFH)

85H

Data

Exception code

Function code

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details

Page 15: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

2

One register writing (FC: 06H)

Operation descriptionWrites a value to one holding register area.

Request message format (from master to slave)

Response message format (from slave to master)

■When completed successfullyThe slave returns the request message received from the master as-is.

■When completed with an error

(H) (L) (H) (L)06H

Holding register number specification

Data

Write data

Function code

(0000H to FFFFH) (0000H to FFFFH)

86H

Data

Exception code

Function code

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details 13

Page 16: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

14

Multiple coil writing (FC: 0FH)

Operation descriptionWrites values (ON/OFF) to multiple coils.

Request message format (from master to slave)

• Device data 1 to n

Ensure that the specified number of write points matches the number of bits specified with the number of

bytes.

For example, when the specified number of write points is 16, set the number of bytes to 2 bytes (= 16 bits).

Response message format (from slave to master)

■When completed successfully

■When completed with an error

• The values (ON/OFF) stored in device data 1 to n are written to the coils in the order of lower bit higher bit of the device data.

• Start coil number: Stores the same value as the start coil number of the request message.

• Number of write points: Stores the same value as the number of write points of the request message.

0FH(H) (L) (H) (L)

DataFunction code

Number of write pointsStart coil number specification Device data 1Number of bytesn

Device data n

Number of bytes n

(0000H to FFFFH) (0001H to 07B0H) (01H to F6H)

b0b1b2b3b4b5b6b7

0: OFF1: ON

Device data 1

Device data n

Bit device storage order

(H) (L) (H) (L)0FH

Data

Number of write pointsStart coil number

Function code

8FH

Data

Exception code

Function code

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details

Page 17: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

2

Multiple register writing (FC: 10H)

Operation descriptionWrites values to multiple holding register areas.

Request message format (from master to slave)

Ensure that the specified number of write points matches the number of bits specified with the number of

bytes.

Response message format (from slave to master)

■When completed successfully

■When completed with an error

• Start holding register number: Stores the same value as the start holding register number of the request message.

• Number of write points: Stores the same value as the number of write points of the request message.

10H

(H) (L) (H) (L) (H) (L) (H) (L)

DataFunction code

Number of write points nStart holding register numberspecification

Device data 1Number of bytes n×2

Device data n

Number of bytes n×2

(0000H to FFFFH) (0001H to 007BH) (01H to F6H)

(H) (L) (H) (L)10H

Start holding register number

Data

Number of write points

Function code

90H

Data

Exception code

Function code

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details 15

Page 18: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

16

Extended file register reading (FC: 14H) (SC: 06H)

Operation descriptionReads the values of multiple extended file register areas.

Request message format (from master to slave)

• Specify the number of sub requests, m, so that the size of the protocol data unit of the request message

does not exceed 253 bytes. The request message will be discarded if the following condition is not met.

[Conditional formula] 253 2 + (m 7)

• Specify the total number of read points of each sub request, N (n1 + ... + nm), so that the size of the protocol

data unit of the response message does not exceed 253 bytes. The slave will return an abnormal response

if the following condition is not met.

[Conditional formula] 253 2 + (m 2) + (N 2)

• File number specification: The upper limit of the file numbers that can be received by an Ethernet-equipped module is the file register size of the mounted

CPU module.

(H) (L)14H

(H) (L) (H) ( L)

(H) (L) (H) (L) (H) (L)

(06H)

(06H)

Number ofbytes m×7

Data

File number specification

Function code

Read start device number

Sub-request 1

Reference number

Number of read points n1

Data

File number specification Read start device number

Sub-request m

Reference number

Number of read points nm

Number of bytes m×7

Number of bytes m×7

(0000H to FFFFH) (0000H to 270FH) (0001H to 007CH)

(0000H to FFFFH) (0000H to 270FH) (0001H to 007CH)

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details

Page 19: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

2

Response message format (from slave to master)

■When completed successfullyN shown below is the total of the device data (n1 + ... + nm).

■When completed with an error

14H

(L)(H) (H) (L)

(L)(H) (H) (L)

(06H)

(06H)

Number of response data bytes m×2+N×2

Device data 1Number of read bytes n1×2+1

Number of read bytes n1×2+1

Reference number

Device data n1

Number of response data bytes m×2+N×2

Device data 1Number of read bytesnm×2+1

Reference number

Device data nm

Number of response data bytes m×2+N×2

Number of read bytes nm×2+1

DataFunction code

Sub-request 1

Data

Sub-request m

94H

Data

Exception code

Function code

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details 17

Page 20: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

18

Extended file register writing (FC: 15H) (SC: 06H)

Operation descriptionWrites 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).

Specify the number of sub requests, m, and the total number of write points of each sub request, N (n1 + ... +

nm), so that the size of the protocol data unit of the request message does not exceed 253 bytes. The request

message will be discarded if the following condition is not met.

[Conditional formula] 253 2 + (m 7) + (N 2)

Response message format (from slave to master)

■When completed successfullyThe slave returns the request message received from the master as-is.

■When completed with an error

• File number specification: The upper limit of the file numbers that can be received by an Ethernet-equipped module is the file register size of the mounted

CPU module.

(H) (L) (H) (L) (H) (L) (H) (L) (H) (L)

(H) (L) (H) (L) (H) (L) (H) (L) (H) (L)15H

(06H)

(06H)

Number ofbytes m×7+N×2

Data

File number specification

Function code

Write start devicenumber

Sub-request 1

Referencenumber

Number of write pointsn1

Number of bytes m×7+N×2

Number of bytes m×7+N×2

Device data 1 Device data n1

Data

File numberspecification

Write start devicenumber

Referencenumber

Number of write pointsnm

Device data 1 Device data nm

Sub-request m

(0001H to 007AH)(0000H to 270FH)(0000H to FFFFH)

(0000H to FFFFH) (0000H to 270FH) (0001H to 007AH)

95H

Data

Exception code

Function code

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details

Page 21: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

2

Holding register mask writing (FC: 16H)

Operation descriptionWrites 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.

If the AND mask value is 0000H, the OR mask value will be the write value.

Request message format (from master to slave)

Response message format (from slave to master)

■When completed successfullyThe slave returns the request message received from the master as-is.

■When completed with an error

With this function, the value stored in the holding register is read from the slave, the AND/OR processing is

performed on the master, and then the mask value is written to the holding register on the slave.

Therefore, if the holding register value is changed during AND/OR processing, the changed value will be

overwritten.

(H) (L) (H) (L)16H

(H) (L)

Target holding register number

DataFunction code

AND mask value OR mask value

(0000H to FFFFH)(0000H to FFFFH)(0000H to FFFFH)

96H

Data

Exception code

Function code

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details 19

Page 22: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

20

Multiple register reading/writing (FC: 17H)

Operation descriptionReads/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)

Ensure that the specified number of write points matches the number of bits specified with the number of

bytes.

Response message format (from slave to master)

■When completed successfully

■When completed with an error

(H) (L)17H

(H) (L) (H) (L) (H) (L) (H) (L)(H) (L)

Data

Read start holding register number

Function code

Number of read pointsn

Write start holdingregister number

Number of bytes m×2

Number of write pointsm

Number ofbytes m×2

Write device data 1 Write device data m

(0000H to FFFFH) (00H to F2H)(0001H to 0079H)(0000H to FFFFH)(0001H to 007DH)

(H) (L)17H

(H) (L)

Read device data 1

DataFunction code

Number of bytesn×2

Read device data n

Number of bytes n×2

97H

Data

Exception code

Function code

2 MODBUS STANDARD FUNCTIONS2.2 MODBUS Standard Function Details

Page 23: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

3

3 ABNORMAL RESPONSE CODES

Abnormal response 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 abnormal response 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.

Abnormal response function code listThis section lists the abnormal response function codes that are stored in the upper byte of the response message format.

(1) Abnormal response function code

(2) Abnormal response code

Abnormal response function code Function name Details

81H Coil reading Coil reading completed with an error.

82H Input reading Input reading completed with an error.

83H Holding register reading Holding register reading completed with an error.

84H Input register reading Input register reading completed with an error.

85H One coil writing Coil writing completed with an error.

86H One register writing Holding register writing completed with an error.

8FH Multiple coil writing Multiple coil writing completed with an error.

90H Multiple register writing Holding register writing completed with an error at

multiple points.

94H Extended file register reading Extended file register reading completed with an

error.

95H Extended file register writing Extended file register writing completed with an error.

96H Holding register mask writing Holding register mask writing completed with an

error.

97H Multiple register reading/writing Register reading/writing completed with an error at

multiple points.

(2)(1)

� � b0b7b8b15

3 ABNORMAL RESPONSE CODES 21

Page 24: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

22

Abnormal response code listThis section lists the abnormal response codes that are stored in the lower byte of the response message format.

Abnormal response code

Error name Error definition and cause Action

01H Function code error The slave received an unsupported function

code.

Check the function codes that are supported by the

slave, and then check the request message sent from

the master.

02H Device address error The specified MODBUS device address is

incorrect.

Check the types and sizes of the MODBUS devices

that are supported by the slave, and then check the

address specification of the request message sent

from the master.

03H Data error The content of the protocol data unit of the

request message is abnormal.

Revise the data unit of the request message sent

from the master.

04H Processing failure Processing was not possible because of an error

that occurred during request message

processing on the slave.

Eliminate the error factor that has occurred on the

slave.

If an Ethernet-equipped module is issuing this code,

use the module diagnostics or a similar method to

identify the problem from the error that is occurring,

and then perform the appropriate actions.

06H Slave busy The slave cannot execute the processing of the

request message because it is executing other

processing.

Retry at a later time.

If an Ethernet-equipped module is issuing this code,

revise the settings so that the number of request

messages that can be received at the same time is

64 or less.

3 ABNORMAL RESPONSE CODES

Page 25: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

3

MEMO

3 ABNORMAL RESPONSE CODES 23

Page 26: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

24

INDEX

A

Abnormal response code list . . . . . . . . . . . . . . . 22Abnormal response function code list . . . . . . . . . 21

D

Descriptions of request message and response message formats . . . . . . . . . . . . . . . . . . . . . . . . 6

M

Master . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

S

Slave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Storage locations of abnormal response code and error code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Page 27: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

I

25

MEMO

Page 28: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

26

REVISIONS*The manual number is given on the bottom left of the back cover.

Japanese manual number: BCN-P5999-1059-A

2018 MITSUBISHI ELECTRIC CORPORATION

Print date *Manual number Revision

October 2018 BCN-P5999-1060-A First edition

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 29: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

27

WARRANTY

Please confirm the following product warranty details before using this product.

1. Gratis Warranty Term and Gratis Warranty RangeIf 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.However, if repairs are required onsite at domestic or overseas location, expenses to send an engineer will be solely at the customer's discretion. Mitsubishi shall not be held responsible for any re-commissioning, maintenance, or testing on-site that involves replacement of the failed module.[Gratis Warranty Term]The gratis warranty term of the product shall be for one year after the date of purchase or delivery to a designated place.Note that after manufacture and shipment from Mitsubishi, the maximum distribution period shall be six (6) months, and the longest gratis warranty term after manufacturing shall be eighteen (18) months. The gratis warranty term of repair parts shall not exceed the gratis warranty term before repairs.[Gratis Warranty Range](1) The range shall be limited to normal use within the usage state, usage methods and usage environment, etc., which

follow the conditions and precautions, etc., given in the instruction manual, user's manual and caution labels on the product.

(2) Even within the gratis warranty term, repairs shall be charged for in the following cases.1. Failure occurring from inappropriate storage or handling, carelessness or negligence by the user. Failure caused

by the user's hardware or software design.2. Failure caused by unapproved modifications, etc., to the product by the user.3. When the Mitsubishi product is assembled into a user's device, Failure that could have been avoided if functions

or structures, judged as necessary in the legal safety measures the user's device is subject to or as necessary by industry standards, had been provided.

4. Failure that could have been avoided if consumable parts (battery, backlight, fuse, etc.) designated in the instruction manual had been correctly serviced or replaced.

5. Failure caused by external irresistible forces such as fires or abnormal voltages, and Failure caused by force majeure such as earthquakes, lightning, wind and water damage.

6. Failure caused by reasons unpredictable by scientific technology standards at time of shipment from Mitsubishi.7. Any other failure found not to be the responsibility of Mitsubishi or that admitted not to be so by the user.

2. Onerous repair term after discontinuation of production(1) Mitsubishi shall accept onerous product repairs for seven (7) years after production of the product is discontinued.

Discontinuation of production shall be notified with Mitsubishi Technical Bulletins, etc.(2) Product supply (including repair parts) is not available after production is discontinued.

3. Overseas serviceOverseas, repairs shall be accepted by Mitsubishi's local overseas FA Center. Note that the repair conditions at each FA Center may differ.

4. Exclusion of loss in opportunity and secondary loss from warranty liabilityRegardless of the gratis warranty term, Mitsubishi shall not be liable for compensation to:(1) Damages caused by any cause found not to be the responsibility of Mitsubishi.(2) Loss in opportunity, lost profits incurred to the user by Failures of Mitsubishi products.(3) Special damages and secondary damages whether foreseeable or not, compensation for accidents, and

compensation for damages to products other than Mitsubishi products.(4) Replacement by the user, maintenance of on-site equipment, start-up test run and other tasks.

5. Changes in product specificationsThe specifications given in the catalogs, manuals or technical documents are subject to change without prior notice.

Page 30: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

28

TRADEMARKSThe 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.

BCN-P5999-1060-A

Page 31: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications
Page 32: MELSEC iQ-R MODBUS/TCP Reference Manual · Thank you for purchasing the Mitsubishi Electric MELSEC iQ-R series programmable controllers. This manual describes the frame specifications

BCN-P5999-1060-A(1810)MEE

Specifications subject to change without notice.

When exported from Japan, this manual does not require application to theMinistry of Economy, Trade and Industry for service transaction permission.

HEAD OFFICE : TOKYO BUILDING, 2-7-3 MARUNOUCHI, CHIYODA-KU, TOKYO 100-8310, JAPANNAGOYA WORKS : 1-14 , YADA-MINAMI 5-CHOME , HIGASHI-KU, NAGOYA , JAPAN