I want to generate a single cycle (as shown in the waveform graph) of analog output using PCI-6711 and then stop/pause the program. I added a condition in the while loop that when i equal the waveform length, the program will break the while loop. However, it doesn't work. Reading by an oscilloscope, I always find that the analog output contains more pulses than what I define (or what shows on the waveform graph). Does anyone have any suggestions that I should try?
Solved! Go to Solution.
This is exactly what Finite Sampling (instead of Continuous) is for!
In the call to DAQmx Timing, choose Finite and *also* wire the adjacent "# samples per channel" input with the right # samples to represent one cycle of your waveform. After you start the task, you can call DAQmx Read to request that same # of samples. When it returns all your data to you, you'll know the task is done so stop it and then your software can react however you choose.
Have a look at the shipping examples for AI to see one of the ways to structure a Finite Sampling task.
P.S. Comparing your loop iterator to your # samples was never the right idea anyway. The loop will iterate as fast as it can, subject to the time it takes to execute the code within it. This has no particular relationship to the hardware sample rate you set up in your AI task. It's pretty typical for sample rates to be at least an order of magnitude faster than software loop iteration rates.