03-20-2008
01:25 PM
- last edited on
10-22-2025
10:59 AM
by
Content Cleaner
I am trying to set the system time on my 9012 RT cRIO using a GPS string and then correct any drift using the SMB connector and the pulse-per-second from the GPS unit. I want the system time to be synced to the GPS time, accurate to the millisecond if possible.The only articles I have found on this subject refer to the article Using the SMB Connector for Digital I/O on cRIO-901x Controllers . This article claims to give code that "You can use the SMB connector of cRIO-9012/9014 controllers to connect a digital device to the controller. For example, if you connect the pulse-per-second (PPS) output of a GPS device to the SMB connector of a cRIO-9012/9014, you can use the GPS device to correct for drift of the system clock of the controller." However, the code posted only reads the SMB pin.
So, I wrote code that receives a time stamp from either a GPS device or a shared variable over the network amd sets the system time to that. If SMB correction is enabled, it waits for the state of the SMB connector (which is receiving PPS output from the gps) to go from true to false (rising edge) and then reads the system time, rounds it up to the next whole second and sets the time. (See the attached screenshot). Why round up? When I set the time I had received a timestamp from somewhere (gps or shared variable). I am always going to receive this time stamp late so the system clock will be set to a time that is earlier than it actually is. So since I have to decide which whole second is occuring when the rising edge of the PPS occurs, it will always have to be the next one (rounding up). Sounds confusing, but it makes sense.
I want the system clock to be synced to the GPS time and accurate to the millisecond. So in order to measure what I have I simply plugged the GPS PPS output into my 9215 Analog module and plotted the square wave over the system time at 10 kHz. Unfortunately there is still a little bit of drift, which is unacceptable.
What I am asking is, what do you guys think of what I have done? Am I doing something wrong here that is resulting in the drift I am receiving? Is my SMB loop inefficient? Should I not be using the 9215 to test it? I just don't know.
Has anyone come up with code that corrects the system clock using the SMB connector and PPS and been happy with the results?
edit-------------
the screenshot of the code doesnt seem to be showing up after I attach it, how do i do that. (sorry about all the edits, trying to get the screenshot to work)
Message Edited by rex1030 on 03-20-2008 02:27 PM
Message Edited by rex1030 on 03-20-2008 02:30 PM
Message Edited by rex1030 on 03-20-2008 02:32 PM
03-20-2008
06:05 PM
- last edited on
10-22-2025
10:59 AM
by
Content Cleaner
Hi Rex,
Just for everyone else, your referring to the article: Using the SMB Connector for Digital I/O on cRIO-901x Controllers correct? To be clear the SMB pin on the cRIO-901x can be used for two purposes:
1. A general purpose DIO line
2. As an input for a PPS signal to help correct for drift of the system clock.
The general purpose DIO line requires the code attached to the above article. To use the SMB input to help correct for drift of the system clock you only need to configure the ni-rt.ini file and you do not need to implement any software/VI code yourself as the 901x controllers have the drift correction code already built into the software. You are just required to enable it by configuring the ni-rt.ini file with the following keys:
Time Sync]
source.rtc.enable=True
source.dio.enable = True
source_priority=dio;rtc;
source.dio.hz = 1.0
I haven't looked at your VI above yet, but if your using the SMB read/write VIs you should remove those as you must either use the SMB line as a General purpose DIO or as an iput for the PPS signal. Doing that may help you control the drift better. I do think that application is interesting and I would be interested to see what you come up with. How is the GPS serial stream coming to the controller? I would think you should be able to wait on a read and set the RT clock in the msec range.
Hope that helps. Let me know how it goes after updating the VI.
Basset Hound
Message Edited by Bassett Hound on 03-20-2008 06:06 PM
03-20-2008 06:09 PM
Oh by the way,
An easy ( relative ) way to post an image of your code is:
Basset Hound
03-25-2008 01:31 PM - edited 03-25-2008 01:41 PM
03-26-2008
12:51 PM
- last edited on
10-22-2025
11:01 AM
by
Content Cleaner
Rex,
I think I understand what your trying to do. First couple of things to make clear: the SMB pin can only be used as either a general DIO pin OR for drift correction, not both at the same time. What this means is you cannot use it both as a DIO line and also use it to help correct for drift by inputing a PPS as you've described. Basically, if your going to use it as a general DIO then the lines in the ini file are not going to do anything for you. Also, if your inputing a pps signal into the the SMB pin ( and not using as a DI input ) it will just correct for drift, and will not give you synchronization between different the different RT systems. The drift correct will not be setting the time in any way at all.
Currently there is not an interrupt method you can use with the SMB pin and polling is the fastest way of checking the pin. I wouldn't recommend the SMB pin to be used for synchronizing systems especially if your using it as just a general DIO line. The is mainly because its just software timed when used as a general DIO. However, you can write/read the pin in the range of 100 usec per write/read.
For synchronizing multiple cRIO systems I would normally recommend adding a DIO module (9401, 9403) to the cRIO to allow synchronization of the FPGA by sharing a start trigger or scan clock. This solution provides synchronization down to microsecond levels.
If your looking for synchronization in the usec level the a DIO module is the way to go. If you need in the 10 of ms range, a NTP time sever will work. If in the seconds range, then normal ethernet communication should be sufficient.
Let me know if that helps at all.
Basset Hound
03-26-2008 01:09 PM
03-27-2008 09:24 PM
03-28-2008
09:53 AM
- last edited on
10-22-2025
11:01 AM
by
Content Cleaner
Message Edited by Bassett Hound on 03-28-2008 09:54 AM
04-09-2008 01:08 PM
04-10-2008 10:03 AM
Hi rex1030,
Thanks for the information! It seems like you have all your questions answered.Good luck with the application!