LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Switching between cases in case structure

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.

Dheeraj Bharadwaj
IIT-Madras
0 Kudos
Message 1 of 10
(4,959 Views)

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.

Message 2 of 10
(4,933 Views)

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

Please remember to accept any solutions and give kudos, Thanks


LV 8.6.1, LV2010,LV2011SP1, FPGA, Win7
Message 3 of 10
(4,922 Views)

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.


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 4 of 10
(4,909 Views)

You wrote that you want the program to " ... and come back to the previous case ..."

That necessitates looping.

Message 5 of 10
(4,904 Views)

@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 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 6 of 10
(4,899 Views)

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

 

 

Please remember to accept any solutions and give kudos, Thanks


LV 8.6.1, LV2010,LV2011SP1, FPGA, Win7
Message 7 of 10
(4,891 Views)

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!

Dheeraj Bharadwaj
IIT-Madras
0 Kudos
Message 8 of 10
(4,876 Views)
Yes. If it does not have one already give the switch a mechanical action. When the button is read it will then pop back out.

Mike...

PS:I don't forget to remove the sequence structure.

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 9 of 10
(4,873 Views)

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.

Message 10 of 10
(4,863 Views)