Source: https://www.scribd.com/doc/60282163/Modbus-Over-Serial-Line-V1
Timestamp: 2017-09-24 20:22:10
Document Index: 425326966

Matched Legal Cases: ['§2', 'art 1', 'art 1', 'art 1', 'art 1', 'art 1', 'art.0', 'art. 0']

Modbus Over Serial Line V1 | Osi Model | Communications Protocols
Uploaded by Roy Moukarzel
MODBUS over serial line specification and implementation guide V1.
These words are underlined. but the full implications should be understood and the case carefully weighed before choosing a different course. MODBUS over Serial Line systems may use different physical interfaces (RS485. another designer may omit the same item. positioned at level 7 of the OSI model.MODBUS over serial line specification and implementation guide V1.org/ 5/44 . The word MUST.ORG 1. or the adjective "REQUIRED". Slave nodes will not typically transmit data without a request from the master node. provides client/server communication between devices connected on buses or networks. (see chapter "Physical Layer") The following figure gives a general representation of MODBUS serial communication stack compared to the 7 layers of the OSI model. means that the item is an absolute requirement of the implementation.3 Conventions In this document. TIA/EIA-485 (RS485) Two-Wire interface is the most common. or the adjective "OPTIONAL".0 MODBUS.2 Protocol overview This document describes the MODBUS over Serial Line protocol. means that this item is truly optional. A master-slave type system has one node (the master node) that issues explicit commands to one of the "slave" nodes and processes responses.org 12/02/02 http://www. when only short point to point communication is required. are considered desired behavior. At the physical level. These recommendations should be used as a guideline when choosing between different options to implement functionality. On MODBUS serial line the client role is provided by the Master of the serial bus and the Slaves nodes act as servers. or the adjective “RECOMMENDED”. Modbus. "SHOULD" / "RECOMMENDED" All recommendations containing the word "SHOULD". RS232). for example. 1. These words are underlined. "MUST" / "REQUIRED" All requirements containing the word "MUST" are mandatory. One designer may choose to include the item because a particular marketplace requires it or because it enhances the product. and do not communicate with other slaves. There may be valid reasons in particular circumstances to ignore this item. RS485 Four-Wire interface may also be implemented. MODBUS Serial Line protocol is a Master-Slave protocol. Layer 7 6 5 4 3 2 1 ISO/OSI Model Application Presentation Session Transport Network Data Link Physical MODBUS Application Protocol Empty Empty Empty Empty MODBUS Serial Line Protocol EIA/TIA-485 (or EIA/TIA-232) MODBUS Application Layer Client / server MODBUS Master / Slave EIA/TIA-485 (or EIA/TIA-232) Figure 2: MODBUS Protocols and ISO/OSI Model MODBUS application layer messaging protocol. A TIA/EIA-232E (RS232) serial interface may also be used as an interface. As an add-on option. This protocol takes place at level 2 of the OSI model.modbus. the following words are used to define the significance of each particular requirement. "MAY" / "OPTIONAL" The word “MAY”.
Signal and optional Power Supply Common a MODBUS Device. symbols.org 12/02/02 http://www. 1. or Transmitter. a MODBUS Device.modbus. EIA/ TIA -485 Standard. One that satisfies all the MUST requirements but not all the SHOULD recommendations is said to be "conditionally compliant". 2W 4W AUI Common DCE Device Driver DTE ITr IDv LT MODBUS Device RS232 RS485 RS485-MODBUS Transceiver The Two-Wire configuration defined in the “Electrical Interface” chapter. which implements an RS232 Data Terminal Equipment. or “MODBUS device” : see this definition. The Four-Wire configuration defined in the “Electrical Interface” chapter. which implements an RS232 Data Circuit-terminating Equipment. for example a programming panel or a PC. In a 2W-or 4W-RS485 MODBUS Network. EIA/ TIA -232 Standard. also named Data Communication Equipment.4 Compliance An implementation is not in conformity if it fails to satisfy one or more of the MUST requirements from its implementation class. Physical bus Interface on Derivation (or tap or device drop) side. An implementation that satisfies all the MUST requirements and all the SHOULD recommendations is said to be "unconditionally compliant".0 MODBUS. Generator. and abbreviations used in this document. a Transmitter and a Receiver (or Driver and Receiver). for example a programmable controller adapter. Modbus.org/ 6/44 . A 2W-or 4W-Network in accordance with this Technical Note.MODBUS over serial line specification and implementation guide V1. or one of its interfaces.ORG 1. Physical bus Interface on Trunk side. a Device that implements MODBUS over Serial Line and respects this Technical Note. Attachment Unit Interface The Signal Common in EIA/TIA Standards. or one of its interfaces. Line Termination.5 Glossary Definition of particular words.
The broadcast requests are necessarily writing commands. The master node initiates only one MODBUS transaction at the same time. The address 0 is reserved to identify a broadcast exchange. All devices must accept the broadcast for writing function. and a reply from the slave. Only one master (at the same time) is connected to the bus. No response is returned to broadcast requests sent by the master. After receiving and processing the request. In that mode. Each slave must have an unique address (from 1 to 247) so that it can be addressed independently from other nodes. The slave nodes will never communicate with each other.MODBUS over serial line specification and implementation guide V1. A MODBUS communication is always initiated by the master.org 12/02/02 http://www. master request reply slave slave slave Figure 3: Unicast mode master request slave slave slave Figure 4: Broadcast mode Modbus. The master node issues a MODBUS request to the slave nodes in two modes : In unicast mode.1 MODBUS Data Link Layer MODBUS Master / Slaves protocol principle The MODBUS Serial Line protocol is a Master-Slaves protocol.org/ 7/44 . the master addresses an individual slave. and one or several (247 maximum number) slaves nodes are also connected to the same serial bus. The slave nodes will never transmit data without receiving a request from the master node.0 MODBUS.ORG 2 2.modbus. In broadcast mode. a MODBUS transaction consists of 2 messages : a request from the master. the master can send a request to all slaves. the slave returns a message (a 'reply') to the master .
The individual slave devices are assigned addresses in the range of 1 – 247.modbus.org/ 8/44 . As described in the previous section the valid slave nodes addresses are in the range of 0 – 247 decimal. The client that initiates a MODBUS transaction builds the MODBUS PDU.5 section.MODBUS over serial line specification and implementation guide V1. The MODBUS Master node has no specific address. (see 2. Two kinds of calculation methods are used depending on the transmission mode that is being used (RTU or ASCII).ORG 2. the Address field only contains the slave address. only the slave nodes must have an address.org 12/02/02 http://www. A master addresses a slave by placing the slave address in the address field of the message. The function code can be followed by a data field that contains request and response parameters.3 MODBUS frame description The MODBUS application protocol [1] defines a simple Protocol Data Unit (PDU) independent of the underlying communication layers: Function code MODBUS PDU Figure 5: Data MODBUS Protocol Data Unit The mapping of MODBUS protocol on a specific bus or network introduces some additional fields on the Protocol Data Unit. it places its own address in the response address field to let the master know which slave is responding. MODBUS SERIAL LINE PDU Address field Function code MODBUS PDU Figure 6: MODBUS frame over Serial Line Data CRC (or LRC) On MODBUS Serial Line. This address must be unique on a MODBUS serial bus. 2. All slave nodes must recognise the broadcast address. and then adds fields in order to build the appropriate communication PDU.2 MODBUS Addressing rules The MODBUS addressing space comprises 256 different addresses. 0 Broadcast address From 1 to 247 Slave individual addresses From 248 to 255 Reserved The Address 0 is reserved as the broadcast address. Error checking field is the result of a "Redundancy Checking" calculation that is performed on the message contents. "The two serial Transmission Modes") Modbus. When the slave returns its response. The function code indicates to the server what kind of action to perform.0 MODBUS.
Then the Master goes into "Idle" state. A request can only be sent in "Idle" state. enabling a retry of the request. for example a reply from an unexpected slave. The maximum number of retries depends on the master set-up. The notation is briefly recalled below : trigger [ guard condition ] / action State_A State_B When a "trigger" event occurs in a system being in "State_A". After sending a request. It prevents the Master from staying indefinitely in "Waiting for reply" state. or an error in the received frame.ORG 2. only if "guard condition" is true. the Response time-out is kept running. Syntax of state diagram : The following state diagrams are drawn in compliance with UML standard notations. the Master checks the reply before starting the data processing. In case of an error detected on the frame. If no reply is received. 2. Value of the Response time-out is application dependant. and an error is generated. An action "action" is then performed. and a “Response Time-out” is started. the Master leaves the "Idle" state.4. system is going into "State_B". The checking may result in an error. a retry may be performed. and cannot send a second request at the same time When a unicast request is sent to a slave.0 MODBUS. the Response time-out expires.modbus.1 Master State diagram The following drawing explains the Master behavior : Request sent in broadcast mode / turnaround delay is started Waiting turnaround delay turnaround delay expiration Idle End of error processing End of reply processing request sent to a slave / response timeout is started Processing reply Reply reception [Expected slave] / response time-out is stopped response time-out expiration Frame error Reply reception [Unexpected slave] Waiting for reply Processing error Figure 7: Some explanations about the state diagram above : Master state diagram State "Idle" = no pending request. the master goes into "Waiting for reply" state.MODBUS over serial line specification and implementation guide V1. In case of a reply received from an unexpected slave.org 12/02/02 http://www.org/ 9/44 . When a reply is received. The RTU and ASCII transmission modes are specified in next chapters using two state diagrams. Modbus. This is the initial state after power-up.4 • • Master / Slaves State Diagrams The Master / slave protocol The transmission mode ( RTU vs ASCII modes) The MODBUS data link layer comprises two separate sub layers : The following sections describes the state diagrams of a master and a slave that are independent of transmission modes used. The reception and the sending of a frame are described.
… In case of error. Once the required action has been completed. 2.5 paragraph. no response is returned from the slaves. invalid action. the slave checks the packet before performing the action requested in the packet. If the slave detects an error in the received frame. please refer to 2. Modbus. in broadcast the Turnaround delay must be long enough for any slave to process only the request and be able to receive a new one. "The two serial Transmission Modes". When a request is received. The state diagram is intentionally very simple. This delay is called "Turnaround delay". See §2. In unicast the Response time out must be set long enough for any slave to process the request and return the response. or retry following transmission error. Frame error consists of : 1) Parity checking applied to each character.ORG When a broadcast request is sent on the serial bus.0 MODBUS.org/ 10/44 . Different errors may occur : format error in the request. or frame not addressed to this slave Figure 8: Some explanations about the above state diagram : Slave state diagram State "Idle" = no pending request.6 "Error Checking Methods" for more explanations.2 Slave State Diagram The following drawing explains the Slave behavior : Idle error reply sent normal reply sent Formatting normal reply reception of a request (from the master) end of processing [unicast mode] Processing required action end of processing [broadcast mode] Checking request check OK error while processing error in request data Formatting error reply error in frame checking. Typically the Response time-out is from 1s to several second at 9600 bps. etc … For more details about frame transmission. a reply must be sent to the master.4. It does not take into account access to the line. and the MODBUS application protocol specification [1]). 2) Redundancy checking applied to the entire frame. Nevertheless a delay is respected by the Master in order to allow any slave to process the current request before sending a new one. no respond is returned to the master.MODBUS over serial line specification and implementation guide V1. Therefore the master goes into "Waiting Turnaround delay" state before going back in "idle" state and before being able to send another request.modbus. MODBUS diagnostics counters are defined and should be managed by any slave in order to provide diagnostic information. Therefore the Turnaround delay should be shorter than the Response time-out. and the Turnaround delay is from 100 ms to 200ms. These counters can be get using the Diagnostic MODBUS function (see Appendix A. a unicast message requires that a reply must be formatted and sent to the master.org 12/02/02 http://www. message framing. This is the initial state after power-up.
ORG 2. Reply analysis and preparation of the following exchange Wait Turnaround delay Wait Response time out Wait REQUEST to slave N error Master REQUEST to slave 1 BROADCAST Slave 1 Request treatment REPLY Error detection Slave N Simultaneous execution of the order by the slaves NO REPLY Physical line Time Exchange i-1 Exchange i Exchange i+1 Figure 9: Master / Slave scenario time diagram Remarks : the duration of the REQUEST.0 MODBUS.org 12/02/02 http://www.org/ 11/44 . Modbus.4. REPLY.3 Master / Slave communication time diagram This following figure shows the time diagram of 3 typical scenarios of Master / Slave communications.modbus. BROACAST phases depends on the communication features (frame length and throughput).MODBUS over serial line specification and implementation guide V1. the duration of the WAIT and TREATMENT phases depends on the request processing time needed for the slave application.
no parity ) may also be used.modbus. each 8–bit byte in a message contains two 4–bit hexadecimal characters.org 12/02/02 http://www. or No Parity checking. In order to ensure a maximum compatibility with other products. The default parity mode must be even parity. The main advantage of this mode is that its greater character density allows better data throughput than ASCII mode for the same baud rate. The format for each byte ( 11 bits ) in RTU mode is : Coding System: Bits per Byte: 8–bit binary 1 start bit 8 data bits.5. If No Parity is implemented. Although the ASCII mode is required in some specific applications. interoperability between MODBUS devices can be reached only if each device has the same transmission mode : All devices must implement the RTU Mode.1 RTU Transmission Mode When devices communicate on a MODBUS serial line using the RTU (Remote Terminal Unit) mode. Each message must be transmitted in a continuous stream of characters. Odd. The transmission mode (and serial port parameters) must be the same for all devices on a MODBUS Serial Line.0 MODBUS. Remark : the use of no parity requires 2 stop bits. Most Significant Bit (MSB) With Parity Checking Start 1 2 3 4 5 6 7 8 Par Stop Figure 10: Bit Sequence in RTU mode Devices may accept by configuration either Even. least significant bit sent first 1 bit for parity completion 1 stop bit Even parity is required. it is recommended to support also No parity mode. How Characters are Transmitted Serially : Each character or byte is sent in this order (left to right): Least Significant Bit (LSB) . RTU or ASCII. .5 The two serial Transmission Modes Two different serial transmission modes are defined : The RTU mode and the ASCII mode. Default setup must be the RTU mode. . other modes ( odd parity. Devices should be set up by the users to the desired transmission mode. an additional stop bit is transmitted to fill out the character frame to a full 11-bit asynchronous character : Without Parity Checking Start 1 2 3 4 5 6 7 8 Stop Stop Figure 11: Bit Sequence in RTU mode (specific case of No Parity) Frame Checking Field : Cyclical Redundancy Checking (CRC) Modbus. The ASCII transmission mode is an option. 2. It determines how information is packed into the message fields and decoded.MODBUS over serial line specification and implementation guide V1. It defines the bit contents of message fields transmitted serially on the line.ORG 2.org/ 12/44 .
5 char MODBUS message Start ≥ 3.MODBUS over serial line specification and implementation guide V1. the message frame is declared incomplete and should be discarded by the receiver. In the following sections. Consequently these two timers must be strictly respected when the baud rate is equal or lower than 19200 Bps.org 12/02/02 http://www.5 char Address Function 8 bits 8 bits Figure 13: Data N x 8 bits CRC Check 16 bits End ≥ 3.5 char Remark : > 1. In RTU mode.5.750ms for inter-frame delay (t3. this time interval is called t3.ORG Frame description : Slave Function Address Code 1 byte 1 byte Data 0 up to 252 byte(s) CRC 2 bytes CRC Low CRC Hi Figure 12: The maximum size of a MODBUS RTU frame is 256 bytes. For baud rates greater than 19200 Bps. Frame 1 OK t0 Frame 2 NOK ≤ 1.5. this leads to a heavy CPU load.modbus.5) and a value of 1. message frames are separated by a silent interval of at least 3.5 char at least 3. Partial messages must be detected and errors must be set as a result. RTU Message Frame 2. Modbus.1. fixed values for the 2 timers should be used: it is recommended to use a value of 750µs for the inter-character time-out (t1.5 timers.5 char The implementation of RTU reception driver may imply the management of a lot of interruptions due to the t1. Frame 1 t0 Frame 2 Frame 3 3.5 char RTU Message Frame The entire message frame must be transmitted as a continuous stream of characters. This allows devices that receive a new frame to begin at the start of the message. and to know when the message is completed.org/ 13/44 . If a silent interval of more than 1.5 char 4.1 MODBUS Message RTU Framing A MODBUS message is placed by the transmitting device into a frame that has a known beginning and ending point.5 character times occurs between two characters.5 and t3.5 char at least 3.5).0 MODBUS. With high communication baud rates.5 character times.
5.org 12/02/02 http://www. The receiving device recalculates a CRC during receipt of the message.5 : 3. It is applied regardless of any parity checking method used for the individual characters of the message.5 expired Control and Waiting t3. the CRC calculation and checking is completed.5.5 t3. Slave addr) flag = frame OK or NOK Initial State Character received / init.1.5 character times Emission Emitted character [if last emitted character] / init. Only the eight bits of data in each character are used for generating the CRC. and compares the calculated value to the actual value it received in the CRC field.org/ 14/44 .5.modbus. Parity. When this is done.5 : 1. In order to reduce the reception processing time the address field can be analysed as soon as it is received without waiting the end of frame.5 expired Idle (ready to receive or to emit) First character received / init.5 Demand of emission t3. and start t1. In RTU mode. an error results. Then a process begins of applying successive 8–bit bytes of the message to the current contents of the register. The CRC high–order byte is the last byte to be sent in the message. If the two values are not equal.5 : timers t3. and start t3. Start and stop bits and the parity bit. 2.5 expired t1. In this case the CRC will be calculated and checked only if the frame is addressed to the slave (broadcast frame included). If not the frame is discarded. t3. The CRC field checks the contents of the entire message.5. When the link is in idle state.MODBUS over serial line specification and implementation guide V1. Then.5 character times t1.5 Comment If frame OK processing frame If frame NOK delete entire frame Comment control frame (CRC. the communication link is declared in "idle" state when there is no transmission activity after a time interval equal to at least 3. the low–order byte of the field is appended first. which appends the CRC to the message. the end of frame is identified when no more character is transmitted on the link after the time interval t3. The link goes to the "active" state. After detection of the end of frame. Both "master" and "slave" points of view are expressed in the same drawing : Character received / flag = frame NOK /start t3.2 CRC Checking The RTU mode includes an error–checking field that is based on a Cyclical Redundancy Checking (CRC) method performed on the message contents. do not apply to the CRC.0 MODBUS.5 Figure 14: Some explanations about the above state diagram: RTU transmission mode state diagram Transition from "Initial State" to "Idle" state needs t3. and start t3. The CRC field contains a 16–bit value implemented as two 8–bit bytes. t3. The CRC value is calculated by the sending device. The CRC calculation is started by first pre-loading a 16–bit register to all 1’s. t3.ORG The following drawing provides a description of the RTU transmission mode state diagram.5 Reception Character received / init.5 characters.5 expired Legend t1.5 time-out expiration : that insures inter-frame delay "Idle" state is the normal state when neither emission nor reception is active.5. Afterwards the address field is analysed to determine if the frame is for the device. followed by the high–order byte. and start t1. The CRC field is appended to the message as the last field in the message. each transmitted character detected on the link is identified as the start of a frame. Modbus.
The final content of the register.ORG During generation of the CRC. each 8–bit character is exclusive ORed with the register contents. no exclusive OR takes place. the low-order byte is appended first. with a zero filled into the most significant bit (MSB) position. after all the bytes of the message have been applied.0 MODBUS. fixed value.org 12/02/02 http://www. is the CRC value. the register is then exclusive ORed with a preset. If the LSB was a 1. If the LSB was a 0. the next 8–bit byte is exclusive ORed with the register’s current value. Modbus.org/ 15/44 . The LSB is extracted and examined. followed by the high-order byte. This process is repeated until eight shifts have been performed. Then the result is shifted in the direction of the least significant bit (LSB). and the process repeats for eight more shifts as described above. When the CRC is appended to the message.MODBUS over serial line specification and implementation guide V1. After the last (eight) shift. A detailed example of CRC generation is contained in Appendix B.modbus.
This mode is used when the physical communication link or the capabilities of the device does not allow the conformance with RTU mode requirements regarding timers management. other modes ( odd parity.5. The default parity mode must be Even parity. How Characters are Transmitted Serially : Each character or byte is sent in this order (left to right): Least Significant Bit (LSB) . it is recommended to support also No parity mode.0 MODBUS. an additional stop bit is transmitted to fill out the character frame : Without Parity Checking Start 1 2 3 4 5 6 7 Stop Stop Figure 16: Frame Checking Field: Bit Sequence in ASCII mode (specific case of No Parity) Longitudinal Redundancy Checking (LRC) Modbus. least significant bit sent first 1 bit for parity completion. Remark : this mode is less efficient than RTU since each byte needs two characters. In order to ensure a maximum compatibility with other products. Remark : the use of no parity requires 2 stop bits. A–F One hexadecimal character contains 4-bits of data within each ASCII character of the message 1 start bit 7 data bits.org/ 16/44 . The format for each byte ( 10 bits) in ASCII mode is : Coding System: Bits per Byte: Hexadecimal. 1 stop bit Even parity is required. or No Parity checking. .2 The ASCII Transmission Mode When devices are setup to communicate on a MODBUS serial line using ASCII (American Standard Code for Information Interchange) mode. Most Significant Bit (MSB) With Parity Checking Start 1 2 3 4 5 6 7 Par Stop Figure 15: Bit Sequence in ASCII mode Devices may accept by configuration either Even. If No Parity is implemented. no parity ) may also be used. ASCII characters 0–9. . Example : The byte 0X5B is encoded as two characters : 0x35 and 0x42 ( 0x35 ="5".org 12/02/02 http://www. Odd.ORG 2.MODBUS over serial line specification and implementation guide V1. and 0x42 ="B" in ASCII ).modbus. each 8–bit byte in a message is sent as two ASCII characters.
Start 1 char : Address 2 chars Function 2 chars Figure 17: Data 0 up to 2x252 char(s) ASCII Message Frame LRC 2 chars End 2 chars CR. and end with a ‘carriage return – line feed’ (CRLF) pair (ASCII 0D and 0A hex). A typical message frame is shown below.modbus. A–F (ASCII coded). The address field of a message frame contains two characters.1 MODBUS Message ASCII Framing A MODBUS message is placed by the transmitting device into a frame that has a known beginning and ending point.0 MODBUS. Consequently. a message is delimited by specific characters as Start-of-frames and End-of-frames. Slave addr. Both "master" and "slave" points of view are expressed in the same drawing : Reception of ":" character / Empty reception buffer Sending of “LF” Idle (ready to receive or to emit) Reception of ":" character Reception Reception of character / Concatenation of character into reception buffer Emission Demand Emission start Reception of "LF" character / control frame (LRC. the maximum size of a MODBUS ASCII frame is 513 characters.5.org/ 17/44 . The devices monitor the bus continuously for the ‘colon’ character. The allowable characters transmitted for all other fields are hexadecimal 0–9.MODBUS over serial line specification and implementation guide V1. In ASCII mode. the maximum data size for ASCII data field (2x252) is the double the maximum data size for RTU data field (252). Parity. Intervals of up to one second may elapse between characters within the message.) Reception of "CR" character Reception of ":" character / Empty reception buffer Sending of “:” Emission Sending of all characters Sending of “CR” Comment If frame OK processing frame If frame NOK delete entire frame Waiting "End of Frame" Emission End Figure 18: ASCII Transmission mode State diagram Modbus. and to know when the message is completed. Unless the user has configured a longer timeout. A message must start with a ‘colon’ ( : ) character (ASCII 3A hex).org 12/02/02 http://www. Partial messages must be detected and errors must be set as a result. Some Wide-Area-Network application may require a timeout in the 4 to 5 second range. to ensure compatibility at MODBUS application level between ASCII mode and RTU mode. an interval greater than 1 second means an error has occurred. When this character is received.LF Remark : Each data byte needs two characters for encoding.ORG 2. Thus. The ASCII framing requirements are synthesized in the following state diagram.2. each device decodes the next character until it detects the End-Of-Frame. Remark : The LF character can be changed using a specific MODBUS application command ( see MODBUS application protocol specification). This allows devices that receive a new frame to begin at the start of the message.
containing an 8–bit binary value. A new reception buffer is then allocated. If the two values are not equal.0 MODBUS. In order to reduce the reception processing time the address field can be analyzed as soon as it is reserved without waiting the end of frame.5. the resulting LRC is ASCII encoded into two bytes and placed at the end of ASCII mode frame prior to the CRLF. If not the frame is discarded.2.ORG Some explanations about the above state diagram : "Idle" state is the normal state when neither emission nor reception is active. Each reception of a ":" character means a beginning of a new message. Afterwards the address field is analyzed to determine if the frame is for the device. 2. The LRC field is one byte. The device that receives calculates an LRC during receipt of the message. and then two’s complementing the result. the LRC calculation and checking is completed. exclusive of the beginning ‘colon’ and terminating CRLF pair characters. the current message is declared incomplete and it is discarded. It is performed on the ASCII message field contents excluding the ‘colon’ character that begins the message. The LRC is calculated by adding together successive 8–bit bytes of the message.org/ 18/44 . which appends the LRC to the message. If a message was in process of reception while receiving such a character.2 LRC Checking In ASCII mode. In ASCII mode.org 12/02/02 http://www. discarding any carries. and compares the calculated value to the actual value it received in the LRC field. an error results. A detailed example of LRC generation is contained in Appendix B. After detection of the end of frame.MODBUS over serial line specification and implementation guide V1. and excluding the CRLF pair at the end of the message.modbus. The LRC value is calculated by the device that emits. It is applied regardless of any parity checking method used for the individual characters of the message. messages include an error–checking field that is based on a Longitudinal Redundancy Checking (LRC) calculation that is performed on the message contents. Modbus.
The slave will not construct a response to the master. If No Parity checking is specified. RTU or ASCII. The CRC field checks the contents of the entire message. messages include an error–checking field that is based on a Cyclical Redundancy Checking (CRC) method. or for No Parity checking ( recommended). This interval is set to be long enough for any slave to respond normally ( unicast request). For example.2 Frame Checking Two kinds of frame checking is used depending on the transmission mode. If either Even or Odd Parity is specified.6. making the total quantity of 1 bits still an even number (four). the parity bit will be a 1.modbus.6 Error Checking Methods Parity checking (even or odd) should be applied to each character.org/ 19/44 . and two 1 bits are dropped from a character containing three 1 bits. If the slave detects a transmission error. An additional stop bit is transmitted to fill out the character frame. if Odd Parity checking is employed. For example. This will determine how the parity bit will be set in each character. the parity bit is calculated and applied to the frame of each character. It is applied regardless of any parity checking method used for the individual characters of the message. messages include an error–checking field that is based on a Longitudinal Redundancy Checking (LRC) method. The master is configured by the user to wait for a predetermined timeout interval ( Response time-out) before aborting the transaction. exclusive of the beginning ‘colon’ and ending CRLF pair. these eight data bits are contained in an RTU character frame: 1100 0101 The total quantity of 1 bits in the frame is four. Thus the timeout will expire and allow the master’s program to handle the error. Frame checking (LRC or CRC) must be applied to the entire message.0 MODBUS. In RTU mode.6.ORG 2. It is applied regardless of any parity checking method used for the individual characters of the message. When the message is transmitted. The LRC field checks the contents of the message.MODBUS over serial line specification and implementation guide V1. The security of standard MODBUS Serial Line is based on two kinds of error checking : Both the character checking and message frame checking are generated in the device (master or slave) that emits and applied to the message contents before transmission. 2. In ASCII mode. the frame’s parity bit will be a 0. The device (slave or master) checks each character and the entire message frame during receipt. the message will not be acted upon. The detailed information about error checking methods is contained in the previous sections.org 12/02/02 http://www. 2.1 Parity Checking Users may configure devices for Even ( required) or Odd Parity checking. no parity bit is transmitted and no parity checking can be made. Note that a message addressed to a nonexistent slave device will also cause a timeout. making an odd quantity (five). Note that parity checking can only detect an error if an odd number of bits are picked up or dropped in a character frame during transmission. the quantity of 1 bits will be counted in the data portion of each character (seven data bits for ASCII mode. The parity bit will then be set to a 0 or 1 to result in an Even or Odd total of 1 bits. Modbus. If Even Parity is used. or eight for RTU). The device that receives counts the quantity of 1 bits and sets an error if they are not the same as configured for that device (all devices on the MODBUS Serial Line must be configured to use the same parity checking method). If Odd Parity is used. the result is still an odd count of 1 bits.
on which bi-directional data are transmitted. forming a daisy-chain. This standard allows point to point and multipoint systems.org 12/02/02 http://www. 115 Kbps. in a “two-wire configuration”. Each device may be connected ( see figure 19): either directly on the trunk cable. Modbus. and must accept an error of 2% in reception situation. On standard MODBUS system. 56 Kbps. … Every implemented baud rate must be respected better than 1% in transmission situation. In such a MODBUS system.2 is the required default Other baud rates may optionally be implemented : 1200. 2400. or D-shell 9 connectors may be used on devices to connect cables (see the chapter “Mechanical Interfaces”). some devices may implement a “Four-Wire” RS485-Interface.2 Kbps are required and 19.1 Physical Layer Preamble A new MODBUS solution over serial line should implement an electrical interface in accordance with EIA/TIA-485 standard ( also known as RS485 standard). 3. … 38400 bps. In addition.org/ 20/44 .MODBUS over serial line specification and implementation guide V1. 4800. typically at the bit rate of 9600 bits per second. a Master Device and one or several Slave Devices communicate on a passive serial line.modbus. RJ45. either on a passive Tap with a derivation cable.ORG 3 3. either on an active Tap with a specific cable. all the devices are connected (in parallel) on a trunk cable constituted by 3 conductors.2 Data Signaling Rates 9600 bps and 19. Screw Terminals.0 MODBUS. A device may also implement an RS232-Interface. Two of those conductors ( the “Two-Wire” configuration ) form a balanced twisted pair.
in a Daisy-Chain ( case of Slave n ) The following conventions are adopted : The interface with the trunk is named ITr (Trunk Interface) The interface between the device and the Passive Tap is named IDv (Derivation Interface) The interface between the device and the Active Tap is named AUI (Attachment Unit Interface) Remarks : 1.org/ 21/44 . Master D R IDv Passive TAP ITr IDv AUI R D ActiveTap ITr ITr Passive TAP LT D R LT R D Slave n Slave 1 Slave 2 Figure 19 : Serial bus infrastructure A multipoint MODBUS Serial Line bus is made of a principal cable (the Trunk). Line terminations are necessary at each extremity of the trunk cable for impedance adaptation (see § "Two-Wire MODBUS Definition" & "Optional Four-Wire MODBUS Definition" for details).1 Electrical Interfaces Multipoint Serial Bus Infrastructure Figure 19 gives a general overview of the serial bus infrastructure in a MODBUS multipoint Serial Line system.modbus. the device is connected directly to the trunk cable. different implementations may operate in the same MODBUS Serial Line system : the device integrates the communication transceiver and is connected to the trunk using a Passive Tap and a derivation cable ( case of Slave 1 and Master ) . the device doesn't integrate the communication transceiver and is connected to the trunk using an Active Tap and a derivation cable (the active TAP integrates the transceiver) ( case of Slave 2 ) .3. As shown in figure 19. 2.3 3.MODBUS over serial line specification and implementation guide V1.org 12/02/02 http://www. and possibly some derivation cables. without using a derivation cable. 3. Such a Tap is named Distributor when it is a passive one. In some cases. A Tap may have several IDv sockets to connect several devices. When using an active Tap.0 MODBUS. the Tap may be connected directly to the IDv-socket or the AUI-socket of the device. Modbus. power supply of the Tap may be provided either via its AUI or ITr interface. ITr and IDv interfaces are described in the following chapters (see § "Two-Wire MODBUS DEFINITION" & "Four-Wire MODBUS DEFINITION").ORG 3.
and Common circuit names must be used in the documentation related to the device and the Tap ( User Guide. a Low level on PMC will switch the port into 4W-MODBUS or RS232-MODBUS Mode. Port mode control : PMC circuit ( TTL compatible ). … ) to facilitate interoperability. D0. Pull Up and Pull Down resistors.0 MODBUS. please refer to section “Multipoint System requirements".2 Two-Wire MODBUS Definition A MODBUS solution over serial line should implement a “Two-Wire” electrical interface in accordance with EIA/TIA-485 standard. on IDv D1 D0 Common For device I/O I/O -Required on device X X X EIA/TIA-485 name B/B’ A/A’ C/C’ Description Transceiver terminal 1. Master 5V D R Pull Up D1 LT Balanced Pair D0 Pull Down LT Common R D D R Slave 1 Slave n Figure 20: General 2-Wire Topology 2W-MODBUS Circuits Definition Required Circuits on ITr D1 D0 Common Notes : • • • For Line Termination (LT). In the first case while an open circuit PMC will ask for the 2W-MODBUS mode. at any time one driver only has the right for transmitting. In fact a third conductor must also interconnect all the devices of the bus : the common.modbus. Optional electrical interfaces may be added. On such a 2W-bus.org/ 22/44 .ORG 3. depending on the implementation. Cabling Guide.3. D1.C.. V1 Voltage ( V1 > V0 for binary 1 [OFF] state ) Transceiver terminal 0. When needed.org 12/02/02 http://www.MODBUS over serial line specification and implementation guide V1. port mode may be controlled either by this external circuit and/or by another way (a switch on the device for example). V0 Voltage ( V0 > V1 for binary 0 [ON] state ) Signal and optional Power Supply Common Modbus. for example : Power Supply : 5.24 V D.
Optional electrical interfaces may be added. Modbus.MODBUS over serial line specification and implementation guide V1.modbus.3 Optional Four-Wire MODBUS Definition Optionally. Va’ Voltage ( Va’ > Vb’ for binary 0 [ON] state ) Signal and optional Power Supply Common TXD0 TXD0 Out X RXD1 RXD0 Common Notes : • • • • RXD1 RXD0 Common In In -- (1) (1) X For Line Termination (LT). which is not correct : the RS422 standard does not support several drivers on one balanced pair. … ) to facilitate interoperability. for example : Power Supply : 5. a driver and a transceiver in accordance with EIA/ TIA-485. PMC circuit : See above ( In 2W-MODBUS Circuits Definition ) the note about this optional circuit. the data on the slave pair ( TXD1-TXD0 ) are only received by the only master. Cabling Guide. In the same way as on a 2W-MODBUS. for each balanced pair. ( Sometimes this solution has been named “RS422”. at any time one driver only has the right for emitting.. Such a device must implement.) M a s te r D R 5 V P u ll U p TXD1 LT S la v e P a ir TXD0 P u ll D o w n P u ll U p 5 V LT R XD1 LT M a s te r P a ir R XD0 P u ll D o w n LT Com m on R D D R S la v e 1 S la v e n Figure 21: General 4-wire topology Optional 4W-MODBUS Circuits Definition Required Circuits on ITr TXD1 on IDv TXD1 For device Out Required on device X EIA/TIA-485 name B Description for IDv Generator terminal 1. Vb’ Voltage ( Vb’ > Va’ for binary 1 [OFF] state ) Receiver terminal 0.org/ 23/44 . The name of the 5 required circuits must be used in the documentation related to the device and the Tap ( User Guide. Those circuits (1) are required only if an 4W-MODBUS option is implemented. Pull Up and Pull Down resistors.C. please refer to section “Multipoint System requirements". such MODBUS devices also permit to implement a 2-pair bus (4 wires) of mono directional data.24 V D. In fact a fifth conductor must also interconnect all the devices of the 4W-bus : the common. Vb Voltage ( Vb > Va for binary 1 [OFF] state ) A Generator terminal 0.ORG 3.3. Va Voltage ( Va > Vb for binary 0 [ON] state ) B’ A’ C/C’ Receiver terminal 1. The data on the master pair ( RXD1-RXD0 ) are only received by the slaves .org 12/02/02 http://www.0 MODBUS.
D1 signals. 3.org 12/02/02 http://www. turning them to the D0 signal TxD1 signal shall be wired with the RxD1 signal.3. To connect a 4W master device ( which have a MODBUS connector) a better solution is to use a Tap which includes the crossing function.1 4W-Cabling System Important Topic In such a 4W-MODBUS. Master Device and Slave Devices have IDv interfaces with the same 5 required circuits. turning them to the D1 signal. but the connection of such crossed cables in a 2-wire system may cause damages.MODBUS over serial line specification and implementation guide V1.2 Compatibility between 4-Wire and 2-Wire cabling In order to connect devices implementing a 2-Wire physical interface to an already existing 4-Wire system. the 4-Wire cabling system can be modified as described below : TxD0 signal shall be wired with the RxD0 signal.0 MODBUS.3.modbus. Pull-down and line terminations resistors shall be re-arranged to correctly adapt the D0. As the master has to : receive from the slave the data on the slave pair ( TXD1-TXD0 ).3.ORG 3. Modbus. and transmit on the master pair ( RXD1-RXD0 . the 4W-cabling system must cross the two pairs of the bus between ITr and the IDv of the master : Signal on Master IDv Name RXD1 Slave Pair RXD0 TXD1 Master Pair TXD0 Common Out -In Out Type In EIA/TIA-485 Name B’ A’ B A C/C’ Circuit on ITr TXD1 TXD0 RXD1 RXD0 Common This crossing may be implemented by crossed cables. received by the slaves) .3. Pull-up.org/ 24/44 .
TxD1 signal shall be wired with the RxD1 signal and then connected to the D1 signal of the trunk.org/ 25/44 .0 MODBUS.modbus.ORG The figure hereafter gives an example where slaves 2 and 3 which use a 2-Wire interface can operate with the Master and the slave 1 which use a 4-Wire interface.MODBUS over serial line specification and implementation guide V1. M a s te r D R 5 V P u ll U p TXD1 LT TXD0 P u ll D o w n R XD1 LT R XD0 Com m on R D D R D R S la v e 1 S la v e 2 S la v e 3 Figure 22 : Changing a 4-Wire cabling system into a 2-Wire cabling system In order to connect devices implementing a 4-Wire physical interface to an already existing 2-Wire system. the 4-Wire interface of the new coming devices can be arranged as describe below : On each 4-Wire device interface : TxD0 signal shall be wired with the RxD0 signal and then connected to the D0 signal of the trunk . The figure hereafter gives an example where slaves 2 and 3 which use a 4-Wire interface can operate with the Master and the slave 1 which use a 2-Wire interface. Master 5V D R Pull Up D1 LT Balanced Pair D0 Pull Down LT Common R D D R D R Slave 1 Slave 2 Slave 3 Figure 23 : Connecting devices with 4-Wire interface to a 2-Wire cabling system Modbus.org 12/02/02 http://www.
for example : Power Supply : PMC circuit : 5. how optional circuits must work if such is the case.0 MODBUS.MODBUS over serial line specification and implementation guide V1. and for the possibility to use Category 5 Cables. For DCE -In -In Out Out In Out X X X X Required on DCE (1) X Required on DTE (1) X Description Signal Common Clear to Send Data Carrier Detected ( from DCE to DTE ) Data Set Ready Data Terminal Ready Request to Send Received Data Transmitted Data 3. RTS may be wired with CTS of the other device. maximum wire capacitance to ground ( 2500 pF.3.. Please refer to chapter “Cables” for the shield.C.org/ 26/44 . then 25 m for a 100 pF/m cable ). Optional RS232-MODBUS Circuits Definition Signal Common CTS DCD DSR DTR RTS RXD TXD Notes : • • • • • • “X” marked signals are required only if an RS232-MODBUS option is implemented.24 V D. Optional electrical interfaces may be added.ORG 3.5 RS232-MODBUS requirements This optional MODBUS on Serial Line system should only be used for short length ( typically less than 20m ) point to point interconnection. Documentation of the device must indicate : ⇒ ⇒ if the device must be considered as a DCE either as a DTE. See above ( In 2W-MODBUS Circuits Definition ) the note about this optional circuit.org 12/02/02 http://www. DTR may be wired with DSR of the other device. Signals are in accordance with EIA/ TIA-232. the EIA/TIA-232 standard must be respected : ⇒ ⇒ circuits definition.3. Then. Modbus.modbus.4 RS232-MODBUS Definition Some devices may implement an RS232-Interface between a DCE and a DTE. Each TXD must be wired with RXD of the other device .
In the specific case shown in the figure 22 ( 4 Wire cabling used as a 2 Wire cabling system) the maximum length must be divided by two. Capacitance or Characteristic Impedance). the maximum length is 1000m.4. . Modbus.modbus. 3. Some devices allow the implementation of a RS485-MODBUS serial line with more than 32 devices. A RS485 system may implement a larger number of devices. preferably at one point only for the entire bus. It is important that the line be terminated at both ends since the propagation is bi-directional. Generally this point is to choose on the master device or on its Tap. Depending of : . The use of repeaters between several RS485-MODBUS is also possible. can be long (see hereafter).4. also named “Bus”. the number of loads on the daisy chain.and the line polarization in need be.ORG 3. without repeater. never more than 20m. along which devices are connected. The maximum length depends on the baud rate.MODBUS over serial line specification and implementation guide V1. 3.4 Grounding Arrangements The « Common » circuit ( Signal and optional Power Supply Common ) must be connected directly to protective ground. The trunk cable.the figure of RS485 Unit Load used by the devices.all the possible addresses. If a multi-port tap is used with n derivations. To minimize the reflections from the end of the RS485-cable it is required to place a Line Termination near each of the 2 Ends of the Bus.4.org 12/02/02 http://www. In this case these MODBUS devices must be documented to say how many of such devices are authorized without repeater. The use of a repeater between two heavy loaded RS485-MODBUS is also possible. For a maximum 9600 Baud Rate and AWG26 (or wider) gauge. the following requirements all apply. directly (daisy chaining) or by short derivation cables. The derivations must be short. and the network configuration (2-wire or 4-wire).1 Maximum number of devices without repeater A figure of 32 devices is always authorized on any RS485-MODBUS system without repeater. 3. in either 2-wire or 4-wire configuration.4. the cable (Gauge.4 Multipoint System requirements For any EIA/ TIA-485 multipoint system.4.0 MODBUS.org/ 27/44 . Its two ends must be connected on Line Terminations.5 Line Termination A reflection in a transmission line is the result of an impedance discontinuity that a travelling wave sees as it propagates down the line. 3.2 Topology An RS485-MODBUS configuration without repeater has one trunk cable. Never place any LT on a derivation cable. .3 Length The end to end length of the trunk cable must be limited. 3. but it is not allowed to place more than 2 LT on one passive D0-D1 balanced pair . each one must respect a maximum length of 40m divided by n.
the lines are not driven and. 10 V minimum ) with a 120 Ohms ( 0. In this case.modbus. In an RS232 interconnections.25 W ) resistor is a better choice when a polarization of the pair must be implemented (see here after). Each MODBUS device must be documented to say : if the device needs a line polarization.org/ 28/44 . 3. such a line polarization. 650 Ohms resistors value may allow a higher number of devices on the serial line bus. if the device implements. or can implement. a polarization of the pair must be implemented at one location for the whole Serial Bus. Line termination may be a 150 ohms value ( 0.ORG A serial capacitor ( 1 nF.0 Each line termination must be connected between the two conductors of the balanced line : D0 and D1. each pair must be terminated at each end of the bus. MODBUS. when no data signal is present. If one or several devices need polarization. one pair of resistors must be connected on the RS-485 balanced pair : a Pull-Up Resistor to a 5V Voltage on D1 circuit. a Pull-Down Resistor to the common circuit on D0 circuit. The value of those resistors must be between 450 Ohms and 650 Ohms. Generally this point is to choose on the master device or on its Tap. In a 4W-system. thus susceptible to external noise or interference. some devices need to bias the network. The maximum number of devices authorized on such a MODBUS Serial Line is reduced by 4 from a MODBUS without polarization. no termination should be wired.MODBUS over serial line specification and implementation guide V1.6 Line Polarization When there is no data activity on an RS-485 balanced pair.4. Modbus. To insure that its receiver stays in a constant state.5 W ) resistor. Other devices must not implement any polarization.org 12/02/02 http://www.
2W-MODBUS RJ45 and 9-pin D-shell Pinouts Pin on Pin on RJ45 D9-shell 3 4 5 7 8 3 5 9 2 1 Level of requirement optional required required recommended required IDv Circuit PMC D1 D0 VP Common ITr Circuit -D1 D0 -Common EIA/TIA485 name -B/B’ A/A’ -C/C’ Description for IDv Port Mode Control Transceiver terminal 1. If a RJ45 ( or a mini-DIN or a D-Shell) connector is used on an equipment for a MODBUS mechanical interface.org/ 29/44 .female connector Common D0 D1 Figure 24: 2W. the pinouts hereafter must be respected for every implemented circuit.modbus.24 V D.. V1 Voltage ( V1 > V0 for binary 1 [OFF] state ) Transceiver terminal 0. a shielded female connector must be chosen. Power Supply Signal and Power Supply Common Modbus.MODBUS over serial line specification and implementation guide V1. All information must be provided to the users about the exact location of each signal.org 12/02/02 http://www.ORG 3.C..0 MODBUS.MODBUS on RJ45 connector ( required pin-out ) Female (Front view) 5 9 4 8 3 7 2 6 1 Male (Front view) 1 6 2 7 3 8 4 9 5 Figure 25: Screw type connectors can also be used.1 Connectors pin-out for 2W-MODBUS Device side . V0 Voltage ( V0 > V1 for binary 0 [ON] state ) Positive 5. 3.5 Mechanical Interfaces Screw Terminals may be used for both IDv and ITr connections. Then the cable-end must have a shielded male connector. with names in accordance with the previous chapter “Electrical Interface”.5. D-shell 9-pin connector If an RJ45 or a 9-pin D-shell connector is used for a standard MODBUS device.
MODBUS on RJ45 connector ( required pin-out ) Female (Front view) 5 9 4 8 3 7 2 6 1 Male (Front view) 1 6 2 7 3 8 4 9 5 Figure 27: Screw type connectors can also be used. Vb’ Voltage ( Vb’ > Va’ for binary 1 [OFF] state ) Port Mode Control Generator terminal 1. D-shell 9-pin connector If an RJ45 or a 9-pin D-shell connector is used for a 4W-MODBUS device.24 V DC Power Supply Signal and Power Supply Common Note : When both 2 and 4-Wire configurations are implemented on the same port. Vb Voltage ( Vb > Va for binary 1 [OFF] state ) Generator terminal 0.ORG 3. the pinouts hereafter must be respected for every implemented circuit. Optional 4W-MODBUS RJ45 and 9-pin D-shell Pinouts Pin on Pin on RJ45 D9-shell 1 2 3 4 5 7 8 8 4 3 5 9 2 1 Level of requirement required required optional required required recommended required IDv Signal RXD0 RXD1 PMC TXD1 TXD0 VP Common ITr Signal RXD0 RXD1 -TXD1 TXD0 -Common EIA/TIA485 name A’ B’ -B A -C/C’ Description for IDv Receiver terminal 0. Va’ Voltage ( Va’ > Vb’ for binary 0 [ON] state ) Receiver terminal 1.org 12/02/02 http://www..modbus.org/ 30/44 . Modbus.. the 4W notations must be used.5. Va Voltage ( Va > Vb for binary 0 [ON] state ) Positive 5.MODBUS over serial line specification and implementation guide V1.female connector Common TXD0 TXD1 RXD1 RXD0 Figure 26: 4W.2 Connectors pin-out for optional 4W-MODBUS Device side .0 MODBUS.
5.org 12/02/02 http://www.modbus. Modbus.0 MODBUS.MODBUS over serial line specification and implementation guide V1.3 RJ45 and 9-pin D-shell Pinouts for optional RS232-MODBUS If an RJ45 or a 9-pin D-shell connector is used for a RS232-MODBUS device. the pinouts hereafter must be respected for every implemented circuit.ORG 3.org/ 31/44 . DCE Underlined pins can be output Pin on Pin on RJ45 D9-shell 1 2 3 6 8 2 3 7 8 5 Level of requirement required required optional optional required Name Circuit Description RS232 Source DTE DCE DCE DTE -- DTE Underlined pins can be output Level of requirement required required optional optional required Pin on RJ45 2 1 6 3 8 Pin on D9shell 3 2 8 7 5 TXD RXD CTS RTS Common Transmitted Data Received Data Clear to Send Request to Send Signal Common Important Note : Some DCE Pinouts are crossed with DTE Pinouts with the same name : A directly pin to pin wired cable ( without any crossing ) must be used between one DTE ( a PC for example ) and a DCE (a PLC for example).
especially for 19200 and higher baud rates. the shell of the connector is connected to the shield of the cable.0 MODBUS. or 1 LED for both purposes.) Error recommended Switched ON : internal fault Flashing : Other faults (Communication fault or configuration error) Device status optional Switched ON : device powered Green Red Recommended colour Yellow Modbus. a Color Code is recommended for the wires in the RS485-MODBUS Cables : Signal Names D1-TXD1 D0-TXD0 Common 4W ( Optional ) 4W ( Optional ) Figure 28: Note : RXD0 RXD1 Recommended Color yellow brown grey white blue Color code for RS485-MODBUS wires Category 5 Cables use other colors. communication status and device status must be indicated by LEDs : LED Communication Level of requirement required State Switched ON during frame reception or sending.org/ 32/44 . ( 2 LEDs for frame reception and frame sending. For the balanced pairs used in an RS485-system. To minimize errors in cabling.modbus. If a connectorized 4 pairs Category 5 Cable is used. 3.MODBUS over serial line specification and implementation guide V1. please remember to the user in the User Guides : “Connection of a crossed cable in a 2-wire MODBUS system may cause damages”.6 Cables A MODBUS over Serial Line Cable must be shielded. An RS485-MODBUS must use a balanced pair (for D0-D1) and a third wire (for the Common).ORG 3. Wire Gauge must be chosen sufficiently wide to permit the maximum length ( 1000 m ).org 12/02/02 http://www. to a maximum length of 600m. Category 5 cables may operate for RS485-MODBUS. At one end of each cable its shield must be connected to protective ground. In addition to that a second balanced pair must be used in a 4W-MODBUS system (for RXD0-RXD1).7 Visual Diagnosis For a visual diagnosis. For RS485-MODBUS. a Characteristic Impedance with a value higher than 100 Ohms may be preferred. AWG 24 is always sufficient for the MODBUS Data. If a connector is used at this end.
4. RJ45…) . On these connectors. CANopen for example. Installation rules.1 Installation and Documentation Installation Product vendor should pay attention to give to the user of a MODBUS System or MODBUS Devices all useful information to prevent them from any error in cabling or bad utilization of cabling accessories : Some other Fieldbuses.2. In such a case. 4.modbus. for an easy start. for the most part. The reachable registers and supported function codes. Modbus.2 User Guide The User Guide of any MODBUS Device or Cabling System Component must include in a non exhaustive manner one or two types of information: 4. "Optional Four-Wire MODBUS Definition" (to mention the Required Circuits) . RJ45…). Optional Interface(s) . Maximum number of devices (without repeater) if greater than 32.1 For any MODBUS Product : The following information should be documented : All the implemented requests.org 12/02/02 http://www. A specific indication relating to the devices addresses. Some Products use for I/O circuits the same connector types ( D-shell.2.ORG 4 4." A "Getting Started" chapter is highly recommended. Port Configuration . no foolproofing is available (polarizing notch or other implementation) . the Master being then in the impossibility to communicate with all present slaves on the bus. that there is not two devices with the same address. use the same connector types ( D-shell. with the documented description of a typical application example.0 MODBUS. The visual diagnostics.MODBUS over serial line specification and implementation guide V1.2 For a MODBUS Product with implemented Options : The different optional parameters must be clearly detailed : ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ Optional serial Transmission mode . "Cables" (special care of crossed cables). Optional Circuit(s) : Power Supply. The operating modes. is to be written in the form of an important warning : "It is of great importance to ensure at the time of the procedure of devices addressing. The required information in the following sections should also be documented : ⇒ ⇒ ⇒ ⇒ "Two-Wire MODBUS Definition" (to mention the Required Circuits) . Optional Parity Checking .org/ 33/44 . Studies are conducted on Ethernet. Optional Baud Rates . "Line Polarization" (to mention a possible Need or an Implementation) . with power supply on the same Balanced Pairs Cable. an abnormal behavior of the whole serial bus can occur.
ORG 5 Implementation Classes Each device on a MODBUS Serial Line must respect all the mandatory requirements of a same implementation class.org 12/02/02 http://www. BASIC Addressing Slave : Master : configurable address to be able to address from 1 to 247 a slave from address 1 to 247 Broadcast Baud Rate Yes 9600 ( 19200 is also recommended) Yes 9600. else 9600) REGULAR Same as Basic Default value - - Parity Mode EVEN RTU or RS232 EVEN RTU Electrical Interface RS485 2W-cabling RS485 2W-cabling (and 4W-cabling as an RS485 2W-cabling additional option) or RS232 - Connector Type RJ 45 ( recommended ) Modbus. The regular class must provide configuration capabilities.modbus.org/ 34/44 .0 MODBUS. the Basic and the Regular classes. The following parameters are used to classify the MODBUS Serial Line devices : • • • • • • Addressing Broadcasting Transmission mode Baud rate Character format Electrical interface parameter Two implementation classes are proposed.MODBUS over serial line specification and implementation guide V1. 19200 + additional configurable baud rates EVEN + possibility to configure NO and ODD parity RTU + ASCII 19200 (if implemented.
The format of the Diagnostic function is described in the MODBUS application protocol specification. Each counter can be get by a sub-function code bound to the counter number. clear counters operation. since its last restart. clear counters operation. It comprises also the error detected in broadcast messages even if an exception message is not returned in this case.1 Appendix Appendix A . Exception responses are described and listed in "MODBUS Application Protocol Specification" document. or power–up. including broadcast messages. clear counters operation. Messages with bad CRC are not taken into account. Exception errors are described and listed in "MODBUS Application Protocol Specification" document.MODBUS over serial line specification and implementation guide V1. (overrun.ORG 6 6. since its last restart.0 MODBUS. clear counters operation. or power–up. clear counters operation. In such cases.1 MODBUS Serial Line defines a list of diagnostic counters to allow performance and error management. or power–up. or power–up.org 12/02/02 http://www. this counter counts the number of broadcast messages it has received. since its last restart. clear counters operation. or power–up.Management of Serial Line Diagnostic Counters General description 6. parity error). These counters are accessible using the MODBUS application protocol and its Diagnostic function (function code 08).1.modbus. Quantity of messages addressed to the remote device for which it returned a Slave Device Busy exception response. Herein is the list of diagnostics and associated sub-function codes supported by a serial line device. A character overrun is caused by data characters arriving at the port faster than they can be stored. or power–up. this counter is also incremented. Quantity of MODBUS exception error detected by the remote device since its last restart. 0x0C 2 Return Bus Communication Error Count 0x0D 3 Return Slave Exception Error Count 0xOE 4 Return Slave Message Count Quantity of messages addressed to the remote device. or by the loss of a character due to a hardware malfunction. Then. or power–up. All counters can be cleared using the sub-function code 0x0A. or in case of a message length < 3 bytes. 0x0F 5 Return Slave No Response Count 0x10 6 Return Slave NAK Count 0x11 7 Return Slave Busy Count 0x12 8 Return Bus Character Overrun Count Modbus. Quantity of messages addressed to the remote device for which it returned a Negative Acknowledge (NAK) exception response. Quantity of messages received by the remote device for which it returned no response (neither a normal response nor an exception response). or power–up. the receiving device is not able to calculate the CRC. Subfunction code Hex 0x0B Counter number Dec 1 Return Bus Message Count Counters Name Comments (for diagram below) Quantity of messages that the remote device has detected on the communications system since its last restart.org/ 35/44 . Quantity of CRC errors encountered by the remote device since its last restart. Exception responses are described and listed in "MODBUS Application Protocol Specification" document Quantity of messages addressed to the remote device that it could not handle due to a character overrun condition. In case of an error detected on the character level. that the remote device has processed since its last restart. clear counters operation. since its last restart. clear counters operation.
1.2 Counters Management Diagram The following diagrams describe when each previous counters must be incremented.0 MODBUS. 3 Rest IDLE reception reception reception max 255 characters number max characters CPT8 = CPT8 + 1 character overrun error end of frame detected 3 characters silence YES error on at least 1 frame character YES NO length < 3 bytes NO YES CRC incorrect NO CPT2 = CPT2 + 1 CPT1 = CPT1 + CPT1 = CPT1 + 1 1 YES slave number = 0 or slave number = my slave number NO YES YES CPT5 = CPT5 + 1 CPT4 = CPT4 + 1 slave number =0 YES slave number 0 NO NO CPT5 = CPT5 + 1 1 CPT4 = CPT4 + 1 slave number = workstation slave number NO YES function code not known YES NO exception n° 1 CPT3 = CPT3 + 1 length incorrect NO exception n° 3 CPT3 = CPT3 + 1 YES addressing incorrect YES NO exception n° 2 CPT3 = CPT3 + 1 data incorrect NO exception n° 3 CPT3 = CPT3 + 1 2 Modbus.modbus.org/ 36/44 .org 12/02/02 http://www.ORG 6.MODBUS over serial line specification and implementation guide V1.
MODBUS over serial line specification and implementation guide V1.org/ 37/44 .0 MODBUS.modbus.ORG 1 3 YES function code not known NO YES function code prohibited in broadcasts NO YES length incorrect NO YES addressing incorrect NO YES data incorrect NO CPT3 = CPT3 + 1 2 2 3 application processing YES processing error NO CPT3 = CPT3 + 1 YES broadcast NO YES broadcast NO exception response response Modbus.org 12/02/02 http://www.
Placing the LRC into the Message When the 8–bit LRC (2 ASCII characters) is transmitted in the message. the high–order character will be transmitted first. A procedure for generating an LRC is: 1. which appends the LRC to the message.org/ 38/44 . containing an 8–bit binary value.MODBUS over serial line specification and implementation guide V1. For example. LRC Character Sequence Example: an example of a C language function performing LRC generation is shown below. The quantity of bytes in the message buffer. Add them into an 8–bit field.0 MODBUS. if the LRC value is 61 hex (0110 0001): Colon Addr Func Data Count Data Data Data Data LRC Hi "6" 0x36 LRC Lo "1" 0x31 CR LF Figure 29: The function takes two arguments: unsigned char *auchMsg.modbus. If the two values are not equal. LRC Generation Function static unsigned char LRC(auchMsg.2 Appendix B . so that carries will be discarded. the carry is discarded automatically. Add all bytes in the message. The device that receives recalculates an LRC during receipt of the message. unsigned short usDataLen. A pointer to the message buffer containing binary data to be used for generating the LRC. Add 1 to produce the twos–complement. Because there is no ninth bit.2. therefore each new addition of a character that would result in a value higher than 255 decimal simply ‘rolls over’ the field’s value through zero. Subtract the final field value from FF hex (all 1’s). return ((unsigned char)(–((char)uchLRC))) . and then two’s complementing the result. usDataLen) unsigned char *auchMsg .ORG 6. to produce the ones–complement. The LRC is an 8–bit field.LRC/CRC Generation 6. { unsigned char uchLRC = 0 . while (usDataLen––) uchLRC += *auchMsg++ . 3. 2. The LRC is calculated by adding together successive 8–bit bytes in the message. followed by the low–order character. The LRC value is calculated by the transmitting device. and compares the calculated value to the actual value it received in the LRC field. excluding the starting ‘colon’ and ending CRLF.org 12/02/02 http://www. discarding any carries.1 LRC Generation The Longitudinal Redundancy Checking (LRC) field is one byte. } /* the function returns the LRC as a type unsigned char */ /* message to calculate LRC upon */ /* quantity of bytes in message */ /* LRC char initialized */ /* pass through message buffer */ /* add buffer byte without carry */ /* return twos complement */ Modbus. unsigned short usDataLen . an error results.
zero–filling the MSB. 4. followed by the highorder byte. a complete 8–bit byte will have been processed. its upper and lower bytes must be swapped as described below. The LSB is extracted and examined. Only the eight bits of data in each character are used for generating the CRC. This process is repeated until eight shifts have been performed. is the CRC value. The final content of the register.0 MODBUS. 2. For example. When the CRC is placed into the message. Call this the CRC register. 8. Placing the CRC into the Message When the 16–bit CRC (two 8–bit bytes) is transmitted in the message. Then the result is shifted in the direction of the least significant bit (LSB). 3. and compares the calculated value to the actual value it received in the CRC field. Repeat Steps 2 through 5 for the next 8–bit byte of the message. Shift the CRC register one bit to the right (toward the LSB). Start and stop bits and the parity bit. containing a 16–bit binary value. with a zero filled into the most significant bit (MSB) position. The CRC is started by first preloading a 16–bit register to all 1’s. (If the LSB was 0): Repeat Step 3 (another shift). The device that receives recalculates a CRC during receipt of the message. the low-order byte will be transmitted first. During generation of the CRC. If the two values are not equal. an error results. no exclusive OR takes place. 7.org 12/02/02 http://www. fixed value. the register is then exclusive ORed with a preset. If the LSB was a 0. putting the result in the CRC register. When this is done.modbus. 6. Load a 16–bit register with FFFF hex (all 1’s). (If the LSB was 1): Exclusive OR the CRC register with the polynomial value 0xA001 (1010 0000 0000 0001). Then a process begins of applying successive 8–bit bytes of the message to the current contents of the register. A procedure for generating a CRC is: 1. and the process repeats for eight more shifts as described above. do not apply to the CRC. 5. Exclusive OR the first 8–bit byte of the message with the low–order byte of the 16–bit CRC register. The CRC value is calculated by the transmitting device. each 8–bit character is exclusive ORed with the register contents. which appends the CRC to the message.ORG 6.MODBUS over serial line specification and implementation guide V1. The final content of the CRC register is the CRC value.2.org/ 39/44 . If the LSB was a 1. after all the characters of the message have been applied. the next 8–bit character is exclusive ORed with the register’s current value. Extract and examine the LSB. Repeat Steps 3 and 4 until 8 shifts have been performed. if the CRC value is 1241 hex (0001 0010 0100 0001): Data Count CRC Lo 0x41 CRC Hi 0x12 Addr Func Data Data Data Data Figure 30: CRC Byte Sequence Modbus.2 CRC Generation The Cyclical Redundancy Checking (CRC) field is two bytes. Continue doing this until all bytes have been processed. After the last (eighth) shift.
MODBUS over serial line specification and implementation guide V1. the 1st byte transmitted is the least significant one.org/ 40/44 . Modbus.modbus.ORG CRC16 XOR BYTE → CRC16 N=0 Move to the right CRC16 No Carry over Yes CRC16 XOR POLY → CRC 16 N=N+1 No N>7 Yes No End of message Following BYTE Yes END XOR = exclusive or N = number of information bits POLY = calculation polynomial of the CRC 16 = 1010 0000 0000 0001 (Generating polynomial = 1 + x2 + x 15 + x 16) In the CRC 16.org 12/02/02 http://www.0 Calculation algorithm of the CRC 16 OxFFFF → CRC16 MODBUS.
XOR polynomial Move 2 Flag to 1.0 MODBUS.modbus.ORG Example of CRC calculation (frame 02 07) CRC register initialization XOR 1st character Move 1 Flag to 1.org/ 41/44 .org 12/02/02 http://www.MODBUS over serial line specification and implementation guide V1. XOR polynomial Move 3 Move 4 1111 0000 1111 0111 1010 1101 0110 1010 1100 0110 0011 1010 1001 Move 5 Move 6 0100 0010 1010 1000 Move 7 Move 8 0100 0010 1010 1000 0000 1111 0000 1111 1111 0000 1111 1111 0000 1111 0111 0011 0000 0011 1001 0100 0000 0100 0010 0001 0000 0001 0000 0001 0000 0000 0000 0000 0000 0000 1000 0000 1000 0100 0010 0000 0010 1001 0100 0010 1111 0000 1111 1111 0000 1111 1111 0000 1111 1111 1111 0000 1111 1111 1111 0000 1111 0111 0011 0000 0011 0000 0011 1001 0000 1001 0100 0000 0100 0010 0000 0010 0001 0000 0000 0000 0000 1000 0100 1111 0000 1101 1110|1 0001 1111 1111|1 0001 1110 11100 11111 0001 1110 11110 11111 0001 1110 11110 11110 0001 1110 0111 1001 11001 0001 1101 11101 0001 1111 01111 0001 0110 00110 10011 0001 1000 01000 00100 00010 XOR 2nd character Move 1 1000 0100 1010 1110 Move 2 0111 1010 1101 Move 3 0110 1010 1100 Move 4 Move 5 0110 0011 1010 1001 Move 6 Move 7 Move 8 0100 0010 0001 Most significant The CRC 16 of the frame is then: 4112 least significant Modbus.
usDataLen ) unsigned char *puchMsg . and the other array contains all of the values for the low byte. The bytes are already swapped in the CRC value that is returned from the function. Therefore the CRC value returned from the function can be directly placed into the message for transmission. } return (uchCRCHi << 8 | uchCRCLo) .org/ 42/44 .modbus. uchCRCLo = uchCRCHi ^ auchCRCHi[uIndex} . unsigned short usDataLen . /* The function returns the CRC as a unsigned short type */ /* message to calculate CRC upon /* quantity of bytes in message /* high byte of CRC initialized /* low byte of CRC initialized /* will index into CRC lookup table */ */ */ */ */ while (usDataLen--) { uIndex = uchCRCLo ^ *puchMsgg++ .org 12/02/02 http://www. All of the possible CRC values are preloaded into two arrays. unsigned char uchCRCLo = 0xFF . CRC Generation Function A pointer to the message buffer containing binary data to be used for generating the CRC The quantity of bytes in the message buffer. Note: This function performs the swapping of the high/low CRC bytes internally. unsigned uIndex . unsigned short CRC16 ( puchMsg. unsigned short usDataLen. which are simply indexed as the function increments through the message buffer. The function takes two arguments: unsigned char *puchMsg.ORG Example An example of a C language function performing CRC generation is shown on the following pages. } /* pass through message buffer /* calculate the CRC */ */ Modbus.0 MODBUS. Indexing the CRC in this way provides faster execution than would be achieved by calculating a new CRC value with each new character from the message buffer. { unsigned char uchCRCHi = 0xFF . One array contains all of the 256 possible CRC values for the high byte of the 16–bit CRC field.MODBUS over serial line specification and implementation guide V1. uchCRCHi = auchCRCLo[uIndex] .
0x00. 0x8F. 0x80. 0x80. 0x40. 0x40. 0xCB. 0x55. 0x6D. 0xC1. 0x73. 0x01. 0xC5. 0xE6. 0x40. 0x80. 0x40. 0x29. 0xB9. 0xAE. 0x00. 0x62. 0x2D. 0xE2. 0x01. 0xC0. 0x0A. 0x00. 0x85. 0x00. 0xD8. 0xC1. 0x5E. 0xC0. 0x41. 0x87. 0x00. Modbus. 0x00. 0x01. 0x01. 0x80. 0xC1. 0x81. 0x81. 0x4F. 0x01. 0xC0. 0x9D. 0x40. 0x81. 0x40. 0x43. 0x1A. 0xD1. 0xC1. 0xBE. 0x01. 0xA1. 0xD4. 0x69. 0x80. 0x00. 0x60. 0x95. 0xA8. 0x66. 0x1B. 0x00. 0x40. 0x40. 0x4A. 0x41. 0x01. 0x40. 0x41. 0x40. 0x80. 0x81. 0xC1.org 12/02/02 http://www. 0x80. 0x3A. 0xC0. 0xFB. 0x18. 0xC1. 0x80. 0xC0. 0xE3. 0xE9. 0x96. 0x80. 0x3C. 0x81. 0xA0. 0x20. 0x8E. 0x81. 0xC1. 0x49. 0xCF. 0x80. 0xC0. 0xC0. 0x80. 0xC1. 0x81. 0xF0. 0xB7. 0xC1. 0x01. 0xDE. 0xB0. 0x08. 0x00. 0xC0. 0x7C. 0xAD. 0x42. 0xC1. 0x81. 0x00. 0x6F. 0xC1. 0x40. 0xC1. 0x81. 0x22. 0xC1. 0x01. 0x6B. 0x41. 0xA3. 0x01. 0xC3. 0x40 }. 0x81. 0x81. 0x41. 0xF3. 0x5A. 0x01. 0x40 }. 0x00. 0x27. 0x9E. 0xC0. 0x81. 0x40. 0x01. 0x80. 0x80. 0xC0. 0x46. 0x9B. 0x88. 0x81. 0xC2. 0xB8. 0x01. 0x40. 0x01. 0x00. 0x41. 0x2A. 0x40. 0xC0. 0xC7. 0xC1. 0x40. 0xC0. 0x30. 0x15. 0x54. 0x00. 0x75. 0xD2. 0x41. 0x4C. 0x23. 0xC1. 0x41. 0x7A. 0x41. 0x4D. 0x81. 0x8A. 0x41. 0xB6. 0x1C. 0x00. 0x99. 0x2E. 0x68. 0xF2. 0x81. 0x21. 0xBD. 0x40. 0x40. 0xD3. 0x00. 0x80. 0x00. 0x8C. 0x81. 0x7E. 0x53. 0x00. 0x8B. 0x01. 0xF7. 0x00. 0xC1. 0xDA. 0x00. 0x81. 0x2F. 0xC1. 0x50. 0xC0. 0x80. 0x56. 0x40. 0xD7. 0x5D. 0x01. 0xC0. 0x40. 0x12. 0x01. 0xC1. 0x47. 0x01. 0x2B. 0xC1. 0x33. 0x92. 0x00. 0xED. 0x01. 0x70. 0x4E. 0xCC. 0x00. 0xEE.0 High-Order Byte Table MODBUS. 0x72. 0xF8. 0x81. 0xC6. 0xC0. 0x7F. 0x63. 0x3F. 0xC1. 0x1E. 0x71. 0x80. 0x40. 0x40. 0xBF. 0x16. 0x8D. 0x00.ORG /* Table of CRC values for high–order byte */ static unsigned char auchCRCHi[] = { 0x00. 0x01. 0x0F. 0xFF. 0xC1. 0xC8. 0xB5. 0x40. 0xC0. 0x1D. 0x9A. 0x37. 0x41. 0x41. 0xE4. 0x52. 0x5B. 0x04. 0x81. 0x81. 0x25. 0x9C. 0x31. 0x79. 0x5F. 0x01. 0x41. 0x40. 0xC0. 0xC0. 0xE0. 0xD0. 0x80. 0x00. 0x28. 0x41. 0x64. 0x6A. 0x80.MODBUS over serial line specification and implementation guide V1. 0xEA. 0xF9. 0x01. 0x41. 0x6E. 0x90. 0xD9. 0x00. 0xCE. 0x41. 0x07. 0x77. 0x58. 0x48. 0x41. 0x81. 0xA5. 0x81. 0xE1. 0x39. 0x83. 0x3D. 0xC1. 0x65. 0xC0. 0xAF. 0x94. 0x41. 0x41. 0xC1. 0xC0. 0x51. 0x81. 0x80. 0x80. 0x4B. 0x01. 0x80. 0x10. 0x17. /* Table of CRC values for low–order byte */ static char auchCRCLo[] = { 0x00. 0x81. 0x80. 0xC0. 0xDC. 0x05. 0xCA. 0x40. 0x93. 0x41. 0x80. 0xAB. 0x14. 0x19.org/ 43/44 . 0x3B. 0xCD. 0x41. 0x81. 0x81. 0x7D. 0x40. 0xC0. 0x01. 0x9F. 0x98. 0x26. 0xC1. 0x44. Low-Order Byte Table 0xC0. 0xC1. 0xBA. 0xC0. 0xC0. 0x7B. 0x81. 0x80. 0xF6. 0x00. 0x41. 0x80. 0xEC. 0x00. 0xBC. 0x5C. 0x32. 0x01. 0x24. 0x41. 0x01. 0xC0. 0x40. 0x80. 0xDF. 0x40. 0x40. 0x00. 0x1F. 0xF4. 0xA2. 0xB3. 0x38. 0x86. 0xC1. 0x36. 0xC4. 0x01. 0x81. 0x06. 0x81. 0xF1. 0xA6. 0x57. 0x35. 0x41. 0x41. 0x41. 0xB2. 0x40. 0x40. 0x81. 0x09. 0xC0. 0x61. 0xA9. 0xEB. 0xC1. 0x40. 0xF5. 0x6C. 0x78. 0x82. 0x89. 0xC0. 0x91. 0xD6. 0x80. 0x11. 0x81. 0xEF. 0x80. 0x45. 0x81.modbus. 0x02. 0xFA. 0x74. 0xAC. 0x34. 0x01. 0x80. 0x00. 0xC9. 0x41. 0x00. 0xC0. 0x2C. 0xA4. 0xC0. 0xC0. 0x41. 0xC1. 0x41. 0x01. 0x01. 0x80. 0x81. 0x00. 0xC1. 0xB1. 0x01. 0x13. 0xFC. 0x03. 0x0C. 0xE5. 0xA7. 0x80. 0x3E. 0x41. 0xC1. 0x41. 0xC1. 0x41. 0x67. 0x0B. 0xDD. 0x84. 0x76. 0x01. 0x41. 0xFD. 0x00. 0x59. 0xC0. 0xFE. 0xDB. 0x0D. 0xC1. 0xC1. 0xB4. 0xBB. 0xD5. 0xAA. 0xE7. 0xE8. 0xC0. 0x80. 0x80. 0x97. 0x0E. 0x01.
References ANSI/ TIA/ EIA-232-F-1997 ANSI/ TIA/ EIA-485-A-1998 Interface Between Data Terminal Equipment and Data Circuit-Terminating Equipment Employing Serial Binary Data Interchange.ORG 6.org Modbus.org/ 44/44 .MODBUS over serial line specification and implementation guide V1. MODBUS application protocol specification MODBUS. Electrical Characteristics of Generators and Receivers for Use in Balanced Digital Multipoint Systems.org 12/02/02 http://www.modbus.0 MODBUS.3 Appendix E .
Documents Similar To Modbus Over Serial Line V1
Planar4Pres.pdf
error detection and correction final general
monitoring_opencomms.pdf
T-REC-X.234-199407-I!!PDF-E
380xxm22