LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to determine if a trigger has been received

I am using a USB-6002 device to start an analog output signal when triggered. How can I determine whether the task has been triggered? The analog output task could take several minutes to complete, so checking whether the task is complete is not an option.

 

I considered creating a dummy task on another channel that shares the same trigger, but completes quickly (such as reading a single sample), then check whether this task is complete. However, all of my AI and AO channels are already reserved for other tasks. I have digital IO lines available, but I don't think it's possible to configure these as part of a triggered task on the USB-6002.

 

Can anyone help me out with this?

 

Attached is a minimum working example that attempts to create a digital input task using the same trigger input as an analog output task.

0 Kudos
Message 1 of 13
(4,064 Views)

Well, you could simply start the digital input task, make it continuous, 1 point at 1000 Hz, and run the output through an Event Structure to generate the "Hey, I've started!" signal you want.  [To be sure, I've not tested this idea, but it sounds, to me, like it might work ...].

 

Bob Schor

0 Kudos
Message 2 of 13
(4,032 Views)

Bob,

Thanks for replying...but I don't understand your idea. How would the digital input task be related to the trigger for the analog output? How would an event structure do anything for me?

0 Kudos
Message 3 of 13
(4,024 Views)

Use Status properties from DAQmx Write Property Node, for example Total Samples Per Channel Generated:

samplesperchannel.png

(I think it's quite obvious how to use them to check if AO task has started).

0 Kudos
Message 4 of 13
(4,005 Views)

When I trigger an Analog Input on my USB-6009 (a predecessor of the USB-6002), I wire a TTL pulse from the "trigger generator" to Pin 29, PFI0.  Simply run another wire from Pin 29 to a DIO terminal of your choice, and configure it as a Digital Input.

 

However, I realize I hadn't thought through the DI Task part completely.  I was focussing on the AI task that "auto-clocks", which the simple DI Task doesn't do.  However, you can easily write a While Loop with a Read DI, put a Delay (ms) with 1 wired to it in the loop (making it a 1KHz "sampler", then use a Shift Register to output Boolean True on a rising edge (I assume you know how to do this).  This replaces the fuzzy thinking about Event Structures (sorry).  Now the only tricky part comes in stopping this loop, but depending on the Version of LabVIEW you are using, various methods come to mind ...

 

Bob Schor

0 Kudos
Message 5 of 13
(3,997 Views)

PiDi,

Thanks for your reply. Unfortunately, the TotalSampPerChanGenerated property node does not behave as expected for real devices.

 

For a simulated USB-6002, this returns 0 before and after the task is started and increments while the task is executed after receiving a trigger (simulated devices are triggered automatically). This is the expected behavior and could be used to determine whether the trigger has arrived.

 

However, for real devices, this property node returns the maximum number of samples immediately after the task is started, before any trigger is received, and does not increment while the task is executed. Could this be a bug? Attached is a VI demonstrating the behavior.

0 Kudos
Message 6 of 13
(3,983 Views)

Bob,

This is an interesting idea. Unfortunately my trigger is a TTL pulse <10us wide so I don't see how this solution would be practical. The software loop with the digital read will not be fast enough to catch the pulse, nor would I want it to be (>100kHz!).

0 Kudos
Message 7 of 13
(3,982 Views)

There's an idea exchange entry requesting a DAQmx property node that would return the "Triggered?" status of a task.   Give it a vote and maybe we'll get such a feature in the future.

 

 

-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 8 of 13
(3,974 Views)

You could try registering for events on your main task or on a secondary task on the same channel as your trigger:

 

DAQmx events.png

0 Kudos
Message 9 of 13
(3,969 Views)

Kyle,

Apparently DAQmx signal events are not supported by the USB-6002. Error -200982.

0 Kudos
Message 10 of 13
(3,958 Views)