LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

get date time string in RT

Hello Folk,

 

I am facing probelm to get correct time string in my RT system. I use get date time string in both host and RT system. I have set same time for host and RT system. This works fine with my host but in RT my time string is 8 hours off though date string is correct.

 

What problem could it be?

 

Your help will be truly appreciated?

CLAD
Passionate for LabVIEW
0 Kudos
Message 1 of 14
(3,271 Views)

The two clocks are unrelated. Windows synchronises with the web, but the RT system does not.

 

You'll have to make your own time synchronisation, or use SNTP, or GPS.

 

To do it yourself, first you need to get the time from the PC, then you can set the clock (Set Time.vi).  You can also set the time from MAX (to ensure that that is the problem). But the clock will drift, since the CPU's clock speed is never exactly as specified. So if the system is on for long periods, you need to synchronise clocks.

 

I'd prefer SNTP, since it is a provem method, and involves less work.

0 Kudos
Message 2 of 14
(3,247 Views)

wiebe@CARYA wrote:

You'll have to make your own time synchronisation, or use SNTP, or GPS.


I don't recommend creating your own synchronization, unless you really feel like it and only need synchronization within a few seconds. Several standard synchronization protocols exist that should give you millisecond-level synchronization.

 

One standard that hasn't been mentioned yet is PTP. You may be interested in using NI-TimeSync, which officially supports PTP. Experimental SNTP support is also available.

------
James Blair
NI R&D
0 Kudos
Message 3 of 14
(3,225 Views)

 

I also recommended SNTP, and not doing it yourself.

 

The nice thing about SNTP is that it's handling the time syncronisation problem at the core. It adjusts CPU speed, and you'll never come close to the results if you do the corrections from LabVIEW. I'm not sure if NI-Timesync does that, I've not used it.

0 Kudos
Message 4 of 14
(3,220 Views)

Hi jatinpatel.  Have you accounted for timezones?  RT usually uses UTC, the PC is usually local time.

 

Matt

0 Kudos
Message 5 of 14
(3,211 Views)

Good point Matt. Both issues have to be addressed, though.

0 Kudos
Message 6 of 14
(3,204 Views)


The two clocks are unrelated. 


Actually I meant to say time stamp in both system is same but get date and time string fucntion gives a wrong string. 

 

Let me clear on this,

when RT time stamp is 10:10:20 AM and I apply it to get date time string it gives 04:10:20 AM.

when Host time stamp is 10:10:20 AM and I apply it to get date time string it gives exact 10:10:20 AM.

 

So I Guess problem is not with syncronisation.

CLAD
Passionate for LabVIEW
0 Kudos
Message 7 of 14
(3,197 Views)

@Matthew_Williams wrote:

Hi jatinpatel.  Have you accounted for timezones?  RT usually uses UTC, the PC is usually local time.

 

Matt


I have set my PC time zone to UTC 5:30 but still dint catch the fault. 

CLAD
Passionate for LabVIEW
0 Kudos
Message 8 of 14
(3,193 Views)

I have set my PC time zone to UTC 5:30 but still dint catch the fault. 


That is because the cRIO clock does not synchronise with the PC clock.

 

Matt's point is (or implies) that even if the clocks are synchronised (with SNTP, NI-Timesync, or manually in MAX), the time you read will still be off when the time zone of the PC and the cRIO are different. The synchronisation will synchronise UTC, and the time you read will (unless you set UTC flag) give you the time zone corrected time. I'd try to work with UTC in all code, and only correct when absolutelly needed. Over here we have automatic daylight correction, and that makes non-UTC even harder.

 

So you need to fix both problems.

0 Kudos
Message 9 of 14
(3,175 Views)

wiebe@CARYA wrote:

I have set my PC time zone to UTC 5:30 but still dint catch the fault. 


That is because the cRIO clock does not synchronise with the PC clock.

 

Matt's point is (or implies) that even if the clocks are synchronised (with SNTP, NI-Timesync, or manually in MAX), the time you read will still be off when the time zone of the PC and the cRIO are different. The synchronisation will synchronise UTC, and the time you read will (unless you set UTC flag) give you the time zone corrected time. I'd try to work with UTC in all code, and only correct when absolutelly needed. Over here we have automatic daylight correction, and that makes non-UTC even harder.

 

So you need to fix both problems.


OkaOkay, I got your point but I dont know how should I go with NI timesync to snchronise the time.
Can you please help some on it?

wiebe@CARYA wrote:

I have set my PC time zone to UTC 5:30 but still dint catch the fault. 


That is because the cRIO clock does not synchronise with the PC clock.


I
CLAD
Passionate for LabVIEW
0 Kudos
Message 10 of 14
(3,153 Views)