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.
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.
02-23-2015 11:29 PM
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.
Solved! Go to Solution.
02-23-2015 11:40 PM
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.
02-24-2015 12:22 AM
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.
02-24-2015 09:19 AM
I know this message has been marked as solved, but here is another way to generate your counter without using shift registers.
02-24-2015 09:32 AM
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.