04-06-2022 05:24 PM
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.
Solved! Go to Solution.
04-06-2022 08:28 PM
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
04-12-2022 01:51 PM
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. 🙂
04-12-2022 04:45 PM
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
04-12-2022 05:56 PM
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 ).
04-12-2022 08:09 PM
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