03-05-2012 08:05 AM
Hello all,
I want to switch between cases in a case structure without using a while loop. I'm working on data acquisition, hence I'd prefer a loop be avoided.
The user has a boolean control, which he can toggle anytime while running the program. Once he toggles the Boolean, the function must execute in the other case and come back to the previous case when done.
I am attaching my program so far. Please help.
Thank you.
03-05-2012 08:40 AM
Something is wrong with your VI. I tried to do a block diagram cleanup on it so I can straighten out some of those wires, and it crashes LabVIEW.
Why are you putting the restriction "without using a while loop" on yourself.
What little I saw of your block diagram before it crashed, it looked like you have a while loop, but your code was inside out. You should have a case structure inside the while loop, not a while loop inside the case structure.
03-05-2012 08:54 AM
that would be a normal structure, a while loop running until it gets a stop signal, inside the while loop would be a case structure vontrolled by something, in your case a boolean. this would run indefinatly until told to stop
03-05-2012 09:21 AM
You also have no error handling so if something goes wrong you will never know it and a huge sequence structure that is doing absolutely nothing. An overall better solution would be a producer-consumer structure that has one loop for acquiring the data and a second that saves the last data collected when you push the button.
Mike...
PS: Also get rid of the express VIs. They are like training wheels on a bicycle: they can get you going but it isn't long before they start holding you back.
03-05-2012 10:03 AM
You wrote that you want the program to " ... and come back to the previous case ..."
That necessitates looping.
03-05-2012 10:07 AM
@paul_a_cardinale wrote:
You wrote that you want the program to " ... and come back to the previous case ..."
That necessitates looping.
Splitting hairs...
Some strange recusive approach may avoid the loop but... I would hate to find that in a diagram just to avoid a loop.
Ben
03-05-2012 10:18 AM
Loops arent evil they are a very useful tool, my currrent system has tight performance constraints yet at the heart of it is a state machine (case structure inside a while loop, where the next state is determined in each case, each state being a case) its a bit more coplicated than you have asked for but i most definatly have the speed
03-05-2012 11:14 AM
Thank you very much for your replies everyone.
So what I need to do is:
1. have a while loop outside with the case structure inside it.
2. eliminate express vi's
3. wire the errors
however, there is this strange problem that LabVIEW crashes everytime I try cleaning up the block diagram. can someone tell me why?
in addition, I'd like that everytime the boolean is toggled to "save data", it must untoggle itself and become false the following loop. how can this be done?
thank you very much again!
03-05-2012 11:19 AM
03-05-2012 12:01 PM
Something must be corrupted on your VI because it crashed mine.
Try deleting half the block diagram, then clean up. Then try deleting the other half. See if you can narrow down what is node is crashing your VI. Otherwise, just start over from scratch on a new VI.