Showing results for 
Search instead for 
Did you mean: 

How to store counter data

Go to solution



I have arranged the circuit seen in attached. At the moment the counter will change from 0 to 1 when the analogue signal from the DAQ changes aka the direction changes from false to true. However I want it to continue to count, 0 to 1 to 2 etc. 


What can I do to achieve this?




0 Kudos
Message 1 of 6

Are you saying that once the condition is met once, you want the increment to continue even the conditon is not met on the next iteration?  If so, you can create another shift register for your boolean, and for your case structure condition, you can put a Or gate there.  The logic is as follow: if the boolean shift register is true or the subvi output is true, increment.




Kudos and Accepted as Solution are welcome!
0 Kudos
Message 2 of 6

Yeah I want the counter to continue but only if the change from false to true occurs again. So false-true happens 5 times, the counter should show 5.


I'm abit of a novice with labview, and the explanation has left me a little confused, although I'm sure its me! Sorry. If the scenario I speak about above is the same as you have detailed a solution for, please could you explain it using an image, that would be great.



0 Kudos
Message 3 of 6
Accepted by PT21

Your code should do what you want.  I have attached a simulated version of your code.  it should continue to count.  I do have two questions for you though.


1. What is your false case?  It seems like your have the option "use default value if unwired" turned on for the case structure output tunnel.  If you don't have a through wire on the false case, you will mess up your counter.


2. Make sure that the subvi that is connected to the case structure is generating the correct boolean event.




Kudos and Accepted as Solution are welcome!
Message 4 of 6

If this psudo-code correctly explains what you want to do, use the attached code:


if (boolean[n-1] == false) AND (boolean[n] == true):

counter += 1



Hope that helps, let me know if that doesnt make sense.

Cory K
Message 5 of 6

Actually, I included an unnecessary extra step, you could do something like this:


Cory K
Message 6 of 6