Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Reliably retrieving current time to cRIO

Hello! I'm currently working on a project where a cRIO constantly measures certain values, and inserts them to a SQL database through an internet connection! With these values it must also insert the current time, so we can know when the measures were taken. But i'm having a lot of trouble with finding a highly reliable method of returning the current time. 

 

I have tried the cRIO built in clock, the problem is that as soon as the cRIO reboots (or the power is shut), the clock is set to its standard time of 1970. This is not very reliable at all, as the cRIO will be put in mining facilities and such, without anyone that can set the clock back. Does anyone know a way to fix this? 

 

The other thing i have tried is getting the time in labview from atomic clocks on the web. I've downloaded two VIs that do this, one uses a .gov server for the time, and the other one retrieves the current time from the US navys atomic clock. The problem with this is that it doesn't always work, sometimes these clocks just return zeros. 

 

It is also possible to set the cRIO time programmatically in labview, but with what? If i use an atomic clock to do it i will have the same problems!

 

Has anyone had similiar problems? Please keep in mind that i'm a beginner in labview and don't know a lot about computers and data communication in general!  Any help would be greatly appreciated, thank you in advance! 

0 Kudos
Message 1 of 5
(5,597 Views)

I forgot to mention that i am using a cRIO 9075, with a 3G SEA module!

0 Kudos
Message 2 of 5
(5,593 Views)

Hi jespercronborn.

 

 

The behavior you are seeing, where the 9075 (and 9076) is resetting the time after a reboot is expected. These controllers do not have a battery, and thus it will forget the time on a reboot. For more information, have a look in the manual p. 17:

* CompactRIO cRIO-9075/9076 Operating Instructions and Specifications

 

One way to solve this, is to use a SNTP server, meaning that the cRIO will get a timestamp from a server. All you need to do, is to modify the ini-file on the RIO target, as explained in this KB:

* Configuring CompactRIO Real-Time Controllers to Synchronize to SNTP Servers

 

NI does not offer a timer server that you can use, so you need to find one yourself or create your own.

* How Do I Configure My Host Computer as an NTP Time Server?

 

When I did a Google search I found a document that list a lot of time servers in Europe:

http://www.google.dk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=7&ved=0CG4QFjAG&url=http%3A%2F%2Fcustome...

 

I have tested by inserting the following lines into the ini-file. IF you already see a section called Time Sync, then you need to replace those lines. The IP-address I use here is just one I found in the document above.

[TIME SYNC]
source_priority = sntp;rtc;
source.sntp.enable = true
source.sntp.address = 192.36.143.151
source.sntp.interval = 60
source.sntp.port = 123
source.sntp.verbose = false
source.sntp.log = false

 

 

You also have another option; If you have a host computer available, you also have the option to get the timestamp from that, and then transfer it using a Network Shared Variable to the RIO target, where you can use the Set Time VI which is part of System Configuration API. You can also see these functions here:

* Why am I Missing VIs From the Real-Time Utilities Palette?

 

Best Regards

Alex E. Munkhaus
Certified LabVIEW Developer (CLD)
System Engineer
0 Kudos
Message 3 of 5
(5,530 Views)

Ok thanks a lot A.E.P! But how do you FTP the NI-rt.ini file from the crio? I'm really not an experienced labview user!

 

Also, i've found a VI that uses NTP! I'll attach it and maybe you could take a look! Shouldn't a NTP VI be as reliable as SNTP? 

0 Kudos
Message 4 of 5
(5,543 Views)

You can open MAX and right click your target, and then click on File Transfer. This will open the Windows File browser and opens a FTP session.

FTP.png

 

The advantage by changing the ini-file is, that it automatically updates the time at every boot. The advantage by using a VI is that you are in charge of when the time should update.

 

I have one comment to your VI: You are using the VI called "RT Set Data and Time" which is actually deprecated and has been replaced by a new set of VIs starting from LabVIEW2012. So if you are using LabVIEW2012 or newer I would advise you to use the System Configuration VIs instead.

 

Best Regards

Alex E. Munkhaus
Certified LabVIEW Developer (CLD)
System Engineer
0 Kudos
Message 5 of 5
(5,539 Views)