LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Are sequence structures the right approach here?

Hi everyone,

The attached VI shows the endmembers in case structure form of a relatively simple task I need to perform.  It takes a bank of 6 digital outputs and toggles between true and false logic.  Between the endmembers, I need to change the logic on some ports sequentially and after time delays.  For instance, changing the case from true false, I need to change line 2 from false to true 2 seconds before I change lines 4 and 5 to true.  I want the user to see only one button to toggle between states, and I want the states to be discrete and not continuously changing.

Are sequence structures the best way to do this?  If I put those into the case structure, won't it re-iterate the sequence over and over?  Or do I need a case structure initialized with shift registers so that it stops after one interation until the next time the user toggles the control?

Thanks for any help on this,
Brad
0 Kudos
Message 1 of 23
(3,031 Views)
I would recommend using an event structure to detect when the user presses your boolean control. Then, within your event structure you can place a case structure that detects if the boolean control is true or false. Each case could then have a sequence structure in it that executes the correct actions.
 
This is just an idea; I'm sure there are many more solutions. I hope this helps.
 
Casey Weltzin
National Instruments
0 Kudos
Message 2 of 23
(3,016 Views)

hi,

can U post the VI for LV 7.1 ?

I'd like to see it.

rgds,

Partha.

- Partha ( CLD until Oct 2024 🙂 )
Message 3 of 23
(2,999 Views)
Here is the VI in 7.1.  In the previous post, I built an array of booleans and wired that to a DAQ Asst.  Here it goes to a bank of boolean indicators.

Brad
0 Kudos
Message 4 of 23
(2,989 Views)
I have tried to implement the event structure suggestion, however these structures are a little over my head right now.  I have a attached my latest attempt which simply tries to make the event structure work without the sequence structures inside yet.  The event (changing the "Toggle Trap" boolean) stops the while loop, which I don't understand because I have wired a separate stop button to the while loop.  I have looked at the examples and have seen multiple comments about latching the button, but I just don't understand the concept here.  Any suggestions?

Thanks,
Brad

(The VI is attached in 7.1 also)
Download All
0 Kudos
Message 5 of 23
(2,981 Views)
The while loop stops because that's what you have programmed it to do. The conditional terminal is the little square in the lower right corner of a while loop. The default for it is "Stop When True" but you have it set to "Continue if True". You can change it by right clicking on it and selecting the stop condition or just left click on it and whatch it change. When it has a red circle inside, it will "Stop When True". A circle with a little arrow is "Continue if True". You should also create an event just for the quit button. Place the quit terminal inside this event and wire it to the conditional terminal. If you set the mechanical action of the  quit button to Latch When Released, you can click on the quit button, the VI will stop, and the quit button will switch back to the false state so you don't have to change the state of the quit button before you run the VI again.
Message 6 of 23
(2,974 Views)
Brad
The reason the case structure stops the loop is because of the way you have the conditional terminal set-up. If you are going to use the continue if true make sure that your variable starts as true. So i changed the terminal to false and added another case for the stop button to stop the loop and here it is in 7.1.
BTW, i like how you posted both versions

Tom
0 Kudos
Message 7 of 23
(2,970 Views)
I have a couple suggestions.  Most important, have two cases in your case structure.  One for the toggle, one for the quit.  Otherwise you will have to wait for a toggle in order to process the quit.  I also lumped the controls into a cluster.  You are converting from array to cluster anyway, this saves you the unbundle.  Finally, since you are toggling each boolean, you can just apply a NOT to the entire array and use a shift register to pass the array from one loop iteration to the other.  This last will save a lot of debugging headaches if you ever need to add/remove bolleans.




Message Edited by jasonhill on 06-14-2006 09:05 AM

Download All
Message 8 of 23
(2,958 Views)
Thanks for the tips, Jason.  The event structure is starting to become a little clearer, but I must admit that I am having trouble visualizing what I am actually telling the program to do.  One question about your posted diagram - why the shift registers on the while loop?

Thanks,
Brad
0 Kudos
Message 9 of 23
(2,938 Views)
Another question for Jason -

In your VI, how are the boolean clusters changing from one case to another?  I don't see this in the program!

Thanks,
Brad
0 Kudos
Message 10 of 23
(2,932 Views)