LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Windows Time

Hello,
 
I am attempting to create a form of "ping logger" in Labview.  What I am actually doing is this:
 
Computer 1 / PC 1 has two VIs running, "UDP_Ping_Sender.vi" and "UDP_Ping_Receiver.vi"
 
Computer 2 / PC 2 has one VI running, "UDP_Ping_Relay.vi"
 
Both computers run Windows XP Pro SP2, Labview 7.1
 
The ping sender (PC 1) sends a packet containing a timestamp to the relay (PC 2) which dumply forwards anything it receives back to the ping receiver (PC 1 again).  I need to keep the sender and receiver VIs separate as ultimately I will be using the relay to send to multiple PCs across the Internet from one sender (broadcasting, sort of).
 
The timestamp is derived from the "Get Date/Time In Seconds" block and the "Tick Count" block.  I am aware the former is accurate to only ~16ms, so I wait until two successive readings of "Get Date/Time In Seconds" are different so that I trigger on the rollover.  I then use the difference between the current "Tick Count" and the "Tick Count" at the time of rollover to increment the time.
 
My problem is that even on the same PC (PC 1), the result of this method in the two VIs is always out by a variable number of milliseconds (usually between +/- 15).  The latency of the network isn't the problem, since it goes through "localhost".  Once running the offset seems fixed.  Maybe the "rollover" is meaningless.  Is there another way I can get an absolutely, real world time in Labview without buying a hardware card.  I only need 1 ms accuracy.
 
Thanks in advance,
 
David

Message Edited by laserjet4200 on 10-18-2007 11:30 AM

0 Kudos
Message 1 of 4
(2,952 Views)

Hi David,

Unfortunately, 1ms accuracy is not possible using software timing. You will always see 10-15ms of inaccuracy using this method, which will cause a problem with any ping times you want to measure.

As an alternative, you could use the System Exec.vi block in LabVIEW (Connectivity > Libraries & Executables > System Exec.vi) to call ping commands as you would in the Windows console. You could call this block repeatedly to ping an address once, then parse the output to get the ping times. This would result in accurate pings that could be called automatically. If this sounds suitable I can make an example for you to have a look at.

Regards,

 
Tom

Applications Engineering, NI UK
Message 2 of 4
(2,896 Views)
Hi Tom,
 
Many thanks for your reply.  I was coming to a similar conclusion myself.  What I didn't mention in my previous message was that I'll ultimately be needing GPS time synchronisation between both ends, so I've decided to go with a PIC / 6025E based solution.  The idea is that the PIC will synchronise to a GPS modules 1PPS output, and the 6025E with Labview will act as an interface between the world of PIC and the world of Ethernet.
 
All the best,
 
David
0 Kudos
Message 3 of 4
(2,884 Views)

This may be more than you need, but the NI PXI-6682 is capable of synchronizing directly to GPS and it also supports IEEE 1588 (a synchronization protocol over ethernet).  This allows you to connect one computer with a 6682 to GPS and then connect all of the rest of the computers via ethernet to the master.  The synchronization is around +/- 100 nS between each node, depending on the ethernet infrastructure.  The 6682 has the ability to timestamp actual hardware signals with a resolution of 10 nS and it has the ability to call Get Time in software to just get the current time. 

If you prefer to use your GPS receiver, the PXI-6682 can also synchronize to a PPS.

-Josh

 
Message 4 of 4
(2,862 Views)