08-26-2014 01:00 PM
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?
08-26-2014 01:04 PM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-26-2014 01:05 PM
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...
08-26-2014 01:13 PM - edited 08-26-2014 01:15 PM
08-26-2014 01:21 PM
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...
08-26-2014 01:21 PM
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?
08-26-2014 01:23 PM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-26-2014 01:32 PM
Thank you very much.
08-26-2014 02:01 PM
@aneps wrote:
Thank you very much.
Give thanks by giving kudos, and marking a post as answering the question.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord