The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Reading the Count (N) Terminal value

SercoSteveB
Active Participant

What is the value in Loop Count Out control following execution of the VI?

Loop Count.png

a) 3

b) 4

c) 5

d) 6

Comments
mini09
Active Participant

The answer is C, as the array size is 4 with an increment added its 5.

Anagha.G
Member

ans is b i.e. 4 as N returns the total iteration counts and loop iterates 4 times

ADrexelDragon
Active Participant

I agree with G.Ana, answer is b. The for loop does not iterate 5 times due to array size of 4.

CLD Certified 2014
BenoitP.
Member

Obviously (size of the array+1)=5

however autoindexing is enabled so the for loop will iterate only 4 times !

agree with all those go on with the answer b !

sumasbhat
Member

Answer is b. i.e 4.

thinnker
Member

I will go with B i.e 4

StefanoFacchine
Member

Hi everyone,

I also consider B to be the correct answer, for the reason explained by BenoitP.

YogeshShivarudrappa
Member

Ans is C. The array size is 4 and +1 will result in 5 (autoindexing will not change value of N). The value of N wil not change throughout the execution of the for loop.

StefanoFacchine
Member

Hi,

I was going also for B, but YogeshShivarudrappa made a good point - I was not sure of the behavior of the N terminal output so I simulated the code to find out the correct results. It turns out that the output is 4, so the correct explanation should be the one given by BenoitP.

BenoitP.
Member

Well,

You have to know the N count terminal behaviour of a For loop.

The N count terminal take the smallest value between :

- The value directly wired to the count terminal N (in the exemple (Array Size+1=5)).

- And all array size entering in the For loop with autoindexing enabled (in the exemple 4).

Easy now, to find the value of the Numeric Control in this exemple :

LabVIEW exemple.png

StefanoFacchine
Member

Hi BenoitP,

I know the behavior at the input node of the N terminal, that is what you correctly explained. I never thought about the output side of the terminal, whether it would take anyway the value directly wired to the input side or the minimum iteration value. This is what I wanted to check

Thank you very much for your explanation!

Btw, in your code the For Loop will execute twice

YogeshShivarudrappa
Member

Thanks BenoitP ... Silly mistake from my end.

mini09
Active Participant

Yeah Benoit correct offen make mistakes with the N terminals...:( need to work out efficiently..

SercoSteveB
Active Participant

Hi Stefano.  you mentioned simulating the code.  The majority of pictures in my posts are VI Snippets, you should be able to drag and drop a VI Snippet direct from your internet browser, to the LV Block Diagram (LV Version permitting), give it a go it is way coooooool.

SercoSteveB
Active Participant

Answer: B. Another awesome thread everybody.  Special shout out to  BenoitP for a nice explanation.  I like to think of For Loop as being lazy, they always go for the smallest number of iterations from those defined.  In addition I like to think of While loops as being dumb, they just keep going until the Conditinal terminal tells them to stop.

From the question; the value out of the N terminal is the number of iterations for the loop, not necessarily the value wired to the N Terminal.

StefanoFacchine
Member

Hi,

thanks Steve, I will try for sure! It looks like something really nice to do!

Regarding the value out of the N terminal, I have noticed that it outputs the number of iterations for the loop already on the first iteration. It does not increase the value starting from '1' and update at each iteration. Just something I found out and I didn't know

ashwinilele
Member

Ans is 4

rupesh.v
Member

ans :B

woo!! awesome example sir,,,,