Modbus standard termination

R

Thread Starter

Roger Irwin

I have been reading the Modbus over serial line specification V1.0 ( http://www.modbus.org ) and have been left a little perplexed by the line biasing scheme.

In a normal RS485 network when the A line is positive wrt the B line then the line is in an idle state (mark). The modbus standard defines the A line as D0 and the B line as D1.

RS485 networks can suffer from false start bits between data packets which can occur while the line is in an high impedance state. There are 3 ways to ensure that this does not occur (or does not cause the loss of a packet):

1) Packets start with a pre-amble and/or doorstep (idle line period) which allows the main packet to be recieved even if the UART had been falsly triggered.

2) A defined and rigidly respected handover period is defined in ordr to ensure that the master returns to transmitting idle within a time that is less than than a minimum time in which the slave maintains the idle line, and visa versa. That way the line never falls into an idle state.

3) Bias resistors are used to maintain the line in a known state when in a high impedance state.

Modbus does not implement 1 or 2, which is not a bad thing as the 3rd method is by far the superior one as it has no bandwidth overhead. Unlike some standards such as DMX which hold the line in BREAK between packets, Modbus expects an idle line state, and therefore I would expect the bias resistors to hold the line in an idle state, that is with A/D0 pulled up to 5V and B/D1 pulled down to 0V.

The specification however seems to reccomend biasing to a break state.

The reccomendation also states that if terminators are used then the number of nodes must be reduced by 4. A common value for these bias resistors is 620 ohms. If we regard the supply as a short circuit, that means they represent a 1.2K load on the line, which would seem to be equivalent to 10 RS485 devices (a std. RS485 load is 12K). On the other hand The standard recommends a 150 ohm terminating resistor, a valid value, but as we all know, RS485 is frequently terminated with 120 ohm resistors. The 1.2K bias impedance in paralell with (1) terminating resistor is 133 ohms, i.e. I would suggest that both from a theoretical viewpoint (and from pratical experience) that it really is not that critical.

The standard also refers to the use of terminating resistors in series with a capacitor may be more appropriate for biased lines. The use of such a technique reduces power consumption in both biased and unbiased schemes. The only difference for biased networks is that it may allow higher values for the terminating resistors, say 10K, because the stop bit pulls the line into the idle state and thus only a minimum (leakage) current from the bias resistors is required to maintain the level. The specification however does not allow such techniques as the maximum value for a bias resistor is 650 ohms. This in itself is slightly odd (thougth not critical) as one school of thought indicates 680 ohms as an optimal value and hence use 620 ohms as the nearest standard resistor value, the modbus standard presumably takes the average of these 2 values!

Another interesting point about the bias resistor specifications is that they are considered as items that may be required by a device, and the device must be documented to state if they require them. This is very odd, **any** 485 modbus device is susceptible to false start bits and the issue of wether to use them is a system one, and not dependent on the device manufacturer. Personaly I would strongly reccomend bias resistors in all Modbus implementations however the standard requires device manufacturers to state that thier device must have them, which rather implies an inferior spec device, so presumably nobody does insist on them. I feel this part of the specification should be reworded to recommend bias resistors on all networks, and recommend that all master devices should be able to provide this bias.

BTW, another issue I have with these specs is the requirement for even parity as default on RTU devices. Allthougth I appreciate that the original Modicon devices all used even parity, this was probably because the UART's thay used had parity generators/checkers built in. Not all UARTS have such facilties, including many popular microcontrollers of the the sort that would be highly suitable for modbus devices. Implementing parity in code can be a serious overhead in a simple device and given that thier is a 16 bit CRC which is a more than adequate error detection technique for 256 byte packets (IP and hardisks only use 16bit CRC's for much larger packets), then perhaps it would be the case to derate the even parity requirement to an optional, and completely eliminate the odd parity which I suspect is never used.

The specification is also vague about higher baud rates. It would suggest that baud rates increase by doubling standard baud rate values (115K, 230K etc.). This makes little sense as at higher baud rates most UARTS will require a 'BAUD rate crystal' to get the correct clock rate, which in a microcontroller can be inconvinient as the UART Clock will be derived from the CPU clock, which may require other values for timing requirements etc. Given that over 115K one is unlikely to be using a standard serial port, it would make more sense to switch over to round number baud rates at higher speeds, i.e. 250K, 500K, 1M etc.

Just my 2C, perhaps I have not understood anything, but it would be interesting to hear what others think. ;-)
 
***********************
Modbus specifies the protocol, not the physical layer.
***********************

