Hi All
This question spans a number of subjects so I hope I have put it in the right area.
I am using an interrupt like function to detect transistions on a digital input (DAQmxCfgChangeDetectionTiming) and setting up a counter/timer to accurately timeout after a specified time period. The while loop requires the ProcessSystemEvents function in there otherwise the change detection function does not work properly as there is not anytime allowed to service this function.
However, the ProcessSystemEvents function usually causes a General Protection Fault as I use the code below or similar code several times during my program.
setup_timer(); //Configures timer counter to time out (go low) after 10 seconds
start_change_detection(); //Monitor digital input 1 for transistions using DAQmxCfgChangeDetectionTiming
read_digital_input(); //Monitor timer output which is connected to digital input 2
while (data[0] ==1) //While timer output is high (timer not timed out)
{
ProcessSystemEvents(); //Do other events while waiting, necessary for change_detection() to work properly
read_digital_input(); //Read digital input again
}
If I wrote the timer function in a second thread and removed the ProcessSystemEvents from the while loop, would this work?
I am using a NI PCI-6229 I/O card, LabWin 8.01
Any help would be appreciated
Regards
Andy