Hi there!
I cant imagine i'm the first person to ask this but unfortunately cant find the right fitting answer.
I have the problem, that i want to sync my analog input and digital output.
At this moment i am reading data from the ADC und logging how many samples i aquired by the variable "readvalues". And every 32 aquired samples i want to set my digital output (dividing down the ai/sampleclock by 32). This works fine so far. But now i see that, dependent on how much load i have on my windows pc, the digital out isnt set sometimes. I can see on the scope, that (while my pc is doing other things than my program e.g. opening another program) the DO is shifted and the pulses are getting longer or shorter but not constant.
What can i try to do? Im actually out of ideas...
Here is an excerpt of my code:
[quote]
while(stoptest!=true)
{
samplecounter = 0;
while (samplecounter == 0)
errorcode = DAQmxReadAnalogF64(InputHandle, sampsperchan, timeout, DAQmx_Val_GroupByScanNumber, analoginputdata, buffersize, &samplecounter, NULL);
readvalues++;
if (readvalues > 32768)
readvalues = 0;
if (readvalues % 32 == 0)
{
sampswritten = 0;
while (sampswritten == 0)
printError(DAQmxWriteDigitalLines(DOHandle1, 1, 1, timeout, DAQmx_Val_GroupByChannel, DOarray, &sampswritten, NULL), "Error writing digital lines on Port 1!");
sampswritten = 0;
while (sampswritten == 0)
printError(DAQmxWriteDigitalLines(DOHandle2, 1, 1, timeout, DAQmx_Val_GroupByChannel, DOarray2, &sampswritten, NULL), "Error writing digital lines on Port 2!");
}
[/quote]
Timing is configured for the InputHandle by
[quote]
printError(DAQmxCfgSampClkTiming(InputHandle, NULL, samplerate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, buffersize), "Problem setting up the sampleclock...");
[/quote]
Your help is greatly appreciated.
Installed Driver is NI-DAQ 8.0
Installed Hardware M-6221
Used Software: Visual C++
In order to understand the recursion, you have to understand the recursion at first!