Any biasing or termination should be left up to the user and his implementation scheme which is based upon his requirements.

I add a prefix parameter option on my devices that will enable the driver but keep the output such that it appears to be a stop condition (high) for at least 1 full character time (user-settable in character times).

Preambles rarely cause a UART to synchronize and are widely misused and misunderstood. Driving the line with a STOP condition is the best option.

Also, if a slave has the bias and it were to be powered down, what will happen? The slave could disable the entire bus. This is why the use should implement his own biasing whether on an independent supply or on the master's end.

Max
 
R
> ***********************
> Modbus specifies the protocol, not the physical layer.
> ***********************

So what is the Modbus serial line specification? There are many 'must do' issues laid down, and recommended pratices which, to my mind, create rather than resolve problems.

> Any biasing or termination should be left up to the user and his implementation scheme which is based upon his requirements. <

As I pointed out in the document, I can see no decent reson for not specifying bias, and good reasons for clarification. Profibus, for example, has a standard terminating network which includes bias, and Profibus users don't even think about this problem.

> I add a prefix parameter option on my devices that will enable the driver but keep the output such that it appears to be a stop condition (high) for at least 1 full character time (user-settable in character times). <

This is one of the options I stated. It is not reliable for two reason: 1) It would require formal timing overlap limits to be defined, 2) One of the advantages of Modbus is that the master may be implemented on a PC's serial port without any special hardware or software drivers, however it would be impossible to ensure such critical timing under these conditions. BTW, the line high state is called an IDLE line, it is the state I would recommend biasing a line to, but the Modbus serial line specification appears to suggest biasing to a line low state (BREAK). This can cause problems for the Modbus protocol and is perhaps why people have had bad experience with biasing schemes.

> Preambles rarely cause a UART to synchronize and are widely misused and misunderstood. Driving the line with a STOP condition is the best option. <

Preambles, if correctly defined, can ensure correct packet reception, and do not entail critical timing on the part of the master. Their disadvantage is that they steal bandwidth.

> Also, if a slave has the bias and it were to be powered down, what will happen? The slave could disable the entire bus. This is why the use should implement his own biasing whether on an independent supply or on the master's end. <

This can cause problems in Profibus networks, when both terminating stations are powered down (in profibus biasing is implemented in the line terminators). However Profibus is a multi master system, in Modbus which is always single master it is sufficient to implement the bias on the Master. Indeed, I am suprised that the spec does not recommend this.

It may be debatable as to whether bias should be mandatory, but I feel that recommended schemes could be far better than what the spec proposes, indeed it appear to me that the recommendations are designed to **cause** problems rather than solve them.
 
It seems that we are on the same page here. I agree with you.

With UART-based protocols, biasing should be implemented so that the bus be in the IDLE state. Not doing so affects "any" UART based protocol - not just Modbus.

I do not think it is appropriate for Modbus-IDA to redefine an already accepted physical layer. In fact the serial spec you refer to makes reference to the RS485 spec.

As for termination issues, it depends on the user's implementation. Termination is only required when a line is long enough to be considered a transmission line. (based on the frequency components, in this case related to slew rate, of the signal) Most often, especially with limited slew rate drivers, the line does not appear to be a t-line. If it happens to be considered a t-line, the termination value is strictly dependent on the characteristics of the line (such as characteristic impedance) and the topology of the network.

I use #24TSP for my Modbus wiring. Because it has high-temperature and has UL flammability rating, the highest charactreistic impedance I could custom order was 50 ohms. After receiving the 1000ft custom roll of wire, (a few pairs, power, etc) my lab measured the impedance with a TDR. Zo is actually around 60 ohms. So for really long runs and high baud rates, what do you think I should tell my customers to use for termination? 100ohm, 120ohm, other?

I just read the serial spec and it does explain that the there should be only one bias point on the bus, preferably at the master or tap. This is good.

Now, the biasing is a little off but it is really dependent on the supply voltage and whether DC termination is used or not. Again, it should be at the user's discretion, not the device manufactureer's discretion.

But, it is simple to make it bias for either IDLE or BREAK with IDLE being preferred.

And about the prefix time that I spoke of earlier. Implementing this scheme does not affect the protocol at all. Since it is a single master system, the master can spend all day driving the bus if he wants. When a slave responds, the only requirement is that it wait at least 3.5ct before the data is sent. It can wait an hour to respond if it wishes, although impractical. What I do is wait 2.0ct and generate a 1.5ct IDLE prefix on my responses. Waiting 3.5ct and then generating a 1.5ct IDLE prefix is okay as well. Each are configurable up to 255ct so it is not really an issue.

