Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with USB-6211 shared trigger

 
Hello,
I am struggling with triggering on AI0 rising edge and synchronizing this with reading DI1. I keep getting error message (-200245) Specified property is not supported by the device or is not applicable to the task.  How do I configure the analog trigger task on AI0 to initiate a trigger for the read DI1 task? I have tried many combinations for the DI1 trigger and seems I may have a hardware limitation?
 
 
 
TaskHandle  ReadDig1 = 0;
TaskHandle  ReadAnalog = 0;
DAQmxErrChk (DAQmxCreateTask("",&ReadAnalog));
DAQmxErrChk (DAQmxCreateTask("",&ReadDig1));
DAQmxErrChk (DAQmxCreateAIVoltageChan(ReadAnalog ,"Dev1/ai0" ,"", DAQmx_Val_Cfg_Default, 0.0, 5.0, DAQmx_Val_Volts, NULL));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(ReadAnalog, "/Dev1/PFI0", DAQmx_Val_Rising));   
DAQmxErrChk (DAQmxCfgSampClkTiming(ReadAnalog, "/Dev1/PFI0", 50.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1));
DAQmxErrChk (DAQmxCreateDIChan(ReadDig1,"Dev1/line1","",DAQmx_Val_ChanForAllLines));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(ReadDig1, "/Dev1/AnalogComparisonEvent", DAQmx_Val_Rising));
DAQmxErrChk (DAQmxCfgSampClkTiming(ReadDig1, "/Dev1/PFI0", 50.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1));

DAQmxErrChk (DAQmxStartTask(ReadAnalog));
DAQmxErrChk (DAQmxStartTask(ReadDig1));
0 Kudos
Message 1 of 4
(3,260 Views)

Hi Tech Products,

Unlike the Analog I/O, the Digital I/O on the USB-6211 is completely software timed and therefore, you will not be able to trigger a digital read from any internal or external source. However, we do have devices such as the USB-6221 and USB-625x which do supports correlated digital I/O (triggered digital acquisition/generation). If you do not have access to one of these devices, one way around this limitation would simply be to use the analog inputs as a digital line and perform a comparison of the readings in software to determine if it is a digital high or a low.

I hope this helps,
S_Hong

S_Hong
National Instruments
Applications Engineer
0 Kudos
Message 2 of 4
(3,242 Views)
 
Below is the code I have generated and I keep getting errors when I try to trigger two tasks from one input edge.
currently the start task for the ReadAnalg1 is getting error -50103 "The specific resource is reserved" 
What am I missing here? How can I share a common trigger and read multiple analog inputs?
 
Thanks,
Tech Products
 
 
DAQmxErrChk (DAQmxCreateTask("",&ReadAnalog0));
DAQmxErrChk (DAQmxCreateTask("",&ReadAnalog1));
 
DAQmxErrChk (DAQmxCreateAIVoltageChan(ReadAnalog0 ,"Dev1/ai0" ,"", DAQmx_Val_Cfg_Default, 0.0, 5.0, DAQmx_Val_Volts, NULL));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(ReadAnalog0, "/Dev1/PFI0", DAQmx_Val_Rising));   
DAQmxErrChk (DAQmxCfgSampClkTiming(ReadAnalog0, "/Dev1/PFI0", 50.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1));
DAQmxErrChk (DAQmxCreateAIVoltageChan(ReadAnalog1 ,"Dev1/ai1" ,"", DAQmx_Val_Cfg_Default, 0.0, 5.0, DAQmx_Val_Volts, NULL));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(ReadAnalog1, "/Dev1/PFI0", DAQmx_Val_Rising));   
DAQmxErrChk (DAQmxCfgSampClkTiming(ReadAnalog1, "/Dev1/PFI0", 50.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1));

DAQmxErrChk (DAQmxStartTask(ReadAnalog0));
DAQmxErrChk (DAQmxStartTask(ReadAnalog1));
0 Kudos
Message 3 of 4
(3,233 Views)
Hi Tech Products,
 
The reason why you are getting error -50103 is because you are trying to run two analog input tasks at the same time. Even though the tasks might be using different channels, this is still a conflict because they require use of the same multiplexer and sample clock. This issue can be resolved by combining your analog read operations into the same task. Therefore, your code must be modified in the following way:
 
DAQmxErrChk (DAQmxCreateTask("",&ReadAnalog0));
DAQmxErrChk (DAQmxCreateAIVoltageChan(ReadAnalog0 ,"Dev1/ai0:1" ,"", DAQmx_Val_Cfg_Default, 0.0, 5.0, DAQmx_Val_Volts, NULL));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(ReadAnalog0, "/Dev1/PFI0", DAQmx_Val_Rising));   
DAQmxErrChk (DAQmxCfgSampClkTiming(ReadAnalog0, "/Dev1/PFI0", 50.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1));

DAQmxErrChk (DAQmxStartTask(ReadAnalog0));
Note that depending on which DAQ device you are using, you may only have access to a single Analog-to-DIgital Converter (ADC). In this case, there will be a slight delay between the samples across the different channels since the channels have to be multiplexed to the ADC.
 
S_Hong
S_Hong
National Instruments
Applications Engineer
Message 4 of 4
(3,211 Views)