Table Of Contents

Time-Based Synchronization in NI-Sync

Version:
    Last Modified: September 15, 2017

    Time-based synchronization, also known as distributed clock synchronization, is characterized by the use of an external timing source such as GPS, 1588, or an external IRIG generator. The system timing module uses the external time reference to determine the present time and create a clock that is locked to the external source. The individual clocks of each module and device in the system are synchronized to the same external source, ensuring synchronization between nodes no matter how far apart they are. Devices act on timing signals originating from a local clock that is synchronized to the other clocks in the system, so instead of sharing timing signals directly, the devices periodically adjust their local timing sources to match the chosen external time reference.

    Using the time-based synchronization method, you can perform the following actions:

    • Create future time events that execute at a specific board time to control clock and trigger signals.
    • Write and read timestamps to measure clock skew, record the start time of data acquisition, and troubleshoot timing issues.
    • Create timed loops that run at a specific time of the day.
    • Discipline the backplane clock to an external time reference.
    • Return the current data and time, or the date and time when a measurement was taken.
    • Generate a sample clock that starts and stops at a specific board time.

    Synchronizing distributed clocks requires constant adjustment. A clock is essentially a two-part device that consists of a frequency source and an accumulator. In theory, if you set two clocks identically and their frequency sources run at the exact same rate, they are synchronized indefinitely. In practice, however, clocks are set with limited precision, frequency sources run at slightly different rates, and the rate of a frequency source changes over time and temperature. Most time-based NI timing and synchronization devices use an over-controlled crystal oscillator (OCXO) or a temperature-controlled crystal oscillator (TCXO) as a frequency source, but even these highly accurate frequency sources vary due to initial manufacturing tolerance, temperature and pressure changes, and aging.

    Because of these instabilities, distributed clocks must be synchronized continually to match each other in frequency and phase. While a time-based system is generally not as accurate as a signal-based system, you can use the time-based synchronization method to synchronize complex systems with many different nodes spread out over a large area--even nodes that are moving--with no loss of accuracy. If you are using the GPS timing protocol, you can even measure the location, speed, and altitude of a node using time-based synchronization.

    You can configure an NI-Sync device to use four different external time references: IEEE 1588-2008, GPS, IRIG-B, and PPS.

    Time-Based Synchronization Phases

    The time-based synchronization method can be broken down into the following phases:

    • Initialize: Create an NI-Sync session to establish communication with a time-based module. Initialize creates a unique session handle that identifies the device to subsequent NI-Sync nodes. You can also use niSync Initialize to reset the device to a known state and verify that the NI-Sync instrument driver is valid for the device.
    • Configure Hardware: Set up your device for synchronization, typically by selecting an external time reference using Set Time Reference. If you are using IEE 1588-2008 as an external time reference, you can also start participation in 1588 in this phase. You can use niSync Properties, Set Time Reference, and Start 1588 in the Configure Hardware phase.
    • Get Time: Use Get Time to return the current board time of your device, which is synchronized with the external time reference you set in the Configure Hardware phase. You can pass this board time on to subsequent nodes to schedule future time events, start clocks at a specific time, or create timed loops in the later phases.

    In the following phases, you configure future time events, enable timestamps, and generate clocks. These phases are independent of each other; you can use all of them, none of them, or a combination of the phases with time-based synchronization.

    • Create Future Time Event: Use Create Future Time Event to schedule a future time event at a later in point in the application. A future time event changes the signal at a specific terminal when the board time reaches a specified point. You can create multiple future time events that change the signal levels on different terminals, change the signal multiple times at the same terminal to create waveforms, or use the future time event as a trigger to start data acquisition. The terminal you create a future time event on cannot be used for other purposes until you clear the future time event.
    • Enable Timestamp Trigger: Use Enable Time Stamp Trigger to record a timestamp every time the signal at a specified terminal changes. This is useful for tracking future time events, recording the timing of data acquisition, and comparing clocks between devices to check for jitter and offset.
    • Create Clock: Use Create Clock to create a custom clock that is synchronized with the external timing reference. You can set the clock to run for a specific number of ticks per cycle, a set length of time, or at a certain frequency. You can use the board time you returned in the Get Time phase to determine when the created clock should start and stop.

    In the following phases, you read timestamps you created and close the connections you established earlier in the application to free the resources for other uses.

    • Read Trigger Timestamp: Use the Read Trigger Time Stamp function to read the timestamps you recorded in the Enable Timestamp Trigger phase. You can read a single timestamp or multiple timestamps in this phase. You can only read timestamps if you enabled the timestamp trigger with Enable Time Stamp Trigger.
    • Clear Future Time Events/Disable Timestamp Trigger/Clear Clock: Disconnect the future time events, timestamp triggers, and clocks you created earlier in the program. Every time you create a future time event, enable a timestamp trigger, or create a clock, you must free the terminal at the end of the program using the appropriate function. Use Clear Future Time Events to remove future time events, Disable Time Stamp Trigger to stop recording timestamps, and Clear Clock to remove a generated clock from a terminal. If you are using IEEE 1588-2008 as the external time reference, you can also stop 1588 participation in this phase.
    • Close: Close the NI-Sync session and end communication between the driver and your device using Close. This phase is necessary for deallocating memory and freeing other operating system resources. You must close every NI-Sync session you initialize, even if an error occurs when you execute the program.

    Recently Viewed Topics