01-30-2023 04:34 AM
Hello,
In this vi, I try to measure the voltage signal in a specific period several times by pushing the start button every time when I want to measure. In the end, I want to gather data from each measurement (loop) in one array (final array) by pushing the stop button.
However, nothing happen when I pushed the stop button. There must be something wrong with this vi but I do not know what it is. Please help me.
Best regards,
Plu
Solved! Go to Solution.
01-30-2023 05:08 AM - edited 01-30-2023 05:10 AM
Hi Puri,
@PuriK. wrote:
However, nothing happen when I pushed the stop button. There must be something wrong with this vi but I do not know what it is. Please help me.
This is wrong:
The stop button is in the outermost while loop, but there are 3 other loops stacked inside.
So the reason is bad program design!
To say it in other words: "OBEY DATAFLOW!" The stop button can only be handled once per iteration of the outermost loop. You need to iterate that loop - but that only happens when all inner loops are stopped…
Btw. what's the point of the innermost loop? Why wait for some time while displaying/plotting the very same data again and again?
(Again my conclusion: the program design is just bad…)
01-30-2023 06:47 AM
@GerdW wrote:
Hi Puri,
@PuriK. wrote:
However, nothing happen when I pushed the stop button. There must be something wrong with this vi but I do not know what it is. Please help me.
This is wrong:
The stop button is in the outermost while loop, but there are 3 other loops stacked inside.
So the reason is bad program design!
To say it in other words: "OBEY DATAFLOW!" The stop button can only be handled once per iteration of the outermost loop. You need to iterate that loop - but that only happens when all inner loops are stopped…
Btw. what's the point of the innermost loop? Why wait for some time while displaying/plotting the very same data again and again?
(Again my conclusion: the program design is just bad…)
To add to what GerdW said, your second loop has a constant wired to the stop terminal. It will never stop, so you're stuck in there. You should really learn about a good architecture. A state machine would be a good start. there really only needs to be one loop for this program.
01-31-2023 07:10 PM
Hi, Thank you for your comment. It helps me make the program work smoothly. It might not perfect now but I will continuously improve it.
01-31-2023 07:12 PM
Thank you for your idea. I am trying to make this vi. works in one loop but has not succeeded yet.
02-01-2023 08:10 AM
@PuriK. wrote:
Thank you for your idea. I am trying to make this vi. works in one loop but has not succeeded yet.
I assume that this reply was to my comment. It is good practice to quote the post that you're replying to. You can do that by hitting the quotation marks above the box.
Did you study about a state machine? You should be able to accomplish all of this in a simple state machine with Initialize, Idle, Running, and Stop states. No need for the nested loops and no need for the sequence structure.
02-02-2023 01:21 AM
@johntrich1971 wrote:
@PuriK. wrote:
Thank you for your idea. I am trying to make this vi. works in one loop but has not succeeded yet.
I assume that this reply was to my comment. It is good practice to quote the post that you're replying to. You can do that by hitting the quotation marks above the box.
Did you study about a state machine? You should be able to accomplish all of this in a simple state machine with Initialize, Idle, Running, and Stop states. No need for the nested loops and no need for the sequence structure.
I must admit that I had not studied about a state machine yet. I will do it after finishing this urgent task. Thank you again for your comment and suggestion to use quotation marks.
02-02-2023 02:36 AM
@PuriK. wrote:
@johntrich1971 wrote:
@PuriK. wrote:
Thank you for your idea. I am trying to make this vi. works in one loop but has not succeeded yet.
I assume that this reply was to my comment. It is good practice to quote the post that you're replying to. You can do that by hitting the quotation marks above the box.
Did you study about a state machine? You should be able to accomplish all of this in a simple state machine with Initialize, Idle, Running, and Stop states. No need for the nested loops and no need for the sequence structure.
I must admit that I had not studied about a state machine yet. I will do it after finishing this urgent task. Thank you again for your comment and suggestion to use quotation marks.
Seems a little backwards since learning the state machine will make you finish this urgent task more efficiently (and probably more quickly as well).
02-02-2023 02:39 AM
Hi Puri,
@PuriK. wrote:
I must admit that I had not studied about a state machine yet. I will do it after finishing this urgent task.
Regarding your problems with other basic stuff you really should take some basic LabVIEW learning as offered at the top of the LabVIEW board. This will really help you to solve your "urgent tasks"…
02-02-2023 02:19 PM
@billko wrote:
@PuriK. wrote:
@johntrich1971 wrote:
@PuriK. wrote:
Thank you for your idea. I am trying to make this vi. works in one loop but has not succeeded yet.
I assume that this reply was to my comment. It is good practice to quote the post that you're replying to. You can do that by hitting the quotation marks above the box.
Did you study about a state machine? You should be able to accomplish all of this in a simple state machine with Initialize, Idle, Running, and Stop states. No need for the nested loops and no need for the sequence structure.
I must admit that I had not studied about a state machine yet. I will do it after finishing this urgent task. Thank you again for your comment and suggestion to use quotation marks.
Seems a little backwards since learning the state machine will make you finish this urgent task more efficiently (and probably more quickly as well).
I agree with this. You can either spend days trying to get this poor code to work or you can spend a few hours learning about a state machine and have your urgent task done this week.