Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Sampling multiple AI channes on USB-6008

I have an NI USB-6008 device, which I'm using to sample two analog input channels.

As long as I'm only monitoring one analog input channel, everything works fine; the problems arise when I try to sample two channels simultaneously.

Question 1:

I want to sample the two channels with different sampling frequencies, FREQ1 and FREQ2 (their sum is well below the maximum sampling rate of 10,000 samples per second). So I roughly do this:
DAQmxCreateTask("task1", &taskHandle1);
DAQmxCreateAIVoltageChan(taskHandle1, "Dev1/ai0", NULL, ...);
DAQmxCfgSampClkTiming(taskHandle1, NULL, FREQ1, DAQmx_Val_Rising, DAQmx_Val_ContSamps, FREQ1);
DAQmxCreateTask("task2", &taskHandle2);
DAQmxCreateAIVoltageChan(taskHandle2, "Dev1/ai1", NULL, ...);
DAQmxCfgSampClkTiming(taskHandle2, NULL, FREQ2, DAQmx_Val_Rising, DAQmx_Val_ContSamps, FREQ2);
DAQmxStartTask(taskHandle1);
DAQmxStartTask(taskHandle2);

The last statement (staring task 2) fails with error -50103 ("The specified resource is reserved. The operation could not be completed as specified.").

What is the problem? Is it impossible to  have two simultaneous analog input tasks?


Question 2:

If I must combine the two input channels into a single task, I'm somewhat unsure about how to do that. In particular,  I don't understand the difference between
  •  DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0,Dev1/ai1",...)
and
  •  DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0",...)
  •  DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai1",...)
Do they have the same effect, or is there a difference?

Question 3:

Can my problem with having different sampling frequencies be soved by replacing my 6008 with a 6009?

Thank for any help.

/ Claus Tondering
0 Kudos
Message 1 of 5
(5,962 Views)
Claus,

your suspicion of Question 2 is correct, you have to create both channels within one task. The reason for this is the architecture of the AI from the USB-6008 (multiplexed).
The one and only difference between the calls stated in question 2 is, that calling "CreateAIVoltageChannel" for each channel itself gives you the possibility to set a dedicated gain for each channel seperatly. Ok, DAQmx does only let "choose" you a specific gain by choosing min and max-values of your acquisition. But they can be different for the channels.
Regards to question 3, that depends on your acqusition-rates. If one channel has to be sampled with 8kHz, the next one with 1kHz, the sum would be below the 10kHz, but it will not be possible to solve it. The reason lies (again) in the architecture of the AI: All channels have to be sampled with the same frrequency, therefore you would have to sample with 16kHz to have both channels sampled with 8kHz. You definetly would reduce the data of channel two by a factor of 8 (to get the 1kHz), but you would have to sample it with 8kHz..... And if you run into that issue, you will have to take a device capable of sampling rates higher than 10kHz.

Norbert B.
NI Germany
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 5
(5,951 Views)
Hi Norbert,

Thanks for your reply.

Looks like I have to start doing some thinking ...

/ Claus Tondering
0 Kudos
Message 3 of 5
(5,940 Views)
I have a very similar question regarding multiple sampling (sequential, not simultaneous) for a 6251 card we have ordered.
I am translating my Trad. NIDAQ code into DAQmx. I'm glad to learn how you can assign different "gains" to multiple channels within a task by configuring the same task handle for different physical channels independently. However, there doesn't seem to be much information on the timing for sequential sampling that would result from this.
1. Do the channels get sampled in the order in which they are configured?
2. If you choose a particular internal timebase and rate with DAQmxCfgSampClkTiming, will the sequential channel sampling adhere to the same timing?
3. If the answer to (2) is no, then how does one choose the data format which includes timing information (Waveform format)?
4. Is it possible to get unscaled integer output that still contains timing information?

I also had a question about the input range settings that have replaced gain settings. I think the 625x cards use bipolar ranges. If I use min/max values of, for example, 6.0V/10.0V, would the internal scaling use +/-10V range or a +/-2V range with some kind of offset?

Thanks in advance,

Tanaya
0 Kudos
Message 4 of 5
(5,689 Views)
Tanaya,

1.) Yes, they do. So if you configure your task to contain channel 1, 0, 5, 3, they will be sampled in this order (1,0,5,3).
2.) You configure the sampleclock for all channels. Each channel has the same clock, which is defined as "samples per second per channel". The overall samplingrate is therefore the product of "number of channels" multiplied by the "samplerate per channel". This rate cannot succeed the maximum samplingrate of the device (typically up to 1 MHz for MIO-devices).
3.) obsolete since 2 is "yes".
4.) Well, that is the "problem" of timestamps: You never get any timestamp of the DAQ-device itself, but from your PC when it fetches the sampled values from the buffer. Unscaled values are the binary value returned from the device during the ADC. Currently, there are no functions which enables you to retrieve waveforms (which equals dataarrays with an initial timestamp and a delta-time) with binary data. Still, you can generate a timestamp on your own (retrieve the "systemtime") near the retrieval of the data. This timestamp will be off a bit, but if your system is properly set up, this can be very close. Nevertheless, you will always have the jitter of the OS in this timestamp.

Regarding your last question:
DAQmx checks your input range using all information available (which means scales) in regard to the used device. So if you use thermocouples and use a range of 0..200° C, it would choose (depending on the type of the couple) something like 0..1V or +/- 1V, depending on the device (if it supports unipolar or not).
In your example, DAQmx would always choose +/- 10V since it does not fit in any other range. Therefore, the gain would be set to 0.5.
If you created a linear scale for the same inputsetting (6-10 V) which scales by 2, your device would use the +/- 5V (if available), setting the gain to 1.0. If +/-5 V is not available, it would stay at +/- 10V.

There are other devices, which can "ignore" DC-offsets, but they are specialized devices....

hope this helps,
Norbert
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 5
(5,594 Views)