LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Counter to count the number of "True" occurances

Just want to count the number of time a condition is true.Help!

Joe
0 Kudos
Message 1 of 6
(3,076 Views)
What exactly is the "condition" that you are trying to count? Is it an input signal, the result of a calculation or what? How fast does the condition change state?

There are a variety of ways of doing what you want depending upon what it is that you're counting.

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 2 of 6
(3,076 Views)
On Tue, 5 Aug 2003 20:08:15 -0500 (CDT), mikeporter
wrote:

>What exactly is the "condition" that you are trying to count? Is it an
>input signal, the result of a calculation or what? How fast does the
>condition change state?
>
>There are a variety of ways of doing what you want depending upon what
>it is that you're counting.
>
>Mike...


I created a vi to parse ascii data from a serial port and am looking
to count the number of occurances of the string. This is probably very
simple but have a brain freeze at the moment

Thanks

Joe
0 Kudos
Message 3 of 6
(3,076 Views)
On Tue, 5 Aug 2003 20:08:15 -0500 (CDT), mikeporter
wrote:

>What exactly is the "condition" that you are trying to count? Is it an
>input signal, the result of a calculation or what? How fast does the
>condition change state?
>
>There are a variety of ways of doing what you want depending upon what
>it is that you're counting.
>
>Mike...

I created a vi to parse ascii data from a serial port and am looking
to count the number of occurances of the string. This is probably very
simple but have a brain freeze at the moment

Thanks

Joe
0 Kudos
Message 4 of 6
(3,076 Views)
One way of doing this would be to put a shift-register on the loop that's reading the port. Initialize the SR with a zero and increment the value each time the desired string is received.

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 6
(3,076 Views)
Feed your string into a while loop that stops when a "match pattern" function returns an empty "matched string" (where the "regular expresion" recieve the string you want to count).

THe Match match pattern "offset" input should be fed from a shift register that is initialized to 0 and updated from the "offset past match" output.

The final iteration value should be the number of occurance of the sub-string.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 6
(3,076 Views)