LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

counter for boolean

Hi , I'm new to labview andI am trying to modify an already existing code. I'm trying to create a simple counter for a boolean output. I tried some example code, but most of them have a stop button to stop the code. In my case I want it to run as long as the the main program is running . Any help will be appreciated
0 Kudos
Message 1 of 8
(3,126 Views)

Hi pnam,

 

Can you be a bit more precise? What kind of boolean output are your talking about? Do you want to record some button presses or something else? And are you going to use this VI as a SubVI that you want it to stop with your main VI? Kindly clarify these things so that we can get you the best solution.

Regards,

Nitzz

(Kudos are alway Welcome;)) 

0 Kudos
Message 2 of 8
(3,120 Views)

What does a stop button have to do with a counter? Is this a different question? Please clarify? If you want to keep running, simply don't press the stop button, right? 😄

 

An "output" is typically just an indicator, so you need to find out the source of the boolean data that causes the output to change. What do you want to count (e.g. true to false transitions or vice versa, value changes, etc.). Or are you measuring the output of an external device? We need more information.

 

Typically, you keep the count in a shift register (initialzed with zero) or feedback node and conditionally increment it when the desired change occurs.

0 Kudos
Message 3 of 8
(3,104 Views)

Here is an example of a simple counter. You will have to adapt it to your situation.

 

 

Tim
GHSP
Message 4 of 8
(3,085 Views)

Could you please downgrade the code to 8.6 and send it to me please.

 

Thanks,

-Priya

0 Kudos
Message 5 of 8
(3,067 Views)

Try this, it's a bit cleaner and simpler. (8.6)

 

(The other example was a bit weird, with extra timeout cases, misguided representations (DBL vs I32) and funny events (mouse up vs value changed)

0 Kudos
Message 6 of 8
(3,062 Views)

Thanks a lot for your help. I need only the 'increment ' even case for my code. Now my question is how do I modify the code if I want to replace the event from the increment button to an output of a boolean?

 

Thanks

-P

0 Kudos
Message 7 of 8
(3,030 Views)

I changed the mechanical action to switch action. You would simply compare the new with the previous value from a feedback node and increment if they differ.

 

(You can easily modify so it only increments on either the TRUE-FALSE or FALSE-TRUE transition bu changing the "not equal" to a "greater than" or "less than" comparison, for example)

0 Kudos
Message 8 of 8
(3,013 Views)