Modbus通信协议(Modbus protocol)

Modbus通信协议

MODBUS是一个请求/应答协议,位于OSI模型的第7层上的应用层报文传输协议。

  • Modbus:1979年,莫迪康,施耐德收购
  • ModbusRtu/ModbusAscill/MobusTcp
  • 开源免费
  • 多种电气接口及通信介质
  • 报文帧简单紧凑

Modbus protocol

Modbus message format,Modbus frame structure

1. Modbus protocol working

  • The Modbus protocol typically follows a master and slave based architecture. Master transmits a request message to a slave and waits for a response message. This architecture provides complete control to the master for flow of information. This has great merits over the previous multidrop networks using RS422/RS485 etc
  • As shown in the figure, Modbus request message is a layered set of data. Controllers can be setup to communicate on standard Modbus networks using either of two transmission modes: ASCII or RTU. Users select the desired mode, along with the serial port communication parameters (baud rate, parity mode, etc), during configuration of each controller. The mode and serial parameters must be the same for all devices on a Modbus network.
  • The selection of ASCII or RTU(remote terminal unit) mode pertains only to standard Modbus networks. It defines the bit contents of message fields transmitted serially on those networks. It determines how information will be packed into the message fields and decoded.
  • When controllers are setup to communicate on a Modbus network using ASCII mode, each eight-bit byte in a message is sent as two ASCII characters. The main advantage of this mode is that it allows time intervals of up to one second to occur between characters without causing an error.
  • When controllers are setup to communicate on a Modbus network using RTU mode, each eight-bit byte in a message contains two four-bit hexadecimal characters. The main advantage of this mode is that its greater character density allows better data throughput than ASCII for the same baud rate. Each message must be transmitted in a continuous stream.

2. Modbus Functions

function codes:

  • (0x01): read coils —> 读取线圈
  • (0x02): read discrete inputs —>
  • (0x03): read holding registers —>
  • (0x04): read input registers —> 读取输入寄存器
  • (0x05): write single coil —> 读取单个线圈
  • (0x06): write single register —> 写单个寄存器
  • (0x15): write mutiple coils —> 写多个线圈
  • (0x16): write mutiple registers —> 写多个寄存器

3.Modbus debugging tools:

  • Modbus poll
  • Modbus Slave
  • VSPD

4. Modbus on serial (RS232、RS485)

4.1 frame format of sending

slave addressfunciton codestart regreg numberCRC
1byte1byte2bytes2bytes2bytes

Tx: 0A 03 01 11 00 01 D4 88

4.2 frame fromat of receiving

slave addressfunciton codebyte countdatadataCRC
1byte1byte2bytes1byte1byte1byte2bytes

Rx: 0A 03 02 xx xx xx xx

es|

Rx: 0A 03 02 xx xx xx xx

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值