LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Control While Loop by means of On/Off Switch, or Even restart the while loop with the button

Solved!
Go to solution

Hello Sir,
I have made a virtual instrument. I need some help regarding if you can tell me how i can restart the while loop in which i have put my DAQ.MX TASK along with trigger and gate.
I want rising curve samples and have to take product and integration of them. If i place the Integration Vi Graphs and Multiplications, they keep on rapidly multiplying. causing error to the required values

I have used cased structure, and switches so that when the value is true it runs the daqmx task, and perform alll the operations after reading the data. BUT IF FALSE, I dont know what to do. 

What i want is that when i turn  a Switch ON , it reads the daqmx again, when the trigger is activated, it plots the graphs and calculations.
Kindly please help!!! 
0 Kudos
Message 1 of 8
(5,217 Views)

(posting by phone, cannot see your vi)

 

All you need is a proper state machine.

0 Kudos
Message 2 of 8
(5,207 Views)

@Ahmed.Arsalan wrote:

Kindly please help!!! 


OK, looked at your code.

 

Please do not attach VIs where the front panel is bigger than the largest monitor and objects scale with the panel. It is a major pain to do anything with your front panel if all decorations are outside the active window and thus nobody will look at your VI. Please fix and re-attach.

 

From a quick glance, your code is just a convoluted jumble of express VIs, dynamic data, and stacked loop. You probably should do a few more LabVIEW tutorials before continuing all this.

 

All you need is a proper architecture, e.g. a "state machine" as already mentioned.

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

Thanks for the comments regarding use of state machine. I tried to implement it though..... 🙂

I am a civil engineer with almost no idea of LABVIEW. All this I have learnt in three days as time is a luxury which i dont enjoy at the moment. i have experiments lined up due in next week. 

 

From a quick glance, your code is just a convoluted jumble of express VIs, dynamic data..


In this time I only require one thing ........help me in this convoluted jumble .........

It works perfectly if Run Continuously! 
NO DOUBT! YOUR LITTLE JUGGLERY WITH MOUSE CAN MAKE MY DAY!

P.S i have shortened it a little bit, this is perhaps the most out of my abilities! 

0 Kudos
Message 4 of 8
(5,181 Views)

Don't hide the labels of the terminals on the block diagram.

 

The problem is that the condition that stops the inner while loop, also stops the outer while loop.  That means it will only run once.

 

If you need something else to stop the outer while loop, than wire that condition to it rather than the same wire coming from the inner while loop.

0 Kudos
Message 5 of 8
(5,156 Views)

@RavensFan

If you need something else to stop the outer while loop, than wire that condition to it rather than the same wire coming from the inner while loop


outer loop should stop with the inner loop.... now how to restart both the loops.....

i cannot allow the integration loop running. as with time the integration values shall increase

0 Kudos
Message 6 of 8
(5,151 Views)
Solution
Accepted by topic author Ahmed.Arsalan

@Ahmed.Arsalan wrote:

@RavensFan

If you need something else to stop the outer while loop, than wire that condition to it rather than the same wire coming from the inner while loop


outer loop should stop with the inner loop.... now how to restart both the loops.....

i cannot allow the integration loop running. as with time the integration values shall increase


You just contradicted yourself.  You want it them to stop together, but then have the outer restart?

 

As pointed out before, refactor this into a state machine.  That way if you have a situation where you want the code to run but basically do nothing such as not integrate, you can have an idle state.

Message 7 of 8
(5,134 Views)

Used the Simple State Machine Template and it worked like a charm....

Thanks @RavensFan 

0 Kudos
Message 8 of 8
(5,081 Views)