Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

USB-6501 Detect an External Trigger

Solved!
Go to solution

I have an external trigger I want to wait and detect with the 6501.  I've tried the following ( based on NI example code 😞

ret = DAQmxCreateTask( NULL, &tsk_hndl[ indx ] );

ret = DAQmxCreateDIChan
(
tsk_hndl[ indx ],
"Dev1/port2/line0:7", //"Dev1/port2/line7"
NULL,
DAQmx_Val_ChanPerLine
);

ret = DAQmxCfgChangeDetectionTiming
(
tsk_hndl[ indx ],
"Dev1/port2/line0:7",
"Dev1/port2/line0:7",
DAQmx_Val_ContSamps,
1
);

 

and the DAQmxCfgChangeDetectionTiming gives me an error of -20077 ( DAQmxErrorInvalidAttributeValue ) and the error string isn't very helpful.  I tried using just line 7 vs lines 0-7.  Since this wasn't working I tried setting it up as a counter ( that same line Port 2 / Line 7 is also CTR0 ) and that also errors.  Right now I'm setting it up as a digital input ( without the change detection ) and reading it continuously in a thread but believe triggers are being made ( trigger appears to have occurred looking at the external equipment via oscope ) and being missed by that approach.  

-G-
0 Kudos
Message 1 of 6
(1,878 Views)
Solution
Accepted by topic author Grasshopper

Based on this doc (and the spec sheet), it doesn't appear that the USB-6501 supports change detection.   Or any other kind of hardware-clocked sampling.   Polling digital state in a software loop can miss short pulses (as you've already seen).

 

Sorry to say, but I think you're running into inherent device limitations.  You would need different hardware to get the capabilities you want.

 

 

-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.
0 Kudos
Message 2 of 6
(1,863 Views)

Kevin, thanks for response.  The links to the docs ( particularly the specs ) was very helpful.  Since change detection isn't supported we tried the counter line but it wouldn't initialize ( error ). 

ret = DAQmxCreateCICountEdgesChan
(
pnl_hndl[indx],
"Dev1/ctr0",
"",
DAQmx_Val_Falling,
0,
DAQmx_Val_CountUp
);

Once I read the specs sheet I change the DAQmx_Val_Rising to _Falling and it initialized.  So, your answer actually helped us with the follow-up question we never wrote. 🙂  

-G-
0 Kudos
Message 3 of 6
(1,824 Views)

Just to confirm for anyone else who comes across the thread:

 

I'm supposing your main strategy is to query the count value in a loop until the value is > 0.  Is that the main thing you're doing to detect the trigger?

 

 

-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.
0 Kudos
Message 4 of 6
(1,808 Views)

Basically.  We have an external trigger ( from a network analyzer ) that is activated every time a measurement sweep is complete.  We want to wait until that trigger occurs and then do other things.  The kicker is that it's in a loop that needs to run in single digit milliseconds so that's why we wanted the card to indicate a detection ( and why we are going to the counter ) because polling it can miss the trigger since it's short ( shooting for under 3 ms ).

-G-
0 Kudos
Message 5 of 6
(1,802 Views)

Oh, repeated triggerings, gotcha.

 

The nice thing with the counter approach is that if Windows starves you of CPU and 2+ triggers happen while you aren't able to poll, you'll at least *know* how many you missed.  It isn't as good as not missing in the first place, but it *does* beat not even being able to know.

 

Good work!

 

 

-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.
0 Kudos
Message 6 of 6
(1,793 Views)