03-12-2009 04:40 AM
Hi all,
i have a simple problem(using USB 6259),
can start the mesurement over Ai trigger, and can meaure multi channels, but not both at once.
- DAQmxCreateAIVoltageChan(hd, "DEV1/ai0",.....) // define ai0 as trigger channel
- DAQmxCfgSampClkTiming
- DAQmxCfgAnlgEdgeRefTrig
- DAQmxStartTask
- DAQmxReadAnalogF64 ( hd, "DEV/ai0:3",.... // i want to measure more channels "ai0:3" not just "ai0"
Thanks
hassan
Solved! Go to Solution.
03-13-2009 05:39 AM
Hi Hassan,
if you take a look at the C Reference (Start->Programs->National Instruments->NI-DAQ->Text-based code support->NI-DAQmx C Reference Help) you will find that the function "DAQmxCreateAIVoltageChan"'s parameter "const char physicalChannel[]" takes all output channels you want to read from later.
So you need to change your code to "DAQmxCreateAIVoltageChan(hd, "DEV1/ai0:3",.....)"
If you want to use a trigger you would have to define its line in the function "DAQmxCfgAnlgEdgeStartTrig(taskHandle,"DEV1/ai1",DAQmx_Val_Rising,1.0);"
So, to sum up:
- in "DAQmxCreateAIVoltageChan" you define all lines you want to be able to read from
- in "DAQmxCfgAnlgEdgeStartTrig" or "DAQmxCfgAnlgEdgeRefTrig" you select the trigger line
- in "DAQmxReadAnalogF64" you just refer to the same task. You defined the lines to be read in the "DAQmxCreateAIVoltageChan" statement. You do not need to specifically name the lines again.
Please see also the various examples you can find in the same start menu folder as the C Reference.
Let me know if you need more information.
Best regards,
Peter
03-25-2009 03:19 AM
Hi Peter,
since I need pre Trigger Samples, I use "DAQmxCfgAnlgEdgeRefTrig" insted of "DAQmxCfgAnlgEdgeStartTrig", so that the problem remains wenn i use:
NIDAQMX_Error( DAQmxCreateAIVoltageChan( hd, DEV1/ai0:3, '', DAQmx_Val_Cfg_Default, 0, 10, DAQmx_Val_Volts, NULL));
NIDAQMX_Error( DAQmxCfgSampClkTiming( hd, '', SampleRate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, NrOfSamples));
NIDAQMX_Error( DAQmxCfgAnlgEdgeRefTrig ( hd, DEV1/ai0, DAQmx_Val_Rising, TriggerVoltage, NrOfPreTrigger));
NIDAQMX_Error( DAQmxStartTask( hd ));
results: Error -200264
Best regards,
Hassan
03-25-2009 03:35 AM
Hi Hassan,
if you use analog triggering with multiple analog channels, you will have to use the APFI0 input as the trigger source. See this KB: Why do I get Error -200264 When Performing Analog Reference Triggering? All you need to do is to wire your analog signal on line 0 to APFI0 (pin 20 in your case) and set the trigger source to APFI0.
The reason for this is that you only have one ADC on board (E or M series) and it will have to switch between the various lines (see this KB: sampling modes). This setting collides with the idea of an analog reference trigger on one specific line (constantly sampling data in a ring buffer until a condition is met). The APFI0 line, however, has its own ADC. Therefore it can run simultaneously.
However, please note that this ADC is fast but has lower resolution than the AI sampling ADC. See these KBs: E Series and M Series Analog Input Trigger Resolution, be aware of a potential Error Between the Analog Trigger Level and the Value of the First Sample
Hope this clarified the issue.
Best regards,
Peter