LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting Loop Iterations

Hello, everyone!
 
My question is simple (I hope): Is there a way to count the number of iterations through a while loop in LabView 8? I am writing a simple app to generate the first fifteen prime numbers (Student/Co-Op), and am trying to use the number of loop iterations to increment the current number being tested.
0 Kudos
Message 1 of 7
(3,591 Views)

cant you just have an indicator on the index of the loop?

you probably ask for something else. could you post your vi?

Message Edited by Gabi1 on 07-16-2007 10:20 PM

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 2 of 7
(3,587 Views)
Oh, I am not trying to use an array, just fifteen numeric indicators arranged in a 5x3 stack on the front panel, Smiley Wink.
0 Kudos
Message 3 of 7
(3,584 Views)
Forgive me, but I'm new to LabView. Can you clarify that statement?
0 Kudos
Message 4 of 7
(3,584 Views)
Here is what I have so far. Just started 20 minutes ago.
0 Kudos
Message 5 of 7
(3,579 Views)

you might need to go trough labview introduction...

 if you want to search for the first 15 nbs, then make a FOR loop of 15 iterations, in which you would have a while loop, looking if the nb is non divisible. to find the iteration of the loop, you have on the bottom left side of the the loop a small 'i' icon. wire it to an indicator (left mouse button - create indicator) to see the iteration. if you want to make operations on it, then wire it to your operator in the while loop.

out of your FOR loop will be created an array of nbs, (i strongly recommand avoid 15 stacked indicators...).

The while loop itself should have two conditional exits: 1) the nb has been found divisible. 2) the nb of iterations is equal the nb to be checked.

this should get you started. begin to write a vi, and post what you get. we will help you trough correction. (any more than that and i would do your job 🙂 )

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 6 of 7
(3,550 Views)

here a starting point based on what you had in mind. it is definitely not optimised, so one might think of more efficient ways of doing it.

remark with this method one can only search from nb 2.
also, there is quite a bit of unnecessary operations there, as well as duplication of info with the shift register. when i get some time i'll make some better engine.

Message Edited by Gabi1 on 07-16-2007 11:31 PM

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 7 of 7
(3,542 Views)