01-12-2011 12:56 PM
I am upgradeing our software from Traditional NIDaq to Daq-mx
I have a task that goes out and reads all 32 channels on a PCI-6254 and then updates a dialog box with its readings, this happens roughly every 500 ms.
So the old code used DaqCheck(), I am using using IsTaskDone, but the problem is according to the reurn value of IsTaskDone() the variable is alwys zero unless I explicity stop the task.
But this behavior does not agree with the documentation, I am only reading a 100 samps from each of the channels, so when this is complete the task should be done. The only way to get it return a value of 1 is to stop the task. If someone could clarify why this behaviour is the way it is
/// Code ///
void CRaw::VContAcqVolts16bit()
"Dev1/ai0","",DAQmx_Val_RSE ,0.0,m_fMaxVal[0],DAQmx_Val_Volts,NULL);
{
int32 status;
int32 read2;
int32 data [1600] = {0};
uInt32 bufferSize = 16;
float64 scandata0 [3200] = {0};
bool32 isdaqdone = FALSE;
VConfigMaxVal16bit();
status = m_pCNI_PCI6254->SCreateTask("16bit",&m_ttaskHandleDEV1);
status = m_pCNI_PCI6254->SCreateAIVoltageChan( m_ttaskHandleDEV1,
status = m_pCNI_PCI6254->SCfgSampClkTiming( m_ttaskHandleDEV1,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,100);
status = m_pCNI_PCI6254->SStartTask( m_ttaskHandleDEV1);
status = m_pCNI_PCI6254->SReadAnalogF64( m_ttaskHandleDEV1,100,-1,DAQmx_Val_GroupByChannel, m_fRawScanData16,10000,&read2,NULL);
//status = m_pCNI_PCI6254->SStopTask(m_ttaskHandleDEV1); //status = m_pCNI_PCI6254->SIsTaskDone(m_ttaskHandleDEV1,&isdaqdone);
status = DAQmxIsTaskDone(m_ttaskHandleDEV1,&isdaqdone);
m_Status16DEV1 = BUSY;
m_Status16DEV7 = BUSY;
}
01-12-2011 01:17 PM - edited 01-12-2011 01:19 PM
I don't get the same behavior, what version of the driver are you using? It looks like you are using some sort of wrapper for the DAQmx C API? It also looks like you're missing half of your CreateAIVoltageChan line (bad copy/paste?).
Just to double-check, are you checking the return value of the function ("status") or the value that is passed by reference ("isdaqdone")? The return value is used to report errors, while the isdaqdone parameter that is passed by reference should tell you if the task has completed. You mentioned getting the function to "return a value of 1" so I just wanted some clarification on this point--the function should return 0 every time unless there is an error (such as an invalid task handle).
Best Regards,
01-12-2011 02:05 PM
I am using 9.1.5f1
Yeah I am wrapping the C functions
Yes that was a bad copy/paste
here is the right one
status = m_pCNI_PCI6254->SCreateAIVoltageChan( m_ttaskHandleDEV1,
And here is where I check
"Dev1/ai0","",DAQmx_Val_RSE ,0.0,m_fMaxVal[0],DAQmx_Val_Volts,NULL);
m_pCNI_PCI6254->SIsTaskDone(m_ttaskHandleDEV1,&isdaqdone);
m_Retrieved_16 = isdaqdone;
01-12-2011 02:07 PM
It still posted funny here is a more readable version
status = m_pCNI_PCI6254->SCreateAIVoltageChan( m_ttaskHandleDEV1,
"Dev1/ai0","",DAQmx_Val_RSE ,0.0,m_fMaxVal[0],DAQmx_Val_Volts,NULL);
m_pCNI_PCI6254->SIsTaskDone(m_ttaskHandleDEV1,&isdaqdone);
m_Retrieved_16 = isdaqdone;
01-12-2011 02:47 PM
Thanks for confirming that--I thought that might have been a long shot but I wanted to ask to be sure.
I'm not sure about the wrapper you're using, but I tried this code based off of the Finite AI shipping example and it seems to be working:
Granted, I'm currently on 9.2.3 on this PC, but I'm not aware of any changes to the driver that would explain the difference in behavior. Do you want to try running my code without the wrapper on your PC? If it doesn't work I can re-image a test machine to 9.1.5 to see if I can reproduce the behavior you're seeing in the DAQmx API.
Best Regards,
01-12-2011 03:00 PM
It looks like it has something to do with my wrapper class
I called the function directly from Daqmx and it works