鼻梁痛什么原因引起的| ab阳性血型是什么血型| 尿蛋白弱阳性是什么意思| 心律不齐是什么原因引起的| 卡司是什么意思| 9年是什么婚| 胸口闷疼是什么原因| 钟馗是什么人物| 六月26日是什么日子| 电动汽车什么牌子好| 康复治疗是做什么的| 为什么肚子越来越大| 类风湿因子是什么意思| 脚气吃什么药| 睡觉磨牙是什么原因| 甲功七项检查什么| playboy是什么牌子| 黄瓜含有什么营养成分| 女生两个月没来月经是什么原因| 糖宝是什么意思| spyder是什么品牌| 美食家是什么意思| 相恋纪念日送什么礼物| 888是什么意思| 进字五行属什么| 早上口干苦是什么原因| 膝盖跪着疼是什么原因| 割包皮去医院挂什么科| 健身吃什么长肌肉最快| 蒙氏结节是什么| 肾结晶是什么病| rp是什么| 灰指甲用什么药治疗| 什么情况会胎停| 脚突然抽筋是什么原因| 什么是腺体| 彼此彼此什么意思| 鲱鱼在中国叫什么鱼| ns是什么单位| 梦见自己给自己理发是什么意思| 周期是什么意思| 肩周炎口服什么药最好| 胃不舒服能吃什么水果| 控销药品什么意思| 病毒为什么会变异| 人为什么要读书| 常州冬至吃什么| 捆是什么意思| 殷是什么意思| 6月8日什么星座| 女是念什么| 射是什么意思| 蓁字五行属什么| 886是什么意思| 八月一号是什么星座| 属虎男和什么属相最配| 为什么会长结石| 亲吻是什么感觉| vc什么时候吃最好| 板栗不能和什么一起吃| 电视黑屏是什么原因| 高考早点吃什么好| 直肠炎是什么原因引起| 花肠是母猪的什么部位| 血红蛋白是查什么的| 丙球是什么| aids是什么病的简称| 元老是什么意思| 牙疼吃什么食物| 堞是什么意思| nmd是什么的缩写| 什么东西最养胃| 阴历六月十五是什么日子| 荨麻疹用什么药最好| ls是什么牌子| 心肌缺血有什么症状和表现| 东四命是什么意思| 怀孕不可以吃什么东西| 尿味重是什么原因| 长期胃胀气什么原因| 36d什么意思| 朝鲜面是什么原料做的| 下午16点是什么时辰| hpv高危是什么意思| 豆泡是什么| 氨水对人体有什么危害| 鼻窦炎首选什么抗生素| 角化异常性疾病是什么| 干燥综合症是什么病| 1938年属什么生肖| 蟑螂喜欢吃什么东西| 93年是什么年| 龟头责是什么意思| 食管裂孔疝是什么原因造成的| 消防队属于什么编制| 为什么脸突然肿了| 水瓶座是什么性格| 三亚是什么海| 为什么会血热| pnh是什么病的简称| 女人胆固醇高什么原因| 桃胶和什么相克| 实时更新是什么意思| 咽喉炎吃什么药好| 三点水及念什么| 下肢静脉血栓吃什么药| 脚腕筋疼是什么原因| 梦见好多葡萄是什么意思| 水床是什么| 血糖高挂什么科| 娘酒是什么酒| 月经不调去医院要做什么检查| 后果的意思是什么| 减肥晚餐适合吃什么| 梦见自己吐了是什么意思| 胰是什么器官| nova是什么牌子| 光年是什么单位| 坪效是什么意思| 猥琐男是什么意思| 黄芪不适合什么人吃| 7月29是什么星座| 吹水是什么意思| 男人吃什么可以补精| 办理健康证需要带什么| 尿维生素c弱阳性是什么意思| 三色堇的花语是什么| 子字五行属什么| 心衰吃什么药好| 噩耗是什么意思| 豆瓣是什么软件| 肾精亏虚是什么意思| 什么方法减肥最快| 紫色是什么颜色调出来的| 二氧化碳低是什么原因| 下下签是什么意思| 舌头凉凉的是什么原因| 奈何桥是什么意思| 河北属于什么地区| 人属于什么界门纲目科属种| 雷锋属什么生肖| 女人的逼是什么意思| 子宫内膜厚什么原因引起的| 夏季吃什么菜| 小孩子眼睛眨得很频繁是什么原因| 睡觉张嘴巴是什么原因| 冰糖里面为什么有白线| 男戴观音女戴佛是什么意思| 马云是什么大学毕业的| hisense什么牌子| 幼儿反复发烧是什么原因| 早上起来口干口苦口臭是什么原因| 什么牌子的钙片好| nsa是什么意思| 平权是什么意思| 革兰氏阳性菌是什么病| 褪黑素不能和什么一起吃| 乳环是什么| 什么腔什么调| 女人生气容易得什么病| 老年人脚肿吃什么药| 日入是什么时辰| 1893年属什么生肖| 慢热型是什么意思| 积液是什么原因造成的怎么治疗| 回是什么生肖| 老年人头晕挂什么科| g点是什么| 胃寒吃点什么药| 尿胆原阴性是什么意思| 弹颏是什么意思| mdt是什么意思| 什么的鸽子| 风情万种的意思是什么| 肠胃炎拉肚子吃什么药| 10周年结婚是什么婚| g代表什么| 身体缺硒有什么症状| 什么叫k线| 616是什么意思| 穆赫兰道到底讲的什么| 无名指是什么经络| 石蜡病理是什么意思| 海水倒灌是什么意思| 什么是自慰| 顶嘴是什么意思| 90年属于什么生肖| 大力是什么药| 去火吃什么水果| 河南话信球是什么意思| 不甚是什么意思| 卖什么小吃简单挣钱| 莒姬是什么位分| 十二指肠霜斑样溃疡是什么意思| 备孕需要吃什么| 梦到活人死了是什么预兆| nak是什么牌子| 閪什么意思| 当演员需要什么条件| 基佬什么意思| hrs是什么意思| 妇科和妇产科有什么区别| 什么呀什么| 右下腹疼是什么原因| 孕晚期高血压对胎儿有什么影响| 凝视的近义词是什么| 前列腺钙化是什么病| 天天睡不着觉什么原因| 情绪化什么意思| 斑秃吃什么药效果好| 囊肿是什么| 脾胃虚寒吃什么中成药| 央企与国企有什么区别| 小土豆是什么意思| 女生下面出血但不是月经为什么| 蛇胆疮是什么引起的| 热得像什么| 见利忘义是什么意思| 掉眉毛是什么原因| 梦见着火是什么预兆| 什么是法定节假日| 圣贤是什么意思| clean什么意思| 过期牛奶有什么用途| 耳朵里面痒用什么药| 格格不入是什么意思| 小资情调是什么意思| 正科级是什么级别| 心肌酶能查出什么病| 猫可以吃什么水果| 香港脚是什么症状图片| 清明为什么插柳枝| 白醋加盐洗脸有什么好处| 凯乐石属于什么档次| 水土不服是什么意思| 北京市长什么级别| 宝宝囟门什么时候闭合| 内脂豆腐是什么| 嗜碱性粒细胞偏高是什么原因| 胆结石吃什么排石最快| 胸膜炎挂什么科| 欧诗漫适合什么年龄| 秋天有什么植物| 松石绿是什么颜色| 蛋白石是什么| 胃黏膜受损是什么症状| 2.8是什么星座| karl lagerfeld是什么牌子| 杜牧字什么| 店小二是什么意思| 艾滋病有什么症状| 不动产是什么意思| 人参和什么泡酒最好| 丝状疣长什么样| 筒骨炖什么好吃| 三公经费指什么| 好高什么远| shark是什么意思| 啤酒不能和什么一起吃| 沙漠玫瑰什么时候开花| 大宝贝是什么意思| 江苏属于什么方向| 什么是偏印| 12388是什么电话| 百度Jump to content

