LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

To count the number of while loops, do you just have to attach a DBL indicator to the little i box in the while loop of the program?

Solved!
Go to solution
I have just followed an example in a book to count while loops and was just want to make sure I havent missed something simple. My program is attached
0 Kudos
Message 1 of 3
(11,548 Views)
Solution
Accepted by topic author ssteel

Hi ssteel,

i can't open your vi at the moment, but as you said you can use the i terminal. To know the iterations you should add 1 to it. I starts with 0.

 

Mike

Message 2 of 3
(11,547 Views)

Hi Ssteel,

 

Just some additional observations/tips on your code...

 

1. I notice that you have a standard stop button going into a "run if true" stop condition of the while loop. In this cercumstance it is common to have the stop condition set as "stop if true". You can change this by right clicking the stop terminal and enabling the "stop if true" property. Obviously, it somewhat depends on your design preferences.

 

2. If you have any issues with the application, perhaps you notice that it is taking over your processor resources, you should add some execution timing into the while loop. You will find the timing functions in the block diagrams functions palette (programming > timing). The Wait (or "wait until next ms") functions will provide your application with "down time", which means that the processor can execute other tasks.

 

3. To elaborate what MikeS81 correctly stated, insert an incriment before the numeric indicator as shown below to get the actual number of cycles (i.e. the count terminal of the "while" and "for" loops are 0 indexed). Also note that I have changed the representation of the count to interger (blue). You do not need floating point precion when displaying the inciment count, at a while loop can only execute a "whole number" of times.

 

incriment count.JPG

 

I hope this has been useful to you Ssteel.

Thanks for your post,

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
Message 3 of 3
(11,505 Views)