LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to count internal activities (like boolean changes)

I want to count the number of boolean false to true changes in my VI. The goal is a program like this: if a>=b do something and b=b+10; And then again: if a>=b do something and b=b+10; and so on. a is an external signal that increases and I want to react every 10mV. How can I do that. Thanks for your help
0 Kudos
Message 1 of 6
(3,265 Views)
The attached VI does what you describe. The key elements are the shift register and while loop. The a is simulated in the example by a vertical slider. You can specify the initial value of b.

Daniel L. Press
PrimeTest Corp.
www.primetest.com
Message 2 of 6
(3,265 Views)
You make a VI with a shift register that you initialize with a start value and the increase you want to detect added to that valuein a case within the loop for initialization. You then have another case where you check whether the current value is above the value stored in the shift register...if it is, add the increase value once again to the shift register value and the next time it will check for an increase above that step...

Now call that VI first with the case selector set to init, and then call it everytime a new value is sampled with the case set to detect increases...

I have attached a simple example, run the demo.vi in the library and you'll see that everytime the simulated value has jumped "10 mA" it runs a case...which here shows a dialog box
.

I have attached
0 Kudos
Message 3 of 6
(3,265 Views)
Try this simple circuit. You can also count keystrokes with this, if you map the keyboard in "advanced" (currently, I have the F1 key programmed for manual advance.)

Eric
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
0 Kudos
Message 4 of 6
(3,265 Views)
Thank you very much, Eric. This helped me a lot. But I had problems when I tried to use the "number of occurrences" in the first while loop. I need that to increase the limit (b) if the condition (a>b) is true => (b=b+10)->new limit. I finally solved this problem with a local variable.
Nico
0 Kudos
Message 5 of 6
(3,265 Views)
Thank you Mads,
but unfortunately I was not able to open the example, because I only have version 6.0.2. But I have found a different solution. If it's not too much afford, could you please send me an example that works on my system, or even a printout of the VI? Thanks

Nico
0 Kudos
Message 6 of 6
(3,265 Views)