《FateGO》成全球第二吸金手游 计划开辟北美市场

From Wikipedia, the free encyclopedia
Modbus
Communication protocol
Developer(s)
  • Modicon (1979–1997)
  • Schneider Electric (1997–2004)
  • Modbus Organization, Inc. (since 2004)
Introduction1979
Logo of Modbus-IDA, the older name of the industry consortium
百度 学雷锋志愿活动的深入开展发挥了主流媒体的示范引领作用,展现了央广职工昂扬向上的精神风貌和社会担当意识。

Modbus (or MODBUS) is a client/server data communications protocol in the application layer.[1] It was originally designed for use with programmable logic controllers (PLCs),[2] but has become a de facto standard communication protocol for communication between industrial electronic devices in a wide range of buses and networks.[3][1]

Modbus is popular in industrial environments because it is openly published and royalty-free. It was developed for industrial applications, is relatively easy to deploy and maintain compared to other standards, and places few restrictions on the format of the data to be transmitted.

The Modbus protocol uses serial communication lines, Ethernet, or the Internet protocol suite as a transport layer.[1] Modbus supports communication to and from multiple devices connected to the same cable or Ethernet network. For example, there can be a device that measures temperature and another device to measure humidity connected to the same cable, both communicating measurements to the same computer, via Modbus.

Modbus is often used to connect a plant/system supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems. Many of the data types are named from industrial control of factory devices, such as ladder logic because of its use in driving relays: a single-bit physical output is called a coil, and a single-bit physical input is called a discrete input or a contact.

It was originally published by in 1979 Modicon (a company later acquired by Schneider Electric in 1997). In 2004, they transferred the rights to the Modbus Organization[4] which is a trade association of users and suppliers of Modbus-compliant devices that advocates for the continued use of the technology.[5]

Protocol description

[edit]
MODBUS communication stack
MODBUS communication stack

