Time Synchronization

The 3DM-CV7 offers a host of features which can be used to synchronize the 3DM-CV7 and an external system. This application note provides a high-level overview of the options at a user's disposal.

The 3DM-CV7 provides two types of synchronization: time domain synchronization and sampling synchronization. Some applications may need one or both of these options. Each method is addressed below, but first it is important to understand the two types of timestamp that the 3DM-CV7 provides.

Timestamps

The 3DM-CV7 maintains two sets of timestamps - Internal or Reference Time, and External Time.

Reference time is a monotonic timer that starts at power-on. It can only increase, will never be adjusted, will not roll over, and does not exhibit any discontinuities. This reference time is used for all internal timekeeping and most computations. Since it is derived from the 3DM-CV7's internal crystal oscillator, it is subject to drift relative to other systems. The main benefit to using reference time is its simplicity and reliability.

The following data fields represent internal reference time:
Reference Timestamp (0xFF,0xD5)
Reference Time Delta (0xFF,0xD6)

External time is meant to be synchronized with other systems. Through the use of the GPS Time Update Command (0x01,0x72) and a pulse-per-second (PPS) signal, external time can track another time source. A dedicated PPS signal allows very precise alignment and elimination of drift. The time update command allows control of the absolute time reference or epoch. The most common use case is for external time to track GPS time, but it can also be used with other systems such as Unix time.

The following data fields represent external time:
External Timestamp (0xFF,0xD7)
External Time Delta (0xFF,0xD8)
GPS Timestamp (0xFF,0xD3)
Delta Time (0xFF,0xD4)

To avoid confusion, we recommend only using the GPS Timestamp (0xFF,0xD3) field if you're actually using GPS time in your application.

External Time Domain Synchronization

As described in the External Time section above, the 3DM-CV7 can synchronize with another time source. An example would be configuring the 3DM-CV7 to timestamp its IMU data in reference to an external time domain such as GPS time. In this case, the sampling of IMU data would be driven by the 3DM-CV7's internal reference clock, but the (external) timestamps generated for that data would be expressed in the GPS time domain.

Method of Time Domain Synchronization

External time synchronization is controlled by the PPS Source Control (0x0C,0x28) . The PPS signal may be generated by the 3DM-CV7 or by another device. The differences are described below according to the PPS source.

To achieve time domain synchronization, a digital PPS line must be connected between the 3DM-CV7 and the other system. This provides a very precise time alignment that cannot be achieved with a serial packet alone.

The external time must be initialized by sending the GPS Time Update Command (0x01,0x72) . This command may be sent once during initialization or periodically (e.g. every second). It must be received within a half-second of the PPS signal's rising edge.

Configuration of the PPS and GPIO is covered on the PPS page.

GPIO Source

A PPS signal from another device can be applied to a GPIO pin. Drift between the external time and the other device's clock will be removed and timing will be very accurate.

GENERATED Source

The 3DM-CV7 can generate its own PPS signal from the internal reference clock. There will be zero drift between the internal and external times. It can be useful to use this mode even without a PPS hardware line as it will ensure the 3DM-CV7 has valid time in all situations. External time can be in whatever reference frame is required by the application.

Sampling/Event Synchronization

Sampling synchronization refers to synchronization methods that align data samples with a digital signal provided by or to an external system.

Methods of Sampling Synchronization

Sampling synchronization is achieved through the event system. A full explanation of the event system can be found here. There are three cases relevant to synchronization with other systems.

Trigger Input

The event system can be configured to generate data synchronized with a clock signal on a GPIO. The 3DM-CV7 will generate interpolated data that corresponds to the instant the GPIO receives a rising or falling edge. This data can be timestamped in the 3DM-CV7's internal reference time or in an external time domain.

The basic concept is to configure one or more event messages linked to a GPIO edge trigger, so that when a pulse arrives data is transmitted using the timestamp of the pulse. Synchronizing Data Output with an External System provides an example configuration.

Trigger Output

The event system can be configured to control a GPIO pin based on a time interval. The interval may be derived from either the reference or external absolute timestamps. Data sampling is unaffected and will be output per the normal streaming behavior. This mode is primarily useful to control another device, such as a camera shutter, which needs to be roughly aligned with data frames. In the camera example, the camera would take pictures at a rate that is locked to the CV7's sample rate.

Note that each pulse has a resolution limitation of 1 ms and thus is subject to much more phase noise than a PPS signal. Despite the low resolution, this method is useful to ensure data rates are consistent between devices and to output signals other than 1 Hz. Data output is not phase-aligned when using regular streaming, but by using event message actions instead (similar to the Trigger Input section), phase alignment is possible.

For this mode, configure a Data Trigger over the desired interval (say 60 Hz) and a corresponding GPIO action which sets the output to the state of the trigger. This is similar to running the following pseudocode every millisecond:

if reference_time.nanoseconds mod 16666667 < 8333334
  then gpio_state = HIGH
  else gpio_state = LOW

See Synchronized Square Wave Output for an example.

Combining Methods

It's important to understand that a PPS signal can't be used to synchronize sampling. The purpose of a PPS signal is to establish a common understanding of time between two or more devices, like two people tuning their watches so they always read the same time.

Likewise, the event system can't establish a common time base. It can only control when things happen, according to the two available clocks in the 3DM-CV7.

Therefore, it may be necessary to use both of these systems in some applications. If your application requires data output alignment and timestamping according to another clock source (for example, generating GPS-timestamped data according to an input pulse), then both systems are required.