11-10-2010 11:10 AM
Hello,
I posted this on a different board then realized it was the wrong location for it.
I am writting an application that needs to monitor an analog signal 100% of the time (no down time). An external analog circuit monitors the analog signal too and triggers a PFI input to start the sampling.
I create a task that is pending on DAQmxReadAnalogF64 and triggered by a PFI input.
The first issue I had with this was that to ensure 100% detection time I had to use an infinite time out i.e. a front on PFI would be detected 100% of the time. An infinite timeout was not the greatest as it prevented my application from exiting (task would never quit).
I added a timeout of 1s and this fixed the issue of having the task to prevent the application from exiting. However now, every 1s I need to stop the acquistion task, start it again and start a new read. My understanding of this is that now I'm not able to detect a front 100%, since part of the time I spend re-initializing the acquisition task.
This is the code I use - could somebody tell me if there is a way to make this code able to detect fronts on PFI 100% of the time, even just after the read has reached a timeout? (code shortened because apparently they are limitations with message length)
When you stop a task, do you prevent any possible triggering on PFI? Is the task still able to acquire after it's been stopped and before it's restarted?
while(true == m_RunTask)
{
int32 startTastStatus = DAQmxStartTask(m_TaskHandle);
samplesRead = 0;
int32 readAnalogStatus = DAQmxReadAnalogF64( m_TaskHandle,
-1,
m_ReadTimeOut,
DAQmx_Val_GroupByScanNumber,
readBuffer,
m_NumSamples,
&samplesRead,
NULL
);
int32 stopTaskStatus = DAQmxStopTask(m_TaskHandle);
switch(readAnalogStatus)
{
case 0:
{
double * p_Data = new double[samplesRead*m_NumChannels]; // OKed
for(uint32_t i = 0; i < static_cast<uint32_t>(samplesRead)*m_NumChannels; i++)
{
p_Data[i] = readBuffer[i];
}
NewTriggerHandle(p_Data, samplesRead);
delete [] p_Data; // OKed
break;
}
case DAQmxErrorSamplesNotYetAvailable:
{
TimeOutHandle();
break;
}
default:
{}
} // switch(readAnalogStatus)
} // while(true = m_Run)
11-10-2010 12:06 PM
I think you found the wrong board again. This is a LabVIEW board and your text based code looks nothing like LabVIEW.
Try the LabWindows board.