# LabVIEW

cancel
Showing results for
Did you mean:

## Check for every ? run through a while loop

I have a while loop. I'd like to know when the while loop has incremented 2 times, 3 times, 4 times, etc. For example, if I set the control to 7, I want a boolean to go positive on each 7th occurance of the loop. Any help?

(I've found several questions about using the while loop iteration, but not my specific question. Sorry if this is a repeat from somewhere).
Richard

Message 1 of 5
(2,677 Views)

## Re: Check for every ? run through a while loop

Good Afternoon,
One way would be to connect your loop iteration to the quotient & remainder function's top input, the number of loops control to the bottom and then a check for =0 to the remainder output.

Attached is an example

Putnam Monroe
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5

LabVIEW Champion

Message 2 of 5
(2,667 Views)

## Re: Check for every ? run through a while loop

use the quotien & remainder function .wire the iteration terminal to the X input , on the Y input wire the number of loop iterations you want to be notified about. the x-y*floor(x/y) output will be zero anytime y divides evenly into x , wire that output to the Equal to Zero function then to your boolean indicator...

Dan
Message 3 of 5
(2,662 Views)

## Re: Check for every ? run through a while loop

Doing that is a simple modulo operation on the iteration count. Use from Numeric the "quotient & Remainder" function. Wire the iteration terminal to x and your count to y. Check the Reminder output with "Equal to 0?". This will be true for each y iteration. The first iteration will be included.
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 4 of 5
(2,660 Views)

## Re: Check for every ? run through a while loop

Thanks for the quick responses! For some reason I was using a shift register, an increment, checking for trailing zeros.... I forgot about the quotient & Remainder trick. Easy!
Richard

Message 5 of 5
(2,646 Views)