LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time synchronization using SNTP

Hello all,

 

I my trying to set up SNTP synchronization of my cRIO to NTP server. To do that, I followed instructions in: http://digital.ni.com/public.nsf/allkb/F2B057C72B537EA2862572D100646D43

When I did reboot on my cRIO, time synchronization was successful. Then I changed the clock on cRIO manually to be 2 minutes ahead of that on NTP server. In this way I wanted to test the time synchronization, but nothing happened, i.e. after 30 minutes of waiting clock on the cRIO is still 2 minutes ahead (synchronization interval is set to 5 seconds).

My question is - if I set the clock on cRIO manually to be 2 minutes ahead, will it always be 2 minutes ahead, i.e. will it be synchronized like that? Or SNTP synchronization is not working well?

If synchronization is working well (i.e. it synchronizes 2 minutes ahead because of my manual intervention), how can I test that synchronization is working well during runtime?

 

Also, I've read somewhere that after synchronization fails to connect with SNTP server 5 times, it won't try ever again. Is this true, and if it is how can I change this?

 

Best,

Marko.

0 Kudos
Message 1 of 13
(6,612 Views)

UPDATE:

 

I did a test with 2 cRIO devices. Both of them are configured to synchronize with NTP server, and they synchronized successfully on reboot. Then I manually changed times on both of them (not long after reboot), where I set the first cRIO to be 20 seconds ahead NTP server time, and the second cRIO to be 20 seconds behind NTP server time. After 12 hours of runtime, times on both cRIO devices are still 20 seconds ahead/behind NTP server time. Time synchronization update interval was set to 10 seconds on both of them.

 

Now I'm confued how time synchronization works on cRIO devices. As I see it, there are two possibilites: (i) clocks were synchronized on reboot, and shortly after that I manually changed the clocks to be 20 seconds ahead/behind NTP server time - maybe cRIO now "thinks" that this is normal situation, i.e. to be 20 seconds ahead/behind; or (ii) NTP time synchronization works only on reboot.

 

In another thread, I read that after 5 failed attemtps to connect to the NTP server, cRIO will quit trying. I'm not sure what does this mean. If it means that cRIO will never again try to connect to the NTP server, this is not good since there is no possibility to define a backup NTP server using ni-rt.ini configuration file. If it means that the cRIO will, at each update event (in my case every 10 seconds), try to connect up to 5 times then this is OK.

 

If I really have a problem with "automatic" time synchronization using NTP via ni-rt.ini configuration file, would you suggest that I do this synchronization programmatically? What is the expected time synchronization accuracy in this case? Another upside of this approach is possibility of defining backup NTP servers. There are few good threads explaining how to do this: https://decibel.ni.com/content/docs/DOC-36432https://decibel.ni.com/content/docs/DOC-26987

 

I'm sorry to have so much questions, but the documentation on NI TimeSync via SNTP is very poor. All I was able to find was this: http://digital.ni.com/public.nsf/allkb/F2B057C72B537EA2862572D100646D43

 

Best,

Marko.

0 Kudos
Message 2 of 13
(6,574 Views)

UPDATE2:

 

After some Googling, I found out that there is a ptpd package (implementation of IEEE 1588 protocol) for Ubuntu, and since all these devices are working on the same network, I decided to give it a shot. After rebooting, cRIO devices detected automatically my server (running Ubuntu Server) with the ptpd package, and now they use it as a master clock for time synchronization. However, I'm unable to configure ptp on my cRIO manually. Attached you can find the screenshot of Time Synchronization using Software 1588 Time Protocol (Ptp) 14.0.0 in Measurement & Automation Explorer 14.0.0f0. As you can see, I can only change the value of Priority One - I wasn't able to find any detailed documentation of the NI PTP plugin, so I assume that 128 is the highest priority?

 

My question is: how can I manually set cRIO devices to be slaves, and how can I manually enter the master clock ID, since I don't want them to switch the master clock after someone else maybe comes into the network. I'm also confused with the State of the cRIO device - it is clear from the cRIO Clock ID and the Master Clock ID that the cRIO device is not the master, and yet under State it says that the cRIO is the MASTER. I don't understand this. When I shut down my server and reboot cRIO devices, then one of cRIOs is the master and the other is slave, but when the server is running and providing the master clock, both of them are masters although they shouldn't be Smiley Sad

 

Is there any detailed documentation of the plugin Software 1588 Time Protocol (Ptp)? I don't know what will happen when cRIO devices loose contact with the Master Clock, or how often cRIO devices are synchronizing. Aggghhhh Smiley Indifferent

 

Another question - how do you determine Clock ID of the device. Is this the MAC address of the network card?

 

Best,

Marko.

0 Kudos
Message 3 of 13
(6,546 Views)

I forgot to add the atachment in my last post, and since I cannot edit the previous post I'm posting a new message.

 

Message for moderator: Can you please merge my 4 posts, there is no need for them to be in separate posts. Thanks!

 

