LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Loop won't stop when stop button is pressed

Solved!
Go to solution
Solution
Accepted by Aather

Hope the attached file will solve your current issueFG.png

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 11 of 18
(2,292 Views)

How do you say that it is recording data? I can see that the Loop is stopped when we click the Stop (Return to Home) button which you have pointed out as issue. I can see the Loop Acceleration Data Producer loop is not stopping since you have  connected only error out and FALSE. This loop in your design will not stop since you are releasing the queue after that loop. Either you must have a local variable of the Stop control or think about re-designing the code ( I am sorry I cannot suggest you to add items to the existing code which would invite trouble). 

-----

The best solution is the one you find it by yourself
0 Kudos
Message 12 of 18
(2,288 Views)

@Aather wrote:

We haven't had any other issues with this code apart from the one that is the reason for this post. This code has been used in operation and has given some good results so the design of the code is not the problem. We are currently in the process of changing the code slightly to fit the new needs that we have.

 

So please could we have an example of the section of code that has been recommended for the problem to be resolved?

 

Kind regards,

Aaron and Stephen


http://www.ioccc.org/2015/dogon/prog.c  Take a look at that code.  Technically, it works.  But, if you wanted to make any changes, wouldn't it be a mess?  The code you've shared is the LabVIEW equivalent of this c code.  It's very difficult to read and will take more time to try to understand how smaller changes will impact the overall program (similar to the stop you're noticing in this post) due to the structure.  It may be in operation.  It may be functional.  But, the design is a problem.  The "slight" changes you're trying to make now likely would already be finished if the code was readable.

 

Someone has posted an example of an FGV for you.  You could have easily found that as well by typing "FGV labview" into google.  First hit: https://decibel.ni.com/content/docs/DOC-2143  A lot of times people will post the idea here for you knowing there's a wealth of resources on the topic already and let you use those rather than recreating those resources.

0 Kudos
Message 13 of 18
(2,274 Views)

Your link for the C code is broken

-----

The best solution is the one you find it by yourself
0 Kudos
Message 14 of 18
(2,266 Views)

Interesting.  It adds some extra to the end of the link.  If you copy/paste the text of the link, you should get to the example. http://www.ioccc.org/2015/dogon/prog.c

 

I'll try to post antoher link as well.

 

Edit:  The link didn't add the extra characters this time and this link should work.

0 Kudos
Message 15 of 18
(2,256 Views)

Hi Palanivel,

 

We have tried to replicate the code that you gave us as an example but have found that we cannot stop the program once it has started, could you help with this (please see code screeshots attached)?

 

As a side note to the other authors who have posted on this discussion, we would like to point out that we are new at using LabVIEW and the were given this code by someone who was very experienced at LabVIEW but was leaving the company so wanted us to carry on from him. The reason we asked for an example code is because this is a forum where people have expertise and are willing to share that, so me and Stephen decided to ask for the example code because we know that any code given is more than likely to help solve our problem.

 

Kind regards,

Aaron and Stephen

Download All
0 Kudos
Message 16 of 18
(2,254 Views)

Hi Aaron,

 

your while loop NEVER stops! Did you check the stop condition carefully? (Did you even try to debug your VI?)

 

Hint: LabVIEW has a AutoCleanup feature (key shortcut Ctrl-U), that prevents hidden or bended wires…

 

Next time please attach snippets instead of plain images!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 17 of 18
(2,252 Views)

His solution used a true.  Yours uses a false.  This is another reason you'd be better off going to the documentation that already exists.  Beyond just giving you the code, it'll explain what's happening.

 

In this case, you're leveraging the fact LV won't release the memory for the shift register until it closes out.  This lets you open the FGV in multiple locations and read the last value.  There are two very key parts to making this work:  1) the shift register must be uninitialized and 2) the while loop must only run once.

 

If you break either of these rules (which you have), you cause problems.  In your case, your code never leaves the FGV after the first time it is called creating a mess.

0 Kudos
Message 18 of 18
(2,233 Views)