Modbus standards or buses include:[1]

  • TCP/IP over Ethernet
  • Asynchronous serial communication in a wide range of standards, technologies: EIA/TIA-232-E, EIA-422, EIA/TIA-485-A, fiber, radio frequency,...
  • MODBUS PLUS, a high speed token passing network.
Architecture of a network for Modbus communication

To support Modbus communication on a network, many modems and gateways incorporate proprietary designs (refer to the diagram: Architecture of a network for Modbus communication). Implementations may deploy either wireline or wireless communication, such as in the ISM radio band, and even Short Message Service (SMS) or General Packet Radio Service (GPRS).

PDU and ADU

[edit]

Modbus defines a client which is an entity that initiates a transaction to request any specific task from its request receiver.[6] The client's "request receiver", which the client has initiated the transaction with, is then called the server.[6] For example, when a microcontroller connects to a sensor to read its data by Modbus on a wired network, e.g RS485 bus, the MCU in this context is the client and the sensor is the server. In former terminology, the client was named master and the server named slave.

Modbus defines a protocol data unit (PDU) independently to its lower layer protocols in its protocol stack. Mapping MODBUS protocol on specific buses or networks requires some additional fields, defined as the application data unit (ADU). The ADU is formed by a client inside a Modbus network when the client initiates a transaction. Contents are:[7]

  • PDU = Function code + data
  • ADU = Additional address + PDU + error check

The ADU is officially called a Modbus frame by the Modbus Organization,[7] although frame is used as the data unit in the data-link layer in the OSI and TCP/IP model (while Modbus is an application layer protocol).

PDU max size is 253 bytes. ADU max size on RS232/RS485 network is 256 bytes, and with TCP is 260 bytes.[8]

For data encoding, Modbus uses a big-endian representation for addresses and data fields. Thus, for a 16-bit value, the most significant byte is sent first. For example, when a 16-bit register has value 0x1234, byte 0x12 is sent before byte 0x34.[8]

Function code is 1 byte which gives the code of the function to execute. Function codes are integer values, ranging from 1 to 255, and the range from 128 to 255 is for exception responses.

The data field of the PDU has the address from 0 to 65535 (not to be confused with the address of the Additional address field of ADU).[9] The data field of the PDU can be empty, and then has a size of 0. In this case, the server will not request any information and the function code defines the function to be executed. If there is no error during the execution process, the data field of the ADU response from server to client will include the data requested, i.e. the data the client previously received. If there is any error, the server will respond with an exception code.[6]

Modbus transaction and PDU

[edit]

A Modbus transaction between client and server includes:[6][10]

  • Step 1: Client initiates a request with PDU = Function code + data request
  • Step 2: Server receives the request from client. Server will then read/parse the function code, get the address of the data field of the PDU, then get this data field value and finally perform the action based on the function code. If there is no error during those steps, the server will respond with PDU = Function code + data response. As long as there is no error during those steps, the server's responding function code will also be the function code sent from the client. If there is any error during those steps, the server will respond with PDU = Exception Function code + Exception code (Reference to PDU mb_excep_rsp_pdu defined below).
  • Step 3: Client receives the response and ends the transaction.

Based on that, Modbus defines 3 PDU types:[8]

  • MODBUS Request PDU, mb_req_pdu
  • MODBUS Response PDU, mb_rsp_pdu
  • MODBUS Exception Response PDU, mb_excep_rsp_pdu
mb_req_pdu = Function code (1 byte) + request data (n bytes)
request data field's size depends on the function code and usually includes values like variable values, data offset, and sub-function codes.[8]
mb_rsp_pdu = Function code (1 byte) + response data (n bytes)
As in mb_req_pdu, response data field's size depends on the function code and usually includes values like variable values, data offset, and sub-function codes.[8]
mb_excep_rsp_pdu = Exception Function code (1 byte) + exception code (1 byte)
Exception Function code = Function code (1 byte) + 0x80. Exception Function code is equal to the Function code, except that its MSB is set to 1.
Exception code (1 byte) of mb_excep_rsp_pdu is defined in the MODBUS Exception Codes table.

Modbus data model

[edit]

Modbus defines its data model based on a series of tables of four primary types:[11]

Primary tables Access Size Features
Discrete input R 1 bit (0–1) Read on/off value
Coil (discrete output)[12] R/W 1 bit (0–1) Read/Write on/off value
Input register R 16 bit words (0–65,535) Read measurements and statuses
Holding register R/W 16 bit words (0–65,535) Read/Write configuration values

For each of the primary tables, the protocol allows individual selection of 65536 data items, and the operations of read or write of those items are designed to span multiple consecutive data items up to a data size limit which is dependent on the transaction function code.[11]

Function code

[edit]

Modbus defines three types of function codes: Public, User-Defined and Reserved.[13]

Public function codes