(I have run into problems where masters and slaves get messed up when I reply faster than 8ct, although the spec says minimum 3.5ct.)
 
J
I'm coming in late in this discussion but just want to add my two cents that may perhaps explain the differences in approach.

Termination is usually only required at high speed, say about 200 kbit/s. Normally Modbus is not run this fast. Many use Modbus at 9600 kbit/s where terminator is not required. However, Profibus-DP is typically run much
faster, something like 93 kbit/s to 12 Mbit/s and then termination makes sense.

Jonas Berge
SMAR
===========
[email protected]
www.smar.com
Learn fieldbus and Ethernet at your own pace: www.isa.org/fieldbuses
Learn OPC and automation software at your own pace: www.isa.org/autosoftware
 
A

Automation Linse

I am a firm believer in RS-485 bias & agree with Jonas that termination rarely has a large impact in small systems. Bias very often solves site problems with repeatability.

However, the general problem with "fixing Modbus" - people doing new products wish to clarify such ambiguous points.

But large companies with literally hundreds (or thousands) of existing Modbus products with "creative" behaviors don't want such fixes as it risks big users demanding older product lines be updated to the new "standard". So they prefer the status-quo; confusing as it may be. Putting a stake in the ground to say method 1 of 5 alternatives is "standard" breaks a lot of existing products.

(my opinion: I'd like to fix & work forward. But how to drive larger interest at modbus.org?)

best regards
- LynnL, www.digi.com
 
C

Curt Wuollet

Hi Lynn

Actually, the diversity makes it interesting. It could be much worse. It could belong to one company, be secret, and nobody elses would work with anything you could buy. Like the other 99% of the automation stuff. Strangely it's the only thing that's not called "open" these days. Someone called Metrikon has been mail bombing me with "open" windows crap again lately. Propagandists _and_ spammers.

Regards

cww
 
C

Curt Wuollet

Which would kill it immediately as a free and Open protocol. I think the people have spoken and would rather have free Modbus with all it's warts. It's a shame other companies can't see this correlation. Open = ubiquitous, closed = obscure. Controlled = closed. There are certainly enough examples.

Regards

cww
 
M

Michael Griffin

Software specifications often tend to be a bit ambiguous in the details. What seems to work best is for an actual implementation to become the defacto standard. If there are any implementation questions which are not answered by
the written specification, they can be answered by looking at the source code.

The key seems to be to have a single universally accepted software source code implementation that can be distributed (and re-distributed) freely. Once this implementation is widely accepted, the written specification is "clarified" to conform to *it*. What this means is that whoever volunteers to write (or donate) the reference implementation is the one who gets to decide the
details.
 
C

Chris McBrien

I'm looking at a diagram where A is closer to the ground side of the supply voltage and B is closer to the +5 Volt rail. Is this the correct way around? This is in the static no data state. So in the static mode B must be more positive than A. The three resistors used in the bias/termination network are 1k2, 120, 1k2 Ohms.

I have seen other diagrams where the A & B labelling has been the other way around. Which is correct?

Chris
 
C
Hi Michael

Yes, the problem with ModBus is that the reference implementation, published by Modicon, came after just about every other implementation in the world. They came upon the formally open notion a bit too late, but better late than never. But the next daring entity that would like their protocol to become truly popular, if not ubiquitous, can do even better by publishing a no-nonsense, truly open, implementation that people are free to use, upon release and avoid the whole issue. Some
smart company is going to do that with a good protocol and get market share and takeup that the control freaks only dream of. And my bet is that they will see far more revenue that way than with transparent attempts to make people pay at every turn to use a protocol.

Regards

cww
 
A

Automation Linse

Unfortunately, neither is "correct" & neither "wrong".

EIA-485 unfortunately defined A/B as logical & not electrical meaning. Thus one of the oldest chip lines (the TI SN75176) labelled its pins for tele comm usage in the old transister-logic days when 5v = binary 0, and 0v = binary 1. All of the hundreds of newer chips have followed this convention. So product vendors who "assume" Texas Instrument knew what they were doing label their A/B "backwards" from how modern computers use the wires. Other vendors "fix" this backwards labeling and connect the TI chip "A" to their "B" and so on.

End result is from now to eternity you'll NEVER be able to know without testing if one vendor's "A" is another vendor's "A" or "B". Fortunately, EIA-485 chips cannot be damaged by reverse wiring

- Lynn A Linse, www.digi.com
 
Top