Modbus Protocol en
Modbus Protocol en
Being able to approach the implementation of the Modbus protocol on various physical media like serial link, Ethernet TCP-IP or Modbus Plus
Implementation Classes
Duration: 40 min.
TOLED
Implementation Classes
TOLED
- Its origins
1978
Modbus is a messaging protocol Created in 1978 by Modicon Open and easy to implement Widely used in industry
TOLED
TOLED
Modbus Plus
Modbus on RS232
Modbus on RS485
TOLED
Client
Server
1,000 rpm
Response
The Client is the entity requesting a service The Server is the entity that provides the service
TOLED
byte
Address Function Code Data Error check
Validity check
The format of the "Address" and "Error check" fields depends on the network media used
TOLED
Server
Response
3 4
1 - 127
Additional information
Requested data
TOLED
Server
Response
3 4
1 - 127
Additional information
Exception function code = Function Code + 80H Value from 129 to 255
TOLED
Exception code = 1
Valid
Exception code = 2
Valid
TOLED
Implementation Classes
TOLED
User defined
User defined
Reserved
Used by certain companies and not available
Public
TOLED
Bit
Read/Write
Input Registers
Word
Read only
Holding Registers
Word
Read/Write
TOLED
Read Discrete Inputs Read Coils Write Single Coil Write Multiple Coils Read Input Registers Read Holding Registers Write Single Register
02 01 05 15 04 03 06 16 23 22 24
Write Multiple Registers Read/Write Multiple Registers Mask Write Register Read FIFO queue
TOLED
Read File record Write File record Read Exception status Diagnostic
20 21 07 08 11 12 17 43 43
Diagnostic
Get Com Event Counter Get Com Event Log Report slave ID Read Device Identification
Other
TOLED
IMPLEMENTATION CLASSES
Implementation Classes
TOLED
Messaging
Device Management
TOLED
Basic
Regular
Extended
Belonging to a class only if all of the required characteristics are supported. A device can also support characteristics of a higher class.
TOLED
- Messaging Classes
Messaging classes are identical for both Client and Server
Access to registers only
Basic
Regular Extended
CF 01: Read Coils CF 02: Read discrete inputs CF 15: Write Multiple Coils CF 08: Diagnostic
Write Single Register and Write Single Coil are strongly recommended for servers (to ensure compatibility with former products).
Modbus Protocol Basics January 2006
TOLED
Basic
Regular Extended
Basic + Access to Vendor URL, Product Name, Model Name, User Application Name
TOLED
Implementation Classes
TOLED
2 bytes
Address of the first register
2 bytes
Number of registers to read
03
0 to 65535
n = 1 to 125
Response:
1 byte
Function Code
2 bytes
Number of bytes read
2 bytes
Value of the first register
2 bytes
Value of the last register
03
2xn
0 to 65535
0 to 65535
TOLED
2 bytes
Address of the first register
2 bytes
Number of registers to write
1 byte
Number of bytes to write
2 bytes
Value of the first register
2 bytes
Value of the last register
16
0 to 65535
n = 1 to 123
2xn
0 to 65535
0 to 65535
Response:
1 byte
Function Code
2 bytes
Address of the first register
2 bytes
Number of registers written
16
0 to 65535
n = 1 to 123
TOLED
2 bytes
Address of the register
2 bytes
Value of the register
06
0 to 65535
0 to 65535
Response:
1 byte
Function Code
2 bytes
Address of the register
2 bytes
Value of the register
06
0 to 65535
0 to 65535
TOLED
- Read Coils
Request:
1 byte
Function Code
2 bytes
Address of the first digital output
2 bytes
Number of digital outputs to read
01
0 to 65535
n =1 to 2000
Response:
1 byte
Function Code
1 byte
Number of bytes read
1 byte
Value of the first byte
1 byte
Value of the last byte
01
n/8 + 1 if R
0 to 255
0 to 255
TOLED
2 bytes
Address of the first digital input
2 bytes
Number of digital inputs to read
02
0 to 65535
n =1 to 2000
Response:
1 byte
Function Code
1 byte
Number of bytes read
1 byte
Value of the first byte
1 byte
Value of the last byte
02
n/8 + 1 if R
0 to 255
0 to 255
TOLED
2 bytes
Address of the first digital output
2 bytes
Number of digital outputs to write
1 byte
Number of bytes to write
1 byte
Value of the first byte
1 byte
Value of the last byte
15
0 to 65535
n =1 to 1968
n/8 + 1 if R
0 to 255
0 to 255
Response:
1 byte
Function Code
2 bytes
Address of the first digital output
2 bytes
Number of digital outputs written
15
0 to 65535
n =1 to 1968
TOLED
1 byte
Function Code
43
14
Access Level
1 to 4
m =0 to 255
Response:
1 byte 1 byte 1 byte 1 byte Implementation class supported 1 byte 1 byte
If split, address of next object
Function Code
43
Access Level
Split response
1 to 3 1 byte
0 = no 255 = yes
1 to 255
1 to 255 n bytes
1 byte
Address object m
Length object m
Value of object
Add. object
Len. object
Value of object
m+1
m+1
m+1
m = 0 to 255
TOLED
n = 1 to 255
Modbus Protocol Basics January 2006