LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed Loop Multiple Cycles

For a piece of researh equipmet I have a series of timed "states", 1 second and up, that set analog and digital values to a DAQ unit .  Each state may have an associated audio prompt, usually taken from the Windows/Media wav files.  It is very important that the time remain accurate even if the prompt takes longer than the programmed time.

 

I have implemented the system as a timed loop which does very well until I turn on the prompt and the prompt duration exceeds the programmed time.  In that case my output extends for an integer number of programmed times until it exceeds the prompt time.  I have attempted to create a vi that truncates the sound at the end of the programmed time, which it does, but still the output stays on.

 

I have attached sample VIs that illistrate the problem.

 

Any help making this work would be appreciated.

 

If it is easier, the prompt could continue over the following "states".

 

William A (Bill) Monette

Indiana University, School of Optometry

Download All
0 Kudos
Message 1 of 3
(2,725 Views)

I did not look at your VIs, but I think the following can help:

when you need to "trigger" a sound or audio prompt, just send a command via a Queue to another parallel loop, which will run your audio sound. In this way the audio will not block the running of the actual loop. Another possible solution if you create a subVI which plays the sound, and you call this subVI async, so it will not block the actual loop...

 

edit: so just put the "Time Limited Sound Player.vi " into another parallel loop, modify this subVI and trigger this loop if the command arrives in the Queue...

By the way, why do you use timed loop? Use the proper DAQmx timing VIs for your DAQ!

edit2: also this infinite while loop is silly, I guess you use the red Abort button to stop the code?

edit3: or at least put some Wait (like 10 msec) into the outer while loop, so when your "Start" boolean is False, you do not hog your CPU. Also, conenct a Stop button for the outer while loop's conditional terminal...

0 Kudos
Message 2 of 3
(2,720 Views)

Hmm, as a second thought, maybe you indeed need the timed loop here. But someone may give better advice. I never had to time accurately analog outputs, I guess here a few millisec deviation is not acceptable? If does, you could just use software timing...

But making a parallel loop for the sound subVI still a possible solution, even if you go with the timed loop...

 

edit: I just started to dig into the DAQmx docs, recently reading about hardware timed single point sampling, but not sure this is the way...lets see if someone comes up with the proper solution ...? Sorry I cannot help more with the DAQmx part. But at least try the parallel loop technique...

0 Kudos
Message 3 of 3
(2,704 Views)