Regarding Modbus

A

Thread Starter

Aditya Ayachit

Hi All!
I have a few questions regarding MODBUS:

The Modbus documentation says that the ASCII protocol has the following feature:

"The main advantage of this mode is that it allows time intervals of up to one second to occur between characters without causing an error."

What is troubling me is following:

What is the reason for allowing such a long interval between 2 characters?
Why is it only there in ASCII format and not in RTU ?
Why is this interval baudrate independent?
( i.e if 1 sec. interval for 9600 baud then 1/2 sec. for 19200 baud)

Another fundamental question that is troubling me is why use ASCII protocol when :
1. It is inefficient in terms of number of bytes sent
2. Larger computation required by Master and slave to cipher / decipher the message

I would appreciate a few examples where ASCII format is used.

Aditya

_______________________________________________
LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc



 
K

Kelvin Proctor

> What is the reason for allowing such a long interval between 2 characters?
> Why is it only there in ASCII format and not in RTU ?

One of the problems with RTU mode is that it is *very* critical that you get the timming correct for it uses a >=3.5 character time break to mark between the frames. This is difficult to measure accuratley under some UARTS and some communications APIs. I'm implementing Modbus in the jModbus project (http://jmodbus.sourceforge.net) and under the java comm API this is quite difficult. IT's easy for a master but for the slave it can be a real pain to get working properly.

Scanning for a : and CR LF sequences is very easy by comparison on some systems.

> Another fundamental question that is troubling me is why use ASCII protocol when :
> 1. It is inefficient in terms of number of bytes sent

This is why most people don't use it any more. Most places use RTU now for the exact reason mentioned above. ASCII mode is really a bit of a hangover from the days when things were much harder to do with micros etc.. (the spec was written in the 70's)

> 2. Larger computation required by Master and slave to cipher / decipher the message

As per above. Althought it is really not that much computation and it not very difficult computation.

Cheers,

Kelvin
 
B

Bob Peterson

Modbus ASCII format is convenient to use over a Modem because there is no guarantee that the entire Modbus packet will be send as a single Modem packet. If a Modbus RTU packet is broken into two parts by the modem, the Modbus packet will be discarded by the receiver, where as if the modem breaks up an ASCII packet it does not matter.

Modbus ASCII format is also handy to use under Windows NT where it is near impossible to get the hardware when you need it. The timing of the RTU format requires that you have control of the serial port that NT refuses to give you. You can use ASCII format under NT without this problem because the timing is not so critical.

You might want to use ASCII format if you are using (for instance) an PLC BASIC module to interface with a Modbus device. It is MUCH simpler to format the strings and you can use a simple terminal emulator to debug things because the sent/received strings are ASCII characters you can actually see. In RTU format, they are gibberish.

ASCII format uses LRC error checking which is somewhat simpler to implement than the CRC error checking used by RTU.

Bob Peterson

_______________________________________________ LinuxPLC mailing list
[email protected]
http://linuxplc.org/mailman/listinfo/linuxplc

 
R

Ryan Van Slooten

-- Bob Peterson wrote:
> Modbus ASCII format is convenient to use over
> a Modem because there is no guarantee that the
> entire Modbus packet will be send as a single
> Modem packet. If a Modbus RTU packet is broken
> into two parts by the modem, the Modbus packet
> will be discarded by the receiver, where as
> if the modem breaks up an ASCII packet it does
> not matter.

This may have been a problem with old 8250
UARTs, but seriously, I've never had a problem
with split packets and Modbus/RTU. Also, since
ASCII packets are twice as long plus one more
byte, you are more likely to split the message
than the shorter RTU.

> Modbus ASCII format is also handy to use under
> Windows NT where it is near impossible to get
> the hardware when you need it. The timing of
> the RTU format requires that you have control
> of the serial port that NT refuses to give you.
> You can use ASCII format under NT without this
> problem because the timing is not so critical.

I have programmed Modbus drivers on NT (and
Linux) many times and I've never had problems
getting access to the serial port. Just use
CreateFile with "COM1" and ReadFile/WriteFile.
Even if you wanted to access the serial driver
directly, that isn't hard either.

<snip/>

> ASCII format uses LRC error checking which is
> somewhat simpler to implement than the CRC error
> checking used by RTU.

Since both algorithms are published and well
known, I don't think either are difficult to implement.

Regards,
Ryan Van Slooten

______________________________________________
LinuxPLC mailing list
[email protected] http://linuxplc.org/mailman/listinfo/linuxplc
 
J

J.P. Cuzzourt

Also, in noisy situations, esp. cheap radio modems for SCADA applications, Modbus RTU is impossible to implement because just keying up the mic. generates enough noise to fool the listeners into thinking a transmission has begun. Modbus ASCII is workable in this situation because there is a start character :)) that must be received first; thus the initial noise bits are ignored, rather than incorporated into the CRC.

J.P. Cuzzourt

_______________________________________________
LinuxPLC mailing list
[email protected] http://linuxplc.org/mailman/listinfo/linuxplc

 
J

Jeff Couperus

I haven't researched the timing and details of RTU mode communications however, in my years of experience with SCADA radio, dial up, and leased line communications ASCII protocol is much easier to implement and works in situations where RTU won't. As far as RTU working with modems it sounds good in theory but I've had numerous systems using standard US Robotics dial up modems which I can't dial into remotely and stay connected while programming with Modsoft for over 30 seconds with RTU mode that I can conect to reliably for as long as needed using RTU mode. In fact on some notebook computers Modicon's concept programming software will not stay cannected reliably in RTU mode even using a direct serial cable connection. Modicon tech support advised us to us ASCII when having problems and it worked. ASCII is slower and RTU is preffered if a reliable connection can be established.
 
M

Mike McCafferty

The ASCII version of Modbus is mainly for keyboard entry using a terminal program. It allows 1 second between bytes no matter what the baud rate because it could be manually typed in by the user. This is good for debugging, and not having a special HMI program or Modbus program. I never use it or specify it because it really is not necessary nowadays.
-Mike
 
> Another fundamental question that is troubling
>me is why use ASCII protocol when :
> 1. It is inefficient in terms of number of
>bytes sent
> 2. Larger computation required by Master and
>slave to cipher / decipher the message

I just wanted to throw my 2 cents in on this. I think ASCII is more reliable. I have had a few cases where RTU flat out would not work and ASCII worked like a champ. Mostly this was with radios and modems. Although, I use ASCII to program from my laptop now because I run modsoft on a 500 MHz machine.

The reason ASCII is more reliable is that RTU is a timing based protocol. So anything that can affect transmission times will hose RTU.

I try to use RTU whenever i can because its faster, a little more secure, and when it works i guess its more reliable. But, if i had to choose 1 protocol to use with modbus for the rest of my projects, it'd be ASCII, hands down. I haven't found an application yet where ASCII flat out would not work.

-jeff
 
Top