Example Program Drafts

Showing results for 
Search instead for 
Did you mean: 

Synchronizing Analog Input FieldDAQ Devices with NI-DAQmx in LabVIEW


FieldDAQ devices support diverse measurement types such as voltage, temperature, and strain. The FieldDAQ Hardware, in conjunction with the DAQmx API, gives users flexible configuration options to achieve the desired correlation across multiple devices. This tutorial highlights some of the diverse options available to achieve synchronization between devices.

1. FieldDAQ Input Devices

FieldDAQ Input Devices are rugged ethernet-based devices that are designed to take measurements in close proximity to the physical phenomenon. FieldDAQ takes advantage of the Time Sensitive Network (TSN) standard IEEE 802.1 to synchronize its measurements to an external time source. 


FieldDAQ Devices can be categorized into two groups based on their synchronization: Delta-Sigma and Slow-Sampled Devices. Delta-Sigma Devices use a free-running 24-bit ADC, convert using a faster sample clock (Sample Clock Timebase), and decimate the Sample Clock Timebase signal to return data at a slower rate (Sample Clock rate). Slow-Sampled Modules use a 24-bit ADC and convert and return data at the rate specified by a clock (Sample Clock rate). For Slow-Sampled Modules, the Sample Clock is external from the ADC in contrast with a Delta-Sigma Device where the sample clock is a result of decimating the Sample Clock Timebase.


The method of implementing synchronization may depend on the categorization of the device. The efficacy of the synchronization method will depend on the Hardware Topology as well as the type of ethernet switch chosen. This tutorial focuses on the necessary LabVIEW code to synchronize devices and assumes the reader has the necessary hardware for their chosen topology to enable synchronization. User should review Selecting a Topology in Designing Distributed TSN Ethernet-Based Measurement Systems to ensure they have the necessary hardware and topology. In this tutorial, synchronization is defined as the steps or techniques used directly or indirectly via the DAQmx driver to start measurements at the same time and to remove drift between subsequent measurements. While the result of these steps increases the sample to sample alignment, the focus is to prevent drift.


Examples in this tutorial use the Snippet functionality in LabVIEW. To learn more about this functionality, please review this tutorial Use VI Snippet to Store and Share Reusable Code Sections.



2. Use a Multidevice Task to Synchronize Multiple FieldDAQ Devices

One of the most robust and easiest methods to synchronize multiple FieldDAQ devices is to place all devices into one task. To use various modules in the same task, place multiple channels across different devices in the Physical Channel control. The Physical control inputs into the Create Virtual Channel VI. Channels from different modules should be included in the same DAQmx Create Channel if they are intended to have the same measurement configuration (voltage range, measurement type, and units) and the same timing and triggering information. 




Figure 1: Multi-Device Synchronization 


If the modules are taking different measurements (such as voltage or current), require different measurement ranges, or need to use different measurement units, then use multiple instances of the DAQmx Create Virtual Channel VI as seen below.




Figure 2: Multi-Device Synchronization using Multiple DAQmx Create Virtual Channel VIs


When using multiple FieldDAQ units in a Line Topology, putting all the devices in a task can fail and return error -209840, "The configured time trigger occurred in the past." This error occurs when the default Time Start Trigger delay used by DAQmx is not long enough to allow the network of FieldDAQs to finish all of their configurations.  To avoid this error, manually increase the time for the Time Start Trigger to a value further in the future by adding additional delay to the trigger, so that all FieldDAQs will have time to complete configuration.  Note that the configuration time varies depending on the network topology and the number of FIeldDAQs in the system.




Figure 3: Multi-Device Synchronization with Time Start Trigger


Placing all the devices into one task to achieve synchronization may not be a feasible solution under certain conditions:


  • All devices in the task will sample and return data at the same rate (FD-11613 will return duplicate samples in order to keep up with FieldDAQ units that can sample at faster rates)
  • Each device placed in the task leads to the potential of a longer configuration time which may not be acceptable for the application
  • Multi-Device Tasks do not work and will error when trying to synchronize FieldDAQ and Time Aware CompactDAQ Chassis (this type of synchronization is discussed later in Manually Synchronize FieldDAQ Devices with Time-Aware cDAQ Chassis)
  • In a line topology, each successive device in the line decreases the synchronization accuracy with respect to the first node and the last node

To work around these issues, it may be beneficial to employ separate tasks and manually synchronize these tasks, as discussed in the following sections. 



