11-08-2011 01:37 AM
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?
Solved! Go to Solution.
11-08-2011 02:27 AM
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.
11-08-2011 07:06 PM - edited 11-08-2011 07:06 PM
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
11-08-2011 07:32 PM
@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.
11-08-2011 07:46 PM
@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. 😉
11-08-2011 09:53 PM
Appologies, I wantaied to maintain Credit.
Here is v2.2 that I hope is more to your satisfaction
06-04-2014 10:16 AM
06-05-2014 11:07 AM
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?
06-05-2014 01:02 PM
@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?
06-05-2014 01:04 PM