Best,

Marko.

0 Kudos
Message 4 of 13
(6,534 Views)

Hi mgulin, 

 

Thank you for your inquiries. Let's try to narrow down the scope of your questions first. Are you going to move forward with NTP or PTP for your timing synchronization? 

 

It may take some time to dive into the depth of your questions, but will try to answer them promptly! 

 

Best, 

Cameron Schaefer

Applications Engineer
National Instruments
0 Kudos
Message 5 of 13
(6,445 Views)

Hi Cameron,

 

Which time synchronization (NTP or PTP) am I going to use depends on your answers 🙂 Let me try narrow down my questions:

 

- What happens when cRIO loses contact with NTP server? I read somewhere that the cRIO will try to connect to NTP server 5 times and then quit trying. I'm wondering, what does this "quit trying" mean: (i) cRIO will try again 5 times after specified sync period expires (e.g. 10 seconds), (ii) cRIO will never try again.

- Is there any threshold under which NTP is continuously synchronizing? I did a NTP time synchronization test, where I manually changed the time on the cRIO to be 20 seconds ahead of the time on NTP server. After 24 hours, clock on the cRIO was still 20 seconds ahead. As I see it, there are two possible reasons for this: (i) there is some threshold for NTP to work properly, (ii) NTP is not working well, i.e. NTP does not synchronize the cRIO time continously. Please note that synchronization via NTP was successful on the cRIO reboot.

- Is there any way to manually configure PTP on the cRIO. In my previous post, in the attached file you can see that I can only change the priority. However, I cannot specify master clock, or even the "working mode" of the cRIO, i.e. I cannot configure cRIO to be MASTER or SLAVE.

 

Maybe I didn't mention this before, but I use Ubuntu Server, where I installed packages for NTP and PTP.

 

Thank you for your time!

 

Best,

Marko.

0 Kudos
Message 6 of 13
(6,432 Views)

Marko, 

 

According to the KnowledgeBase article you referenced (How do I Configure My CompactRIO Controller to Synchronize to SNTP Servers), there is an error tolerance that will cease to adjust the processor clock if the tolerance is exceeded. However, after reviewing some internal documentation, this may not be true. It looks like the only reason it would not attempt to sync is if the server fails to connect 5 times. Afterwards, it terminates the thread and will not continue trying to sync unless prompted to do so. 

 

When configuring PTP, only the priority field is editable - the lowest priority cRIO on the network will act as the master. Setting the time of the master cRIO can be done in software using the functions provided in LabVIEW RT, or manually in MAX. However, it should be noted that you cannot use both SNTP and PTP simultaneously on a single cRIO. 

 

The documentation for this functionality is limited, so diving into these particulars will take time and collaboration with our R&D Department.  If you want to synchronise to sub milisecond precision this has to be done with PTP with cRIOs on the same network. Otherwise, across multiple networks, you would have to use SNTP to sync with some external timeserver. This would not provide the same level of accuracy as PTP.

 

Let me know if this helps, and what you would like clarification on. 

 

 

Cameron Schaefer

Applications Engineer
National Instruments
0 Kudos
Message 7 of 13
(6,366 Views)

Cameron,

 

- since I cannot specify backup SNTP server, i don't want to my cRIO to stop synchronizing if my server crashes for a day or two, so automatic SNTP via configuration .ini file is out of question

- since I cannot edit other fields in PTP, e.g. I cannot specify the master, then PTP is also out of question

 

I'm not interested in synchronization on milisecond precision, but on second precision. I've noticed that cRIO devices have drift that is not negligible, and drifts very fast (4-7 seconds per week). It seems that I should do this time synchronization programmatically. Can you please refer me how should I do this, since I cannot find any documentation.

 

Thanks!

 

Best,

Marko.

0 Kudos
Message 8 of 13
(6,285 Views)

Marko, 

 

Any "networked" synchronization runs the risk of losing communication. Additionally, you can specify the master in PTP - the cRIO with the lowest priority will act as the master. The default priority is 128, so all you would need to do to set a particular cRIO as the master is change the priority to 127 or lower. I'm not too sure what the alternative would be if you do not want to use PTP or SNTP. You will still need a time reference to recognize the drift. 

 

What is your overall application? How many cRIOs are you trying to synchronize? 

 

Below are two examples of synchronzing multiple cRIOs: 

 

http://www.ni.com/white-paper/4217/en/

https://decibel.ni.com/content/docs/DOC-14770

 

 

Cameron Schaefer

Applications Engineer
National Instruments
0 Kudos
Message 9 of 13
(6,233 Views)

If you have a look here there is lots of information on the various time server protocols, you can probably implement one using TCP/IP in LabVIEW if you want to "roll your own" http://wiki.tcl.tk/3391

 

You can then use the system configuration VIs to update the date/time on the cRIO.

 

Probably not suitable for high-accuracy applications but good enough for the 1-second accuracy you're looking for.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 10 of 13
(6,218 Views)