LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mantain an event in a event case structure usin a switch when pressed boolean

Good mornig.

Sorry if the question makes no sense or it´s too simple, but I´m new in LabVIEW.

I´m trying to make a while loop that contains an event  structure with different cases. The idea is to press a button, then the case structure will choose an specific case, and continue doing that case through the while loop while the button is still pressed. I was looking and I only found to activate the case each time the boolean changes, so it does not mantain through loops. How could be the best way to solve this?
Thank you.

0 Kudos
Message 1 of 7
(1,018 Views)

Hi d,

 


@d_hunter13 wrote:

I´m trying to make a while loop that contains an event  structure with different cases. The idea is to press a button, then the case structure will choose an specific case, and continue doing that case through the while loop while the button is still pressed.


So there is an event structure with a ValueChange event case for your button.

And there is a case structure next to the event structure, where you execute a certain case.

 

What's the problem to only change the case/state of your case structure whenever the button value changes?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(1,001 Views)

You are not interested in events, but in the value (state) of the button. Poll the button value and do whatever you need in a Case (not Event) structure.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 7
(999 Views)

Yes, but I already have a case structure, and the program does not seem to work with a case structure inside another one

0 Kudos
Message 4 of 7
(973 Views)

Hi d,

 


@d_hunter13 wrote:

Yes, but I already have a case structure, and the program does not seem to work with a case structure inside another one


So you already have some code and you have problems with that code.

But you hesitate to share your code with us to allow us to suggest improvements on your code!?

 

Do you see the pattern?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 7
(967 Views)

If you only need to select what to do depending on which button is clicked on, I suggest using a set of radio buttons. You can replace and configure the buttons in that container as you wish.

 

If you really want to do something while a button is pressed, then I suggest you do that in another process (while-loop). The “while” in that sentence hints to that. Here’s one possible solution sketch: Send a “Press 1” or “Press 2” message to the other process when that button is pressed. The other loop remembers the last pressed button and does that action until another button is pressed:

thols_0-1676036202737.png

 

But a VI from you will mean we can stop guessing what you want and help you more effectively.

 

Certified LabVIEW Architect
0 Kudos
Message 6 of 7
(948 Views)

One reason you may be having trouble is that the problem, as you've explained it to us in words (not in LabVIEW code, which you've failed to show us), is "problematic".  Suppose you have 3 Boolean switches with "Push-button" mechanical actions, call them "1", "2", and "3".  When "1" is pressed, you want to "Do 1", with a similar "Do 2" and "Do 3".  What about when none of them is pressed?  You need a "Do 0" (or "Do Nothing"), which suggests creating an Enum with those four "Do x" values.

 

Your Event Structure needs 3 Value Change cases that use the value of the "Do x" Control to set the value of the Enum.  Your Main While Loop needs a Case Statement that is driven by the Enum to do one of the 4 "Do x" cases.

 

Or you could use a Radio Button Control ...

 

Bob Schor

0 Kudos
Message 7 of 7
(937 Views)