Showing results for 
Search instead for 
Did you mean: 

I want the Boolean to work once every second.




 I want the Boolean to work once every second. I tried making it using a while loop and shift register, but I don't know what to do. Please help me. Thank you.

0 Kudos
Message 1 of 12

Define what you mean by "work". That's a very ambiguous term.. Do you mean switch back and forth?


Events and controls are for user interaction. Why is your terminal a control instead of an indicator?

Delete the event structure and place a 1s wait in the loop, then keep a boolean in a shift register that you invert with every iteration. Connect the indicator to it. Add a stop button to end the loop.





Did you attach the wrong image? I don't see the shift register you mention.


See how far you get.

Did you do the beginner tutorials?

LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 2 of 12

What do you mean by 'work once every second'


Do you want to make it change value or are you trying to make it respond to a user mouse click.


The inner structure is an event structure which responds to user events or a timeout (if a value is wired to the blue timer in the top left).


If you want to run some code when the user clicks the button add an event for that button and place your code in there.


If you just want to do something with the value of the button every second remove the event strucutre but leave the while loop, add a wait function (look in the timing palette).


If you are more specific with what you are after I may be able to give you some more help

0 Kudos
Message 3 of 12



The VI above is the one I originally made.


I want to read data once every second when I click the Read the Data Boolean.


First, I tried while loop in event structure.

But the program never exited the while loop. Therefore, forced termination was forced.





And Secondly, I tried while loop and shift register.

But I don't know how to send the indicator in the shift register to the boolean in the event structure.




So please help me and give me some advice.


Thank You!!

0 Kudos
Message 4 of 12

First, please don't use monster sized fonts in your message.  I'll ask the moderator to edit your message to make it reasonable.


Second, in your second image, you don't have anything connected to the stop terminal of your inner while loop.  Your code won't actually run because it will be broken.


Third, read Caveats and Recommendations when Using Events in LabVIEW - LabVIEW 2016 Help.  You'll see that by default, LabVIEW will lock a front panel until the event completes.  So if completing the event requires a person to hit another button, then it can't happen.  A quick fix would be to disable locking the front panel for the event case.





0 Kudos
Message 5 of 12

Not really sure what you want.  Try this.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 12

Please tell us what you want to, not how you want to do it. From your description you are approaching the problem completely wrong. You have a simple problem that has very simple solutions that have been solved by master programmers a long time ago.


There is no need for any events except possibly for an independent UI loop in certain architectures.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 7 of 12

Let me see if I understand what you want to do. You want to read data 1 time per second, but only if the button on the screen is set on. In that case you just need a while loop with the code to read the data inside the True case of a case structure. The button would be connected to the case structure. Outside the  case structure you would have a 1 second loop timer. You would also have a button to stop the program (note that there may be some lag in pressing the button and the program being stopped).

0 Kudos
Message 8 of 12

I want if I push the "Read the Data" boolean, this "Read the Data" program work once per one second. and If I push the end button, Read the Data program is stop ( it must not mean stopping entirety program!)

And if I push other boolean while the program reads the data, I want to operation other program at the same time.

0 Kudos
Message 9 of 12

You don’t need two different buttons to start and stop recording data. As for the other program you can do it the same way, though it is starting to sound as if you need to consider a state machine architecture.

0 Kudos
Message 10 of 12