3. Manually Synchronize Multiple FieldDAQ Devices with Separate Tasks 

To manually synchronize FieldDAQ units in separate tasks, configure a Time Start Trigger for each task and a congruent timestamp for the when input for the DAQmx Start Trigger Time.vi. 




Figure 4: FieldDAQ Synchronization with Separate Tasks


Since all devices are TSN capable, the onboard clocks used to take measurements have already been steered so that they do not drift with respect to each other. The only signal between tasks that is needed is a Time Start Trigger. To synchronize Delta-Sigma FieldDAQ Devices, a different approach is needed due to how the ADCs operate. 


Delta-Sigma  ADCs are free-running ADCs that begin acquiring data as soon as power is provided. To reconfigure the ADC, a signal is sent to the ADC to stop and start it and any device settings using the ADCs. Reconfiguring the ADC performs many functions, including clearing out old samples, synchronizing  the ADC’s acquisitions with any external device(s) sharing the same Sample Clock Timebase, and changing  the rate of the ADC’s Timebase. After the device is started, there is a variable amount of time before the device returns the first sample. This variable amount of time is called the Reset Time, and the signal that stops and starts the Delta-Sigma ADC is called the Synchronization Pulse.



Figure 5: Timing Diagram for Delta-Sigma ADCs


The reset time is a function of the sample rate and the device. For example, a device running at 100 kHz compared to another device running at 50 kHz will have different reset times. The time needed to reset the ADC can be found using the DAQmx Timing Property Node SyncPulse.ResetTime. The reset time is also specified in the Device's Specifications/Datsheet as part of the Group Delay or Input Delay specification. The group delay specification includes the analog delay a fixed time and a digital delay a variable time that is dependent on the sample rate. The reset time is equal to the digital delay.  The analog delay isn't accounted for in this tutorial. 



Figure 6. Different Reset Times for FieldDAQ Units Running at Different Rates


Due to the difference in reset times and sample rates, the ADC running at a faster sample rate will return numerous samples before the ADC with the slower sample rate returns the first sample. This behavior can be modified and will be discussed later. Different devices may have different reset times for equivalent sample rates



Figure 7: Timing Diagram for a Delta-Sigma ADC with two different reset times


The FD-11603 and FD-11637 have equivalent reset times for equivalent sample rates. This may not be true for other  DeltaSigma FieldDAQ devices.  

The Delta-Sigma ADC is free-running, and the synchronization pulse is sent to reconfigure the ADC and device for the desired use case. The first sample will be returned to the user after sending the Start Trigger.



Figure 8: Timing Diagram for the First Sample Sent to the User


To account for any difference in reset times  (as mentioned above), you will adjust/delay the time that the Synchronization pulse and Start Trigger is sent to specific modules. Shifting around the Synchronization Pulse and the Start Trigger has limits and tradeoffs. Delaying the Start Trigger can cause the device to fail to capture the first available sample (second sample clock) and increases the time from when the application is started to the time the first sample is received.


To account for the difference in Reset Times, you use two synchronization pulses (a requirement since we are using two separate tasks) and delay the task with the shorter Reset Time. This will shift the synchronization pulse of a module that takes less time to reset, thus ensuring that both devices with a slow and fast Reset Time end their reset sequence at the same time.




Figure 9: Delaying a Synchronization Pulse for a mismatch in reset times due to different device


The exact amount to delay a Synchronization Pulse can be determined by using the property node SyncPulse.ResetTime to determine the reset time and calculating the absolute value  of the difference between the reset times. This difference is then added to the shorter reset time using the SyncPulse.Time.when property.




Figure 10: FieldDAQ Synchronization with Separate Tasks for Delta-Sigma Devices


To synchronize two devices  sampling at different rates, we must shift the Synchronization Pulse of the task with the slowest reset time and also shift the Start Trigger so that the next sample clocks of both tasks are both aligned.



Figure 11: Delaying a Synchronization Pulse and Start Trigger for a mismatch in reset times due to different device and sample rates


The exact amount to delay the Start Trigger is determined by reading from the SampClk.Rate and analyzing the ratio between the sample rates to determine how many clocks of the fastest sample rate occur before the slower sample rate. We then shift the start trigger the appropriate amount of time to shift the Start Time. The analysis of the ratio between the sample rates provides a value to shift the Start Trigger so that it aligns the first sample clock . This analysis is only suitable when the faster sample rate is an integer multiple of the slower sample rate.




