Showing results for 
Search instead for 
Did you mean: 


Go to solution


i have the next code in labview which generates a random number between 0-100, i would like to do a counter which count each time that the random number is >50, but i don´t know how increase the times,i just see 1 when this happen,but if i have a new number >50 the counter is still 1, how could i increase the times that random number is >50?   the case false is the same but i add +0, not +1 as true case



Message 1 of 10

You have the right idea with the shift register. But the shift register needs to be on the outer while loop. Connect the wire through the case structure in the false case. You don't need the inner for loop since it only executes one time. Also it is an initialized shift register since you have the zero wired to the left side. The result will always be 0+1. (Note, there is an increment function that you could use instead of adding 1)

LabVIEW 2012

0 Kudos
Message 2 of 10

sorry,i don´t understand what do you want to say with this: the shift register needs to be on the outer while loop?


0 Kudos
Message 3 of 10

Feedback as counter

Some times the feedback node can give a clean implementation since you do not have to pass the wires across the entire block diagram.  Also the feedback node has a conditional terminal and initializer in place.



Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 4 of 10

for example if i generate 10 random numbers,and there are 6 values >50 i want to see 6 in the output, but i just see 1

i want to accumulate the true case


0 Kudos
Message 5 of 10
Accepted by topic author mariomoskis

You can use a feedback node. That is a good way to do it but those can seem confusing to new users. They really are not complex but with inputs on the right it can seem strange.


See this example. The first loop shows what I was talking about with the shift register and case structure. You can also use the select function as shown in the second loop.


[Edit: I attached another method of incrementing using the bool to 0,1 function.






LabVIEW 2012

Message 6 of 10

Thanks!!! it works well

0 Kudos
Message 7 of 10

I have tried both of the recommended schematics and I still get 0 and 1. Can anyone help me out. Maybe I am using a wrong function but I am not sure why it is not working properly.



0 Kudos
Message 8 of 10



You have not tried the recommended schematics as they contain shift registers and your code does not. It is not the same code.


Read up about shift registers. Any introductory course explains them.

0 Kudos
Message 9 of 10

Thank you for the help, I understand what I did wrong. thanks again



0 Kudos
Message 10 of 10