LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to execute the functionality of button at a time of pressing if function is in continuous loop?

Hello,

I am facing one basic problem that how can I execute the button which I have used in my vi at a time of pressing means in my vi I have used 4 button 1. Start 2. OK 3. Save and 4. Stop button

when user press start button then continuous loop will be executed and after pressing OK it will stop that loop and waiting for next instruction from user whether he want to do reading operation again or he want to save or he want to stop.

The thing is when I press start button then while loop is execute then its not possible to press stop button or save button, user need to wait until OK button is pressed.

 

Will you please guide me how can I do so that when ever user press any button that button is executed at time.

Thank you very much once again.

0 Kudos
Message 1 of 8
(3,216 Views)

Take a look at the template "Producer/Consumer Design Pattern - Events".  You'll be able to have your Front Panel controls send commands and the consumer loop can respond appropriately.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 8
(3,211 Views)

Thank you for suggestion.

I had took a look already, but because of while loop I got confused.

That when continuous loop is in picture then save and stop button need to wait until continuous loop stop.

But I want that after pressing start button if user want to press save/stop then its work properly.

Thank you very much once again.

0 Kudos
Message 3 of 8
(3,204 Views)

Hello,

I tried to set my vi as producer consumer event structure,

now after pressing start button I can press save button and its working good but the thing is program is not reset,means I want to reset program after pressing save button.

Here in my case after pressing save rest of other button also not working properly.

Can you please suggest me some solution regarding to this. 

Thank you very much.

0 Kudos
Message 4 of 8
(3,135 Views)

Hi

 

After a quick look at your VI i can see that you stop most the loops after pressing the save button, however without starting them again.

I found a guide that might help you out.
http://digital.ni.com/public.nsf/allkb/19973E97DD7AFED386256E1D0075404F

 

Hope this helps!

0 Kudos
Message 5 of 8
(3,124 Views)

Hi Ankit,

 

There are some issue in your code mention below please have a look and correct these will work fine for your requirement.

 

1. Save button Boolean value pass to the lower wheel conditional loop means if you press save your bottom loop will stop working this is not the code requirement you have to continue loop and tigger start event in last using value tigger event property to tigger again start event.

       This step will reset your loop and start from zero.

 

2. According to me I think both loop should stop only in stop condition so you can remove stop function from upper loop and pass the button value in both loop directly to wheel loop condition terminal.

       Upper loop direct and lower both loop local variable.

 

3. Why you want to stop your upper loop on any error condition, you should Handel the errors and keep running the code.

 

4. What is the use of queue no case related with dequeue in bottom loop.

 

5. Wheel loop in a event is not  good practice so you can use your queue structure here to run continuous lower code.

 

I hope these changes can improve your code.

Thanks and Regards
Himanshu Goyal | LabVIEW Engineer- Power System Automation
Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
It Only gets BETTER!!!
Message 6 of 8
(3,121 Views)

Thank you everyone for help..

I tried with attached vi, I think its working good.

Is there any suggestion to improve that vi which use to help to reduce the time consumption.

Thank you very much once again.

0 Kudos
Message 7 of 8
(3,114 Views)

A few things.

 

Don't do this.  You'll end up in the Rube Goldberg thread...

voltageforcecapacitance%20without%20instrument[1]_BD.png

 

Do this, instead.

voltageforcecapacitance%20without%20instrument[1]_BD.png

 

What do you mean by "reduce the time consumption"?  You have a 1 second wait in your loop.

 

Finally...

why.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 8 of 8
(3,096 Views)