LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case Structure and Event Structure keeps using old values

Solved!
Go to solution

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.

 

Kwan90_1-1591921141004.png

 

Kwan90_0-1591920868823.png

 

Thanks in advance!!!

Kwan

 

0 Kudos
Message 1 of 10
(3,796 Views)

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

0 Kudos
Message 2 of 10
(3,751 Views)

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 structureone event structure

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

With my second attempt, I used 2 case structure. How come it cannot complete the loop until both event structures is executed?

 

two case structure.PNG

 

0 Kudos
Message 3 of 10
(3,672 Views)
Solution
Accepted by topic author Ddarma

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.

 

 

0 Kudos
Message 4 of 10
(3,668 Views)

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. 

0 Kudos
Message 5 of 10
(3,652 Views)

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?

 
0 Kudos
Message 6 of 10
(3,644 Views)

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.

0 Kudos
Message 7 of 10
(3,640 Views)

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.

0 Kudos
Message 8 of 10
(3,633 Views)

ok makes sense. Thanks again for the help!

0 Kudos
Message 9 of 10
(3,632 Views)
"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. " Since you have the "empty center" on the Connection, it's a "Use default value" Connection. Since you have nothing wired to it, it defaults to False, resulting in "Please Close the door". As already mentioned, the solution is to wire True of the button wire to the border Connection. (Why do the editor randomly capitalize letters?)
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 10
(3,578 Views)