LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use network time protocol on ciro to get timestamp?

Solved!
Go to solution
I would like to grab a timestamp from a network time protocol server like NIST on a cRIO device connected to the internet. How can I do this? There has to be someone in our labview community that has done this before or knows how to do it. Code examples appreciated 🙂
---------------------------------
[will work for kudos]
0 Kudos
Message 1 of 13
(5,700 Views)

Hi rex1030,

see this search results link.

 

I think #3 and #4 should help.

 

Mike

Message 2 of 13
(5,696 Views)
Solution
Accepted by topic author rex1030

Open Mouth, insert foot. http://digital.ni.com/public.nsf/allkb/F2B057C72B537EA2862572D100646D43

 

cRIO can now (8.6) automatically syncronize to an SNTP server on a specified interval. If I set that up it will automatically keep the system clock right and i can just grab the system time when i need a time stamp.

 

Why isnt the NI search as good as just using google to search the NI site? Why doesn't NI implement a google search? It's so easy i have it on my websites.

---------------------------------
[will work for kudos]
0 Kudos
Message 3 of 13
(5,695 Views)

Hi Rex,

 

Sorry to re-open an old thread - did you get the SNTP synchronisation working on your RT target?

 

I'm trying to do this on a cRIO-9014 to synch with the clock on my PC (trying to synch 5 RIOs on a LAN) and am not convinced it's working, but not sure how to debug.

 

Did you use an internet-based SNTP server or a local one? If a local one, can you let me know what you used (and if it's free!)

 

I've tried turning on the verbose errors and am looking in the error log via MAX but not seeing any errors - does anyone know whether errors from the service will get stacked in here??? Or any other ways to debug and see if it's doing what it's supposed to, or if not, then why.

 

Any help appreciated!

 

Cheers,

 

Mark

Certified LabVIEW Architect
0 Kudos
Message 4 of 13
(5,587 Views)

The network time protocol functionality of the crio synchronizes the crio's internal time to that of a Network Time Protocol server once per minute. This insures the crio's time is always accurate within a few milliseconds (I forget the exact specs).

 

Using the article linked earlier i modified the ni-rt.ini file with the code given there and used the ip of one of the NIST Automic Clock NTP servers in Boulder, Colorado, which I found here: http://tf.nist.gov/tf-cgi/servers.cgi

 

I have tested and confirmed this works quite well for my application.

 

From my understanding, you are trying to use the crio's NTP functionality to synchronize the crio to the clock on your computer. Considering the fact that the crio's clock is much more accurate than the one on your pc, this seems a little backwards. What I would suggest you do is find a program that synchronizes your computer's clock to an external NTP server and choose the same NTP server that you have configured the crio to synchronize to. I recommend one of the NIST servers I told you about. I do know that windows has the ability to synchronize your clock to an NTP server of your choosing and you may not need to get any external software at all, you and your crio would just need an internet connection

 

You did not specify what kind of accuracy in your synchronization you were hoping to achieve, but be sure to look at the specs of both the crio sync and the program on your pc to see what kind of accuracy you will be getting. 

 

If this is not an option, there is another way to 'synchronize'. If you are using a crio-pc architecture where the pc is triggering an acquisition on the crio you can simply record the pc's time when the trigger is sent and send that timestamp over shared variable to the crio to be recorded along with your data as the time when the acquisition started. Then the dt between data points will remain constant so you can extrapolate timestamps from there.

 

I hope I helped. Let me know what you think.

---------------------------------
[will work for kudos]
Message 5 of 13
(5,564 Views)

Hello Mark,

 

I had difficulty using the built in Windows XP NTP server, is that what you are trying to use?  I'm not sure if I was setting things up wrong or what but it never worked for me.  I ended up using http://www.meinberg.de/english/sw/ntp.htm and it worked great.

 

rex1030, you are correct that the PC clock isn't the greatest, but in my case I needed to keep the time on the PC and several cRIOs in sync and I didn't have internet access.

 

I don't know if error messages would be accessible from MAX but I do know that there are console prints (at least there are in 2009 and I expect there are in 8.6).  See http://digital.ni.com/public.nsf/allkb/354A5124E6A667988625701B004A77CD for information on accessing the cRIO's console out.

 

Let me know if you have any more questions.

 

Sebastian

Message 6 of 13
(5,560 Views)

Hi guys,

 

Thanks for the tips! My application is similar to Sebastian's - ie: I need the 5 RIOs to be synchronized to (approximately) the same time, but I'm not too worried whether that time is synchronized to an external server or not.

 

I'm not expecting the LAN the RIOs are on to be able to see the external internet, so I was thinking of steering clear of using internet-based time servers and using a local one. I think I downloaded the one you linked earlier - so might give that a go again.

 

Just one more question - how tight can you expect the synchronisation between networked devices to be with NTP/SNTP? The devices only sample at 1 second period at the very fastest, so I'd ideally like them to be within 500ms of each other, and I can just about achieve that by pinging them UDP packets from the host PC with the latest time and using the time update VIs, but I know it's not an ideal way to do it. Can I realistically expect timing synchronization with time servers to be as tight as this requirement or tighter?

 

Cheers for the quick replies!

 

Mark

 

 

Certified LabVIEW Architect
0 Kudos
Message 7 of 13
(5,547 Views)

The accuracy you get from NTP/SNTP depends a lot of network latency.  Wikipedia claims about 10 ms for NTPv4 on the public internet, but as good as 200 us on a local network. 

 

SNTP uses a simplified algorithm that results in lower accuracy so I'd hesitate to say you can expect those kinds of numbers, but based on what I've read and my experiences, I expect SNTP on a local network to greatly exceed the requirements you have described.  Perhaps the best thing to do would be to get a couple cRIOs up and running and write a little application to test synchronization.  SNTP is also quite a bit easier to use than bouncing UDP packets around.

Message Edited by speleato on 08-18-2009 04:32 PM
0 Kudos
Message 8 of 13
(5,539 Views)

Hi,

 

Thanks for the advice again, I've tried setting 2 RIOs up with the rt-ini file mods they suggested in the KB, pointed them first to my local NTP server (on my PC, a 3rd party one, not Windows'), then to an internet one (I have the RIOs on the internet router), but no joy with either yet 😞 The clocks just don't see to synchronise, they stay a second or 2 out on average. I can definitely ping the internet NTP server from my machine, and my local NTP server/client (on my PC) can synch with it.

 

If you have easy access to one, would you mind posting one of your ni-rt.ini files with your NTP modifications just in case I can spot if I am doing something totally stupid in the ini file modifications?

 

Many thanks,

 

Mark

Certified LabVIEW Architect
0 Kudos
Message 9 of 13
(5,526 Views)

NTP and SNTP use port 123 for their communication. If you have a firewall to the external internet (which you should have) you may have to explicitedly allow outgoing UDP traffic on that port.

 

Rolf Kalbermatter

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 13
(5,518 Views)