Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx : configure continuous digital acquisition with start and stop trigger

Solved!
Go to solution

Hello all

 

I'm posting because I can't find a solution to my problem.

As written in the title I want to simply do a continuous acquisition (continous sampling) of a digital line. The fact that it is a digital line instead of an analog one is no big deal, I presume. I want to start acquisition on a rising edge of digital trigger (PFI0 for example) and stop acquisition on a trigger too (falling edge on the same signal (PFI0 still then) or a new rising edge). This way I could precisely control the duration of acquisition and/or the start or stop from other devices.

 

As it is a digital acquisition you need to do a first "trick" : create a dummy task of analog input and retrieve the clock to do the digital input. I parameter this analog task to start on a trigger. It works but I can't find a way to stop it on another trigger.

 

Do you hav any idea how to implement this ??

 

Finaly I didn't find an easy way to carefully break the VI from waiting for a trigger (in case you want to restart an acquisition with different parameters for example). Do you use Abort task or is it better to set a timeout on reading Digital channel VI until trigger occurs ?

 

Any help would be appreciated !!!

Thanks

 

Config : LV 2010, Daqmx last version and USB ni 6251 card.

0 Kudos
Message 1 of 6
(7,824 Views)

Hello Youann,

 

in fact you are not able to do stop trigger directly. However, you can use reference trigger to implement it.

 

There is an example you can find at Start Trigger and Stop After n Pulses for Continuous Analog Input with DAQmx. I haven't checked it in details. but it seems it should work.

 

regards,

stefo

Certified-LabVIEW-Developer_rgb.jpg

Message 2 of 6
(7,816 Views)

Thank you for answering me.

This solution is based on the fact that you know how many pulses to count before stopping...

So this is not the fonctionnality I want to add in my program... 😞

Anyway this is a good idea for fixed duration acquisition.

 

If someone has another idea or know there is no way...

 

0 Kudos
Message 3 of 6
(7,812 Views)

You *might* be able to use a pause trigger to accomplish what you're after.  It won't be foolproof, but if you know enough about the potential timing of your trigger signals it might be workable.  The goal will be to use a pause trigger (which is inherently state-sensitive) to try to accomplish the same effect as an edge-sensitive stop trigger.

 

Unfortunately, it appears that M-series DI tasks may not support pause triggering directly (based on a brief & superficial test on a simulated device.)  So you might need a second layer of indirection via a counter.  Using 2 counters may let you make the system more foolproof but at the cost of occupying board resources you might need for other things.

 

You've already got a method to make an AO sample clock start on a digital start trigger.  Now you can configure a counter to generate a pulse train based on the AO sample clock.  The DI task will now use the counter output as its sample clock. 

 

Set the counter up to be pause-triggered so it will pause after the transition you'd like to treat as a "stop edge."  If the signal will stay in that paused state long enough for you to notice, then you already have your not-quite-foolproof-but-pretty-workable solution.  If the signal just makes a brief pulse, then you can use the 2nd counter to generate a single long pulse that's triggered by the "stop edge", and have the first counter configured to use the 2nd counter's output as a pause trigger.

 

It's not trivial -- but it should be doable. 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 4 of 6
(7,803 Views)
Solution
Accepted by topic author YoannG

Hey Yoann,

 

One way is to use counters as Kevin described. For me is usually easier  to create dummy task which has timing engine (like AI), but it depends on what resource you have available on your board which you will not need :D.

 

In fact the example is the same as what you need for continuous measurement - just what you need to do is to remove the counter part, and change reference trigger to be external (your stop trigger).

 

with this approach you should be able to do continuous measurement - i have noticed that you need DI - in fact with little modification you should be able to use this example. DI doesn't have its own timing engine, therefore you need to use external sample clock. If we use the example to create dummy AI to provide sample clock, and we start DI task before we start dummy AI, then we can pretty much get continuous clock which starts on start trigger and stops on reference trigger.

 

Just have a look into the modification - again, I haven't tested it, but logic seems to be correct.

 

DI_Start&Stop.png

 

with kind regards,

stefo

Certified-LabVIEW-Developer_rgb.jpg

Message 5 of 6
(7,790 Views)

Hello to you

 

I thank you for helping me about this problem. 

 

I test the dummy task example and it's kinda working.

The program could start acquisition on a trig and stop when there is another trig. But the timing for stopping the DI task is not perfect, and you got a good timing for the start and a bad one for the stop. So it's working but not exactly in the best way.

 

I think making DI tasks is a real nightmare... They could have done something a bit simpler, as they have done for analog input...

 

Thanks again !

 

Here is a little code to test the system. One can see that duration of each acquisition in trig for dtart and stop is random...

 

0 Kudos
Message 6 of 6
(7,756 Views)