LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to limit x to be > y always in x+y

Solved!
Go to solution

Hello:

 

In the following simple vi, how do I limit the value of x to always be greater than y?

 

x+y.JPG

 

For instance, if I set y = 10 then x cannot be set to a value less than 10. The values for x and y should remain changeable.

 

Thanks.

Alfredo
0 Kudos
Message 1 of 7
(2,662 Views)
Solution
Accepted by topic author AlfredoT
Use the In Range and Coerce function.  Set the lower limit to Y, infinity for upper limit, and wire the coerced output as X.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 7
(2,660 Views)

Thanks a bunch!

Now for a related question: I see that the function you suggested has a true/false output, perhaps I can use it for the following.

 

If I set x to be less than y (say x = 5 and y = 10) and I would like the value of x to not be allowed to be 5 but go straight to y if this is the case (o that x automatically sets to y when x<y), how would I accomplish this? Thanks.

Alfredo
0 Kudos
Message 3 of 7
(2,648 Views)

AlfredoT wrote:

 

If I set x to be less than y (say x = 5 and y = 10) and I would like the value of x to not be allowed to be 5 but go straight to y if this is the case (o that x automatically sets to y when x<y), how would I accomplish this? Thanks.


That is exactly what the coerced output does.  It will set the input (x) to either the high limit or the low limit (Y).  In this case, x is lower than the low limit, so the coerced output will be equal to the lower limit.  In whatever code you use X and Y as inputs, use the coerced output instead of X.  No additional code needed.

 

My Labview is down, waiting for a license, so I cannot give you an example.  I hope this is clear enough.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 7
(2,642 Views)

I understand what you mean because I have tested it. Thank you.

What I meant was something slightly different: I would like the value of x on the display to change from the value < y to y. I understand that the coerced output will be as such but the displayed x remains whatever value < y I had set it to.

Alfredo
0 Kudos
Message 5 of 7
(2,630 Views)

Create a local variable for the X control (right click on control and select create - local variable).  Wire the coerced outptut to the local variable.  If you get a broken wire, right click on the local variable and select Change to Write.

 

- tbob

Inventor of the WORM Global
Message 6 of 7
(2,607 Views)

Perfect!

Thank you. I wish I had thought of that.

Alfredo
0 Kudos
Message 7 of 7
(2,604 Views)