MODBUS Communication
MODBUS Communication
2 What is Modbus
3 Modbus RTU
4 Modbus TCP/IP
5 Modbus TCP
6 Modbus TCP
Internal
Positioning of The Main Networks
Sensor Machine
AS-i* Sercos,…
Respons time
CANopen*
DeviceNet Process
Fipio Fipway
Modbus +
Management
Modbus*
Profibus DP / PA
Profibus FMS
Ethernet TCP/IP*
Power SCADA
Edge Control Operation GeoSCADA MachineSCADA PlantSCADA
(PSO)
Connected
Products PowerProtective RTUs, Breakers,
Meters Relays PLCs Trip
FD
Breakers, Variable UPSs BCPMs
Water,
Air,
Speed
Units, Sensors, Gas,
Gateways Gateways Drives Steam
Medium
Speakers
(Transmitter and Receiver)
Internal
• Transmit by Air
• Same Frequency
• Radio must be Switched on
• Same Language
• Do not speak at the same time
• Acknowledge the message
Internal
Internal
Internal
Internal
Internal
Twisted Pairs Coaxial Cable Optical fiber Cable
Internal
Common Medium
Twisted pair(s) wires
Easy to install, and the least expensive. Low
Cost of
Coaxial cable the
The coaxial cable has excellent electrical medium
properties and is suitable for high speed
transmission.
Optical fiber
This is suitable for use in harsh industrial
environments. The transmission is reliable over long
distances. High
The choice of the MEDIUM affects the transmission quality :
✓ Speed
✓ Length of the bus
✓ Electromagnetic immunity
Internal
RJ45
Internal
RJ45
Internal
RJ45
Internal
Patch
Cord
Internal
Internal
Twisted Pairs
RS-232
● Point to Point (P2P)
● Distance < 15 meters , Speed < 20
Kbps
● Logic High : -3V ~ -15V
● Logic Low: +3V ~ +15V
Internal
Twisted Pairs
RS-422A
● Full Duplex , 4 Wires (2 Transmission,2
Reception)
● Distance < 1200 meters , Speed < 100
Kbps
● High Logic: Voltage difference +2V ~ +6V
● Low Logic: Voltage difference -2V ~ -6V
Internal
RS-422A
Internal
Twisted Pairs
RS-485
● Half Duplex , 2 Wires
● Distance < 1200 meters , Speed < 100
Kbps
● High Logic: Voltage difference +2V ~ +6V
● Low Logic: Voltage difference -2V ~ -6V
● Max Speed 10 Mbps at distance 12m
Internal
Twisted Pairs
Internal
Internal
Internal
Frame
011101010101 011000010101 111110001101 010111010101 11011010101 0111010101 010111110101
Internal
Data Types
How Data is structured
Internal
Medium Access Methods
1) Master/Slave
Internal
Communication Protocol Specifications
Master Slave Vs Peer to Peer
Internal
Medium Access Methods
3) Random Access
1- CSMA\CD
2- CSMA\CA
Internal
CSMA\CA
Internal
Random Access with Non-Destructive Collisions
Stop
Dominant Recessive
Dominant Recessive
Dominant Recessive
Internal
Random Access with Non-Destructive Collisions
The message remains valid, due to a system of dominant and recessive bits
● the device with the lower priority stops its transmission (recessive bit)
● the device with the higher priority completes its transmission
● the device with the lower priority tries to send its message again as soon
as the medium is free
Dominant Stop
Recessive
Stop Stop
Waiting time 5s
Internal
Random Access with Destructive Collisions
Step-by-step operation in the event of a collision:
● any messages in the course of transmission are stopped
● a scrambling frame is sent: the frame is lost
● a random wait time is observed
● the message is resent
Stop
Internal
Question
Internal
What is Modbus?
1. Modbus is a request-reply messaging protocol.
2. some documentation describe this technology as a request-response or
command-respond messaging protocol.
3. The device that initiates the communication, the client ”Master”, sends a request
message.
4. the addressed device, the server “Slave”, sends a reply message.
01110101010
01110101010 01100001010
01100001010 11111000110
11111000110 01011101010
01011101010 11011010101
11011010101 0111010101
0111010101 01011111010
01011111010
11 11 11 11 11
1 2 3
Internal
Modbus Frame
011101010101 011000010101 111110001101 010111010101 11011010101 0111010101 010111110101
Internal
Modbus Frame
Internal
Modbus Frame
1 ~ 247
• Request
• A master addresses a slave by placing the slave address in the address field of the
message.
• Response
• When the slave sends its response, it places its own address in this address field of
the response to let the master know which slave is responding.
Internal
Modbus Frame
Register starts with Meaning Range
0X Coil 00001-09999
1X Discrete Input 10001-19999
3X Analog input Registers 30001-39999
4X Holding Registers 40001-49999
Internal
Function Codes
Code Function
01 (0x01) Read n consecutive output bits
02 (0x02) Read n consecutive input bits
03 (0x03) Read n consecutive output words
04 (0x04) Read n consecutive input words
05 (0x05) Write 1 output bit
06 (0x06) Write 1 output word
07 (0x07) Read exception status
08 (0x08) Access diagnostic counters
15 (0x0F) Write n output bits
16 (0x10) Write n output words
23 (0x17) Read/Write n output words
43 (0x2B) Read identification
http://www.modbus.org
Internal
Modbus Frame
XXXXXX Modbus register list
Internal
Data Types
4000 0 1 2 3 4 5 6 7
1
Bit 0 Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 Bit 7
4000
2
Byte 0
4000
3
word 0
8 9 10 11 12 13 14 15
Bit 8 Bit 9 Bit 10 Bit 11 Bit 12 Bit 13 Bit 14 Bit 15
9999 Byte 1
9
Confidential Property of Schneider Electric |
Internal
Exercise
IA
IB
IC Speed Setpoint
Motor Torque
Internal
Modbus Frame
Register starts with Meaning Range
0X Coil 00001-09999
1X Discrete Input 10001-19999
3X Analog input Registers 30001-39999
4X Holding Registers 40001-49999
Internal
Modbus Frame
Dev Add. Func. Code Regi s. Number Regi s. Count
1
1 4 0002 3
Address Data
0001 10001
0002 500
0003 500
0004 500
0005 1234
Internal
Modbus Frame
Parity Check
Even, Odd, none
CRC
Internal
Modbus Frame
Dev Add. Func. Code Regi s. Number Regi s. Count
1
1 4 0002 3
Address Data
0001 10001
0002 500
0003 500
0004 500
0005 1234
Internal
Request Frame
Internal
Response Frame
Internal
Example of Read Request
Request
1 byte 1 byte 2 bytes 2 bytes 2 bytes
Slave Function First word Number of
CRC16
Address code = 3 address words to read
Response
1 byte 1 byte 2 bytes 2 bytes 2 bytes 2 bytes
Slave Function Number of Value of the Value of the
CRC16
Address code = 3 bytes read first word last word
Internal
Modbus RTU
Modbus RTU Frame Description
Internal
Ethernet Modbus TCP/IP
• Modbus Frames over Ethernet
• Modbus Serial
Internal
OSI Model: Encapsulation Principle
Internal
OSI Model Data Packet
Open System Interconnection
Internal
OSI Model
Open System Interconnection
Internal
BOOTP Server (cont.)
My name is TesysT_072,
Device #2 Can I get an IP Address?
Internal
DHCP Server Examples
Example with M580
Device #1
My name is TesysT_072,
Can I get an IP Address?
Master (Server)
New Device Sure! You are listed in my table. TesysT_072 192.168.0.87
Take this address: 192.168.0.87
Moreover, I found a
configuration corresponding to
your role name. Here is your Saved Config. of TesysT_072
new configuration.
Internal
ARP
– If there is a response, the device should not assume the IP (duplicate address)
Internal
OSI Model
Open System InterconnectionNTP
SMTP 172.16.4.1
Modbus TCP
Internal
TCP (cont.)
Client y
Socket Source port Dest port 172.16.4.3
1 3003 502
172.16.4.2
Internal
TCP Connections
• Point to point messaging protocol
• Uses a handshake process to establish a connection
• Connection is managed by setting bits in the TCP message to request (SYN), acknowledge (ACK), terminate or abort
the connection (FIN)
Client O
P Server
E
N
C
L
O
S
E
Internal
UDP (User Datagram Protocol)
• Transport protocol like TCP but without Acknowledgement
• Provides an unreliable mechanism to transport data
• The network interface does not have as much work to do as with TCP
• Allows the Broadcast message, unlike TCP that requires a dedicated socket between the end
device. Applications example using UDP :
• Simple Network Management Protocol (SNMP)
• Network Time Protocol (NTP)
Internal
OSI Model
Open System Interconnection
• A router has an interface for each different networks. A table of those interfaces tells the router on which interface to send
the packet
PLC
Router
172.16.4.254 172.16.5.254
172.16.5.1
172.16.4.1
Nota : If there is not a router on the local network, the default gateway can be left blank or 0.0.0.0
Internal
Revision Questions
- How is Float data read in 16 bit register?
- I find address 40001:7 , what does it mean?
- Least significant bit and the most significant bit
- If you need one bit, do you must read all the register ?
- What is Modbus TCP/IP?
- What are the layers supporting TCP\IP
- Difference between CSMA\CA and CSMA\CD
- What does Baud Rate mean ?
- What is the range for Modbus device addressees
- Main Difference between RS232 and RS485
- What should I do to connect Modbus RTU devices to Modbus TP\IP master