From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

please help oscillating counter

Solved!
Go to solution

Is it possible to create to create a counter that will start at 0 and count up to 10, when it hits 10 it will count back down to 0, and restart again and again. I need to be able to see the change in value in an indicator on the front panel.

 

I've been working on this for a few days and all i can get it to do is count up to 10 then have a compare statement to check if it is 10, once its true it will decrease to 9. the problem is the compare statement is no longer true so it will count back up to 10, resulting in the output value osciliating between 9 and 10.

 

 

0 Kudos
Message 1 of 5
(2,749 Views)

Maintain another shift register that is either a boolean that tells whether you are counting up or down.  Or it could be a numeric that stores either a 1 or a -1 to determine whether you are adding or subtracting.  When you get to the other end, then either invert the boolean or flip the sign on the numeric.

0 Kudos
Message 2 of 5
(2,743 Views)
Solution
Accepted by topic author nevik

I tried creating another value that would be either a 0 or a 1 when my main counter hit either of its limits, but it would switch as soon as it wasnt at the limit, which continued the same problem. while looking at boolean though I managed to create a latch that would hold the case in a state until it hit a limit. thank you for your help.

0 Kudos
Message 3 of 5
(2,734 Views)

I know this message has been marked as solved, but here is another way to generate your counter without using shift registers.

0 Kudos
Message 4 of 5
(2,694 Views)

What is wrong with using a shift register?  The alternative to a shift register is a feedback node.  But you know that already because you used one in the previous message.

0 Kudos
Message 5 of 5
(2,682 Views)