how to programatically repeat a DAQ sequence?

I am running a DAQ experiment using NIDAQ Tools MX (IP 6.03A, WinXP).

The general scheme is (1) define a stimulus output wave , (2) start DAQ tasks for waveform generation (using the stimulus output wave), counter (trigger) generation, and repetitively triggered wave scanning (input, sampled acquisition). A scan hook function processes the input waves after each triggered scan, counts the scan iterations, and upon reaching a count limit, stops all DAQ tasks. To give concrete numbers, each scan waveform lasts 0.4 seconds, and I typically scan 6 times to be sure the stimulus-response function has settled to equilibrium. This all works with no problem.

My question concerns how to programatically change the stimulus waveform by varying an input parameter, and repeat this entire DAQ sequence. One issue seems to be how to ensure the outer procedure loop (that changes the stimulus) executes synchronously with the DAQ cycle, and does not outrun it. Most things I have tried give an error message that the waveform scanning task is running, even after it should have stopped. Various error trapping methods (as suggested in the NIDAQ Tools manual) have not revealed the source of the problem.

I welcome any suggestions, and can provide code snippets if requested.
I have found one, slightly awkward solution to the repeated DAQ sequence problem. Instead of enclosing the start and stop DAQ functions in an outer loop, I use the DAQmx_Scan hook function to control the program flow.
(1) sense the scan iteration number; when appropriate
(2) stop the stimulus generation, stop the scan triggers, save relevant parameters
(3) modify the stimulus wave, retart stimulus generation and scan triggers, and repeat the cycle as desired.
This requires keeping track of and incrementing various counter indices. It's a bit ugly, but it seems to work. Fortunately, in this instance I do not need precise synchronism between the stimulus and input waveforms.

Stephen R. Chinn
Wow. Long time without a reply...

I might point out that this is the approach taken by NIDAQmxRepeatedScanProcs, supplied with NIDAQ Tools MX. After installing NIDAQ Tools MX, add this line to the main Procedure window:


John Weeks
WaveMetrics, Inc.
"Wow" is right. It's been so long I can't recall the original problem. What I do know is that my experiment has been working well for over a year with
DAQmx_Scan/DEV="dev1"/RPT/TRIG="/dev1/ctr0out"/AVE={100,50}/RPTH="scan_hook()"/STRT WAVES = ScanString

Perhaps the /RPT flag did the trick.