[edit]
Function type Function name Function code Comment
Data Access Bit access Physical Discrete Inputs Read Discrete Inputs 2
Internal Bits or Physical Coils Read Coils 1
Write Single Coil 5
Write Multiple Coils 15
16-bit access Physical Input Registers Read Input Registers 4
Internal Registers or Physical Output Registers Read Multiple Holding Registers 3
Write Single Holding Register 6
Write Multiple Holding Registers 16
Read/Write Multiple Registers 23
Mask Write Register 22
Read FIFO Queue 24
File Record Access Read File Record 20
Write File Record 21
Diagnostics Read Exception Status 7 serial only
Diagnostic 8 serial only
Get Com Event Counter 11 serial only
Get Com Event Log 12 serial only
Report Server ID 17 serial only
Read Device Identification 43
Other Encapsulated Interface Transport 43

Note: Some sources use terminology that differs from the standard; for example Force Single Coil instead of Write Single Coil.[14]

Function code 01 (read coils) as an example of public function code

[edit]

Function code 01 (read coils) allows reading the state from 1 to 2000 coils of a remote device. mb_req_pdu (request PDU) will then have 2 bytes to indicate the address of the first coil to read (from 0x0000 to 0xFFFF), and 2 bytes to indicate the number of coils to read. mb_req_pdu defines coil address by index 0, i.e the first coil has address 0x0. On a successful execution, mb_rsp_pdu will return one byte to note the function code (0x01), followed by one byte to indicate the number of data bytes it is returning (n), which will be the number of coils requested by mb_req_pdu, divided by 8 bits per byte, and rounded up. The remainder of the response will be the specified number (n) of data bytes.[15] That is, the mb_req_pdu and mb_rsp_pdu of function code 01 will take the following form:[15]

mb_req_pdu:
  • Function code: 0x01 (1 byte)
  • Starting Address (1st coil address to read): From 0x0000 to 0xFFFF (2 bytes)
  • Quantity of coils to read: Range from 1 to 2000 (0x7D0) (2 bytes)
mb_rsp_pdu:
  • Function code: 0x01 (1 byte)
  • Byte count: 1 byte (n=quantity of coils/8, rounded up)
  • Coil Status: n bytes

For instance, mb_req_pdu and mb_rsp_pdu to read coils status from 20-38 will be:[16]

mb_req_pdu:
  • Function code: 0x01
  • Starting Address High byte: 0x00
  • Starting Address Low byte: 0x13
  • Quantity of Outputs High byte: 0x00
  • Quantity of Outputs Low byte: 0x13
Starting Address (2 bytes) is 0x0013, (or 19 in decimal) which is the 20th coil.
Quantity of Outputs (2 bytes) is 0x0013, (or 19 in decimal) which corresponds to 19 values of status of coils 20th to 38th.
mb_rsp_pdu:
  • Function code: 0x01
  • Byte Count: 0x03
  • Outputs status 27-20: 0xCD
  • Outputs status 35-28: 0x6B
  • Outputs status 38-36: 0x05
As 19 coils (20-38) are required, 3 bytes is used to indicate the coil's state. So that Byte Count is 0x03. States of coil from 20 to 27 is 0xCD, which is 1100 1101 in binary. So coil 27 is MSb, and coil 20 is LSb. Same for coil 28 to 35. With coil from 36 to 38, the state will be 0x05, which is 0000 0101. Coil 38 state is the 3rd bit (count from the right), i.e 1, coil 37 is 0, and coil 36 state is LSb bit, i.e. 1. 5 left bits are all 0.

User-defined function codes

[edit]

User-Defined Function Codes are function codes defined by users. Modbus gives two range of values for user-defined function codes: 65 to 72 and 100 to 110. Obviously, user-defined function codes are not unique.[13]

Reserved function codes

[edit]

Reserved Function Codes are function codes used by some companies for legacy product and are not available for public use.[13]

Exception responses

[edit]

When a client sends a request to a server, there can be four possible events for that request:[17]

  • If server receives the request and execute successfully, server will return a normal response.
  • If server cannot receive the request as having communication channel error, server will not respond anything to the client. Client will then have the timeout request error.
  • If server receives the request and detect an error on the communication channel (e.g parity, LRC, CRC), server will not response anything to the client. Client will then have the timeout request error.
  • If server receives the request and is unable to execute it (e.g client requests to read a non-existent register), server will return an exception response to client to indicate the nature of the error.

Exception response message includes two other fields when compared to a normal response message:[17]

  • Function Code: Function code's MSB bit of Exception is 1. This will make this function code 0x80 higher than then request message function code.
  • Data: Server returns the exception code inside the Data field. This field defines the nature of the error.

All Modbus exception code:[18]

