LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event counting

I want to count and display each time a logic high (boolean 1) occurs in my program I aslo need to be able to reset the counter.

0 Kudos
Message 1 of 4
(2,456 Views)

Hi Russellg,

place a while loop around your boolean input. Create a shift register on it. Initialize it with 0. Insert two case structures in your loop. Connect your boolean input to the first one. Take a wire and connect it on the left side of your shift register. Wire it through both case structures (the false cases). Connect a boolean control to the second case structure. Now change to the true cases. Place a "+1" into the first one and connect it. Place a 0 in the second one and connect it with the output. Im not sure how you stop your while loop, you can connect another boolean control to it. You should have a timing inside the loop. If you use DAQmx, then connect a timeout to it.

 

Mike

Message 2 of 4
(2,447 Views)

Hello Russell,

 

Another option is to use a shift register to save the previous value of the boolean, and then NOT the output of the left shift register terminal and AND it with the current value of the boolean.  This will be true only when the value goes from false to true.  At this point you can wire this into a case structure that has an increment in the true case.  It is a similar solution to the previous one suggested, but perhaps a little bit more straightforward.  As far as resetting the value to zero,  all you need is another case structure with the a boolean connected to its input that either leaves the count alone, or sets it to zero.  Hope this helps!

0 Kudos
Message 3 of 4
(2,408 Views)

To only trigger for transitions in one direction, you would use an "implies", e.g. as follows:

 

 

(what is your LabVIEW version)

 

 

Message Edited by altenbach on 11-20-2008 09:27 AM
0 Kudos
Message 4 of 4
(2,402 Views)