LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stopping VI , takes to long

Solved!
Go to solution

Hi , im using the myDAQ device to sample audio data , i've built an vi , with sampling rate of 22.05K and 220.5K samples , so the sampling duration is 10 sec , when the sampling is ended it writes wav file and shows the signal on the waveform chart , i'v added an while loop with a stop button. few questions :

1. the stopping procees is too longs , from the time i pushed the stop button till it realy stops takes few seconds , why is that ?

2. how to add a play button , in purpose to play the sampled file ?

3. i want to add an matlab script to process and plot the processed data , how can i connect between the sampled data , and the matlab script ?

I've also uploaded my VI.

 

Thank you in advance.

0 Kudos
Message 1 of 24
(3,895 Views)

Don't use stacked loops, use a flat state machine instead.

 

When you press the stop button, the VI can only stop once the inner loop has finished, and that can only happen if the "stopped" output becomes FALSE. How often does that happen?

 

(Alternatively, yout stop button belongs inside the innermost loop combined with some logic to stop both loops when true.)

 

(Sorry, I don't have DAQ installed, so I cannont see how your express VI is configured)

0 Kudos
Message 2 of 24
(3,886 Views)

How are you stopping it now?  Your DAQ assistant runs for 10 seconds, and the only thing that stops that inner loop is the DAQ assistant, which is set to run continuously.

 

Ignoring that point for the moment, assuming that it does somehow stop the inner loop,  the problem with the long stop is that the outer loop has the stop button which is read very early in the 10 seconds.  Assume you hit the stop button 1 second in,  it has to wait 9 more seconds for the inner DAQ assistant to finish it collection (then assume that the inner while loop does stop then.)  well the outer while loop still has a False on the stop terminal because the button was read before you pressed it.   Now the outer while loop runs again, it reads the True on the stop button, but you have to wait 10 more seconds for the DAQ assistant.  So now you've waiting 19 seconds from when you pressed the stop button.  (Turn on highlight execution to see how the VI works.)

 

You should get rid of the outer while loop and move the stop button into the inner while loop and wire it to the DAQ assistant.

 

All your other questions (replay a file, connecting to Matlab) are all much more sophisticated and really shouldn't be answered until you get the basic problems of your VI fixed.

 

EDIT:  I missed the fact the inner while loop is set to the less common Continue if True.  So the inner while loop only runs once because the DAQ assistant is never "Stopped".  Eliminate the inner while loop and connect your Stop terminal to the DAQ assistant.  The rest of my comments about the location of the stop button as it is now, do apply.

0 Kudos
Message 3 of 24
(3,874 Views)

thank you for the fast response , i've tried to do as you said , here is the result :

Capture.PNG

again the stopping process is taking time...

what am i doing wrong ?

0 Kudos
Message 4 of 24
(3,861 Views)

Cobmetal wrote:

again the stopping process is taking time...

what am i doing wrong ?


The stop button gets only read once per iteration of the loop. The duration of each DAQ call determines how often that happens.

0 Kudos
Message 5 of 24
(3,853 Views)

Altenbach is right: the duration is determined by the DAQ call, and you have configured the daq assistant to acquire ten seconds worth of data.  So you have the same problem that you had before.  What you should do instead is to break the data acquisition into smaller chunks, say acquire one second of data at a time, and combine the chunks when you have them all.

0 Kudos
Message 6 of 24
(3,841 Views)

so , if i understood you right , i change the "samples to read paramter" to 22.05k , and now it will sample every 1 second , but how i save and combine these chunks into one peace and show the final result on the chart ?

0 Kudos
Message 7 of 24
(3,826 Views)

@Cobmetal wrote:

so , if i understood you right , i change the "samples to read paramter" to 22.05k , and now it will sample every 1 second , but how i save and combine these chunks into one peace and show the final result on the chart ?


You are currently use a graph.  If you use a chart, it will all be done for you.  A graph just displays the last thing that was written to it.  A chart has a history that it keeps.  So you just write your new values to the chart and it will automatically add the data to the display.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 24
(3,816 Views)

Crossrulz is correct, a waveform chart is the simplest way to show all the data.  You can simply place the chart in your loop and it will work.  If you need to accumulate the data for other purposes, like analyzing it, you can use a state machine as Altenbach suggests.  You can find more information about state machines here.  You can store the data in a shift register to pass it from one iteration of the loop to the next.

0 Kudos
Message 9 of 24
(3,799 Views)

thank you , i modified the vi as you said , and now , the stop button works great .but it saves me only one second to the wave file and not the all samples.... 

0 Kudos
Message 10 of 24
(3,767 Views)