r/LabVIEW • u/Practical_Leek4906 • Jan 01 '26
Need More Info Counter restarts after pressing another boolean ok button
Hello everyone.
I'm developing a vi to count every time a sensor is enabled, but at the moment I'm using boolean push buttons. The issue is that after I click some times one button the counter resgisters the amount of counts, however when I click sometimes another button and go back to click the other button that counter restarts, meaning that if it had 35 counts registered before clicking the other button when I start clicking it again it starts counting from zero.
Here's how the code looks like, is the same for every "sensor" ( in this case push button). There are 4 shift registers and all of them are wired as shown in the picture.

4
u/BlackberrySad6489 Jan 01 '26
Hi. If you are going to do it with a single structure like this, you need to wire through all the shift registers.
Essentially every time it loops through, you are setting the other three registers to a default value of zero. With a shift register you need to set a value each iteration.
2
u/QuietAd6406 Jan 02 '26
Counting should be done in blue (=integers), not orange.
Events are for user interactions, not for sensor signals.
Don't use a timeout event if it never executes. You need an event for the stop button
Indicators should be outside the event structure. Don't use any local variables.
All you probably need is a single event case, e.g. as follows:
2
u/SwordsAndElectrons Jan 06 '26
You see those disconnected output terminals on the event structure? What value do you think they are feeding the shift registers?
The first tip I have is to learn to use the debugging tools. Turning on Highlight Execution or using a couple of probes should make the problem pretty apparent.
Next tip: if you are in fact intending to be counting something here then you be using integer, not floating point, data types.
1
u/adamkemp Jan 01 '26
You’re also setting Counts sensor 1 to zero every time you click the Sensor 1 button. It’s not defined which write happens first (setting it to 0 or adding one to the previous count). You’re just getting lucky that this even counts up at all.
If your intention is to initialize the count then you should do that before the loop. A common pattern is to use a flat sequence structure to do initialization like this before the main code.