Manual name [manual number]DescriptionAvailable form
MELSEC iQ-R MODBUS and MODBUS/TCP
Reference Manual
[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.
• Other manuals can be accessed from the links in the manual.
• The hardware specifications of each part can be found from the product figures.
• Pages that users often browse can be bookmarked.
• Sample programs can be copied to an engineering tool.
Protocol (MODBUS, MODBUS/TCP) that reads and writes data from a target
device to a module
e-Manual
PDF
TERMS
Unless otherwise specified, this manual uses the following terms.
Ter mDescription
MasterA name for the side that requests function execution
MODBUS deviceA device used in communications via the MODBUS protocol
Request messageA message that requests function execution to slaves.
Response messageA message that returns execution results of functions from a slave to the master
SlaveA name for the side that processes execution requests from the master and returns the execution results
In the MODBUS protocol, the master requests function execution to the slaves.
GENERIC TERMS AND ABBREVIATIONS
Unless otherwise specified, this manual uses the following generic terms and abbreviations.
Generic term/abbreviationDescription
C24A MELSEC iQ-R series serial communication module
FCAn abbreviation of function code
SCAn abbreviation of sub code
5
1FRAME SPECIFICATIONS
DataAddress fieldFunction codeError check
Protocol data unit
Start
END
(Start)
DataAddress fieldFunction codeError checkAddress field
3.5 character time
or more
1 byte1 byte
0 to 252 bytes
2 bytes
3.5 character time
or more
1 byte
Error check calculation range
1.1MODBUS Protocol Frame Specifications
This section describes the frame specifications of the MODBUS protocol.
Area nameDescription
Address field■When request message is sent from the master to a slave
Protocol data unitFunction code■When request message is sent from the master to a slave
Data■When request message is sent from the master to a slave
Error checkThe master adds a check code in a request message and transmits the request message.
The following frame modes are available.
• RTU mode
• ASCII mode
The frame mode of C24 must be consistent with that of the target device.
• 0: Sends a request message to all the slaves. (Broadcast)
• 1 to 247: Stores the target slave station number.
■When response message is sent from a slave to the master
The host station number is stored when sending a response message.
Specifies the content of the processing instructed from the master to a slave.
■When response message is sent from a slave to the master
A requested function code is stored in the case of normal completion.
The most significant bit turns ON in the case of error completion.
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.
The slave, which received the request message, recalculates the check code in the request message
and determines whether the message is correct or not.
The message is discarded if it has an error.
The error check method differs depending on the frame mode.
6
RTU mode
In this mode, frames are received or sent in binary codes.
The frame specifications are compliant with the MODBUS protocol specifications.
Error check in RTU mode
The error check in the RTU mode is conducted by CRC (Cyclic Redundancy Check).
C24 calculates the CRC by the following steps.
Follow the same steps to calculate the CRC when conducting an error check on the target device.
1. Load the 16-bit register whose bits are all '1'.
2. The CRC is calculated every 8 bits from the upper bit of the frame.
Calculate the exclusive OR (XOR) from the 8 bits of the frame and the bits of the step 1.
3. Shift the result of step 2 by 1 bit to the right.
1 FRAME SPECIFICATIONS
1.1 MODBUS Protocol Frame Specifications
4. 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
Ex.
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.
5. Repeat the step 3 and 4 until the bit is shifted up to 8 times.
6. Calculate the exclusive OR (XOR) from the result of step 5 and the next 8 bits of the frame.
7. Repeat the step 3 to 6.
8. Repeat the above operations until the end of the data unit is reached. The final value is a calculated CRC value.
9. The CRC value is stored in the frame in the order of lower 8 bits to upper 8 bits.
The following is a calculation example in the case where function code 07H is sent to station No.2.
0014HClear overrun counter and flagPage 37 Clear overrun counter and flag (sub-function code: 14H)
Function nameReference
Page 27 Clear counters and diagnostic register (sub-function code: 0AH)
register
Page 29 Return bus communication error count (sub-function code: 0CH)
count
Page 35 Return bus character overrun count (sub-function code: 12H)
count
2 MODBUS STANDARD FUNCTION LIST
13
3MODBUS STANDARD FUNCTION DETAILS
(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 read
bytes n
Device data 1Device data n
Number of read bytes n
b0b1b2b3b4b5b6b7
0: OFF
1: ON
Device data 1
Device data n
Bit device storage order
81H
Data
Exception code
Function code
This chapter describes protocol data unit formats.
3.1Read Coils (FC: 01H)
Operation description
Reads 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
14
• Device data 1 to n
• The read coil status is stored in the order of lower bit to higher bit.
• If the number of read points is not a multiple of eight, the remaining bits are all set to 0.
■ When completed with an error
3 MODBUS STANDARD FUNCTION DETAILS
3.1 Read Coils (FC: 01H)
3.2Read Discrete Inputs (FC: 02H)
(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 read
bytes n
Device data 1Device data n
Number of read bytes n
b0b1b2b3b4b5b6b7
0: OFF
1: ON
Device data 1
Device data n
Bit device storage order
82H
Data
Exception code
Function code
Operation description
Reads 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
3
• Device data 1 to n
• The read input status is stored in the order of lower bit to higher bit.
• If the number of read points is not a multiple of eight, the remaining bits are all set to 0.
■ When completed with an error
3 MODBUS STANDARD FUNCTION DETAILS
3.2 Read Discrete Inputs (FC: 02H)
15
3.3Read Holding Registers (FC: 03H)
(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 read
bytes n×2
Device data 1Device data n
Number of read bytes n×2
83H
Data
Exception code
Function code
Operation description
Reads one or multiple holding register values.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
• For example, when n = 4, the number of read bytes is 4 2 = 8.
■ When completed with an error
16
3 MODBUS STANDARD FUNCTION DETAILS
3.3 Read Holding Registers (FC: 03H)
3.4Read Input Registers (FC: 04H)
(H)(L)(H)(L)
04H
Data
Number of read pointsStart input register number
specification
Function code
(0000H to FFFFH)(0001H to 007DH)
04H
(H)(L)(H)(L)
DataFunction code
Number of read
bytes n×2
Device data 1Device data n
Number of read bytes n×2
84H
Data
Exception code
Function code
Operation description
Reads one or multiple input register values.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
3
• For example, when n = 4, the number of read bytes is 4 2 = 8.
■ When completed with an error
3 MODBUS STANDARD FUNCTION DETAILS
3.4 Read Input Registers (FC: 04H)
17
3.5Write Single Coil (FC: 05H)
(H)(L)(H)(L)
05H
FF00H: ON
0000H: OFF
Coil number specification
Data
ON/OFF specification
Function code
(0000H to FFFFH)
85H
Data
Exception code
Function code
Operation description
Writes a value (ON/OFF) to one coil.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
The slave returns the request message received from the master as-is.
■ When completed with an error
18
3 MODBUS STANDARD FUNCTION DETAILS
3.5 Write Single Coil (FC: 05H)
3.6Write Single Register (FC: 06H)
(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
Operation description
Writes a value to one holding register area.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
The slave returns the request message received from the master as-is.
■ When completed with an error
3
3 MODBUS STANDARD FUNCTION DETAILS
3.6 Write Single Register (FC: 06H)
19
3.7Read Exception Status (FC: 07H)
07H
Function code
07H
Data
Error information
Function code
87H
Data
Exception code
Function code
Operation description
Reads the error status.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
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)
■ When completed with an error
20
3 MODBUS STANDARD FUNCTION DETAILS
3.7 Read Exception Status (FC: 07H)
3.8Diagnostics (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.
The communication status of MODBUS can be checked by a diagnostic counter of the MODBUS standard function.
■ Diagnostic counter
CounterBuffer memoryMODBUS standard function
Typ eDescriptionCH1CH2
Bus message count
Bus communication error
*1
count
Exception error countCounts the number of exception error occurrences.
Slave message countCounts the number of times that messages addressed to the
Slave no-response count Counts the number of times that broadcast request messages
Slave NAK countRefers to the number of times that NAK responses were
Slave busy countRefers to the number of times that busy responses were
Character overrun countCounts the number of times that the request message size
*1
Counts the number of messages detected on the line.32512
Counts the number of the following error messages detected on
the line.
• CRC/LRC error message
• Overrun/parity error
• Short frame (less than 3 bytes)
• Character overrun (256 bytes or more)
Messages other than the above are counted by the bus
message count.
(Including broadcast messages)
host were processed.
(Including when broadcast request messages were received)
were received.
received in a master device.
It is always '0' in C24s.
received in a master device.
It is always '0' in C24s.
exceeded the upper limit.
(7F00H)
32513
(7F01H)
32522
(7F0AH)
32518
(7F06H)
32519
(7F07H)
32520
(7F08H)
32521
(7F09H)
32514
(7F02H)
32576
(7F40H)
32577
(7F41H)
32586
(7F4AH)
32582
(7F46H)
32583
(7F47H)
32584
(7F48H)
32585
(7F49H)
32578
(7F42H)
Page 28 Return bus message
count (sub-function code: 0BH)
Page 29 Return bus
communication error count (subfunction code: 0CH)
Page 30 Return bus exception
error count (sub-function code: 0DH)
The following diagnostic resisters will be cleared.
• 'CH1/2 side LED lighting status and communication error status' of the buffer memory (Un\G513/Un\G514)
• 'CH1/2 side exception code storage area' of the buffer memory (Un\G28674/Un\G28676)
*1 Clears only the receiving channel side area.
*1
Request message format (from master to slave)
*1
3
Response message format (from slave to master)
■ When completed successfully
The slave returns the request message received from the master as-is.
■ When completed with an error
3 MODBUS STANDARD FUNCTION DETAILS
3.8 Diagnostics (FC: 08H)
27
Return bus message count (sub-function code: 0BH)
(H)(L)
08H(000BH)(0000H)
(H)(L)
DataFunction codeSub-function code
(H)(L)
(H)(L)
08H(000BH)
Function codeSub-function code
Bus message count value
Data
(0000H to FFFFH)
88H
Data
Exception code
Function code
Operation description
Reads out the number of messages detected on the line to the master.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
Returns the count value of the buffer memory listed below to the master.
• 'Bus message count' (Un\G32512/Un\G32576)
Refer to the following for the counter descriptions, count range, and count clear methods.
Page 21 Checking communication conditions using a diagnostic counter
■ When completed with an error
28
3 MODBUS STANDARD FUNCTION DETAILS
3.8 Diagnostics (FC: 08H)
Return bus communication error count (sub-function code: 0CH)
(H)(L)
08H(000CH)(0000H)
(H)(L)
DataFunction codeSub-function code
(H)(L)
(H)(L)
08H(000CH)
Function codeSub-function code
Bus communication
error count value
Data
(0000H to FFFFH)
88H
Data
Exception code
Function code
Operation description
Reads out the number of error messages detected on the line to the master.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
3
Returns the count value of the buffer memory listed below to the master.
• 'Bus communication error count' (Un\G32513/Un\G32577)
Refer to the following for the counter descriptions, count range, and count clear methods.
Page 21 Checking communication conditions using a diagnostic counter
■ When completed with an error
3 MODBUS STANDARD FUNCTION DETAILS
3.8 Diagnostics (FC: 08H)
29
Return bus exception error count (sub-function code: 0DH)
(H)(L)
08H(000DH)(0000H)
(H)(L)
DataFunction codeSub-function code
(H)(L)
(H)(L)
08H(000DH)
Function codeSub-function code
Exception error count value
Data
(0000H to FFFFH)
88H
Data
Exception code
Function code
Operation description
Reads out the frequency of exception errors to the master.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
Returns the count value of the buffer memory listed below to the master.
• 'Exception error count' (Un\G332522/Un\G32586)
Refer to the following for the counter descriptions, count range, and count clear methods.
Page 21 Checking communication conditions using a diagnostic counter
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)
Response message format (from slave to master)
■ When completed successfully
3
Returns the count value of the buffer memory listed below to the master.
• 'Slave message count' (Un\G32518/Un\G32582)
Refer to the following for the counter descriptions, count range, and count clear methods.
Page 21 Checking communication conditions using a diagnostic counter
■ When completed with an error
3 MODBUS STANDARD FUNCTION DETAILS
3.8 Diagnostics (FC: 08H)
31
Return slave no response count (sub-function code: 0FH)
(H)(L)
08H(000FH)(0000H)
(H)(L)
DataFunction codeSub-function code
(H)(L)
(H)(L)
08H(000FH)
Function codeSub-function code
Slave no-response count value
Data
(0000H to FFFFH)
88H
Data
Exception code
Function code
Operation description
Reads to out the number of broadcast request messages received to the master.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
Returns the count value of the buffer memory listed below to the master.
• 'Slave no-response count' (Un\G32519/Un\G32583)
Refer to the following for the counter descriptions, count range, and count clear methods.
Page 21 Checking communication conditions using a diagnostic counter
■ When completed with an error
32
3 MODBUS STANDARD FUNCTION DETAILS
3.8 Diagnostics (FC: 08H)
Return slave NAK count (sub-function code: 10H)
(H)(L)
08H(0010H)(0000H)
(H)(L)
DataFunction codeSub-function code
(H)(L)
(H)(L)
08H(0010H)
Function codeSub-function code
Slave NAK count value
Data
(0000H)
88H
Data
Exception code
Function code
Operation description
Reads out the number of NAK responses to the master.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
3
Returns the count value of the buffer memory listed below to the master.
• 'Slave NAK count' (Un\G32520/Un\G32584)
It is always '0' in C24s.
■ When completed with an error
3 MODBUS STANDARD FUNCTION DETAILS
3.8 Diagnostics (FC: 08H)
33
Return slave busy count (sub-function code: 11H)
(H)(L)
08H(0011H)(0000H)
(H)(L)
DataFunction codeSub-function code
(H)(L)
(H)(L)
08H(0011H)
Function codeSub-function code
Slave busy count value
Data
(0000H)
88H
Data
Exception code
Function code
Operation description
Reads out the number of busy responses to the master.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
Returns the count value of the buffer memory listed below to the master.
• 'Slave busy count' (Un\G32521/Un\G32585)
It is always '0' in C24s.
■ When completed with an error
34
3 MODBUS STANDARD FUNCTION DETAILS
3.8 Diagnostics (FC: 08H)
Return bus character overrun count (sub-function code: 12H)
(H)(L)
08H(0012H)(0000H)
(H)(L)
DataFunction codeSub-function code
(H)(L)
(H)(L)
08H(0012H)
Function codeSub-function code
Bus character overrun
count value
Data
(0000H to FFFFH)
88H
Data
Exception code
Function code
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)
Response message format (from slave to master)
■ When completed successfully
3
Returns the count value of the buffer memory listed below to the master.
• 'Character overrun count' (Un\G32514/Un\G32578)
Refer to the following for the counter descriptions, count range, and count clear methods.
Page 21 Checking communication conditions using a diagnostic counter
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)
Response message format (from slave to master)
■ When completed successfully
Returns the count value of the buffer memory listed below to the master.
• 'Character overrun count' (Un\G32514/Un\G32578)
Refer to the following for the counter descriptions, count range, and count clear methods.
Page 21 Checking communication conditions using a diagnostic counter
■ When completed with an error
36
3 MODBUS STANDARD FUNCTION DETAILS
3.8 Diagnostics (FC: 08H)
Clear overrun counter and flag (sub-function code: 14H)
(H)(L)
08H(0014H)(0000H)
(H)(L)
DataFunction codeSub-function code
88H
Data
Exception code
Function code
Operation description
Clears the overrun error counter and flag.
C24 clears the character overrun count value.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
The slave returns the request message received from the master as-is.
■ When completed with an error
3
3 MODBUS STANDARD FUNCTION DETAILS
3.8 Diagnostics (FC: 08H)
37
3.9Get Communications Event Counter (FC: 0BH)
0BH
Function code
(H)(L)(H)(L)
0BH
(0000H)
Program command status
Data
Communications
event count value
Function code
(0000H to FFFFH)
8BH
Data
Exception code
Function code
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)
Response message format (from slave to master)
■ When completed successfully
Since C24 does not support any program commands, 0000H is stored in the program command status.
Returns the count value of the buffer memory listed below to the master.
• 'Communications event count' (Un\G32523 to Un\G32587)
The count is stopped if it has reached FFFFH.
Reset the counter by any of the following methods when restarting the count.
• b2 to b5: Unused (Fixed to 0)
While the occurrence of busy status (exception code 05H to 07H) is stored for the MODBUS protocol, '0' is
stored for C24 because this kind of events does not occur in it.
• b6: Fixed to 1
• b7: Unused (Fixed to '0')
04H is stored to the communications event log.
00H is stored to the communications event log.
The communications event can be cleared by either of the following:
• Clear setting of the communications event log with the restart communications option. (Page 23 Restart
communications option (sub-function code: 01H))
• Turn the power OFF and ON, or reset the programmable controller CPU.
40
3 MODBUS STANDARD FUNCTION DETAILS
3.10 Get Communications Event Log (FC: 0CH)
3.11Write Multiple Coils (FC: 0FH)
0FH
(H)(L)(H)(L)
DataFunction code
Number of write pointsStart coil number specificationDevice data 1Number of bytes
n
Device data n
Number of bytes n
(0000H to FFFFH)(0001H to 07B0H)(01H to F6H)
b0b1b2b3b4b5b6b7
0: OFF
1: 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
Operation description
Writes values (ON/OFF) to multiple coils.
Request message format (from master to slave)
• Device data 1 to n
3
• The values (ON/OFF) stored in device data 1 to n are written to the coils in the order of lower bit to higher bit of the device data.
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
• 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.
■ When completed with an error
3 MODBUS STANDARD FUNCTION DETAILS
3.11 Write Multiple Coils (FC: 0FH)
41
3.12Write Multiple Registers (FC: 10H)
10H
(H)(L)(H)(L)(H)(L)(H)(L)
DataFunction code
Number of write points nStart holding register number
specification
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
Operation description
Writes 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
• 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.
■ When completed with an error
42
3 MODBUS STANDARD FUNCTION DETAILS
3.12 Write Multiple Registers (FC: 10H)
3.13Report Slave ID (FC: 11H)
11H
Function code
11H
(02H)
DataFunction code
Number of
bytes
Programmable
controller CPU
STOP/RUN
state
Programmable
controller
CPU type
91H
Data
Exception code
Function code
Operation description
Acquires the information of C24 mounted station into the master.
Request message format (from master to slave)
Response message format (from slave to master)
■ When completed successfully
3
• Programmable controller CPU type: Page 43 Programmable controller CPU type
• Programmable controller CPU STOP/RUN: STOP (00H), RUN (FFH)
■ When completed with an error
Programmable controller CPU type
C24 will return any of the following programmable controller CPU type data.
The programmable controller CPU type is the original for C24s.
Module nameModelProgrammable controller CPU type returned to Master
Programmable controller CPUR00CPUA0H
R01CPUA1H
R02CPUA2H
R04CPU00H
R08CPU01H
R16CPU02H
R32CPU03H
R120CPU04H
R04ENCPU05H
R08ENCPU06H
R16ENCPU07H
R32ENCPU08H
R120ENCPU09H
3 MODBUS STANDARD FUNCTION DETAILS
3.13 Report Slave ID (FC: 11H)
43
Module nameModelProgrammable controller CPU type returned to Master
Process CPUR08PCPU41H
R16PCPU42H
R32PCPU43H
R120PCPU44H
SIL2 process CPUR08PSFCPU51H
R16PSFCPU52H
R32PSFCPU53H
R120PSFCPU54H
Safety CPUR08SFCPU91H
R16SFCPU92H
R32SFCPU93H
R120SFCPU94H
C Controller moduleR12CCPU-V20H
Remote head moduleRJ72GF15-T260H
RJ72GF15-T2(SR)61H
RJ72GF15-T2(LR)62H
44
3 MODBUS STANDARD FUNCTION DETAILS
3.13 Report Slave ID (FC: 11H)
3.14Read File Record (FC: 14H) (SC: 06H)
(H)(L)
14H
(H)(L)(H)( L)
(H)(L)(H)(L)(H)(L)
(06H)
(06H)
Number of
bytes 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)
Operation description
Reads the values of multiple extended file register areas.
Request message format (from master to slave)
3
• 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.
• 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)
3 MODBUS STANDARD FUNCTION DETAILS
3.14 Read File Record (FC: 14H) (SC: 06H)
45
Response message format (from slave to master)
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 1
Number of
read bytes
nm×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
■ When completed successfully
N shown below is the total of the device data (n1 + ... + nm).
■ When completed with an error
46
3 MODBUS STANDARD FUNCTION DETAILS
3.14 Read File Record (FC: 14H) (SC: 06H)
3.15Write File Record (FC: 15H) (SC: 06H)
(H)(L)(H)(L)(H)(L)(H)(L)(H)(L)
(H)(L)(H)(L)(H)(L)(H)(L)(H)(L)
15H
(06H)
(06H)
Number of
bytes
m×7+N×2
Data
File number
specification
Function code
Write start device
number
Sub-request 1
Reference
number
Number of write points
n1
Number of bytes m×7+N×2
Number of bytes m×7+N×2
Device data 1Device data n1
Data
File number
specification
Write start device
number
Reference
number
Number of write pointsnmDevice data 1Device 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
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).
3
• 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.
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 successfully
The slave returns the request message received from the master as-is.
■ When completed with an error
3 MODBUS STANDARD FUNCTION DETAILS
3.15 Write File Record (FC: 15H) (SC: 06H)
47
3.16Mask Write Register (FC: 16H)
(H)(L)(H)(L)
16H
(H)(L)
Target holding register number
DataFunction code
AND mask valueOR mask value
(0000H to FFFFH)(0000H to FFFFH)(0000H to FFFFH)
96H
Data
Exception code
Function code
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.
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 successfully
The 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.
48
3 MODBUS STANDARD FUNCTION DETAILS
3.16 Mask Write Register (FC: 16H)
3.17Read/Write Multiple Registers (FC: 17H)
(H)(L)
17H
(H)(L)(H)(L)(H)(L)(H)(L)(H)(L)
Data
Read start holding
register number
Function code
Number of read pointsnWrite start holding
register number
Number of bytes m×2
Number of write pointsmNumber of
bytes m×2
Write device data 1Write 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 bytes
n×2
Read device data n
Number of bytes n×2
97H
Data
Exception code
Function code
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)
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
3
■ When completed with an error
3 MODBUS STANDARD FUNCTION DETAILS
3.17 Read/Write Multiple Registers (FC: 17H)
49
4EXCEPTION CODES
(2)(1)
·
·
b0b7b8b15
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.
(1) Abnormal response function code
(2) Exception code
Abnormal response function code list
This section lists the abnormal response function codes that are stored in the upper byte of the response message format.
Abnormal response function codeFunction nameDetails
81HRead coils'Read coils' completed with an error.
82HRead discrete inputs'Read discrete inputs' completed with an error.
83HRead holding registers'Read holding registers' completed with an error.
84HRead input registers'Read input registers' completed with an error.
85HWrite single coil'Write single coil' completed with an error.
86HWrite single register'Write single holding register' completed with an error.
87HRead exception status'Read exception status' completed with an error.
88HPage 13 Diagnosis function details'Diagnostics' completed with an error.
8BHGet communications event counter'Get communications event counter' completed with
8CHGet communications event log'Get communications event log' completed with an
8FHWrite multiple coils'Write multiple coils' completed with an error.
90HWrite multiple registers'Write multiple holding registers' completed with an
91HReport slave ID'Report slave ID' completed with an error.
94HRead file record'Read file record' completed with an error.
95HWrite file record'Write file record' completed with an error.
96HMask write register'Mask write register' completed with an error.
97HRead/Write multiple registers'Read/Write multiple registers' completed with an
an error.
error.
error.
error.
50
4 EXCEPTION CODES
Exception code list
This section lists the exception codes that are stored in the lower byte of the response message format.
Exception code Error nameError definition and causeAction
01HFunction code errorThe slave received an unsupported function
code.
02HDevice address errorThe specified MODBUS device address is
incorrect.
03HData errorThe content of the protocol data unit of the
request message is abnormal.
04HProcessing failureProcessing was not possible because of an error
that occurred during request message
processing on the slave.
06HSlave busyThe slave cannot execute the processing of the
request message because it is executing other
processing.
Check the function codes that are supported by the
slave, and then check the request message sent from
the master.
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.
Revise the data unit of the request message sent
from the master.
Eliminate the error factor that has occurred on the
slave.
If a 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.
Retry at a later time.
If a 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.
4
4 EXCEPTION CODES
51
INDEX
A
Abnormal response function code list . . . . . . . . . 50
D
Descriptions of request message and response
message formats
Storage locations of exception code and error code 12
. . . . . . . . . . . . . . . . . . . . . . . 11
52
MEMO
I
53
REVISIONS
*The manual number is given on the bottom left of the back cover.
Print date*Manual numberRevision
October 2018BCN-P5999-1060-AFirst edition
October 2020BCN-P5999-1060-B■Added models
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.
2018 MITSUBISHI ELECTRIC CORPORATION
RJ71C24, RJ71C24-R2, RJ71C24-R4
■Added functions
MODBUS slave function
■Added or modified parts
CONDITIONS OF USE FOR THE PRODUCT, INTRODUCTION, RELEVANT MANUALS, TERMS,
GENERIC TERMS AND ABBREVIATIONS, Chapter 1, Section 1.1, Section 1.2, Section 1.3,
Chapter 2, Chapter 3, Section 3.7, Section 3.8, Section 3.9, Section 3.10, Section 3.13, Chapter 4
54
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.
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 service
Overseas, 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 liability
Regardless 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 specifications
The specifications given in the catalogs, manuals or technical documents are subject to change without prior notice.
55
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.
56
BCN-P5999-1060-B(2010)
Specifications subject to change without notice.
When exported from Japan, this manual does not require application to the
Ministry of Economy, Trade and Industry for service transaction permission.
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
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.