Code Text Details
1 Illegal Function Function code received in the query is not recognized or allowed by server
2 Illegal Data Address Data address of some or all the required entities are not allowed or do not exist in server
3 Illegal Data Value Value is not accepted by server
4 Server Device Failure Unrecoverable error occurred while server was attempting to perform requested action
5 Acknowledge Server has accepted request and is processing it, but a long duration of time is required. This response is returned to prevent a timeout error from occurring in the client. client can next issue a Poll Program Complete message to determine whether processing is completed
6 Server Device Busy Server is engaged in processing a long-duration command; client should retry later
7 Negative Acknowledge Server cannot perform the programming functions; client should request diagnostic or error information from server
8 Memory Parity Error Server detected a parity error in memory; client can retry the request
10 Gateway Path Unavailable Specialized for Modbus gateways: indicates a misconfigured gateway
11 Gateway Target Device Failed to Respond Specialized for Modbus gateways: sent when server fails to respond

Modbus over Serial Line protocol

[edit]

Modbus standard also defines Modbus over Serial Line, a protocol over the data link layer of the OSI model for the Modbus application layer protocol to be communicated over a serial bus.[19] Modbus Serial Line protocol is a master-slave protocol which supports one master and multiple slaves in the serial bus.[20] With Modbus protocol on the application layer, client/server model is used for the devices on the communication channel. With Modbus over Serial Line, client's role is implemented by master, and the server's role is implemented by slave.[20][21]

The organization's naming convention inverts the common usage of having multiple clients and only one server. To avoid this confusion, the RS-485 transport layer uses the terms "node" or "device" instead of "server", and the "client" is not a "node".[21]

