11-17-2015 09:49 PM
Hello sir
i need to handel the while loopps as they run in sequence. i can use sequence structure but issue is in my program i also have one already queue . please help me how can i handel this issue
thanks
Solved! Go to Solution.
11-17-2015 10:09 PM - edited 11-17-2015 10:10 PM
You're listing off three loops but also three runs, so which is it? Do you have three parallel loops, or are you trying to handle three difference cases based on a single while loop iterating 3 times? It sounds like you have way too many loops when not necessary...
Are you trying to start and end each loop in order? Then just create a data dependency from one loop to the next and they will operate that way. But that's not a good practice no matter what you're trying to do.
You should give us more information about what you're trying to do in the end for us to better help you with the best solution, not just the solution you think you want.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
11-17-2015 10:32 PM
@IrfanRazzaq wrote:
Hello sir
i need to handel the while loopps as they run in sequence. i can use sequence structure but issue is in my program i also have one already queue . please help me how can i handel this issue
thanks
You're using a queue and yet you don't know how to do this? This is a recipe for disaster. Please learn the LabVIEW basics before continuing!
11-18-2015 06:29 AM
dear i know how to use the Queue . i think you could not got my point i need the Queue Part execute More then 2 time but the remainig part just once. if i use all in one queue then each part will run once
11-18-2015 06:40 AM
Dear james thanks for your reply,
im working on cognitive radio networks in first loop my code search free Band
in 2nd loop it select the available band
third is queue in which it get the data from computer change it into packet, modulate the data using QAM then transmit it
i need the queue part to run more then 2 time to transmit complete data
i need this work in sequence as>>>> sensing >>channel Selection>> Transmission(but in sequence transmission part run for more time then the remaning)
Hope now you will got my point
11-18-2015 06:54 AM
@IrfanRazzaq wrote:
i need this work in sequence as>>>> sensing >>channel Selection>> Transmission(but in sequence transmission part run for more time then the remaning)
Hope now you will got my point
Sounds more like a State Machine is needed, not multiple loops.
11-18-2015 08:40 AM - edited 11-18-2015 08:42 AM
You definitely want a State Machine. You can't do what you want using a sequence structure, as you've said. So you need an architecture that can operate multiple different cases in some order, but also repeat states when necessary.
The Simple State Machine template that ships with LabVIEW is really the best way for new developers to get familiar with LabVIEW while utilizing a semi-scalable architecture.
Here's a broad example of how a state machine works:
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
11-29-2015 05:45 AM
Hello Sir,
Hope you are fine!
i create state machine, now i need to stop the loops. for this purpose i use the elapsed time it work correctly for the first time but for second time it start malfunctioning . code is atteched. please help me to correct this problum.
11-30-2015 10:34 AM
Hello IrfanRazzaq,
Is the malfunction that the VI is stopping early the second time you run it? If so, it's likely because the boolean you have wired to the larger while loop's stop terminal is being set "true" but not reset to "false" after you run the VI. Try running it once, then after stopping click on the boolean again before running the VI a second time. If this fixes your problem, then you should right click on that boolean and select "Mechanical Action" and one of the latching options (the second row of mechanical actions). Alternatively, you could replace that boolean with a Stop Button for the same effect.
While that may fix the malfunction you are seeing, the way you have it set up may not be ideal as a way to stop your state machine. In your code the boolean is only read once after each inner loop (or state) completes execution, which is likely not your intention. I would suggest you spend some time looking at the Project Template suggested by James or the State Machine example that ships with LabVIEW and seeing how they stop execution of a state machine. The State Machine Example can be found by found by opening LabVIEW and selecting "Help" -> "Find Examples..." and then selecting the "State Machine Fundamentals.vi" option from under the "Fundamentals" -> "Loops and Structures" folders.
If the boolean is not the issue, could you provide more information about what malfunction you are seeing in your code?
11-30-2015 10:41 AM
Irfan, try what GatorBait suggested to solve your specific issue.
That being said your "state machine" that you attached isn't set up correctly. You just have everything in the timeout case with a timeout of 1ms and no other event cases. The traditional event based state machine (like the template shipped with LabVIEW) has the case structure outside the event structure, so you end up with: Event Structure inside of a Case Structure inside of a While Loop. The state machine should return to a case called "Idle" or "Wait for Event" or similar to handle the event structure. This Idle case handles if the user presses the Stop button and sends a True value to the stop terminal, or goes to an "Exit" case, etc.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'