LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the value incremented only when the loop is true?

Hi,

   From the snapshot attached, i want to increment the value of number indicator only once when its true and should increment the value again when the loop is true..i mean i want to get the number of times the loop is true.

But in this vi i am getting the value incremented many number of times when the loop is true because the while loop is running continuously. 

 

 

0 Kudos
Message 1 of 12
(8,227 Views)

Normal,

 

Rule n°1 with using While loop => add a timing function (as 'Wait' or 'Wait until') in the loop and ask you if you eventually you needn't it.

 

So, in your case (the most case), you need a timing function to let the processor have dead time to execute other thread and more, let you the time to manage your interaction with interface.

 

To be concrete add  TimingFunction.jpg in your loop.

 

 

Message Edité par J.DECHET le 01-21-2010 01:15 PM
0 Kudos
Message 2 of 12
(8,221 Views)

Thanks for the reply..

But the solution wont work correct because as i am using real time acquiring of data.

For example:from the snapshot the 'water' indicates the real time value and the 'high thres' indicates the fixed threshold value. i want only the counter value to be incremented once only when the value goes beyond the threshold value.It may remain in true condition for a long time but i don't want to increment the counter value continuously.

The counter value should be incremented only when the condition is true next any other time during data acquiring. 

0 Kudos
Message 3 of 12
(8,208 Views)

First of all,

I think that more people can help you if you post a real picture like .jpg or .png instead of a word 2007 .docx.

Also I am not getting what you are trying anyway. You want to increment a counter when a loop is true?

Or everytime a certain condition inside the loop is true?

If so, then you could add a case structure with an increment.

I bet there are several other methods too.

 

cheers,

Pattos

LabVIEW Gretchin
Message 4 of 12
(8,206 Views)

I just read your reply.

you want to only increment the counter when the value changes from false to true am I right?

you can do that with an event structure.

Just add a case with value change and compare the new and the old value of your condition.

Pattos

LabVIEW Gretchin
Message 5 of 12
(8,205 Views)
Ya you got my question.Thanks a lot for your answer.
0 Kudos
Message 6 of 12
(8,201 Views)

muralicgowda wrote:

   From the snapshot attached, i want to increment the value of number indicator only once when its true and should increment the value again when the loop is true..i mean i want to get the number of times the loop is true.

But in this vi i am getting the value incremented many number of times when the loop is true because the while loop is running continuously. 


A loop is a structure and not a boolean, so it cannot be false or true and thus I don't understand the question! 🙂

 

Why don't you attach the actual VI instead of a word document? Your code is very difficult to understand because it seems to suffer from severe localitis, and some of the few visible terminals don't show a label. What's in the other cases of the case structures?

 

Incrementing a value is better done in a shift register or feedback node. What's the purpose of the "absolute value" function. As long as you make sure you don't start with a negative value, it should not be needed. If you are looking for a off-on transition, try "implies" with the current and previous value of the boolean. (For an example, have a look at this post and the quoted example in it.)

Message Edited by altenbach on 01-21-2010 08:47 AM
0 Kudos
Message 7 of 12
(8,169 Views)

Hi,

    The VI cannot be posted because i am using many other subvi's and the snapshot i had posted was a part of the main vi...let me explain clearly my problem:

The only thing is that the values will be continuously logging and i am comparing with a threshold value. So whenever the value is higher than threshold my boolean will be high and i want the counter to be indicated as 1 (the high value indication may remain for a longer time and at that time my counter should be indicated as 1 itself,but in my logic the counter value will be incremented many times because of the while loop) and if the other time the boolean is false and again high,my counter should be 2.

I hope you understood the problem,if so please give me a solution else let me know to still elaborate the my question.

0 Kudos
Message 8 of 12
(8,132 Views)

This example will increment the counter value when the boolean changes from false to true.

 

Transition count1.png

 

The boolean function "Implies" is used to detect that the current value of the boolean is true and that the previous value (from the shift register) was false.

When these conditions are met, the output of "Implies" is false. Otherwise the output is true.

 

I hope this helps,

steve

 

 

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
Message 9 of 12
(8,111 Views)

Hi,

     Thanks for the reply will try this and get you back.. 

0 Kudos
Message 10 of 12
(8,106 Views)