LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a Threshold

Here is my dilemma. I have a program that outputs certain true/false data depending on a series of cases. The cases are dependent on an input variable, that can range from 0 to 100. It is constantly changing between these values in a while loop. Right now, I have the cases set up as follows:
Input 0 to 25: Outputs: F,F
Input 25-50: Outputs: F,T
Input 50-100: Outputs: T,F
The cases are determined by the "in range" vi which sees if the variable is in the 0-25 range...etc. The cases are all set up properly for these ranges. I'll try to attach my file as an 'answer' to this question. I'd like the ability to create a threshold of 5.

For example, if the input variable gets up to the 25-50 range, and then drops back down to
23, I still want the output to be: F,T. If the input variable drops all the way back to 20, I want the output to be again in the 0-25 range: F,F.

I need to do the same thing for the change from 50-max. If the input variable drops to 46, I still want the outputs to be in the 50-100 range: T,F.

In essense, if the variable moves from a lower to a higher range, keep it in that higher range until the variable drops to 5 below the minimum value for that higher range (ie, dropping from 25 to 20). Once that has happened, move back down into the lower range. If the variable then goes up again to 25, change the output to be in the 25-50 range.

I know I'm not explaining this very well, but feel free to email me at jdalton@nal.com if you have a solution to my problem or if you have any questions regarding the explanation above. Any sample code added to my own (hopefully below) would be greatly appreciated.
0 Kudos
Message 1 of 5
(3,404 Views)
The attached file:
0 Kudos
Message 2 of 5
(3,404 Views)
Your example is simple enough. I have modified it by adding a threshold variable. This variable starts at 0 and is added or subtracted from the limits that you are checking. It is 0 for the first check only, then is set to as number (in this case 5). I used local variables for this. You could hide the threshold variable if you do not want the user to change it.

I hope this is the kind of thing you are looking for.

Rob
0 Kudos
Message 3 of 5
(3,403 Views)
You must think in arrays and ranges. You have been seduced by the "in range" function. Try the approach in my example. I just edited yours. Also, remember to add some delay to while loops! 🙂

Dan Press
www.primetest.com
0 Kudos
Message 4 of 5
(3,403 Views)
Perfect!!! Precisely what I was looking for. And as for the delay in while loops, I just sort of threw this program together. My actual program contains much more data, but it still runs in a while loop. So there is a delay in there. Thanks for your help!
0 Kudos
Message 5 of 5
(3,403 Views)