06-08-2010 08:35 PM
we used to use PCI-6025E along with traditional NI-DAQ to acquire data from a meter using two simple commands AI_Configure to configure the channel and AI_VRead to read in a sample whenever I need in my thread (basically for every 15msec). We would like to replace this board with USB-6008, but unfortunately this is not supported by traditional NI-DAQ. Is there any simple way to do this? We are not looking for anything fancy, all we need is to configure the device to acquire analog data on AI0 within +/-10V range and be able to read in a sample whenever we want to. Application development is in Visual C++ 6.0. Any help is greatly appreciated. Thanks.
06-09-2010 10:25 AM
To add more detail to my post above, I did try using NI-DAQmx libraries as follows in a simple program, but the data its acquiring is not right.
//the following code is in a thread
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev2/ai0","",DAQmx_Val_RSE,-10,10,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,NULL,1000.,DAQmx_Val_Rising,DAQmx_Val_ContSamps ,1));
fp = fopen("c:\\acquire.txt","w+");
while(parent->run)
{
::WaitForSingleObject(WaitEvents, 15);
DAQmxErrChk (DAQmxStartTask(taskHandle));
DAQmxReadAnalogF64(taskHandle,1,10.,DAQmx_Val_GroupByChannel,data,1,&read,NULL);
DAQmxStopTask (taskHandle);
fprintf(fp, "%f\n",data[0]);
}
fclose(fp);
DAQmxClearTask (taskHandle);
//the data its writing into file
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000 .....................
Is there something that I am missing here in the code?? When I use max explorer and run test panels, it shows the right signal (which is a dynamic sine wave between 50 - 100Hz)
thanks
06-09-2010 03:32 PM
Hello,
Have you tried looking at the examples that come with DAQmx? You can find these under your Start Menu » Programs » National Instruments » NI-DAQ » Text Based Code Support » C++ Examples.
I would suggest looking at Analog In » Measure Voltage » ContAcqVoltageSamples_IntClk. Try this out and see if you still show the same values in your .txt file.