Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get a USB 6009 Multi Analog Input With both Differential and Single Ended Functioning at the same time?

Hello, here's my question:

I have a USB-6009 and I am using NI-DAQmx Base in C++.

I have tried (unsuccessfully) to implement a situation where channels ai0 and ai1 operate in differential mode and channels ai6 and ai2 operate in single ended mode (non referenced), meaning that each of ai2 and ai6 has a different wire connected to it with different voltage...each of which I would like to know the value of seperately.

Here is an example of trying ai0 & ai1 in differential and ai2 in single ended in referenced mode (non-referenced causes a program error...).
I create the task handles as seperate items:

    DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
    DAQmxErrChk (DAQmxBaseCreateTask("",&task2));
    DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,"Dev1/ai0:1","",DAQmx_Val_Diff,min,max,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(task2,"Dev1/ai2","",DAQmx_Val_RSE,min,max,DAQmx_Val_Volts,NULL));

and then start the tasks:
    DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
    DAQmxErrChk (DAQmxBaseStartTask(task2));

The program just sits there and doesn't spit anything out in the loop where I call the 'DaqmxBaseReadAnalog64' function.

Any ideas? If there is any example code on how to run differential inputs and analog inputs simultaneously, I'd appreciate a glance at it!

Thanks!
0 Kudos
Message 1 of 6
(3,924 Views)
I think you have a couple of problems:

1) You can't have two AI tasks operating on the same device at the same time. Instead, make one task and put all your AI channels into the same one.

You should be able to mix differential and NRSE channels in the same task.

2) You don't have (or at least you don't show) any timing configuration. You need a call to DAQmxCfgSampClkTiming to set up the scan clock.

On the other hand, if you want to use software timing, this isn't necessary (see the example ContAcqSamp-SWTimed that is installed with NI-DAQmx in the Measure Slow Varying Signal folder). Perhaps somehow your application missed an error from having more than one task configured.
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
Message 2 of 6
(3,917 Views)
Hi John,
 
If I don't create 2 AI tasks would this be as simple as:
 
 DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
 DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,"Dev1/ai0:1","",DAQmx_Val_Diff,min,max,DAQmx_Val_Volts,NULL));
 DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,"Dev1/ai2","",DAQmx_Val_NRSE,min,max,DAQmx_Val_Volts,NULL));
 DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,"Dev1/ai6","",DAQmx_Val_NRSE,min,max,DAQmx_Val_Volts,NULL));
 
?
 
The answer: Yes. It is.
 
Problem: NRSE causes the program to hang!! But RSE work perfectly for my purposes. Wonder if there is some underlying issue here with DAQmxBase...?
 
Also: I am runnning my own timing stuff. It was a snippet of code that I posted before.
 
Everything works with RSE just as I wanted it to, so my problem is solved. Just wonder what's up with NRSE?
 
Thanks for your help John!
 
 
 
0 Kudos
Message 3 of 6
(3,911 Views)
Oh, yeah. NRSE and USB-6009. Heh.

USB-6009 doesn't have NRSE as an option. Sounds like your DAQmxErrChk macro isn't doing the right thing. These sorts of errors should cause DAQmxStartTask to return an error when it tries to verify the task.
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
Message 4 of 6
(3,899 Views)

The error check macro was acutally doing the right thing. Problem is that my test program that I setup to mess around with stuff, before I change my actual project code, brings up a DOS prompt to run the code. So, when the error message came out (when trying to use the NRSE for e.g. Smiley Wink ) the prompt just closed.

Thanks again,

Nathan

Message Edited by ElectricNathan on 08-30-2005 10:20 AM

0 Kudos
Message 5 of 6
(3,886 Views)
Ah. In similar situations I put in a call to getc() which causes the program to hang waiting for input. That way the DOS window stays around long enough to read the output.

I presume there must be another way to do it...
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
0 Kudos
Message 6 of 6
(3,879 Views)