LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

How to store counter data

Hi,

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?

Thanks.

Message 1 of 6
(2,561 Views)

Re: How to store counter data

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.

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
Message 2 of 6
(2,546 Views)

Re: How to store counter data

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.

Thanks!

Message 3 of 6
(2,531 Views)
Solution
Accepted by topic author PT21

Re: How to store counter data

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.

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
Message 4 of 6
(2,512 Views)

Re: How to store counter data

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
(2,508 Views)

Re: How to store counter data

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

Cory K
Message 6 of 6
(2,502 Views)