LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to count the number of 'True' outputs from an 'Equal?' function?

In my program, I have an 'Equal?' function which returns 'True' whenever x=y. How can I count the number of 'True' and display? I mean, for example, when it say True, the counter should display '1', when it say true next time the counter should display '2', like wise 3, 4.... so on. Can any one help me to do this? Is there any function which conts and display the number of 'true' outcomes?

0 Kudos
Message 1 of 9
(3,666 Views)

A feedback node or a shift register in your loop can keep track of the number of times an equal is true.  Post some code if this isn't clear.

Message 2 of 9
(3,663 Views)

This logic should be in loop right? Well create a shift register on the loop and initialize it with 0. Inside the loop, increment the value in the SR if the result of your comparison is True and don't increment it if the comparison returns False.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 9
(3,660 Views)

Example_VI_BD.png

Message 4 of 9
(3,653 Views)

Yup, that would do it. One enhancement is that there is a function called Boolean to (0,1). It return 0 if the input if false or 1 if its true. Wire the boolean to the input of that function and add the result to the shift register contents. It will do the same as what you have but will be slightly (microsocpically) more efficient.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 9
(3,643 Views)

Thank you for the suggestion. But in my case, the output of the 'Equal' function is fed to an event structure. Once when I run the program, the Event structure will excecutes whenever the 'Equal' functions returns 'True'. It will continue several times till I stop the program. So, I am worrying how to add a shift register on the 'event structure'. Or anything similar on an event structure to count the number?

0 Kudos
Message 6 of 9
(3,641 Views)

Is your event structure in a while loop?  Then that's where the shift register can go.  But for portability a feedback node can be used if the VI is not reentrant.

Message 7 of 9
(3,637 Views)

Thank you very much.

0 Kudos
Message 8 of 9
(3,631 Views)

@aneps wrote:

Thank you very much.


Give thanks by giving kudos, and marking a post as answering the question.

0 Kudos
Message 9 of 9
(3,616 Views)