11-07-2017 04:43 PM - edited 11-07-2017 04:56 PM
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.
11-07-2017 08:37 PM
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
11-07-2017 09:34 PM
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?
11-08-2017 02:07 AM
11-08-2017 08:45 AM
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
11-08-2017 11:09 AM
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.
11-08-2017 11:53 AM - edited 11-08-2017 11:53 AM
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!).
11-08-2017 12:29 PM
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
11-08-2017 12:58 PM
You could try registering for events on your main task or on a secondary task on the same channel as your trigger:
11-08-2017 01:50 PM
Kyle,
Apparently DAQmx signal events are not supported by the USB-6002. Error -200982.