Modbus RTU Framing Question

C

Thread Starter

criders

Hello all,

I am trying to create an embedded controller that has a Modbus Communication protocol. I am still in the early stages of learning about the microcontroller that I am using. Anyhow, I do not know how to determine the silent interval of at least 3.5 character times for the message framing or the silent interval of more than 1.5 character times occurs between two characters.

Example is the Baud Rate is 9600
then:
Message Frame Value = (1/9600) * 3.5 = 365uS
Chr Frame Value = = (1/9600) * 1.5 = 156uS

I have no idea if this i the right way to determine this. Any help would be cool.

Thanks,
criders
 
J

Jerry Miille

You are off by an order of magnitude. You are using bit time in your calculations and you should be using character time which is 10 or 11 bits depending on your serial port settings. Strictly by the spec, a character is always 11 bits, one start, 8 data, 1 parity and 1 stop. If no parity is used then there should be 2 stop bits.

Miille Applied Research Co., Inc
http://www.miille.com/
Jerry Miille
 
Thank you Jerry for the response!

Please bear with me. This is the first time I have ever tried to create something like this. Most of my experience with Modbus in the past was from the a host PC and I learned just enough to get data from the various types of controllers.

If I am understanding everything correctly,

Example is the Baud Rate is 9600
then:

Character Time = (11 characters)/9600kBd
= 1.14ms
Message Frame Value = (1.14ms) * 3.5 = 4.01ms
Chr Frame Value = (1.14ms) * 1.5 = 1.71ms

Is this it or is it time for me to start my new career as a contestant on those TV reality shows?

criders
 
J

Jerry Miille

To be correct you should say Character Time=11 BITS/9600 baud (not Kbaud). That is 9600 bits per second.

You have the final numbers right, but I have to tell you that almost no one pays strict attention to them. You will find lots of applications that have inter-character delays of longer than 1.5 character times, even longer than 3.5 character time in some cases. You will need to build in a way to override the specification numbers.

Think about this: if two devices are attempting to communicate using Modbus RTU and BOTH really use the 3.5 character time as a framing mark then the communication will never work because it is impossible to synchronize to EXACTLY 3.5 character time between two independent systems. That is why the framing time is specified to be 3.5 character time OR LONGER.

Or suppose your connection is over a modem or a satellite. There could be significant delays inserted in the bit stream that will exceed the specifications that are beyond your control. Build in a way to adjust this time.

Most modern day microcontrollers have very precise timers that can be used to set the delays but I repeat, build in a way to adjust the timing if you want a product that will work everywhere.

Jerry Miille

Miille Applied Research Co., Inc.
http://www.miille.com/
 
Top