I want to use both rising and falling edges as sample clock for Analog Input or Output. How can I do this?
To synchronize both the rising and falling edge timing of the pulse signal with the analog input or output, create an analog input or output task and a digital input task, which is a virtual channel necessary for change detection, and set the DAQmx Timing function to "Change Detection" mode. Route the pulse signal to the line of the device specified by the digital input task. Use the device name such as Dev1 set by Measurement & Automation Explorer (NI MAX).
In addition, change detection is supported only for some devices. For the list of supported devices, refer to the following link.
Set "Rising edge physical channel" and "Falling edge physical channel" of the DAQmx Timing function set in "Change Detection" mode to the same pin and set the sample mode to "Continuous Samples". Set the DAQmx Timing function of the analog input or output task to "Sample Clock" mode and set the "source" terminal to "/device name/ChangeDetectionEvent".
An example to synchronize change detection and analog input with LabVIEW is as follows.
In VB.NET or C#, in the ReadDigChan_ChangeDetection_Events example, set Lines, Rising Edge Lines, Falling Edge Lines to "/device name/port 0/line 0:7". Next, execute an example program like ContAcqVoltageSamples_ExtClkDigStart that accepts an external signal as the timing clock source, and set the Clock Source of Timing Parameters to "/device name/ChangeDetectionEvent" in the displayed window.
By executing the above two examples together, the digital task executes change detection, and the analog task can collect data at the timing of change detection.
VB.NET or C# change detection examples can be found in [NI-DAQmx Example Folder]\DotNET [Version]\Digital\Read Values\ReadDigChan_ChangeDetection_Events. In addition, examples of analog input that accept external signals can be found in [NI-DAQmx Example Folder]\DotNET [Version]\Analog In\Measure Voltage\ContAcqVoltageSamples_ExtClkDigStart. You can open NI-DAQmx examples by selecting National Instruments»NI-DAQmx»NI-DAQmx Examples from the start button.
In ANSI C, open the ReadDigChan-ChangeDetection example, and change line (the second argument) of the DAQmxCreateDIChan function in line 68 and risingEdgeChan and fallingEdgeChan (second and third arguments) of the DAQmxCfgChangeDetectionTiming function in line 69 to the desired device name.
Next, set source (the second argument) of the DAQmxCfgSampClkTiming function in the example of analog input or output to "/device name/ChangeDetectionEvent".
By executing the above two examples together, the digital task executes change detection and the analog task collects data at the timing of change detection.
An ANSI C change detection example can be found in [NI - DAQmx Sample Folder]\DAQmx ANSI C\Digital\Read Values\Read Dig Chan - Change Detection. Also, ANSI C's analog input or output samples can be found in [NI-DAQmx Sample Folder]\DAQmx ANSI C\Analog In or Analog Out. You can open NI-DAQmx examples by selecting National Instruments»NI-DAQmx»NI-DAQmx Examples from the start button.
For details on change detection, please refer to the following link.
Thank you for your feedback.
You changed your response to Not Helpful
You changed your response to Helpful
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.