09-17-2019 05:56 PM
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
Solved! Go to Solution.
09-17-2019 06:02 PM - edited 09-17-2019 06:03 PM
(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?
09-17-2019 06:16 PM
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.
09-17-2019 06:48 PM
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
09-17-2019 07:19 PM
@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
09-17-2019 11:01 PM - edited 09-17-2019 11:03 PM
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.
09-17-2019 11:28 PM
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.
09-17-2019 11:36 PM
@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
09-18-2019 12:50 AM - edited 09-18-2019 12:54 AM
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
09-18-2019 01:22 AM
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