LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

can not get data from while loop

Solved!
Go to solution

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

 

0 Kudos
Message 1 of 10
(2,013 Views)
Solution
Accepted by topic author PuriK.

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:

GerdW_0-1675076772251.png

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…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(1,992 Views)
Solution
Accepted by topic author PuriK.

@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:

GerdW_0-1675076772251.png

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. 

Message 3 of 10
(1,968 Views)

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.

0 Kudos
Message 4 of 10
(1,924 Views)

Thank you for your idea. I am trying to make this vi. works in one loop but has not succeeded yet. 

0 Kudos
Message 5 of 10
(1,921 Views)

@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. 

Message 6 of 10
(1,871 Views)

 

 


@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. 

0 Kudos
Message 7 of 10
(1,849 Views)

@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).

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 8 of 10
(1,839 Views)

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"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 10
(1,835 Views)

@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.

Message 10 of 10
(1,811 Views)