05-04-2009 01:41 AM
Hi
I am using a NI-6013-PCI card, and used DAQ_Op and DAQ_Start to acquire data from the device (with gain set to 1), which have a CCD camera to acquire data.
I did migrated the application to DAQmx, it is working fine but the intensity of the graph plotted using the data is lower than the expected one.
While migrating the old code I replaced DAQ_Op by the logic given below
/*------------------------------------------------------------------------------------------------*/
TaskHandle ulTaskHandle = 0;
DAQmxCreateTask("", &ulTaskHandle);
double dMaxVolt = 5.0;
double dMinVolt = -5.0;
DAQmxCreateAIVoltageChan(ulTaskHandle, "Dev1/ai0", "", DAQmx_Val_Cfg_Default, dMinVolt, dMaxVolt, DAQmx_Val_Volts, NULL);
/* This function handles various select signal combinations.
* - Select_Signal(1, ND_PFI_2, ND_IN_CONVERT, ND_HIGH_TO_LOW)
* - Select_Signal(1, ND_SCANCLK_LINE, ND_SCANCLK, ND_LOW_TO_HIGH)
*/
RouteSignal();
DAQmxCfgSampClkTiming(ulTaskHandle, NULL, dSampleRate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, ul64SamplePerChan);
DAQmxStartTask(ulTaskHandle);
/* Allocate memory for data acquisition. */
double* pDataBuf = new double[ulCount+1];
long lSamplesToRead = (long)ulCount;
long lSampsPerChanRead = 0;
DAQmxReadAnalogF64(ulTaskHandle, DAQmx_Val_Auto, DAQmx_Val_WaitInfinitely, DAQmx_Val_GroupByChannel, pDataBuf, lSamplesToRead, &lSampsPerChanRead, NULL);
if (ulCount != (unsigned long)lSampsPerChanRead)
{
}
else
{
for (unsigned long ulIdx = 0; ulIdx < ulCount; ulIdx++)
{
/* psBuffer is a short array.
* Here I try to convert and copy the new buffer (double values)
* to old buffer (short values)
*
* I assume that old values will be in the range of millivolt.
* To convert the volt values from current buffer to millivolt I am multiplying it by 1000
*
* I don't know whether it is true/
*(psBuffer+ulIdx) = static_cast<short>((*(pDataBuf+ulIdx)*1000));
}
}
I am not sure whether the conversion I did from new buffer to old buffer is true. Do I need to create a DAQmx_Val_FromCustomScale to get the same value as DAQ_Op returned?
Could you found any thing wrong with the logic? How can I get the same value as DAQ_Op returned from the double buffer returned by DAQmxReadAnalogF64() Is there any other best mechanism available?
regards
Praveen.DA
Solved! Go to Solution.
05-08-2009 12:52 AM
Hi,
I called NI support team yesterday and made a post in the discussion forum, but I didn’t get any reply from NI! I am in a difficult situation!!!
I shall explain my problem once again.
I had an old application (VC++) using NIDAQ and it was using DAQ_Op(), with gain 1, to read data using the NI 6013 PCI card. Currently I migrated it to DAQmx. Below given code was used to replace the DAQ_Op() function.
I am facing problem due to the difference in data values acquired DAQ and DAQmx.
I connected the card (no device connected to the card) to my computer and called DAQ_Op() and DAQmx functions to read data. I got data as given below.
DAQ
3594
3602
3595
3610
3604
3597
3606
3596
3599
3606
DAQmx
0.563507
0.563049
0.563354
0.563660
0.563965
0.563965
0.563965
0.563660
0.564117
0.563812
From the data I found that DAQmx value is around 6500 times lower than that of DAQ.
1. What does this means?
2. Why the values are different?
In DAQ data is retrieved as a short integer value while in DAQmx it is it is retrieved as double precision float values.
1. I would like to know how above data is represented in DAQ and DAQmx?
2. Also can you specify the unit of the value returned in DAQ and DAQmx?
Regards
Praveen.DA
DAQmxCreateTask("", &ulTaskHandle);
DAQmxCreateAIVoltageChan(ulTaskHandle, "Dev1/ai0", "", DAQmx_Val_Cfg_Default, 5.0, -5.0, DAQmx_Val_Volts, NULL);
DAQmxCfgSampClkTiming(ulTaskHandle, NULL, dSampleRate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, ul64SamplePerChan);
DAQmxStartTask(ulTaskHandle);
double* pDataBuf = new double[ulCount+1];
long lSamplesToRead = (long)ulCount;
long lSampsPerChanRead = 0;
DAQmxReadAnalogF64(ulTaskHandle, DAQmx_Val_Auto, DAQmx_Val_WaitInfinitely, DAQmx_Val_GroupByChannel, pDataBuf, lSamplesToRead, &lSampsPerChanRead, NULL);
for (unsigned long ulIdx = 0; ulIdx < ulCount; ulIdx++)
{
/* Copy data in pDataBuf to short value buffer for further processing */
}
05-08-2009 07:02 AM
05-13-2009 03:38 AM
I found the reason for this bug.
I was using NI-6013-PCI card. and tried to read data using DAQmxReadAnalogDataf64() function.
From the specification of NI-6013-PCI card, I found thet the analog data input resolution is 16 bytes. So it should be read using a function that reads 16 bit data. DAQmxReadBinaryI16, DAQmxReadBinaryU16 or DAQmxReadRaw can be used in this regards.
So, you should refer the resulution of input data, from the specification of the DAQ device, before using a particular read function.
05-13-2009 09:18 AM
05-13-2009 11:30 PM