Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Non-uniform retriggering of an AI task with USB-6002

Solved!
Go to solution

Hi all,

 

I want to use USB-6002 to acquire a sample from an analog input voltage for a specified number of digital triggers. The triggers do not come at regular time intervals. For those interested, the triggers are generated when a motorized stage reaches specific positions. Due to the acceleration and speed of the motor, I do not control when the triggers come in. Below, I am attaching a plot of what I am hoping to achieve.

 

Omnistic_1-1712573198979.png

 

My current solution is attached to this post, and below is a screenshot of the VI.

 

Omnistic_0-1712572676742.png

 

My problem is that I have to start-and-stop the analog input task for every trigger, and my code isn't able to keep up when the triggers come to close to one another in time. My goal is to have triggers that can come as close as 1ms between each others. I was reading about retriggerable tasks, and I am aware USB-6002 doesn't have those. However, USB-6002 has a counter, and I was able to count all the triggers, without missing any, when the temporal spacing between trigger becomes as low as 1ms. However, I do not understand how to use the counter as a clock source for the analog input task. Can someone help me with my issue? Is that even feasible with USB-6002?

 

Thank you for your help and take care,

 

David

 

 

0 Kudos
Message 1 of 10
(464 Views)
Solution
Accepted by topic author Omnistic

Unfortunately, there is no way to implement non-uniform triggering using this low-cost DAQ. An external clock source must have a uniform frequency. NI-DAQmx will throw an error if your clock signal is not the same as the sample rate value specified.

 

One possible workaround would be doing offline processing. Connect the analog signal to AI0 and the trigger signal to AI1. Add both channels to the same task to synchronize them. USB-6002 supports an aggregated sample rate of 50kS/s so you would get 25kS/s, which is roughly 4% of the timing error for the trigger signal of 1ms. Log both data and do offline processing to extract the data from AI0 when there is a rising edge for AI1.

 

-------------------------------------------------------
Control Lead | Intelline Inc
Message 2 of 10
(445 Views)

Thank you for the quick reply. I will implement the solution you propose. However, out of curiosity, can you tell me which DAQ would be able to achieve the non-uniform retriggering?

 

Thank you very much and take care,

 

David

0 Kudos
Message 3 of 10
(418 Views)

@ZYOng wrote:

Unfortunately, there is no way to implement non-uniform triggering using this low-cost DAQ. An external clock source must have a uniform frequency. NI-DAQmx will throw an error if your clock signal is not the same as the sample rate value specified.


Are you really sure about that ZYOng? 

 

If so, that would make the 6002 pretty unique among NI's devices because it's quite common for them to allow the use of a non-uniform frequency external sample clock, without throwing an error for a poor guess at the frequency.

 

To the OP: to try this out, the key would be to configure the external signal to be the sample clock 'source' in your call to DAQmx Timing.  Remove the call to DAQmx Trigger, it wouldn't be needed.  You also don't need the loop for your Finite Sampling task.  Just start it once, request all your samples in a single call to DAQmx Read (select a multi-sample version rather than a 1 sample version), then stop & clear. 

 

Note: the code you posted isn't clear whether you expect 19 samples (as defined in DAQmx Timing) or 9 samples (as implied by your For Loop iterations with 1 sample per iteration).

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 10
(417 Views)

@Kevin_Price

 

Apologies for the confusion with my hard coded number of samples. I have tried to make a code with your suggested changes. The screenshot of the VI can be found below.

 

Omnistic_0-1712589693643.png

 

Running this VI returns the following error.

 

Omnistic_1-1712589733474.png

 

Did I correctly understand your suggestion and does it mean the non-uniform triggering is indeed impossible?

 

Thank you for your help and take care,


David

0 Kudos
Message 5 of 10
(392 Views)

X-Series supports re-triggerable tasks natively.

I just realized that you might be able to use a re-triggerable task in USB-6002 as well. Download the legacy example from Archived: Download Legacy NI-DAQmx Shipping Examples for LabVIEW 2011 and Earlier and go to Multi-function - Counter Retriggable Pulse Train Generation for AI Sample Clock

 

Reference: Retriggerable Tasks in NI-DAQmx

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 6 of 10
(362 Views)

@ZYOng

 

As I mentioned in my question, I do not think USB-6002 supports retriggerable tasks natively. I had previously find this information on this forum: https://forums.ni.com/t5/Multifunction-DAQ/USB-6002-Triggering/td-p/3308609. I am a beginner with LabVIEW and I don't fully understand the example that you linked, but it seem to use the CO Pulse Freq (see screenshot below). My pulses come at irregular intervals and therefore do no exhibit a fixed frequency, would that still work?

Omnistic_0-1712645405841.png

From that example, I also don't really get the overall architecture. What is the Source for the Digital Start Edge? I have a single counter on USB-6002 and it can be on PFI0 or PFI1. By default, it is on PFI0 I believe. If I wire my trigger signal onto PFI0 as the counter, what shall I wire for the Digital Start Edge? Apologies if it is a basic question, but I'm a little bit lost.

 

Thanks for your help and take care,

 

David

 

0 Kudos
Message 7 of 10
(337 Views)

That legacy example was designed before the re-triggerable feature was added to the X Series.

I gonna be honest that I have never used it but I think it is worth a try.

 

Retriggerable Tasks in NI-DAQmx explains the working principle.

 

ZYOng_0-1712660363738.png

 

PFI stands for Programmable function interfaces. The Digital Start Edge can be any PFI. If you wire the trigger signal to PFI0, just specify the trigger as PFI0

 

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 8 of 10
(311 Views)

Usually when you select a device in MAX there's a tab for "Device Routes" that lets you see which timing signal routings are allowed (for things like clocks, triggers, counters, etc.)   However, when  I created a simulated USB-6002, there wasn't even a tab, implying to me that it supports no user-defined routing at all.  That and the error you got sure makes it look like the 6002 will not allow any kind of external sample clock.   Just like ZYOng said back in msg #2.

 

Since the linked legacy example depends on setting up a retriggerable counter pulse train (not supported by the 6002 which can only count edges, not generate pulses) and then routing the output pulses for use as an AI sample clock (also apparently not supported by the 6002), I'm afraid there's not a simple direct solution after all.

 

ZYOng's original response back in msg #2 is going to be your best workaround with the 6002.  Capture both the analog and pulse signal in a single AI task at a high enough rate, and then find the samples of interest after the fact during post-processing.

 

 

-Kevin P

 

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 9 of 10
(305 Views)

Makes sense. Thanks to you both.

 

David

0 Kudos
Message 10 of 10
(287 Views)