MODBUS Address

R

Thread Starter

RAMA

Hi,

I am a newbie here and to MODBUS. I am writing slave program to communicate with a MODBUS master. I am confused about how many bits are there in address. Does the address have 9 bits so as to distinguish from other bytes? If so, can I take it as beginning of the frame?

If it has only 8 bits, how do I identify the beginning of the frame? I am thinking of a condition in which my slave is just powered on, and I could be in the middle of the frame!

Thanks in advance
 
The Modbus Standard Modbus over Serial Line V1.02 (downloadable for free at Modbus.org) says:

The format ( 11 bits ) for each byte in RTU mode is:
Bit order per Byte:
1 start bit
8 data bits, least significant bit sent first
1 bit for parity completion
1 stop bit

The requirement for a parity bit is frequently ignored with the widespread use of 8-N-1 format.

So, in answer to your question, the start bit is the initial bit seen on the serial line.

Any slave device that "awakens" during the middle of a message will ignore the message because the CRC won't match up to a partial message and the address byte will have been missed or will be partial and uninterpretable.
 
R

RAMA DASARATH

Thank you very much David.

Thanks again for the swift response too.
So that means, I start looking for the frame from my slave address, and if the CRC does not match, I go back to looking for the next address that is matching my slave address! Kindly correct me if I am wrong.
I was expecting some simpler way (which I thought I was missing) to identify the beginning of the frame.

Thanks once again for the excellent and precise info that I was looking for.
 
L

Lynn August Linse

Technically, you are also supposed to watch for time-gaps in the bytes. The serial line should be idle for at 3.5 character times BEFORE the slave address, and then the rest of the message should not have more than a 1.5 character time-gap between bytes.

You cannot just keep looking for a valid CRC as bytes fly in, as there is a high probability that from time to time you'll detect a valid CRC calculation in the middle of a message. So you need to either decode the message & estimate lengths, or wait for the 3.5 character time-gap after the real CRC.

You can find the Modbus serial standard at modbus.org.
 
Top