Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with Multiple Calls to DAQmxCreateAIVoltageChan

I am running continuous acquisition. The following code that starts my task works fine:

 

DAQmxCreateTask( "MyTask", &m_TaskHandle );
	
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai0:7", "", DAQmx_Val_Diff, -5.0, 5.0, DAQmx_Val_Volts, NULL) );

DAQmxCfgSampClkTiming( m_TaskHandle, "", rSampleFreq, DAQmx_Val_Rising, DAQmx_Val_ContSamps, iCount ) );

DAQmxSetAIConvRate( m_TaskHandle, 200000.0 ) );

DAQmxStartTask( m_TaskHandle );

 

If I replace the singel DAQmxCreateAIVoltageChan call that sets up 8 channels with the same gain, to 8 separate calls with different, or the same gain:

 

 

DAQmxCreateTask( "MyTask", &m_TaskHandle );
	
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai0", "", DAQmx_Val_Diff, -5.0, 5.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai1", "", DAQmx_Val_Diff, -5.0, 5.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai2", "", DAQmx_Val_Diff, -5.0, 5.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai3", "", DAQmx_Val_Diff, -5.0, 5.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai4", "", DAQmx_Val_Diff, -5.0, 5.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai5", "", DAQmx_Val_Diff, -5.0, 5.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai6", "", DAQmx_Val_Diff, -5.0, 5.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai7", "", DAQmx_Val_Diff, -5.0, 5.0, DAQmx_Val_Volts, NULL) );

DAQmxCfgSampClkTiming( m_TaskHandle, "", rSampleFreq, DAQmx_Val_Rising, DAQmx_Val_ContSamps, iCount ) );

DAQmxSetAIConvRate( m_TaskHandle, 200000.0 ) );

DAQmxStartTask( m_TaskHandle );

 

or

 

DAQmxCreateTask( "MyTask", &m_TaskHandle );
	
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai0", "", DAQmx_Val_Diff,  -5.0,  5.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai1", "", DAQmx_Val_Diff, -10.0, 10.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai2", "", DAQmx_Val_Diff,  -5.0,  5.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai3", "", DAQmx_Val_Diff,  -0.5,  0.5, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai4", "", DAQmx_Val_Diff,  -5.0,  5.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai5", "", DAQmx_Val_Diff, -10.0, 10.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai6", "", DAQmx_Val_Diff,  -5.0,  5.0, DAQmx_Val_Volts, NULL) );
DAQmxCreateAIVoltageChan( m_TaskHandle, "Dev1/ai7", "", DAQmx_Val_Diff,  -0.5,  0.5, DAQmx_Val_Volts, NULL) );

DAQmxCfgSampClkTiming( m_TaskHandle, "", rSampleFreq, DAQmx_Val_Rising, DAQmx_Val_ContSamps, iCount ) );

DAQmxSetAIConvRate( m_TaskHandle, 200000.0 ) );

DAQmxStartTask( m_TaskHandle );

 

 

the first channel data is not present. It is simply filled with noise. Any help would be greately appreciated.

 

 

0 Kudos
Message 1 of 5
(7,662 Views)

Hey ckDuffey,

 

What hardware are you using?  What version of DAQmx driver do you have?  Is there a specific reason you are setting the Convert Clock rate in your program?  From what I can tell you are doing everything correctly, it is strange that only one channel is filling with noise.  I have a few things to try out and a few questions to ask to try and narrow down what could be happening here.

 

What voltage range is the noise?  What voltage do you expect?  If you take out the other 8 channels, only have one channel in your task, and add one channel at a time, can you reproduce the noise with just two channels or more?

 

 

Kyle A.
National Instruments
Senior Applications Engineer
0 Kudos
Message 2 of 5
(7,642 Views)

Kyle,

 

Thanks for responding. I will need some time to answer all of your questions, but will start with quick answers to those I already know.

 

The hardware is a PCI 6013.

 

The DAQmx driver is the latest one off your website that is not a beta.

 

DAQmxSetAIConvRate is used so that I scan through the channels at the maximum rate (200 kS) to minimize phase error bewteen each channel. The card is being used for 60 Hz and 400 Hz power measurements.

 

I have been using this code on a system with external programmable gain amps for years. I now am applying it on a system with a fixed high voltage divider on the input, and need to use the programmable gain on the card.

 

I am applying a sine wave input. With the old method (i.e. one call to DAQmxCreateAIVoltageChan), I can see the signal on each channel. With the new method to make use of the programmable gain amps, no signal appears on the first channel, just some background noise. It appears on the other channels.

 

I can't run only 1 or 2 channels in this application unfortunately, since all of the code (thousands of lines) is dependent upon 8 channels of data being returned.

 

I will get an idea of the noise level, but I don't think the level of the noise is the issue. The signal simply is not there, and all that is left is noise.

 

Thanks again, and I look forward to your additional responses.

 

Chris...

0 Kudos
Message 3 of 5
(7,637 Views)

Hi Chris,

 

I don't know how much flexibility you have with testing this system, but if you could make a simple program that can recreate this issue apart from your actual application that would be helpful to further test the issue you are seeing.  I would want to see the behavior of the system with just that channel in the task, or having 7 channels in the task excluding the one that is reading noise.  A simulated sinusoid would also help eliminate possibilities.

 

This is certainly strange and unexpected behavior, and it is difficult to tell what exactly is causing the issue.  If you add the channels from the bottom to the top maybe that could produce different results?  For example, ai7 would be added first and ai0 at the end.

 

Aside from testing, you could try reinstalling the DAQmx driver, but I am unsure if that will change anything.  An NI-Spy capture may provide additional insight if you want to get one of those.  If you can perform any of these steps and let me know the results, it may help narrow down places to look at that could cause this issue, thanks.

Kyle A.
National Instruments
Senior Applications Engineer
0 Kudos
Message 4 of 5
(7,613 Views)

Kyle,

 

You were correct. The code works the same. I had some intermittant connection in the hardware creating the issue. Thanks for all of your help.

 

Chris...

0 Kudos
Message 5 of 5
(7,600 Views)