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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

no button response in while loop

Hi,

 

I am preparing for the CLD test and working on the car wash problem. Instead of a more complicated architecture, I am using a simple state machine to handle it.

 

One thing I have problem with is the pause timer and stop excution inside one state. I have a stopwatch subvi called in a while loop. The pause is connected with a local variable of the pause button. And if the elapsed time is larger than 4 seconds or the stop button is pressed, the while loop will end.

 

Now, when I run it, and try to press the pause and stop button it doesn't response the click. What is wrong?

 

I have tested the functionality of the timer using a simple vi and it works fine.

 

Thanks.

 

 

 

Download All
0 Kudos
Message 1 of 7
(2,751 Views)

What is happening in the stop watch VI?  Is there a loop inside of it.

 

Have you tried following the data flow by using Execution highlighting?

 

Are you sure you are going to be ready to take the CLD?  Have you taken the CLAD yet?  Using local variables and stacked sequences are two things that will hurt you big time on the CLD.

Message Edited by Ravens Fan on 03-17-2009 01:06 PM
0 Kudos
Message 2 of 7
(2,735 Views)

Thanks.

 

I think I am not ready especially after you asked me these questions. I read some posts in LAVA and people are suggesting using simple state machine instead of anything more complicated.

 

For example: 

 

http://forums.lavag.org/CLD-Exam-Tips-t10385.html

 

 

Speaking of local variables, I know they are prone to error, but they are very convinient to use. Is there a general solution for alternative? 

 

 

 Yeah, I did passed the CLAD exam.

 

 

 In terms of the stopwatch vi, it does have a loop inside but it only excute once it is called. I am using uninitiated shift register to store the elapsed time. Please see the attachment.

 

 

Thanks.

 

 

 

0 Kudos
Message 3 of 7
(2,710 Views)

In general, a functional global variable is a better alternative for storing a data value and using it elsewhere. Ben's Action Engine nugget expands on its use even further.

 

In your subVI, there is no need to use the local variables at all because you have the two terminals for the controls sitting there unused.

 

As for your original problem, I was thinking you had a loop inside the subVI that was trapping the execution of the code.  I see that is not the case.  With only some screenshots, I can't figure out why you pause or reset buttons aren't working they way they should.  I can't see what is going on in other cases.

 

You say the test VI works okay but the state machine VI doesn't?  In your state machine VI, you only have one value wired up to the subVI.  What is the default value for the other input?  Perhaps it is true and is always resetting itself when that runs?

0 Kudos
Message 4 of 7
(2,692 Views)

Thanks so much for your advices.

 

I found a way to fix it but I don't know why. In the state machine, the states are:

 

1. initiate

2. wait to start

3. state 1

4. state 2

5. state 3

 

in the 2nd state, a event handler is included to sense the value change of the start button. if it changes, the next state will be state 1. If I bypass this state, everything works fine.

 

In the event handler, there are 3 event entries.

 

1. start button - if changes, move on to the next state

2. stop button - if changes, stop vi

3. time out - 20 ms, after that it goes back to the same state.

 

Why this 2nd state can cause non-response buttons in the later state?

 

Thanks.

 

 

 

 

 

0 Kudos
Message 5 of 7
(2,678 Views)

This is the first I heard an event structure is involved.

 

See if the events have a state that says "Lock front panel until Event Case for this Event Completes", perhaps one of those is hanging you up.

 

Another thing to look at.  What is the default value for your enum and default case for your state machine?  In you Stop button case, you don't have any constant wired to the tunnel in the event structure, so the default value will get passed out and into the next iteration of the state machine.

0 Kudos
Message 6 of 7
(2,672 Views)

Thanks!

 

The 'lock front panel' is selected. After it is deselected, the vi works fine.

 

I didn't even know there is such an option before.

 

I will make sure look into the functional global before taking CLD test and try to replace the local variables 🙂

 

0 Kudos
Message 7 of 7
(2,662 Views)