Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Modbus RTU

Status
Not open for further replies.

desgin

Full Member level 1
Full Member level 1
Joined
Apr 7, 2017
Messages
96
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
813
Hello All,

In Modbus RTU mode, messages start with a silent interval of at least 3.5 character times.
I want to make it ( idle mode in interval of 3.5 character times ) using uart of PIC microcontroller.
How Master/Slave recognizes the silent interval when the stream of data receives to RX ?
How can i make a logic for the same in MPLAB X IDE ?

Thanks,
Desgin
 

Hi,

On any UART transfer the last bit should be the STOP bit ("0").
So you can (re)start a timer on every "0" ... with a timeout of 3.5 charater times. (Probably my choice).

Other SW option:
If you use a UART_receive_ISR then you might trigger the timer here.

Or you can build a retrtiggerable monoflop (hardware), to trigger an interrupt.

All these options will trigger an interrupt after the 3.5 characters idle time.

****
But I think the 3.5 character times does not have to be exact 3.5 character times but >=3.5ct.
If so, you don´t need an 3.5ct interrupt, but simply a "clear to send flag".
Then, just before sending a new message you have to poll and "wait for the cts flag".

Depending on the microcontroller .. it may have supporting hardware for this.
I´ve used this feature on an STM32F10x

Klaus
 

Actually, the MODBUS interoperability lab tests for an RTU interframe gap of 3.5 character's' duration at 19200 bps and below, but at 38Kbps and above they only need ~ 1.75milliseconds (I use 2 milliseconds). This is what I have implemented in shipping product and it has passed MODBUS-compliance lab certification with these recommendations, worked through gateways, etc..

What I found to be the simplest code implementation, was to simply run a 1 millisecond free-running timer interrupt (you could choose 2 millisecond on really constrained MCU) that increments a tick count.. Then, in your code where you process a received MB-RTU msg frame to see if it is for you or not, you just grab the tick count when you determine the msg is valid for you. When you have a response ready in queue to send, just grab the current value of the tick counter and compare/subtract the tick count from the "msg is for me" tick count. If the difference is >= the required number of millisecond ticks then your code starts the transmission of the response. Just be sure to handle the rollover of the tick count properly in your checking.
 

MODBUS has two idle specifications, t1.5 and t3.5. Messages must be transmitted continuously with not more than t1.5 inter-character space. Between messages, at least t3.5 idle time must be kept.

Respectively a receiver checks for > t1.5 gaps to reset the state machine to idle state. The actual detection threshold would be set somewhere between t1.5 and t3.5.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top