Is it possible to synchronize the time/clock between MODBUS master and slaves?

Asked by Yishin Li

Hello,

I am currently evaluating a suitable communication protocol for real-time control through USB interface. One of a very important requirement is synchronizing the time between Master and Slave nodes. I'm wondering if this is included in the MODBUS protocol, or, could it be implemented with extended functions?

Regards,

Yishin

Question information

Language:
English Edit question
Status:
Solved
For:
libmodbus Edit question
Assignee:
No assignee Edit question
Solved by:
Todd Denniston
Solved:
Last query:
Last reply:
Revision history for this message
Best Todd Denniston (todd-denniston) said :
#1

Yishin Li wrote, On 05/14/2009 11:10 AM:
> New question #71150 on libmodbus:
> https://answers.launchpad.net/libmodbus/+question/71150
>
> Hello,
>
> I am currently evaluating a suitable communication protocol for
> real-time control through USB interface.

You are aware that as soon as you put more than one device on an originating
hub (in the computer) USB becomes a less than real-time interface right?
I have seen Folks attempt to do NTP through USB GPS interfaces, and if there
is ANY other device on that independent hub, the time gets VERY jittery.

> One of a very important requirement is synchronizing
> the time between Master and Slave nodes.
> I'm wondering if this is included in the MODBUS protocol,
> or, could it be implemented with extended functions?

It has been a while since I looked at the MODBUS protocol, but if you could
send a current time (of day/year) in a message at something like pulse per
second rate, and feed that into NTP on the slave you might achieve what you
desire.

I would further suggest looking at the NTP code to see if it can act as a
serial server, if so hook it into sending the PPS messages.

>
> Regards,
>
> Yishin
>

--
Todd Denniston
Crane Division, Naval Surface Warfare Center (NSWC Crane)
Harnessing the Power of Technology for the Warfighter

Revision history for this message
Yishin Li (yishin-li) said :
#2

> Todd Denniston proposed the following answer:
> > Yishin Li wrote, On 05/14/2009 11:10 AM:
> >
> > I am currently evaluating a suitable communication protocol for
> > real-time control through USB interface.
>
> You are aware that as soon as you put more than one device on an originating
> hub (in the computer) USB becomes a less than real-time interface right?

I should measure the delay for multiple USB devices for a single hub later.
Currently, my configuration is one USB 1.1 device with FTDI FT245R as the usb
transceiver. The usb_write(pc_to_usb) delay is around 1 ~ 2 ms; the round trip
delay(a usb_write() followed by a usb_read()) is around 1 ~ 7 ms. The reason
is explained at 2.2 (page 5) of
http://www.ftdichip.com/Documents/AppNotes/AN232B-04_DataLatencyFlow.pdf

As a result, for EMC2 project (http://www.linuxcnc.org/), it's difficult to
generate accurate pulses for servo/stepper motors with USB interface. I'm
thinking of resolving this issue by streaming the SERVO commands through USB.

My draft idea is to modify the MODBUS RTU protocol a bit, i.e. replacing its
Stop-and-wait ARQ behavior with Go-Back-N. The goal is to eliminate the
effect of USB latency, yet keep the connection reliability provided by modbus.

How do you think about this approach? Does it have fundamental flow?

> > One of a very important requirement is synchronizing
> > the time between Master and Slave nodes.
> > I'm wondering if this is included in the MODBUS protocol,
> > or, could it be implemented with extended functions?
>
> It has been a while since I looked at the MODBUS protocol, but if you could
> send a current time (of day/year) in a message at something like pulse per
> second rate, and feed that into NTP on the slave you might achieve what you
> desire.
>
> I would further suggest looking at the NTP code to see if it can act as a
> serial server, if so hook it into sending the PPS messages.
>

Thanks, this input is helpful.

--
Yishin Li

Revision history for this message
Yishin Li (yishin-li) said :
#3

Thanks Todd Denniston, that solved my question.

Revision history for this message
Stéphane Raimbault (sra) said :
#4

What solution are you using finally (NTP or protocol modification)?

Revision history for this message
Yishin Li (yishin-li) said :
#5

Hi Stephane,

I need both. NTP is for eliminating the jitter of USB packet arrival time (essential). Go-Back-N is for fully utilizing the available USB bandwidth (optional).

My next task is bring the MESA 7i43 usb board (http://www.mesanet.com/motioncardinfo.html) be aware of MODBUS protocol. That requires some verilog coding and FPGA programming.

Also, I'm evaluating the implementation for modbus-over-usb. The MBAP will be identical to MODBUS/TCP. And, I'm thinking of implementing a hardware abstraction layer for variety of USB devices. I'm learning UrJTAG for how they isolate the application/protocol layer from hardware layer.

Yishin