The (Modbus Organization) is using "client-server" to describe Modbus communications, characterized by communication between [client device (s), which initiates communication and makes requests of server device(s), which process requests and return an appropriate response (or error message).

A serial bus for Modbus over Serial Line can have a maximum of 247 slaves communicating with one master. Those slaves have a unique address ranging from 1 to 247 (decimal value).[22] The master doesn't need to have an address.[22] The communication process is initiated by the master, as only it can initiate a Modbus transaction. A slave will never transmit any data or perform any action without a request from the master, and slaves cannot communicate with each other.[23]

In Modbus over Serial Line, the master initiates requests to the slaves in unicast or broadcast modes. In unicast mode, the master will initiate a request to a single slave with a specific address. Upon receiving and finishing the request, the slave will respond with a message to the master.[22] In this mode, a Modbus transaction includes two messages: one request from the master and one reply from the slave. Each slave must have a unique address (from 1 to 247) to be addressed independently for the communication.[22] In broadcast mode, the master can send a request to all the slaves, using the broadcast address 0,[22] which is the address reserved for broadcast exchanges (and not the master address). Slaves must accept broadcast exchanges but must not respond.[23] The mapping of PDU of Modbus to the serial bus of Modbus over Serial Line protocol results in Modbus Serial Line PDU.[22]

Modbus Serial Line PDU = Address + PDU + CRC (or LRC)

With PDU = Function code + data

  • Address is slave address
  • PDU is defined identically to the PDU of Modbus Application protocol
  • The Error check field with CRC/LRC: The error check methods depend on the protocol versions of the MODBUS over Serial Line, whether it is Modbus RTU or Modbus ASCII.

On the physical layer, MODBUS over Serial Line performs its communication on bit by RS485 or RS232, with TIA/EIA-485 Two-Wire interface as the most popular way. RS485 Four-Wire interface is also used. TIA/EIA-232-E (RS232) can also be used but is limited to point-to-point short-range communication.[20] MODBUS over Serial Line has two transmission modes RTU and ASCII which are corresponded to two versions of the protocol, known as Modbus RTU and Modbus ASCII.[24]

Modbus RTU

[edit]

Modbus RTU (Remote Terminal Unit), which is the most common implementation available for Modbus, makes use of a compact, binary representation of the data for protocol communication. The RTU format follows the commands/data with a cyclic redundancy check checksum as an error check mechanism to ensure the reliability of data. A Modbus RTU message must be transmitted continuously without inter-character hesitations. Modbus messages are framed (separated) by idle (silent) periods. Each byte (8 bits) of data is sent as 11 bits:[3][24]

  • 1 start bit
  • 8 bit data/message, least significant bit sent first
  • 1 bit parity
  • 1 stop bit

The default is even parity, while odd or no parity may be implemented as additional options.[24]

A Modbus RTU frame then will be:[25]

Slave Address Modbus PDU CRC
Function Code Data
1 byte 1 byte 0 – 252 bytes 2 bytes: 1 CRC low byte and 1 CRC high byte

The CRC calculation is widely known as CRC-16-MODBUS, whose polynomial is x16 + x15 + x2 + 1 (normal hexadecimal algebraic polynomial being 8005 and reversed A001).[26]

Example of a Modbus RTU frame in hexadecimal: 01 04 02 FF FF B8 80 (CRC-16-MODBUS calculation for the 5 bytes from 01 to FF gives 80B8, which is transmitted least significant byte first).

To ensure frame integrity during the transmission, the time interval between two frames must be at least the transmission time of 3.5 characters, and the time interval between two consecutive characters must be no more than the transmission time of 1.5 characters.[25] For example, with the default data rate of 19200 bit/s, the transmission times of 3.5 (t3.5) and 1.5 (t1.5) 11-bit characters are:

For higher data rates, Modbus RTU recommends to use the fixed values 750 μs for t1.5 and 1.750 ms for t3.5.[25]

Modbus ASCII

[edit]

Modbus ASCII makes use of ASCII characters (chars) for protocol communication. The ASCII format uses a longitudinal redundancy check checksum. Modbus ASCII messages are framed by a leading colon (":", ASCII value 3A16) and trailing newline (CR/LF, ASCII values 0D16 and 0A16). Modbus ACSII frame do not need to be sent in bursts like Modbus RTU, a delay up to 1 second is permitted between each character transmission by default. Each ASCII character is sent as 10 bits:

  • 1 start bit
  • 7 bit ASCII character, least significant bit sent first
  • 1 bit parity
  • 1 stop bit

The default is even parity, while odd or no parity may be implemented as additional options.

A Modbus ASCII frame includes:[27]

Start Slave Address Modbus PDU LRC End
Function Code Data
1 char (always ":") 2 chars 2 chars 0-252 x 2 chars 2 chars 2 chars (always CR/LF)

Address, Function, Data, and LRC are ASCII hexadecimal encoded values, whereby each byte (8 bits) of information is encoded as two human-readable ASCII characters from the ranges 0–9 and A–F. For example, a byte value of 122 (11110102 or 7A16) is encoded as two ASCII characters, "7" and "A", and transmitted as two bytes, 55 (3716, ASCII value for "7") and 65 (4116, ASCII value for "A").

LRC is calculated as the sum of 8-bit values (excluding the start and end characters), negated (two's complement) and encoded as an 8-bit value. For example, if Address, Function, and Data are 247, 3, 19, 137, 0, and 10, the two's complement of their sum (416) is ?416; this trimmed to 8 bits is 96 (256?×?2???416 = 6016), giving the following 17 ASCII character frame: :F7031389000A60??. LRC is specified for use only as a checksum: because it is calculated on the encoded data rather than the transmitted characters, its 'longitudinal' characteristic is not available for use with parity bits to locate single-bit errors.

Modbus Messaging on TCP/IP

[edit]

Modbus TCP

[edit]

Modbus TCP or Modbus TCP/IP is a Modbus variant used for communications over TCP/IP networks, connecting over port 502.[28] It does not require a checksum calculation, as lower layers already provide checksum protection.

Modbus TCP nomenclature is the same as for the Modbus over Serial line protocol, as any device which send out a Modbus command, is the 'client' and the response comes from a 'server'.[29]

The ADU for Modbus TCP is officially called Modbus TCP/IP ADU by the Modbus organization[30] and is also called Modbus TCP frame by other parties.[3]

MODBUS TCP/IP ADU = MBAP Header + Function code + Data

Where MBAP - which stands for MODBUS Application Protocol header - is the dedicated header used on TCP/IP to identify the MODBUS Application Data Unit.

The MBAP Header contains the following fields:[31]

Name Length (bytes) Function
Transaction identifier 2 For synchronization between messages of server and client
Protocol identifier 2 0 for Modbus/TCP
Length field 2 Number of remaining bytes in this frame
Unit identifier 1 Server address (255 if not used), treated like slave address in Modbus over Serial line

Unit identifier is used with Modbus TCP devices that are composites of several Modbus devices, e.g. Modbus TCP to Modbus RTU gateways. In such a case, the unit identifier is the Server Address of the device behind the gateway.

A MODBUS TCP/IP ADU/Modbus TCP frame format then will be:[31][30]

Transaction identifier Protocol identifier Length Unit identifier Function code Data
2 bytes 2 bytes 2 bytes 1 byte 1 byte n bytes

Example of a Modbus TCP/IP ADU/Modbus TCP frame in hexadecimal

[edit]

12 34 00 00 00 06 01 03 00 01 00 01

  • 0x12 and 0x34 : With transaction ID = 0x1234 (2 bytes) as a "unique number" to be identified between the Modbus TCP client/server, the transaction ID High byte is 0x12 and transaction ID Low byte is 0x34
  • 0x00 and 0x00 : Protocol identifier high byte and low byte
  • 0x00 and 0x06 : Length high byte and low byte. The length is 6 bytes which includes: unit identifier (slave address) (1 byte), function code (1 byte), high byte of the register address to read (1 byte), low byte of the register address to read (1 byte) and data (2 bytes = high byte and low byte of the number of registers to read)
  • 0x01 : Unit identifier (slave address)
  • 0x03 : Function code (Read Multiple Holding Registers)
  • 0x00 and 0x01 : high byte and low byte of the register address to read. The register address to read in this case is 0x0001.
  • 0x00 and 0x01 : high byte and low byte of the number of registers to read. The number of registers to read in this case is 0x0001. (i.e 1 register)

Other Modbus protocol versions over TCP/IP

[edit]
  • Modbus over TCP/IP, Modbus over TCP, or Modbus RTU/IP – a variant that differs from Modbus TCP in that a checksum is included in the payload, as with Modbus RTU.
  • Modbus over UDP – some have experimented with using Modbus over UDP on IP networks, which removes the overhead of TCP.[32]

Other Modbus protocol versions

[edit]

Besides the widely used Modbus RTU, Modbus ASCII and Modbus TCP, there are many variants of Modbus protocols:

  • Modbus Plus (Modbus+, MB+, or MBP) – Modbus Plus is proprietary to Schneider Electric, though it is unpublished rather than patented, and unlike the other variants, it supports peer-to-peer communications between multiple clients.[33] Despite the name, Modbus Plus[34] is not a variant of Modbus. It is a different protocol, involving token passing. It requires a dedicated co-processor to handle fast HDLC-like token rotation. It uses twisted pair at 1 Mbit/s and includes transformer isolation at each node, which makes it transition/edge-triggered instead of voltage/level-triggered. Special hardware is required to connect Modbus Plus to a computer, typically a card made for the ISA, PCI, or PCMCIA bus. Modbus Plus is normally implemented using a custom chipset available only to partners of Schneider.
  • Pemex Modbus – an extension of standard Modbus with support for historical and flow data. It was designed for the Pemex oil and gas company for use in process control and never gained widespread adoption.
  • Enron Modbus – another extension of standard Modbus developed by Enron with support for 32-bit integer and floating-point variables, and historical and flow data. Data types are mapped using standard addresses.[35] The historical data serves to meet an American Petroleum Institute (API) industry standard for how data should be stored.[citation needed]

Data models and function calls are identical for the first four variants listed above; only the encapsulation is different. However the variants are not interoperable, nor are the frame formats.

JBUS mapping

[edit]

Another de facto protocol closely related to Modbus appeared later, and was defined by PLC maker April Automates, the result of a collaborative effort between French companies Renault Automation and Merlin Gerin et Cie in 1985: JBUS. Differences between Modbus and JBUS at that time (number of entities, server stations) are now irrelevant as this protocol almost disappeared with the April PLC series, which AEG Schneider Automation bought in 1994 and then made obsolete. However, the name JBUS has survived to some extent.

JBUS supports function codes 1, 2, 3, 4, 5, 6, 15, and 16 and thus all the entities described above, although numbering is different:

  • Number and address coincide: entity #x has address x in the data frame.
  • Consequently, entity number does not include the entity type. For example, holding register #40010 in Modbus will be holding register #9, at address 9 in JBUS.
  • Number 0 (and thus address 0) is not supported. The server should not implement any real data at this number and address, and it can return a null value or throw an error when requested.

Limitations

[edit]
  • Since Modbus was designed in the late 1970s to communicate to programmable logic controllers, the number of data types is limited to those understood by PLCs at the time. Large binary objects are not supported.
  • No standard way exists for a node to find the description of a data object, for example, to learn that a register value represents a temperature between 30 and 175 degrees.
  • Since Modbus is a client/server (formerly master/slave) protocol,[21] there is no way for a field device to get data by the event handler mechanism (except over Ethernet TCP/IP, called open-mbus) as the client node must routinely poll each field device and look for changes in the data. This consumes bandwidth and network time in applications where bandwidth may be expensive, such as over a low-bit-rate radio link.
  • Modbus is restricted to addressing 247 devices on one data link, which limits the number of field devices that may be connected to a parent station (again, Ethernet TCP/IP is an exception).
  • Modbus protocol itself provides no security against unauthorized commands or interception of data.[36]

See also

[edit]

References

[edit]
  1. ^ a b c d MODBUS Application Protocol 2012, p. 2.
  2. ^ MODICON, Inc. 1996, "Preface"
  3. ^ a b c Drury, Bill (2009). Control Techniques Drives and Controls Handbook (PDF) (2nd ed.). Institution of Engineering and Technology. pp. 508–.
  4. ^ "Modbus FAQ". Modbus. Modbus Organization, Inc. Retrieved 1 November 2012.
  5. ^ "About Modbus Organization". Modbus. Modbus Organization, Inc. Retrieved 8 November 2012.
  6. ^ a b c d MODBUS Application Protocol 2012, p. 4, "4.1 Protocol description"
  7. ^ a b MODBUS Application Protocol 2012, p. 3, "4.1 Protocol description"
  8. ^ a b c d e MODBUS Application Protocol 2012, p. 5, "4.1 Protocol description"
  9. ^ MODBUS Application Protocol 2012, p. 7, "4.4 MODBUS Addressing model"
  10. ^ MODBUS Application Protocol 2012, p. 9, "Figure 9 MODBUS Transaction state diagram"
  11. ^ a b MODBUS Application Protocol 2012, p. 6, "4.3 MODBUS Data model"
  12. ^ "Modpoll Modbus Master Simulator". modbusdriver.com. Retrieved 2025-08-06"-t 0" is for "Discrete output (coil) data type"{{cite web}}: CS1 maint: postscript (link)
  13. ^ a b c MODBUS Application Protocol 2012, p. 10, "5 Function Code Categories"
  14. ^ Clarke, Gordon; Reynders, Deon (2004). Practical Modern Scada Protocols: Dnp3, 60870.5 and Related Systems. Newnes. pp. 47–51. ISBN 0-7506-5799-5.
  15. ^ a b MODBUS Application Protocol 2012, p. 11
  16. ^ MODBUS Application Protocol 2012, p. 12, "6.1 01 (0x01) Read Coils"
  17. ^ a b MODBUS Application Protocol 2012, p. 47, "7 MODBUS Exception Responses"
  18. ^ MODBUS Application Protocol 2012, p. 48, "7 MODBUS Exception Responses"
  19. ^ MODBUS over Serial Line protocol 2006, p. 4
  20. ^ a b c MODBUS over Serial Line protocol 2006, p. 5
  21. ^ a b c "Modbus Organization Replaces Master-Slave with Client-Server (press release)" (PDF). modbus.org. 9 July 2020. Retrieved 11 July 2023.
  22. ^ a b c d e f MODBUS over Serial Line protocol 2006, p. 8
  23. ^ a b MODBUS over Serial Line protocol 2006, p. 7
  24. ^ a b c MODBUS over Serial Line protocol 2006, p. 12
  25. ^ a b c MODBUS over Serial Line protocol 2006, p. 13, "2.5.1.1 MODBUS Message RTU Framing"
  26. ^ MODBUS over Serial Line protocol 2006, p. 39
  27. ^ MODBUS over Serial Line protocol 2006, p. 17, "2.5.2.1 MODBUS Message ASCII Framing"
  28. ^ MODBUS Messaging on TCP/IP 2006, p. 6
  29. ^ Prat, Jér?me (13 February 2017). "Crash Course: Client/Server/Master/Slave". ProSoft Technology. Retrieved 2025-08-06.
  30. ^ a b MODBUS Messaging on TCP/IP 2006, p. 4, "3.1.2 MODBUS On TCP/IP Application Data Unit"
  31. ^ a b MODBUS Messaging on TCP/IP 2006, p. 5, "3.1.3 MBAP Header description"
  32. ^ "Java Modbus Library - About". 2010. Retrieved 2025-08-06.
  33. ^ "What is the difference between Modbus and Modbus Plus?". Schneider Electric. 21 August 2004. Retrieved 2025-08-06.
  34. ^ "Modbus Plus - Modbus Plus Network - Products overview - Schneider Electric United States". Schneider-electric.com. Retrieved 2025-08-06.
  35. ^ "Simply Modbus - About Enron Modbus". Simply Modbus. Retrieved 2025-08-06.
  36. ^ Palmer; Shenoi, Sujeet, eds. (23–25 March 2009). Critical Infrastructure Protection III. Third IFIP WG 11. 10 International Conference. Hanover, New Hampshire: Springer. p. 87. ISBN 978-3-642-04797-8.

Works cited

[edit]
[edit]

Official

[edit]

Other

[edit]
开水冲鸡蛋有什么好处 消化不良吃什么药最好 寄居蟹用什么水养 眼睛视物模糊是什么原因 北极熊为什么不怕冷
二聚体是什么意思 私联是什么意思 吃什么排宿便清肠彻底 阴囊湿疹是什么原因造成的 衔接是什么意思
酷盖是什么意思 三月十五是什么星座 什么样的升旗仪式 来年是什么意思 子宫脱垂吃什么药怎么恢复正常
胃胆汁反流是什么原因引起的 背弃是什么意思 放疗期间吃什么食物最好 练瑜伽有什么好处 待字闺中是什么意思
孩子发烧手脚冰凉是什么原因aiwuzhiyu.com 陈赫的老婆叫什么名字hcv8jop8ns6r.cn 若无其事的若是什么意思hcv9jop4ns3r.cn gi值是什么意思hcv8jop0ns7r.cn 小儿积食吃什么药hcv8jop6ns7r.cn
秋分是什么意思hcv8jop9ns0r.cn 屁股又叫什么xinjiangjialails.com mild是什么意思hcv7jop7ns1r.cn 气血不足什么症状hcv9jop2ns1r.cn vp16是什么药hcv7jop9ns8r.cn
肛瘘是什么hcv8jop4ns1r.cn 肌张力障碍是什么病0735v.com 桑葚什么时候成熟hcv9jop0ns9r.cn 信徒是什么意思hcv9jop8ns2r.cn 高什么远瞩hcv7jop9ns2r.cn
中国属于什么气候hcv8jop4ns8r.cn 猪利是什么hcv8jop2ns5r.cn 陪产假什么时候开始休hcv7jop9ns0r.cn 什么人容易得间质瘤hcv9jop6ns8r.cn 李商隐被称为什么hcv8jop2ns3r.cn
百度