06-11-2020 07:20 PM
Hi everyone,
When I click the Stop button why does it keep running the case structure instead of immediately stopping? Also, how come after LabView executes the Case and Event structure the overall program does not stop? It always requires 2 executions to execute the Stop command.
I added the flat sequence only to attempt to stop any race conditions, did not work but just left it here to show I my attempt at stopping it.
Thanks in advance!!!
Kwan
Solved! Go to Solution.
06-11-2020 10:26 PM - edited 06-11-2020 10:27 PM
The Stop button is read very early. Even more so because it is in the first frame of the flat sequence structure.
So even if you press stop, you have to get through the second frame, before the loop iterates and it can be read as True in the first frame.
Then the 2nd frame has to run again.
Your stop button should be an event case in the event structure.
Also, it is very abnormal to use a mouse up event for a button. You should use the Value Change event.
The buttons themselves should be placed inside their respective event cases.
Turn on highlight execution so you can understand the dataflow process better.
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
Learn LabVIEW
06-15-2020 01:47 PM
Thanks for the input, I looked through the PDF you sent. I wish i saw that when I was just getting started so would know which features were available in LabView. I believe my issue here is not covered in the case event/structure section. Also, I noticed that when I chose "Value change" on the buttons it will run 2 times because it executes one time for "Mouse Down" and "Mouse Up". I am going to stick with "Mouse button Up" to resolve this.
I made changes to my code and I believe I can solve this with 3 cases in the case structure, working on it now. But having trouble with making 3 cases with that one button (beginner problems)
For learning purposes, what is wrong with my code that has 1 event structure? When the "STOP" button is pressed, it will always display "Please close the door" even if the input selection is on True or False.
one event structure
With my second attempt, I used 2 case structure. How come it cannot complete the loop until both event structures is executed?
06-15-2020 01:57 PM
1. Don't use Mouse Up. It should be Stop: Value Change. The reason you get the dialog box is that you have an unwired tunnel for that event case which defaults to false. If you want it based on the INPUT control, then the case structure should be wired to the Input terminal. Move that case structure inside the start case. Or put a True constant on the terminal in the Stop case going to that case structure.
2. Data Flow. You actually used 2 Event Structures. Not 2 Case Structures. No structure can complete until all code inside of it completes. You still have the other event structure waiting for an event to execute. Doing this is violating the information in the link about event structures I attached.
06-15-2020 03:08 PM - edited 06-15-2020 03:09 PM
To achieve what I think that you are wanting move your case structure inside your event structure in the Start case.
If this is part of a larger project then perhaps you should consider a state machine architecture.
Edited to add: Also, I couldn't open your file currently but please do be sure to set your buttons to latch and use a value change event with the buttons being read inside the event.
06-15-2020 03:31 PM
1. THIS WORKED! thank you!
I am not sure if I understood your second option you suggested. I tried to "put a True constant on the terminal in the Stop case going to that case structure" but it just just ran the True Case and display "True". Was this what you meant?
06-15-2020 03:33 PM
Yes. that is what I meant.
Because you were asking why it was running the dialog in the False case whenever you pressed the stop button.
06-15-2020 03:39 PM
Thanks John, the program works now after moving the case structure inside.
I haven't tried a state machine yet but i will learn that in my future projects. Thank you for letting me know about that option.
06-15-2020 03:40 PM
ok makes sense. Thanks again for the help!
06-16-2020 04:07 AM