Example Code

Scope Acquisition with GPS Timestamping

Code and Documents

Attachment

Overview

There are many examples that ship with LabVIEW and NI Scope for acquiring data, but what if you need to overwrite the standard timestamp with a timestamp from a GPS signal. This could be for a variety of reasons, including that the acquisitions are happening in quick succession but over a number of distributed systems, which would mean you need a very accurate timestamp on each system in order to be able to read them back in the correct order during offline analysis.

Description

The 2 attached examples export the start trigger for the scope acquisition from the NI Scope module (see hardware section below for details on which NI Scope module to use) to the PXI backplane on PXI_trig0, and the NI GPS Timing and Synchronisation card (PXI-6682 or PXIe-6683H - referred to as the GPS module for the rest of this article) is set up to trigger from PXI_trig0. Everytime the GPS module triggers it will grab an accurate timestamp and pass it back to LabVIEW. We then overwrite the timestamp in the NI Scope read cluster with the more accurate timestamp.

If the GPS module does not have a valid GPS signal it will read the timestamp from the PXI system clock. This could be due to adverse weather conditions preventing the GPS antenna from being able to pick up the satelites, or there may not have been enough time from system start up to get a full GPS packet (GPS packets are 30 seconds long so it will take at least 30 seconds to lock on, probably more).

Steps to run "niScope Real Timestamp - Write to TDMS.vi"

This example will grab the time domain data from the NI scope module each time it is triggered, and then perform a software FFT on each channel of data. The time domain data, FFT data and GPS timestamp are then sent via a queue to the file IO loop where it is all logged to a TDMS file.


  1. Download example code
  2. Ensure an NI Scope module is plugged in with a valid signal wired into Channel 0. This example can also take in values on Channel 1 and log data to file from both channels. This example will work with most NI Scope PXI modules as it does not use the Onboard Signal Processing (OSP) which the other examples use. The example was tested with a 1MHz sine wave from an NI PXI-5404 Function Generator.
  3. Ensure the terminals selected for GPS Resource Name, Scope Resource Name and Backplane Trigger are correctly selected
    1. Scope Resource Name is the name of the NI Scope module as defined in MAX
    2. GPS Resource Name is the name of the NI GPS Timing and Synchronisation Module as defined in MAX
    3. Backplane Trigger is the route to the Scope trigger for the GPS module to pick up its start trigger from. Set this to be /"GPS Module"/PXI_Trig0 - so if the GPS Module is named PXI1Slot4, this should be /PXI1Slot4/PXI_Trig0
    4. Select a valid TDMS file path
    5. Ensure the scope settings are correct for the application.
    6. Run the code

Steps to run "niScope EX OSP Downconversion with Real Timestamp.vi"

This example has to be run on a PXI Scope module with OSP - such as a PXI-5142. Each time round the bottom loop the code sets up a grab and acquires a waveform of time domain data when the Analog Trigger is set. The trigger is again exported to PXI_trig0 and picked up by the GPS module. For every acquisition of data the onboard signal processing is used to downconvert the data by mixing it with a centre frequency as defined in the control "Centre Frequency". The Read Measurement function then passes back a hardware calculated FFT cluster.

The timestamp is then used to overwrite the timestamp in the time domain waveform before the time domain data and FFT data are passed via a queue to the file IO loop where they are logged to a file.

  • Download example code
  • Ensure an NI Scope module is plugged in with a valid signal wired into Channel 0. The OSP is only supported on Channel 0 for the PXI-5142 and therefore Channel 0 has to be used. This example will work with most NI Scope PXI modules as it does not use the Onboard Signal Processing (OSP) which the other examples use. The example was tested with a 1MHz sine wave from an NI PXI-5404 Function Generator.
  • Ensure the terminals selected for GPS Resource Name, Scope Resource Name and Backplane Trigger are correctly selected
  1. Scope Resource Name is the name of the NI Scope module as defined in MAX
  2. GPS Resource Name is the name of the NI GPS Timing and Synchronisation Module as defined in MAX
  3. Backplane Trigger is the route to the Scope trigger for the GPS module to pick up its start trigger from. Set this to be /"GPS Module"/PXI_Trig0 - so if the GPS Module is named PXI1Slot4, this should be /PXI1Slot4/PXI_Trig0
  4. Select a valid TDMS file path
  5. Ensure the scope settings are correct for the application.
  6. Run the code

Requirements

Software

LabVIEW 2013

NI Scope

NI Sync

Hardware

PXI chassis and controller

PXI-5142 (or other NI Scope module for the non OSP example) with input signal

PXI-6682 or PXIe-6683H with valid GPS signal.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors