LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

control the numeric controls with boolean switch

Hi All,

 

Please check the attached vi, it's not working in false condition. please suggest the solution.

 

Thanks

0 Kudos
Message 1 of 10
(1,491 Views)

You've coded it to do nothing when the switch is False; so that's how it behaves.

Also, it's badly coded: The loop spins wildly when the switch is False.

 

My suggestion is that you describe what you want it to do.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 2 of 10
(1,478 Views)

I would recommend to start with the learning resources listed at the top of the forum. Learn the basics of graphical programming and dataflow.

 

Some hints:

If the boolean is false, all you execute is an empty case as fast as the computer allows. The event structure can never execute and will queue up an infinite number of events, one with each change of one of the numerics.

Once the boolean is switched back to TRUE, all queued up events will fire, again as fast as the computer allows.

There is no obvious way to stop your VI. You can only abort.

Event structures should NEVER be placed inside case structures unless you can guarantee that they are reachable when needed.

 

Tell us exactly what the code should do as a function of user interaction. Maybe the case structure belongs inside the event case, e.g. if you want to prevent parallel updates of the numerics?

0 Kudos
Message 3 of 10
(1,466 Views)

yes, I wanted parallel updates of the numeric control when boolean is true and independent numeric control when boolean is false.

0 Kudos
Message 4 of 10
(1,431 Views)

OK, so place the case structure (containing the local variables in the TRUE case and the FALSE case empty) inside the event as I already suggested. The event will fire on a value change, but only update the other control of the boolean is true.

0 Kudos
Message 5 of 10
(1,405 Views)

Thank you, sir, Any other methods to do it.?

0 Kudos
Message 6 of 10
(1,394 Views)

@infent08 wrote:

Thank you, sir, Any other methods to do it.?


Yes, there are millions of other methods to do the same, but this is probably the simplest. Try to come up with at least five alternatives. A good exercise! 😄

 

(Why do you ask? Is there anything you don't like about the solution?)

0 Kudos
Message 7 of 10
(1,389 Views)

sorry tried your  solution but  not able to do it . please suggest me other solution.

Thank you

0 Kudos
Message 8 of 10
(1,381 Views)

@infent08 wrote:

sorry tried your  solution but  not able to do it . please suggest me other solution.


... then show us what you did and we'll fix it. It will work just fine!

0 Kudos
Message 9 of 10
(1,379 Views)

Maybe you haven't fully defined all required behaviors:

 

So far we have:

 

  • If Boolean is TRUE
    • If Numeric A is changed, numeric B gets updated with the same value
    • If Numeric B is changed, numeric A gets updated with the same value
  • If Boolean is FALSE
    • If Numeric A is changed, numeric B remains unchanged
    • If Numeric B is changed, numeric A remains unchanged

 

 

We don't know the rest:

 

  • What are the control values when the program starts?
  • What should happen if the switch goes from FALSE to TRUE and the two numerics differ?
  • Should both become the same? If so, which numeric wins?
  • How can we stop the program?
  • What should happen when the program stops?
  • etc. etc.

 

0 Kudos
Message 10 of 10
(1,377 Views)