LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make stop button to work again in a while loop

Solved!
Go to solution

Hi Application Engineers,

 

There is a data generation loop followed by a data selection loop, I would like to start the data generation and data selection again and again, so I added another while loop to include the data generation and selection loops, however, the stop button for the data generation loop just work for the first run, how to make the stop data generation button to work for all runs?

 

The second run of data generation should start after clicking the stop data selection button, the data generation should stop and move to the subsequent data selection loop after clicking the stop data generation.   

 

I tried all mechanic actions, switch/latch when pressed/released/until released for the stop data generation button,  no one worked it out.

 

Could someone help me with this issue?  attached is a simple VI for troubleshooting.

 

Thanks,

Gu

0 Kudos
Message 1 of 27
(3,393 Views)

(Posting by phone, cannot see your code)

 

I would seriously rethink the architecture (loops inside loops, stop to start something, etc.) and learn about state machines.

 

Sounds like a dataflow problem. Is the terminal of the button in a place where it gets read as needed?

0 Kudos
Message 2 of 27
(3,384 Views)

Like Altenbach, I am posting by phone.  But my initial thought was you need a mechanical action on your button to be Latched When Released.  Then my mind also went to "should be a state machine".  Could also be an Event Structure locking the panel.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 27
(3,370 Views)

Thank you,   Altenbach and  Crossrulz.

 

I will read the web and learn how to code a state machine and may come back to you if I encounter more issues.

 

Gu

 

0 Kudos
Message 4 of 27
(3,355 Views)

@altenbach wrote:

(Posting by phone, cannot see your code)

 

I would seriously rethink the architecture (loops inside loops, stop to start something, etc.) and learn about state machines.

 

Sounds like a dataflow problem. Is the terminal of the button in a place where it gets read as needed?


The VI posted looks like one that you (CA) wrote; especially since it has the MODCA suffix. Don't think it is a problem with your VI, think the OP is not sure how to modify your work to meet their needs.

 

mcduff

0 Kudos
Message 5 of 27
(3,345 Views)
Solution
Accepted by topic author edmonton

Here is a snippet of the VI.  The stop2 button is set for Switch Until Released, an uncommon action.

 

Christian certainly would not have provide a VI that looks the way this one does now.

 

Message 6 of 27
(3,294 Views)

I agree, a filename containing the term "MODCA" should be a reserved term. It means two things: (1) the code is based on something broken, not written by me. (2) I modified to fix a specific problem, often leaving other questionable parts as-is.

 

It is not polite to butcher and heavily modify my solution code without changing the filename. In any case, a link to the original threads should always be included as reference.

0 Kudos
Message 7 of 27
(3,288 Views)

@RavensFan wrote:

Here is a snippet of the VI.  The stop2 button is set for Switch Until Released, an uncommon action.

 

Christian certainly would not have provide a VI that looks the way this one does now.


I admit, I did not look at the posted VI in detail, but I saw MODCA and complex numbers in a plot, two calling cards of CA. 😊 After seeing those, I did not think to examine the VI, and assumed it was correct.

 

mcduff

0 Kudos
Message 8 of 27
(3,281 Views)

Hi Dr  Altenbach,

 

I am sorry for forgetting to change the file name prior to posting the VI. It was modified from your solution code.  

 

Taking your suggestion,I have read state machine on web and learned that it is beneficial to use  it. However, after thinking about my application VI, I have to keep the data generation part with a conditional stop in a case or a state.  The stop button stops responding once it is in a case structure. Attached are two VIs, one with a case structure and another one without the case structure. The stop data generation button works in the VI without case structure, and does not work in the VI with a case structure.

 

State machine uses case structure in a while loop. It seams difficulty to get out of the issue.

 

Thanks,

Gu

Download All
0 Kudos
Message 9 of 27
(3,262 Views)

Hi RavensFan,

Thanks for your reply.

 

The stop2 button was set for Switch Until Released, which made a single click the button to stop the data selection loop, while Switch When Pressed/Released requires a double click the button to stop the data selection loop. luckily, I found that the Stop Data Generation button works fine once the Stop Data Selection button (stop2) is set for Switch When Pressed/Released.

 

It is good to learn the internal correlation between the stop actions in two loops. 

 

Gu

0 Kudos
Message 10 of 27
(3,250 Views)