LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem updateing time from internet

Solved!
Go to solution

Hello All,

 

I am trying to update the time on a realtime PXI Controller from a Stratum 2 NTP internet site.

 

There are two methods offered by NI:

Method 1 - Driver for PXI (LV >=2009)

Method 2 - Code Based

 

The code based example (which works well) uses an NIST Server.

 

I have tried to adapt this to an NTP sever (Port 123, 0.au.pool.ntp.org which resolves to 116.66.160.39 [right now]).

 

NTP is a UDP protocol but I don't fully understand how to use it in labview.

I can ping the address,

I can't seem to be able to open a TCP session.

I can open a UDP Session but I can't read from it, nor Write to it.

 

 

Any suggestions?

 

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 1 of 11
(3,581 Views)
Solution
Accepted by topic author Timmar

I don't understand why the code example you are quoting labels the diagram constants and subVI icons with "NTP", because it uses the "daytime" protocol, which is quite different. How were you trying to adapt it to NTP? Changing the port to 123/UDP is definitely not enough. (And why would you even try TCP???)

 

You need to properly format an NTP request in order to get a reply, and there is an RFC that describes it in detail.

 

Long ago I wote a quick a dirty pure LabVIEW example to query an NTP server and parse the result. For details see this thread. Maybe it will give you some ideas.

Message 2 of 11
(3,575 Views)

Altenbach,

 

As always I am in awe,

 

I wish I had put in the correct search parameters into the forum and found This thread

 

My code was very close to yours with one exception, The request packet.

The information I found on the web said "GET TIME\r\f" which in hindsight sent me down a 2 day blind alley.

 

Out of interest, where did you find the request packet format?

 

Attached is your code, modified as per jimwu's suggestion, I have also added an aussie NTP server pool address (For future readers of this post, modify it to your region for most accurate results)

 

Again,

Thanks,

You are a lifesaver

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 3 of 11
(3,551 Views)

@Timmar wrote:

Out of interest, where did you find the request packet format?


I actually included a link in the diagram comments, and some quotes from the RFC.

 

Start here.

0 Kudos
Message 4 of 11
(3,545 Views)

@Timmar wrote:

Attached is your code, modified as per jimwu's suggestion, I have also added an aussie NTP server pool address (For future readers of this post, modify it to your region for most accurate results)



Changing the "LI|VM|Mode" value in the cluster makes no difference because it will be overwritten immediately by the bundle by name operation, where it is replaced by "00100011"

 

Also, if you modify and repost one of my VIs, please add a note in the diagram comments, because such changes are out of my control and have nothing to do with me, even though only my name seems to remain on the diagram. Suddenly pople will ask me about some VI mutilated by others and I have no idea what it's all about. 😉

Message 5 of 11
(3,539 Views)

Appologies, I wantaied to maintain Credit.

 

Here is v2.2 that I hope is more to your satisfaction

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
Message 6 of 11
(3,529 Views)

Very useful!!

 

0 Kudos
Message 7 of 11
(3,385 Views)

Is there a similar solution for LV 8.2?  -- I could not get it to work in LV 8.2 because it lacks the fixed-point numeric data type...

Is there a way to overcome this?

0 Kudos
Message 8 of 11
(3,366 Views)

@ecande wrote:

Is there a similar solution for LV 8.2?  -- I could not get it to work in LV 8.2 because it lacks the fixed-point numeric data type...

Is there a way to overcome this?


Yes, of course! In the end, everything is just bits.

 

What resolution do you really need? If you only need 1s resolution, you can just drop the fractional part and parse it as integer.  Else you simply need to parse the integer and fractional parts seperately and do some math. What is giving you problems? 

0 Kudos
Message 9 of 11
(3,356 Views)

Now that you mention, I can work fine with 1s resolution.

 

Thanks!!

Smiley Happy

Spoiler
 

 

 

0 Kudos
Message 10 of 11
(3,352 Views)