Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI DAQ (voltage averaging)

Anyway to instruct a NI DAQ card to perform average voltage measurements instead of calling AI_Read() one at a time?
I am using the 6052E card with NI DAQ software and I can't instruct the card to make X number of measurements on a given AI channel.
It appears that the NI hardware or NI DAQ software only allows one measurement at a time.  My application has four separate threads trying to make voltage measurements on 4 separate AI channels but while averaging in one channel (looping around the AI_Read() call) the others must wait while the current channel is finished.  Any help is greatly appreciated.
 
-Brian
0 Kudos
Message 1 of 6
(3,916 Views)
Not so clear from what you have said, but, do you mean 4 different threads are 4 different tasks created for channels and running in 4 different while loops?


@SWeng wrote:
  My application has four separate threads trying to make voltage measurements on 4 separate AI channels but while averaging in one channel (looping around the AI_Read() call) the others must wait while the current channel is finished.  Any help is greatly appreciated.
 
-Brian



If you have only one task of 4 channels, yes ofcourse the voltage is read one after other since the DAQ card is basically an ADC with  multiplexer. It would be better if you paste a small code illustrating your problem so that we can see through it and help you


Message Edited by Vsh on 04-08-2008 03:13 PM
0 Kudos
Message 2 of 6
(3,901 Views)
Yes, the 1st thread calls AI_VRead() on AI channel 3, the 2nd thread calls AI_VRead on AI channel 4, the 3rd thread calls AI_VRead on AI channel 5 and the 4th thread calls AI_VRead on AI channel 6.  Earlier I said AI_Read() but the call is AI_VRead().  Anyways the measurements are in differential mode and needs lots of averaging.  The API doesn't allow you to supply the number of measurements to make and return the averaged reading.  My application has to call AI_VRead() 20,000 times and perform the averaging.  This stinks in my opinion, having a Windows application make 20,000 calls into a driver is just begging for delays, one call would be much better.  Also it appears that 4 AI channels cannot be read simultaneously.  Or am I wrong.
0 Kudos
Message 3 of 6
(3,894 Views)


SWeng wrote:
Yes, the 1st thread calls AI_VRead() on AI channel 3, the 2nd thread calls AI_VRead on AI channel 4, the 3rd thread calls AI_VRead on AI channel 5 and the 4th thread calls AI_VRead on AI channel 6. 
You need not create different threads for different channels. All channels can be under one single task (or your "thread"). You just have to specify multiple channels(formatting the channel string) in a single task. Refer to your LabVIEW/DAQmx Help for how to create channel string. Search for "Physical channel Syntax" in LV help.
 

SWeng wrote:
The API doesn't allow you to supply the number of measurements to make and return the averaged reading.  My application has to call AI_VRead() 20,000 times and perform the averaging. 
Yes it IS possible to read a specified number of measurements using DAQmx read vi.
Select multiple samples in the Polymorphic VI selector of DAQmx Read.vi, and set the number of samples you want to read.


SWeng wrote:
  Also it appears that 4 AI channels cannot be read simultaneously.  Or am I wrong.

Not sure what do you mean by "simultaneously", simultaneoulsy in the ADC or simultaneoulsy in the task created by you?, If you are talking about ADC, yes you are right since the DAQ card is a  multiplexer. But from the task created, you can read simultanous rmeasurements.
 
It would be better if you post your code or attach an image of your code so that you can have a better help in the forums.


Message Edited by Vsh on 04-09-2008 09:38 AM
0 Kudos
Message 4 of 6
(3,877 Views)

Hi SWeng,

The AI_VRead() function is designed to read one channel when you call the function. In order to read multiple channels with hardware timing I would recommend looking at the example program SCANsingleBufSync.c. This file can be found under C:\Program Files\National Instruments\NI-DAQ\Examples\VisualC\Ai if you installed C support with your Traditional NI-DAQ drivers.

If the example is not on your computer see the Knowledge Base article, How Do I Install Examples for Visual Basic, Visual C++, and Delphi with NI-DAQ? Also some help files for the examples can be found in the article, Where Do I Find Help for Visual Basic and C Examples in Traditional NI-DAQ?

If you are developing a new program and do not have to use Traditional NI-DAQ I would strongly recommend using our newer NI-DAQmx drivers. They will work fine with your 6052e as long as it is in the PCI or PXI form factor. If you have a DAQPad-6052E then you have to use the Traditional NI-DAQ drivers.

The DAQmx driver is more robust and easier to use. A great article for learning the basics of DAQmx is the Developer Zone, Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications. I would also recommend looking at the Getting Started with NI-DAQmx series of articles.

Let me know if you have any questions and have a great week.

Thanks,

Nathan
NI Chief Hardware Engineer
Message 5 of 6
(3,857 Views)
 Smiley Mad was it not in labview??? 


Message Edited by Vsh on 04-09-2008 06:57 PM
0 Kudos
Message 6 of 6
(3,846 Views)