LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can you see if this would work??

I am using a while loop and a case structure to program. What I would like to do is to run the true part of the case structure (with a while loop) until I press stop, and have the while loop stop as well as moving on to "False" in the case structure. Could you look at my program to see if it will do what I want it to do? (I haven't programmed in awhile (and when I was more familiar with it, I still wasn't an expert by any means!), so any help is appreciated!) 
Thanks! I've attached the program.
0 Kudos
Message 1 of 23
(3,879 Views)
First of all, when your while loop stops, the False condition will not be executed automatically.  Also, you don't have anything wired to the condition terminal of the Case structure.  If you want to execute the code in the True case, then when the stop button is pressed execute the False case, I would advise that you get rid of the case structure entirely.  Use a flat sequence structure and put the code from the True case in the first sequence.  Put the code from the False case in the second sequence.  Or  better yet, instead of using flat sequences, use data flow.  Put an Error In and Error Out terminal in your subvi and main.  Wire Error In through the loop.  Wire error output from loop to error in of the subiv, wire error out of subvi to error in of DAQ express vi.
Another point is do you really need to execute the relay close code inside your loop?  If not, put it before the loop so that it doesn't continuously send commands to close relays that are already closed.  Use error ins and outs to create data dependant execution flow.
- tbob

Inventor of the WORM Global
Message 2 of 23
(3,870 Views)
The VI will not work as you have it now. The case structure executes only one case (depending on what is connected to the terminal with the "?" on the left side) each time it is called. You could put a loop around the case structure, but if you always want the False case to execute after the loop in the True case, the case structure is not needed at all. See the attachment for a modification to your VI.

Lynn
Message 3 of 23
(3,867 Views)

Thanks! (That helps soooo much!!!)

There is a broken wire between the while loop and the stacked sequence structure. Do you know why that is?

Thanks again,

Bethany 🙂

0 Kudos
Message 4 of 23
(3,864 Views)
Do I even need to use a while loop if I put it in a flat sequence structure (could you look at the code that Lynn gave me?)
 
Could you attach a sample of how to use data flow? Just so I can see how that would work better.... I don't mind if you mess with my code to show me. Should I put the relay open before the structures as well?
 
Thanks! I appreciate it!
 
0 Kudos
Message 5 of 23
(3,858 Views)
Bethany,

The wire is not broken on my copy. That wire has the value of the boolean connected to the stop terminal of the loop. Since the loop is set to Stop if True, the value will always be True after the loop stops. The wire is there to establish data dependency, forcing the sequence node to execute after the while loop completes. If your subVIs all had error clusters in and out those could be wired for the same effect without the sequence.
Message 6 of 23
(3,855 Views)
Are the relay open functions to execute before or after the data acquisitions, or does it not matter? As currently set up, you cannot be sure which will happen first.

Lynn
Message 7 of 23
(3,854 Views)

Thanks for your help! I'd like the digital switches to open (the relays) at the same time the DAQ/voltages run. How could I get them timed together? Thanks!

 

Also, how do I get the error clusters set up on the subVIs? Do you have an example of how that is done? I don't quite understand how to do that.

Thanks so much,

Bethany

0 Kudos
Message 8 of 23
(3,850 Views)
Bethany,

I modified your VI to use a simple state machine. It does limited error checking but shows the use of the error clusters. This type of program architecture is very versatile and robust.

As implemented the relays are set first, then the acquistion occurs. How nearly simultaneous you can get depends a lot on your hardware.

Lynn
Message 9 of 23
(3,840 Views)

Lynn,

Thank - you!!!!!!!! That looks MUCH better than I had it!!! Very exciting. I really appreciate your help! I can see how it works, except for where/how does it input "0" as the voltage value for the second screen (when the relays are turned off)? I wasn't able to follow that.

Thanks,

Bethany

0 Kudos
Message 10 of 23
(3,830 Views)