首页 Modbus Communication Protocol

Modbus Communication Protocol

举报
开通vip

Modbus Communication ProtocolModbus Communication Protocol Modbus protocol is a protocol used for communication between the PLC and Modicon controllers invented in 1978. Modbus communication protocol participant is defind as “master”(MASTER) and “Slave”(SLA VE). Modbus regulate that onl...

Modbus Communication Protocol
Modbus Communication Protocol Modbus protocol is a protocol used for communication between the PLC and Modicon controllers invented in 1978. Modbus communication protocol participant is defind as “master”(MASTER) and “Slave”(SLA VE). Modbus regulate that only the main station with the initiative, the smart passive response from the station, including the answer to the error message. This article will set the master station PLC, high-voltage switchgear protection device is set to 1, the capacitor feeder cabinet protection device is set to the 2nd slave. Modbus protocol has two transmission modes, ASCII and RTU. In ASCII mode, each message requires two 8ABit byte ASCII characters. The advantage is to allow the transmission of characters to reach 1s intervals without error. In RTU mode, each byte contains two 4Bit of 8Bit hexadecimal characters. The advantage is in the same baud rate, sending more than ASCII mode date. But each message must be transmitted in a continuous steam of date. In this paper, the model is RTU mode. It does not start and stop bits, but at least 3.5 character intervals (T1-T2-T3-T4)mark the beginning and the end. RTU mode use CRC16 redundancy check. The information frame from the address field, and CRC check domain functional domain structure. All of the characters from the 16-bit hexadecimal number components. Bits of each byte are: 1 start bit, 8 data bits, a parity bit, 1 or 2 stop bits (when no parity). Modbus protocol is used in a common language electronic controller. Through this agreement, between the controllers, the controller via the network (such as Ethernet) and other devices can communicate. It has become a common industry standard. Modbus protocol is a widely in industrial applications is truly open, standard network protocol, by most SCADA (Supervisor Control And Data Acquisition Supervisory Control and Data Acquisition System) HM Engineering (Human Machine Interface HMI) software support, so it actually has become a common industry standard. With it different manufacturers of industrial control devices can be connected into a network, centralized monitoring. This protocol defines a message structure used by the controller to recognize, whether they are to communicate what network. It describes the process a controller requests access to other devices, if the response to requests from other devices, as well as how to detect errors and recorded. It sets out the message filed pattern and content of public format. When on a Modbus network communications protocol determines how each controller need to know their device address, recognize a message sent by address, decide what action to produce. If you need to respond, the controller will generate a message and send it using Modbus protocol. In other networks, including Modbus protocol message into the frame structure used on this network or packet. This conversion also expanded network solution based on specific sections address, routing paths, and errors detection methods. Modbus has two transmission modes, one is in ASCII mode, and the other is the RTU mode. When the controller is set on the Modbus network to work ASCI (American Standard Code for Information Interchange) mode communications, each s in message byte characters are sent as two ASCI workers. The main advantage of this approach is the time interval to send characters to reach one second without generating an error. 1.On the Modbus Network Transfusion Standard Modbus port is using an RS-232 compatible serial interface, which defines the connector pins, cables, signal bits, baud rate, and parity. Modem controller directly or via a network. The use of master-slave controller communication technologies, that is, only one device (the master) can initiate transmission (query). Other devices (slaves) respond accordingly based on the data on the provided by the master query. Typical master devices: Host and programmable instrumentation. Typical from the device: the programmable controller. Master device can be used alone and, also, and all communications to broadcast from a device from the device communications. If a separate communication, returns a response message from the device, if the query is broadcast, not to make any response. Modbus protocol to establish the format of the master device query: device (or broadcast) address, function code, all of the data to be sent, an error detection filed. Modbus protocol consists of news from the device to respond, including the recognition domain to act, any data to be returned, and an error detection filed. If an error occurs during message reception, or from the device can not execute its commands, and send it out as a response to oral communication mode device will create an error message from the. 2.On the Other Networks Transfusion On other networks, peer to peer communications controller technology, the initial and any control can communicate with other controllers. So in a separate communication, the controller can be used as the master devise can also be used as a slave device. Providing a plurality of internal channels allows the transmission process simultaneously. In the message bit, Modbus protocol still provides a master-slave principle, although the network communication methods are equal. If a controller sends a message, it’s just as a master device, and expects to get a response from the slave device. Similarly, when the controller receives a message, it creates a response from the device format and sent back to the controller. 3.Query a Response Cycle (1) Query Query message function code announces what function are selected from the device to perform. Data section contains any additional information from the device to perform the function. For example: function code read from the device 03 is required to maintain registers and return their contents. Data segment must contain the information about the device to sue from: where to register and start reading to read the number of registers. Error detection filed will to provide an authentication method of the message content from the device correctly. (2) Response If you produce a normal response from the device, in response to the message functional code in response to the query message function code. Data segment includes data collected from the device: register value or state. If an error occurs, the function code will be modified to respond to the message is used to indicate an error, but the data segment contains a description of the error message code. Error detection allows the master device to confirm the message content is available. 4.Modbus Message Frame Two transmission modes (ASCII or RTU), the transmission device to a Modbus message into a frame with start and end, which allows the receiving device to work at the beginning of the message, the read address assignment information to determine which device is select (broadcast then passed to all devices), to determine when the information has been completed. Portion of the message and the error can be detected can be set to return results. (1)ASCII frame Use ASCH mode, message with a colon(:) character (ASCH code 3AH) began to carriage return line feed end (ASC Engineering 1 yard ODH, OAH). Transmission of characters you can use the other fields are hexadecimal 0…9, A…F. Continuously detect devices on the network”:” character, when there is a colon when received, each device decodes the next field (the address filed) to determine whether to issue their own. Time message sent longest interval between characters cannot be more than one second; otherwise the receiving device will consider transmission errors. A typical message frame is as follows. (2)RTU mode Use RTU mode, messages start with a silent interval of at least 3.5 character times. In the network baud diverse character time, this is most easily achieved (as shown in the T1-T2-T3-T4 below). The first transmitted is the device address. You can use the transmission character hexadecimal 0-9, A-F. Constantly testing the network bus network equipment, including pauses during the interval. When the first field (the address field) is received, each device decodes to determine whether destined for their own. After the last transmitted character, one of at least 3.5 character times marks the end of the message. A new message can begin after this pause. The entire message frame is as a continuous steam to be transmitted. If, before completion of the frame over the dwell time of 1.5 character times, the receiving device flushes the incomplete message and assumes that the next byte is the address filed of a new message. Likewise, if a new message in less than then before the start, the receiving device will consider it a continuation of the previous message in the 3.5 character times. This will result in an error because the value is not possible in the final CRC field is correct. A typical message frame is as follows: (3)The address field Address field of the message frame contains two characters (ASCAII) or 8Bit (RTU). Possible from the device address is 0…247(decimal). The address range is a single device…247. It will be contacted by the master device address into the address field of the message to strobe from the device. When sending response messages from the device, it put his address in response to the address field in order to know which one master device to respond. Address 0 is used as a broadcast address, so that all can understand from the device. When the network for a higher level of Modbus protocol, broadcast or otherwise many not be allowed to replace. (4)How the functional domains Message frame function code field contains the two characters (ASC Engineering I) or Hits (RTU). Possible decimal code range is 1…255. Of course, some code is applicable to all controllers, some of which are used in some kind of control, and some reserved for later use. When the message is sent from the master device from the device, the function code field will tell what behavior from the device needs to perform. For example, to read the switch status input, read the contents of a sent of data registers, read from the diagnostic status of the device, allowing transferred records from the device calibration procedures. When the response from the device, it uses the function code field to indicate a normal response (correct) or have some kind of error occurred (called the opposition to respond). Normal response comes from the device to respond only to the corresponding function code. Response to objections, the device returns from the normal code, a code equal to, but the position of the most significant logic one. For example: one sent from the master device required to read a message from a group holding registers, the code will produce the following functions: 00000011(hexadecimal 03H) Normal response comes from the device to respond only to the same function code. Objection response, it returns: 10000011(hexadecimal 83H) In addition to the error function code has been modified due to objections, the response message into the data field from the device a unique code, which can tell the master what error occurred. After the master device applications get dissent response typical process is re-filing, or diagnostic message sent from the device and reported to the operator. (5)The data filed Data Domain is a collection of two hexadecimal digits, in the range 00…FF. Network transmission mode which can be composed of a pair of ASCII characters or characters of a RTU. Sent from the master device contains additional information from the data field device message: From the equipment must be used for performing the functions defined by the code should do. This includes non-contiguous register addresses to the actual number of bytes of data the number of items in the domain to deal with. For example, if the primary device needs to read a group of holding registers (function code 03) from the device, the data field specifies the starting register and quantity of registers to be read. If you write a group from the master device registers (function code 10 hex), the data field is specified in the starting register and write the number of registers to write, the number of data bytes of data field, to write to register data. If no error occurs, the device returns from the data field contains the data from the request. If an error occurs, this field contains an exception code; the master application can be used to determine the next course of action to take. A data field in the message may not exist (zero length). For example, the master asked to respond to communications from the device event log (function code O B hex), and any additional information from the device without. (6)Error detection field There are two standard Modbus network error detection methods. Depending on the contents of the error detection field detection method may be selected. ASCII Elected to use ASCII mode for the character frame error detection field contains two ASCII characters. This is done using LRC (Longitudinal Redundancy Detection) method is calculated for the content of the message, not including start and colon carriage return character, LRC character appended to the front carriage return. RTU Elected as a character frame with RTU mode, error detection field contains a 16Bits value (two 8-bit characters realization). An error detection field of the message content by cyclic redundancy check method derived. Additional CRC field at the end of the message, the low byte first and then when you add the high byte. Therefore, the high byte CRC is the last byte to send a message. (7)Continuous transmission of characters When news of the standard Modbus series of network transmission, each character is sent in the following manner (left to right): the least significant bit…most significant bit ASCII characters when using the frame bit sequence is: 5. Detection Error may occur in communication systems in two ways: transmission errors; programming or operator error. Modbus systems have dedicated these two error handling. Communication error generally refers to digital packets in a change in circumstances packets to add or reduce the number of bits is rare. The most common error is the noise caused by communication: communication channel unwanted electrical signals, electrical interference from the machine, damage to the channel, impulse noise (spikes) and so will generate such signals. Standard Modbus serial network use two error detection methods. Parity is available to each character frame detection (LRC or CRC) applies to the entire message. They were produced before the message is sent by the master device; the device detects each character and the entire message frame from the receiving process. When parity or redundancy checks error detection communication, message processing will stop over. No further communication error occurs, the message will be regarded as unreliable. The program enables Modbus Modbus host system cannot receive a response to make the case “Communication error must have occurred,” the judge after a certain period of time. The length of this period of time depending on the baud rate, packet type from the scan time machine may be. Once the time is set to host programmed to automatically resending message. Two Modbus RTU transmission mode ASCII and RTU, their character formats are optional parity bit. The first nine data fields RTU mode is a parity bit (8 data bits,1 parity bits). If you do not use parity, no parity bit is sent. Modbus parity system is optional; users configure the interface device, to deal with odd or even parity for proper selection. However, the configuration of all the devices in the system must use the same options. Modbus error checking system is to ensure the quality of data transmission. Not detected for detection of a parity error, the system uses the CRC:cyclic redundancy checks (CRC) and a longitudinal redundancy check (LRC). Redundancy checks what the specific use, as the transmission mode may be. RTU transmission method using cyclic redundancies (CRC), ASCII transfer mode longitudinal redundancy check LRC, two redundancy error is carried out automatically. (1)Parity Users can configure the controller is odd or even parity or no parity. This will determine how each character parity bit is set. If you specify an odd or even parity, “1” digit will count to the number of bits per character (ASCII Mode 7 data bits, RTU in 8 data bits). For example RTU character frame contains the following 8 data bits. 11000101 The number of the “I” is 4. If it is an even parity, the parity bit of the frame will be 0, so that “1” is still the number 4. If you are using odd parity, the parity bit will be a frame, making the “1” number is five. If no parity bit, no parity bit is transmitted, nor for verification testing. Instead of filling an additional stop bit to be transmitted in the character frame. (2)LRC detection ASCII mode, the message includes a filed-based LRC error detection methods. LRC field checks the contents of the message field in addition to be start and end of the colon carriage return line numbers outside. LRC field is one that contains an 8-byte binary value. LRC value is calculated and placed in the message frame transmission equipment; the receiving device calculates the LRC during the reception of the message: it receives and compares the value of the message LRC field, if the two values are unequal, there is an error. LRC method is message byres Hit continuous accumulation, dropped into place. (3)CRC detection Use RTU mode, message include a domain-based CRC error detection method. CRC field checks the contents of the entire message. CRC field is two byres, containing a 16-bit binary value. Calculated by the transmitting device before it is added to message. The receiving device recalculates the received message CRC, and compared with the value of the received CRC field, if the two values are different, wrong. CRC value is to be transferred to an all “1”in the register 16, then calls a subroutine in the message the current consecutive 8-byte values in the registers for processing. Each character only in Hit CRC data valid start and stop bits, and parity bits are invalid. CRC generation process, each 8 characters individually and register contents or (OR), the results of the least significant (LSB) bit direction, the most significant bit (MSB) to 0 padding. LSB is extracted to detect if the LSB is a separate register and preset values or what, if LSB is 0, no. The whole process is repeated eight times. After the last one (Section 8) is completed, the next 8-byte and single-phase and the current value of the register or. The final register value is the CRC value for the message in all the bytes after execution. When it is added to the message, CRC will becomposed by low byte first, followed by the high byte. 6. Conclusion Modbus protocol is a common language, which was used between the electronic controllers and it is a common industry standard. With the development of computer technology, the use of computer data communication has been more widely used in modern industrial production and process control. After using the Modbus communication protocol, you can quickly and easily achieve the different production control device networking site, to facilitate centralized monitoring. It is basis for a digital communication network to achieve the production and control room equipment a higher level of network communications. The technology set intelligent sensing, control, computer and digital communication technologies as a whole, has become a popular development of automation technology, the future will lead to great changes in network communication equipment automation systems field between. Modbus通讯 协议 离婚协议模板下载合伙人协议 下载渠道分销协议免费下载敬业协议下载授课协议下载 Modbus协议是Modicon公司1978年发明的一个用于PLC和控制器之间通讯的协议。Modbus协议将通信参与者规定为“主站”(MASTER)和“从站”(SLAVE)。Modbus规定,只有主站具有主动权,从站只能被动的响应,包括回答出错信息。本文将PLC设定为主站,高压柜保护装置设定为1号从站,电容馈线柜保护装置设定为2号从站。Modbus协议有ASCII和RTU两种传输模式。在ASCII方式中,消息中的每个8Bit字节需要2个ASCII字符,其优点是准许字符的传输间隔达到1秒而不产生错误;在RTU方式中,每个8Bit字节包含两个4Bit的十六进制字符,其优点在同样的波特率下,可比ASCII方式传送更多的数据,但是每个消息必须以连续的数据流传输。本文采用的模式是RTU模式。它没有起始位和停止位,而是以至少3.5个字符间隔时间(T1-T2-T3-T4)标志开始和结束。RTU模式采用CRC16冗余校验方式,信息帧由地址域、功能域和CRC检验域构成,所有字符位由16进制数组成。每个字节的位包括:1个起始位,8个数据位,1个奇偶校验位,1个或2个停止位(无奇偶检验时)。 Modbus协议是应用于电子控制器上的一种通用语言。通过此协议,控制器相互之间、控制器经由网络(例如以太网)和其它设备之间可以通讯。它已经成为一通用工业 标准 excel标准偏差excel标准偏差函数exl标准差函数国标检验抽样标准表免费下载红头文件格式标准下载 。Modbus协议是一种在工业领域被广泛为应用的真正开放、标准的网络通讯协议,被大部分SCADA(Supervisor Control And Data Acquisition数据采集与监视控制系统)HMI(Human Machine Interface人机界面)软件支持,所以它实际上已经成为一种通用的工业标准。有了它不同厂商生产的控制设备可以连成工业网络,进行集中监控。此协议定义了一个控制器能认识使用的消息结构,而不管它们是经过何种网络进行通讯的。它描述了一控制器请求访问其它设备的过程,如果回应来自其它设备的请求,以及怎样侦测错误 记录 混凝土 养护记录下载土方回填监理旁站记录免费下载集备记录下载集备记录下载集备记录下载 。它制定了消息域格局和内容的公共格式。挡在一Modbus网络上通讯时,此协议决定了每个控制器须要知道它们的设备地址,识别按地址发来的消息,决定要产生何种行动。如果需要回应,控制器将生成反馈信息并用Modbus协议发出。在其它网络上,包含了Modbus协议的消息转换为在此网络上使用的帧或包的结构。这种转换也扩展了根据具体的网络解决节地址、路由路径及错误检测的 方法 快递客服问题件处理详细方法山木方法pdf计算方法pdf华与华方法下载八字理论方法下载 。 Modbus有两种传输方式,一种是ASCII模式,另一种是RTU模式。当控制器设为在Modbus网络上一ASCII(美国标准信息交换代码)模式通讯,在消息中的每个s字节都作为两个ASCII字符发送。这种方式的主要优点是字符发送的时间间隔可达到1秒而不产生错误。 1.在Modbus网络上传输 标准的Modbus口是使用-RS-232兼容串行口,它东一了连接口的针脚、电缆、电号位、传输波特率、奇偶校验。控制器能直接或经由Modcm组网。控制器通讯使用主-从技术,即仅-设备(主设备)能初始化传输(查询)。其它设备(从设备)根据主设备查询提供的数据作出相应反应。典型的主设备:主机和可编程仪表。典型的从设备:可编程控制器。主设备可单独和从设备通讯,也能以广播方式和所有从设备通讯。如果单独通讯,从设备返回-消息作为回应,如果是以广播方式查询的,则不作任何回应。Modbus协议建立了主设备查询的格式:设备(或广播)地址、功能代码、所有要发送的数-错误检测域。从设备回应消息也由Modbus协议构成,包括确认要行动的域、任何要返回的数据和一错误检测域。如果在消息接收过程中发生-错误,或从设备不鞥执行其命令,从设备将建立一错误信息并把它作为回应发送出去口通讯模式。 2.在其它网络上传输 在其它网络上,控制器使用对等技术通讯,故任何控制都能初始和其它控制器的通讯。这样在单独的通讯过程中,控制器既可作为主设备也可作为从设备。提供的多个内部通道可允许同时发生的传输进程。在消息位,Modbus协议仍提供了主-从原则,尽管网络通讯方法是对等。如果一控制器发送一消息,它只是作为主设备,并期望从从设备得到回应。同样,当控制器接收到一消息,它将建立一从设备回应格式并返回给发送的控制器。 3.查询-回应周期 (1)查询 查询消息中的功能代码告之被选中的从设备要执行何种功能。数据段包含了从设备要执行功能的任何附加信息。例如:功能代码03是要求从设备读保持寄存器并返回它们的内容。数据段必须包含要告之从设备的信息:从何寄存器开始读及要读的寄存器数量。错误检测域为从设备提供了一种验证消息内容是否正确 的方法。 (2)回应 如果从设备产生一正常的回应,在回应消息中的功能代码的回应。数据段包含了从设备收集的数据:寄存器值或状态。如果有错误发生,功能代码将被修改以用于回应消息是错误的,同时数据段包含了描述此错误信息的代码。错误检测允许主设备确认消息内容是否可用。 4.Modbus消息帧 两种传输模式中(ASCII或RTU),传输设备以将Modbus消息转为由起点和终点的帧,这就允许接收的设备在消息起始开始工作,读地址分配信息,判断哪一个设备被选中(广播方式则传给所有设备),判断何时信息已完成。部分的信息也能检测到并且错误能设置为返回结果。 (1) ASCII帧 使用ASCII模式,消息以冒号(:)字符(ASCII码3AH)开始,以回车换行符结束(ASACII码0DH,0AH)。其它域可以使用的传输字符是十六进制的0…9, A…F。网络上的设备不断检测“;”字符,当有一个冒号接收到时,每个设备都解码下个域(地址域)来判断是否发给自己的。消息中字符间发送的时间间隔最长不能超过1秒,否则接收的设备将认为传输错误。一个典型此消息帧如下显示: (2) RTU模式 使用RTU模式,消息发送至少以3.5个字符时间的停顿间隔开始。在网络波特率下多样的字符时间,这是最容易实现的。传输的第一个域是设备地址。可以使用的传输字符是十六进制的0-9,A-F。网络设备不断检测网络总线,包括停顿间隔时间内。当第一个域(地址域)接收到,每个设备都进行解码以判断是否发往自己的。在最后一个传输字符之后,一个至少3.5个字符时间的停顿标定了消息的结束。一个新的消息可在此停顿后开始。整个消息帧作为一连续的流传输。如果在帧完成之前有超过1.5个字符时间的停顿时间,接收设备将刷新不完整的消息并假定下一字节是一个消息开始,接收的设备将认为它是前一消息的延续。这将导致一个错误,因为在最后的CRC域的值不可能是正确的。 (3)地址域 消息帧的地址域包含两个字符(ASCII)或8Bit(RTU)。可能的从设备地址是 0…247(十进制)。单个设备的地址范围是1…247。主设备通过将要联络的从设备地址放入消息的地址域来选通从设备。当从设备发送回应消息时,它把自己的地址放入回应的地址域中,以便主设备知道是哪一个设备作出回应。地址0是用作广播地址,以使所有的从设备都能认识。当Modbus水准的网络,广播可能不允许或以其他方式代替。 (4)如何处理功能域 消息帧中的功能代码域包含了两个字符(ASCII)或Bits(RTU)。可能的代码范围是十进制的1…255.当然,有些代码是适用于所有控制器,有些是应用于某种控制器,还有些保留以备后用。当消息从主设备发往从设备时,功能代码域将告之从设备需要执行哪些行为。例如去读取输入的开关状态,读一组寄存器的数据内容,读从设备的诊断状态,允许调入、记录、校验在从设备中的程序等。当从设备回应时,它使用功能代码域来指示是正常回应(无误)还是有某种错误发生(称作异议回应)。对正常回应,从设备仅回应相应的功能代码。对异议回应,从设备发往从设备的消息要求读一组保持寄存器,将产生如下功能代码: 00000011(十六进制03H) 对正常回应,从设备仅回应同样的功能代码。对异议回应,它返回: 10000011(十六进制83H) 除功能代码因异议错误作了修改外,从设备将一独特的代码放回应消息的数据域中,这能告诉主设备发生了什么错误。主设备应用程序得到异议的回应后,典型的处理过程是重发消息,或者诊断发给从设备的消息并报告给操作员。 (5)数据域 数据域是由两个十六进制数集合构成的,范围00…FF。根据网络传输模式,这可以是由一堆ASCII字符组成或由一RTU字符组成。从主设备发给从设备消息的数据域包含附加的信息:从设备必须用于进行执行由功能代码所定义的所为。这包括了向不连续的寄存器地址,要处理项的数目,域中实际数据字节数。例如,如果主设备需要从设备读取一组保持寄存器(功能代码03),数据域指定了起始寄存器以及要读的寄存器数量。如果主设备写一组从设备的寄存器(功能代码10十六进制),数据域则指明了要写的起始寄存器以及要写的据寄存器数量,数据域的数据字节数,要写入寄存器的数据。如果没有错误发生,从设备返回的数 据域包含请求的数量。如果有错误发生,此域包含一异议代码,主设备应用程序可以来判断采取下一步行动。在某种消息中数据域可以是不存在的(0长度)。例如,主设备要求从设备回应通信时间记录(功能代码0B十六进制),从设备不需要任何附加的信息。 (6)错误检测域 标准的Modbus误检测方法。错误检测域的内容视所选的检测方法而定。 ASCII 当选用ASCII模式作字符数,错误检测域包含两个ASCII字符。这是使用LRC(纵向冗长检测)方法对消息内容计算的得出的,不包括开始的冒号符以及回车换行符。LRC字符附加在回车换行符前面。 RTU 当选用RTU模式作字符帧,错误检测域包含一个16Bits值(用两个8位的字符来实现)。错误检测域的内容是通过对消息内容进行循环冗余检测方法得出的。CRC域附加在消息的最后,添加时先是低字节然后是高字节。故CRC的高位字节是发送的最后一个字节。 (7)字符的连续传输 当消息在标准的Modbus时去,每个字符以如下方式发送(从左到右):最低有效位,最高有效位使用ASCII字符帧。 5.错误检测方法 通讯系统中可能发生的错误有两种:传输错误;编程或操作错误。Modbus 错误各有专门的处理方式。通讯错误一般指的是报文内的数位有所改变,报文中增添或减少位的情况是很少见的。最常引起通讯错误的是噪声:通讯通道中不需要的电信号,来自机器的电干扰,对通道的损害,脉冲噪声(尖峰脉冲)等都会产生这类电信号。标准的Modbus用两种错误检测方法。奇偶检验对每个字符都可用,帧检测(LRC或CRC)应用于整个消息。它们都是在消息发送前由主设备产生的,从设备在接收过程中检测每个字符和整个消息帧。当奇偶校验或冗余检验出通讯错误时,报文处理就会停笔。从机不再继续通讯,不对此报文产生应答。通讯错误一旦发生,报文便视为不可靠。而Modbus得Modbus时间过后未收到应答的情况下做出“通讯错误必已发生”的判断。这一段时间的长度视为波特率、 报文类型、从机的扫描时间而定。时间一旦设定即可对主机编程,使之自动重发报文。 Modbus传送方式ASCII和RTU,其字符格式内均有任选的奇偶校验位。RTU 方式的数据字段第9位是奇偶校验位(8个数据位,1个奇偶校验位);ASCII的数据字段以第8位为奇偶校验位(7个数据位,1个奇偶位)。若不使用奇偶校验,则无奇偶校验位发送。Modbus校验是任选项, 用户在对接口设备进行配置时,应对奇校验或偶校验进行适当选择。但系统内所有设备的配置必须采用相同的任选项。 Modbus系统的错误检查,用以保证数据传送的质量。要检出奇偶检验未能检出的错误,系统使用冗余校验:循环冗余校验(CRC)和纵向冗余校验(LRC)。具体使用何种冗余校验,视传送方式而定。RTU传送方式用循环冗余校验(CRC), ASCII传送方式用纵向校验(LRC),这两种冗余错误校验都是自动进行的。 (1)奇偶校验 用户可以配置控制器是奇校验或偶校验,或无校验。这将决定了每个字符中的奇偶校验位是如何设置的,如果指定了奇校验或偶校验,“1”的位数将算到每个字符的位数中(ASCII模式7个数据位,RTU中8个数据位)。例如RTU字符帧包含以下8个数据位: 11000101 整个“1”的数目是4个。如果使用了偶校验,帧的奇偶校验位将是0,使得整个“1”的个数仍是4个。如果使用了奇校验,帧的奇偶校验位将是1,使得整个“1”的个数是5个。如果没有指定奇偶校验位,传输时就没有校验位,也不进行检验检测。代替一附加的停止位填充至要传输的字符帧中。 (2) LRC检测 使用ASCII模式,消息包括了一基于LRC方法的错误检测域。LRC域检测了消息域中除开始的冒号及结束的回车换行号外的内容。LRC域是一个包含一个8位二进制值的字节。LRC值由传输设备计算并放到消息帧中接收设备在接收消息的过程中计算LRC:并将它和接收到消息中LRC域中的值比较,如果两个值不等,说明有错误。LRC方法是将消息中的Hit的字节连续累加,丢弃进位。 (3) CRC检测 使用RTU模式,消息包括了一基于CRC方法的错误检测域。CRC域检测了整个消息的内容。CRC域是两个字节,包含一16位的二进制值。它由传输设备计算后加入到消息中。接收设备重新计算收到消息的CRC,并与接收到的CRC域中的值比较,如果两个值不同,则有误。CRC是先调入一值是全“1”的16位寄存器,然后调用一子程序将消息中连续的8位字节当前寄存器中的值进行处理。仅每个字符中的Hit数据对CRC有效,起始位和停止位以及奇偶校验位均无效。 CRC产生过程中,每个8位字符都单独和寄存器内容相或(OR),结果向最低位有效(LSB)位方向移动,最高有效位(MSB)以0填充。LSB被提取出来检测,如果LSB为1,寄存器单独和预置的值或一下,如果LSB为0,则不进行。整个过程要重复8次。在最后一位(第8位)完成后,下一个8位字节又单独和寄存器的当前值相或。最终寄存器中的值,是消息中所有的字节都执行之后的CRC值。CRC添加到消息中时,低字节先加入,然后高字节。 6.结论 Modbus协议是应用于电子控制器上的一种通用语言,也是一种通用的工业标准。随着计算机技术的不断发展,利用微机进行通讯在现代工业生产和过程控制中得到了越来越广泛的应用。采用Modbus通讯协议后,可以方便快速地实现对不同生产现场的控制设备进行组网,便于集中监控。它作为数字通信网络的基础,实现了生产过程及控制设备间更高层次的网络通信。该技术集智能传感,控制,计算机和数字通信技术为一体,已成为自动化技术发展的一个热门,未来必会导致自动化系统领域的设备之间的网络通信的巨大变化。
本文档为【Modbus Communication Protocol】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_731942
暂无简介~
格式:doc
大小:67KB
软件:Word
页数:0
分类:生产制造
上传时间:2019-06-28
浏览量:26