LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

counter increment and decrement in a while loop

I am having a little problem with a DAQ project that I am working on involving a counter in a case subvi
which exists in a while loop. The trigger for the counter is a boolean variable which remains true for x amount of time
while the signal is greater than a certain amount, however during this time the counter increments until it is false again. What I want it to do is increment it by +1
for this time and store this value so that it can be compared in other logic statemnts. Any advice.

Regards Shaun Oxley
soxley@student.ecu.edu.au
0 Kudos
Message 1 of 4
(5,094 Views)
Shaun,
If I understand - you want to count only once per True state (trigger). I attached a VI that compares the previous trigger state and previous count, and only adds 1 to the count when you get a new trigger.
Run it and simulate the trigger by toggling the trigger control.
Good luck with it, Doug
0 Kudos
Message 2 of 4
(5,094 Views)

I have problem that i want counter to increment by 1 when switch case is true and when false same counter should  decrement by 1 from last incremented  value, again when true it should increment form last decremented value.so on can you provide code for that ,please 

thank you

0 Kudos
Message 3 of 4
(4,051 Views)

(This seems only remotely related to this 12 year old thread. It is not the same A new thread would have been more appropriate.)

 

All you need is to keep your counter value in a shift register and use a case structure that has a decrement in one case and an increment in the other case.

 

See how far you get. What is the loop rate? I assume that the couter should keep incrementing or decrementing while the switch remains unchanged. Right?

0 Kudos
Message 4 of 4
(4,043 Views)