LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Realization of a counter within an IF.

Solved!
Go to solution

Good, I summarize my problem: I have a series of conditions and each time one of them is fulfilled I would like a led to light up and an accountant to increase, that is, having 4 conditions, there would have to be 4 counters. I show it in an image what I have done together with the code in java so they can understand me.

 

Java code:

for (i = 0; i <10; i ++)

if (x <0.25) {

     Turn on a led1;

     r1 = r1 + 1;

} else if (x> = 0.25 & <= 0.5) {

     Turn on a led2;

     r2 = r2 + 1;

} else if (x> 0.5 & x <= 0.75) {

     I turn on a led3;

     r3 = r3 + 1;

} else {

     I turn on a led4;

     r4 = r4 + 1;

}

}

 

I have made the conditions and the for loop, but I do not know how to pass a counter to each condition so that each time one of the ifs is fulfilled, the respective led lights up and the counter accumulates.

 

I hope you can help me !!

0 Kudos
Message 1 of 2
(2,057 Views)
Solution
Accepted by topic author jose_1819

The is an In Range and Coerce for comparing to an upper and lower limit.  But you can convert the boolean result of a comparison to a 0 or 1 and add it to a shift register initialized to 0.  Do this for each of the ranges.  Here are the first two cases. 

compare.png

 

What do you want to do with the LED?  Once they are lit up, what happens to them on the next iteration? 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 2 of 2
(2,044 Views)