LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to program a button that can only be switched under certain conditions

Solved!
Go to solution

Hello everyone! 

 

What I want to program are 3 buttons (let's say A, B, C), and for operator to be able to switch to A (from B or C) a certain conditions must be fulfilled. Same for the other two. So if B is lighten up and he presses button A, button A lights up only if for example, Temperature is under 50 degrees. I want them to be exclusive from each other (only one can be on) but all of them can be off. 

 

Could you help me with this? Would really appreciate if someone could upload a simple example in a .VI

 

Thank you so much!

0 Kudos
Message 1 of 9
(1,819 Views)

I would probably go with radio buttons with the option to have none as a valid selection.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 9
(1,783 Views)

Hey thank you for replying I really appreciate it!

 

That's what I've tried (I still need to add the OFF option), but now I'm facing another problem. So the three button options I've set are: warmup, standby and ready. 

 

Given two number controls A and B, to be in Standby A=0 and to be in ready A=0 and B=0 and warmup doesn't have any condition. But I also want to program it so that if the READY button is pressed (A=0 and B=0) but I change manually B=2, I want the button to go back to STANDBY position. Is there any way to do this? 

 

I attach what I've done so far. 

I'm very new to LabView so maybe there is some mistake in my .VI

would really appreciate all your feedback, thank you!

 

0 Kudos
Message 3 of 9
(1,772 Views)

I will have to look at it from home; my version at work is older than your VI.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 9
(1,709 Views)
Solution
Accepted by topic author IreneAd

Hi Irene,

 


@IreneAd wrote:

I'm very new to LabView so maybe there is some mistake in my .VI

would really appreciate all your feedback, thank you!


See this:

You really should learn the basics, like avoiding (unneeded) local variables or setting up the event structure correctly!

There's only one local variable left now…

 


@IreneAd wrote:

 But I also want to program it so that if the READY button is pressed (A=0 and B=0) but I change manually B=2, I want the button to go back to STANDBY position. Is there any way to do this? 


Yes, sure! You just need to program it according to your requirement!

When the event structure/case should react on value change events of B then why didn't you setup the event case for that event?

Do you spot the difference?

 

Btw. why did you choose the DBL datatype for A&B, when you just check for "==0" or "<>0"? Why don't you use a boolean controls instead?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Download All
0 Kudos
Message 5 of 9
(1,699 Views)

Oh, I see... thank you!

 

So does that mean that if I want the program to update the value of A and B, I have to add them to the event structure value change?

 

And in case I had more controls, let's say A,B,C,D,E,F,G,H,I. Should I add them just like I did (edit events handled by this event case) or is there an easier way to do it (maybe put all of them in an array?)

 

If A and B were local variables (because I had to use them somwhere else), would this work the same way?

 

I used DBL because I was just testing, but you are right a boolean control would be simpler. 

 

Thank you! I'm slowly learning how LabView works so if you have any recomended guides on this feel free to mention them. 

0 Kudos
Message 6 of 9
(1,669 Views)

Hi Irene,

 


@IreneAd wrote:

So does that mean that if I want the program to update the value of A and B, I have to add them to the event structure value change?


No, the other way around!

When the user changes the values in A or B then then event case is handling those ValueChange events!

 


@IreneAd wrote:

And in case I had more controls, let's say A,B,C,D,E,F,G,H,I. Should I add them just like I did (edit events handled by this event case) or is there an easier way to do it (maybe put all of them in an array?) 


General rule: related items of the same datatype belong into an array…

(Why handle 9 items individually when you can handle them at all within one array?)

 


@IreneAd wrote:

If A and B were local variables (because I had to use them somwhere else), would this work the same way?


No.

The event structure handles ValueChange events, which come from user input or special "Value(signalling)" property nodes! Writing to local variables will not create a ValueChange event!

Best regards,
GerdW


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

So in case I had to use A and B as local variables because they come from somewhere else, what would you use to program the same functionality? 

 

Sorry for asking so many questions, I'm a bit confused. 

0 Kudos
Message 8 of 9
(1,659 Views)

Hi Irene,

 


@IreneAd wrote:

So in case I had to use A and B as local variables because they come from somewhere else, what would you use to program the same functionality? 


I would use a different approach than an event structure waiting for user input…

 

What about a statemachine, checking conditions and changing states as needed?

What about using User events when you want to stick with an event structure?

There are so many options, depending on your (complete list of) requirements…

Best regards,
GerdW


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