Computer Network 5. Modbus
-
Upload
felix-lin -
Category
Technology
-
view
433 -
download
0
description
Transcript of Computer Network 5. Modbus
V. Modbus
Felix Lin
Computer Network
Review
OSI Model Modbus
Application Layer
Presentation Layer
Session Layer
Transport Layer
Network Layer
Data Link Layer
Physical Layer
Modbus
NA
NA/Ports
NA/TCP
NA/IP
RS-232/MAC
Serial/Ethernet
Mapping
Overview
• Published by Modicon in 1979• Modbus is a Protocol, NOT RS232 or
RS485 neither• Use for communication between
individual equipment• RTU/ASCII• Usually over RS232, RS485 or TCP/IP.• Take TCP 502 port to use
Protocol Stack
Use Case
General Frame
• ADU – Application Data Unit– Maxima size is 256Byte (inherited from RS485)
• PDU – Protocol Data Unit– Maxima size is 253Byte
(ADU – 1Byte Server Address – 2Byte CRC)
• Use big-endian representation
How It Works?
Data Model
Primary tables Object type TypeDiscretes Input Single bit RO
Coils Single bit RW
Input Registers 16- bit word RO
Holding Registers 16- bit word RW
Type of Function Codes
• Public– Data Access (Read/Write)• Bit Access• Word Access(16bits)
– Diagnostic– Other
• User Defined • Reserved for Exception
(128~255)
Function Codes(Data Access)
Code Description Type
Bit Access
0x01 Read Coils Read
0x02 Read Discrete Inputs Read
0x05 Write Single Coil Write
0x15 Write Multiple Coils Write
Word Access(16bits
)
0x03 Read Holding Registers Read
0x04 Read Input Register Read
0x06 Write Single Register Write
0x10 Write Multiple Registers Write
Exception CodesCode Name
0x01 ILLEGAL FUNCTION0x02 ILLEGAL DATA ADDRESS0x03 ILLEGAL DATA VALUE0x04 SERVER DEVICE FAILURE0x05 ACKNOWLEDGE0x06 SERVER DEVICE BUSY0x08 MEMORY PARITY ERROR0x0A GATEWAY PATH UNAVAILABLE0x0B GATEWAY TARGET DEVICE FAILED TO RESPOND
Transaction State Diagram
Read Coils
Read Discrete Inputs
Read Holding Registers
Read Input Registers
Write Single Coil
Write Single Register
Write Multiple registers