Figure 12: FieldDAQ Synchronization with Separate Tasks for Delta-Sigma Devices


As illustrated in Figure 11, the Start Trigger  is also shifted by the largest Reset Time to ensure that the ADC has completed resetting before we attempt to return a sample.

I/O Device time is used in the above example due to the accuracy in translation between Host Time and I/O Device time.  



4. Manually Synchronize FieldDAQ Devices and Time-Aware cDAQ Chassis

FieldDAQ devices can also synchronize to another device that  is Time-Aware or TSN capable. Examples of these devices are the cDAQ-9185 and cDAQ-9189.  An understanding of C Series Synchronization schemes along with device grouping provided in Synchronizing Analog Input C Series Modules with NI-DAQmx in LabVIEW is assumed for this section. 




Figure 13: FieldDAQ Synchronization with cDAQ-9185 and cDAQ-9189


The above example is identical to the code required to synchronize two FieldDAQ units in separate tasks ( Figure 3) except one of the task is specific to Time-Aware cDAQ Chassis. The above code is intended for synchronizing Slow-Sampled FieldDAQ Devices with Successive Approximation Register (SAR) or Slow-Sampled C Series Modules. For a list of SAR and Slow-Sampled C Series Devices, please see Synchronizing Analog Input C Series Modules with NI-DAQmx in LabVIEW


When synchronizing Delta-Sigma FieldDAQ Devices and C Series Delta-Sigma Modules that are running at similar or different rates, the difference in Reset Times, the Reset Times, and the variable number of samples that occur due to the difference in sample rates must be considered. The example below is identical to the example shown in Figure 5 except one of the task is specific to Time-Aware cDAQ chassis, and both devices are directed to use a Sample Clock Timebase Rate that are equivalent. The subVIs necessary for this example are attached to this document in the top right-hand corner.




Figure 14: FieldDAQ Synchronization with cDAQ-9185 and cDAQ-9189 for Delta Sigma Devices


The example above has both the FieldDAQ device and Time Aware cDAQ Chassis (cDAQ-9185 and cDAQ-9189) use a 12.8 MHz Sample Clock Timebase. Another clock common to both devices is the 13.1072 MHz Timebase. To achieve the same sample rate, both devices may use Sample Clock Timebases of a similar rate. In some cases, achieving an equivalent sample rate between FieldDAQ and Time Aware cDAQ Chassis will require that each task use a Sample Clock Timebase with a differing rates. Acquiring at the same sample rate is not required for synchronization.  Please review the Specifications/Datasheet for each device to see which sample rates are available and which Sample Clock Timebase must be selected for the desired sample rate. 


Synchronizing a FieldDAQ Delta Sigma Device and a SAR C Series Module comes with challenges due to the timing differences between Delta-Sigma and SAR devices. The synchronization scheme must account for the Reset Time of the FieldDAQ Delta Sigma Device, the difference in sample rates, and the time it takes to retrieve the first sample. The subVIs necessary for this example are attached to this document in the top right-hand corner.




Figure 15: FieldDAQ Delta Sigma Devices Synchronization with SAR Modules in cDAQ-9185 and cDAQ-9189

The time it takes to retrieve the first sample could be accounted for by specifically shifting the Start Time of the SAR Module. The property node to delay the start time is chosen due to a minimum delay of 4 ticks of the 80MHz clock. Shifting the Start Time still incurs this delay, but setting the delay via the property node overwrites this delay. The delay written must be greater than 4 ticks of the 80MHz clock.


Starting in DAQmx 18.6 a new DAQmx Timing Property is available called First Sample Clock When. This property allows you to set the time when the first sample clock will be generated in terms of System Time or I/O Device Time. This property performs the calculations demonstrated in Figure 15 internally, including start trigger time, difference in reset times, and first sample alignment when using multiple rates. The First Sample Clock When property can be used to align acquisition start times on any combination of module types including DSA, SAR, Slow Sampled and FieldDAQ devices. The example below demonstrates how to use the property.




5. Conclusion

This tutorial demonstrated several synchronization options.  When synchronizing at the same rate, programming can be simplified by referring to several devices within the same task. Depending on the type of FieldDAQ Device or a need for diverse timing configuration options such as sample rates this tutorial provides many options for synchronization. These options represent an overview of different ways to synchronize FieldDAQ that are suitable for the timing requirements in many application areas.



6. Additional Resources