LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Some help with sound output problem

guys it's me again, need more help this time, i have incorporate the sound functionality in, and it is supposed to play a sound non stop(supposedly a buzzer sound) when the speed hit 120KM/H, but whenever the sound is playing, all the rest of the sub VI will stop, namely my VISA READ and TCP/IP READ will come to a haul when the sound is playing, and will run for another cycle before the sound will play again.

My question is... is it able to make the sound play simultaneously with my sub VIs? and not running independantly?

I have attached my necessary VIs here, the VI with the sound is Data Receiving Serial And TCP.vi

Thanks in advance!
0 Kudos
Message 1 of 12
(4,400 Views)
That's because the loop where you generate the sounds is embedded in your master while loop.  The master while loop isn't able to move on to its next iteration until all code inside of it is complete, which includes the loop generating the sound.
 
What you need to do is move your sound generation loop outside of your master program in it's own parallel while loop.  You can then use a notifier or a local variable to tell it when to run.
0 Kudos
Message 2 of 12
(4,376 Views)
oh, i guessed that as well, but when i try to drag the >120 boolean out of my master while loop, the output doesn't get passed out of the while loop at all, how can i drag it out?
0 Kudos
Message 3 of 12
(4,372 Views)
You don't drag it out because you can't. As Ravens Fan indicated, you have to use some other mechanism to pass information to this other parallel loop. As noted, a local variable or notifier can be used. Open the Example Finder (Help -> Find Examples) and do a search on "loops". Open the example "Stopping Parallel While Loops with Reset". This shows using a local variable. You can create an indicator for the ">120" test in your main loop and then read its value in the other loop using a local variable of that indicator.
0 Kudos
Message 4 of 12
(4,361 Views)
thanks for all the help guys, i finally got it working, took me awhile to understand how to use local variable. 😛

thanks again! :womantongue:
0 Kudos
Message 5 of 12
(4,338 Views)
A local variable is actually a poor way to do this, since it opens the way to race conditions.  I would recommend a queue for future use (or a notifier if you need to send the data to multiple places).
0 Kudos
Message 6 of 12
(4,327 Views)

@DFGray wrote:
A local variable is actually a poor way to do this, since it opens the way to race conditions. 

True, but not always the case. After all, the example I pointed to was a perfectly reasonable example, and the local variable use was not being "abused", as the examples in this thread show. Smiley Wink


Message Edited by smercurio_fc on 05-23-2008 10:24 AM
0 Kudos
Message 7 of 12
(4,321 Views)
Even if you don't abuse it, a local is always much slower than a queue or notifier.  The reason is that a local is not simply a register.  It is an interface to a front panel object.  When you write it, the front panel must be properly updated (yes, it is much faster with a hidden front panel object).  When you read it, it makes a copy.  It also forces a thread swap to the user interface thread.  This sort of thread thrashing can severely degrade performance.  A queue has none of these issues and is almost a simple pointer.

Last, but not least, think about the unskilled user who will be using your code as an example or modifying it.  You may know not to abuse a local, do they?  Better to design a system which is hard to abuse.  It makes it that much likelier you will not accidentally abuse it yourself (been there, done that, don't want to go back).
0 Kudos
Message 8 of 12
(4,275 Views)
Well, the "good and bad" of locals have been trashed around on this forum (and others) many times, and I'm not about to get involved into yet another debate about them. The user has the information, and they can do with it what they want.
0 Kudos
Message 9 of 12
(4,266 Views)
hmm... so let's say notifier is a better choice, how can i do it? hope someone can give me some guidance~
0 Kudos
Message 10 of 12
(4,244 Views)