LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Boolean and array can't be populated outside of timed loop.

Solved!
Go to solution

alainschaerer_0-1716558049837.png

 

I have a timed loop and 2 shift registers (green and orange). The orange shift register is an array and the green shift register a boolean. For some reason, both the boolean and the array are not populated outside the timed loop when I probe it, but inside they are populated. I also tried connecting the shift register of the boolean directly to the case structure, but that also didnt work because the boolean wasnt populated.

 

Has anybody erver been in the situation where a value couldnt be populated outside a loop?

 

0 Kudos
Message 1 of 12
(403 Views)

Welcome to the LabVIEW Forums, Alain.

 

One of the most frustrating aspects of the Forums is trying to help new LabVIEW Users who ask good questions, but don't provide us with the proper information to help them.  In general, pictures of tiny pieces of LabVIEW code are rarely useful -- we cannot see the "context" of the issue (what came before, for example), and can't follow "twisted wires".  Similarly, we can't try to "run your code" and see the bug for ourselves.

 

Please post an entire VI, as a VI, not as a "picture".  But there's a problem here, as well -- you (as a new user of LabVIEW) might be using the "latest version", and many of us (the "old-timers") are using older versions, and cannot open your code!  But you can open your code yourself, go to the File Menu, and "Save for Previous Version", specifying LabVIEW 2019 or 2021 (which seems to work for most of us, myself included).

 

It should be (relatively) easy to spot the issue with your Shift Registers if we can see the entire extent of the "wire" that seems to be associated with them.  If I were to "guess", I would say there's a "broken wire" hidden somewhere on your Block Diagram, or, my usual mistake, a "missing wire" ...

 

Bob Schor

0 Kudos
Message 2 of 12
(374 Views)

The Case Structure inside of your Timed Loop looks like it has multiple output tunnels for the Boolean on top of each other.  That is a miswire.  As Bob said, this is where the actual VI would be helpful as then we can try to move tunnels around and see what is wired where.


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 12
(357 Views)

@Bob_Schor Understood. I attached a .vi file that should be usable with the 2019 Version.

0 Kudos
Message 4 of 12
(350 Views)

Actually, there is a case structure inside the timed loop and the boolean is inside that case structure, correct. However, the case structure is evaluated as true when I try to probe the boolean outside the loop, which means that is should work from a programmatic standpoint. Im not sure if that is a problem in labview though?
If its not possible to have multiple output tunnels, what is the alternative to get the value of that boolean outside of the loop?

0 Kudos
Message 5 of 12
(349 Views)

@Bob_Schor wrote:

Welcome to the LabVIEW Forums, Alain.

 

One of the most frustrating aspects of the Forums is trying to help new LabVIEW Users who ask good questions, but don't provide us with the proper information to help them.  In general, pictures of tiny pieces of LabVIEW code are rarely useful -- we cannot see the "context" of the issue (what came before, for example), and can't follow "twisted wires".  Similarly, we can't try to "run your code" and see the bug for ourselves.

 

Please post an entire VI, as a VI, not as a "picture".  But there's a problem here, as well -- you (as a new user of LabVIEW) might be using the "latest version", and many of us (the "old-timers") are using older versions, and cannot open your code!  But you can open your code yourself, go to the File Menu, and "Save for Previous Version", specifying LabVIEW 2019 or 2021 (which seems to work for most of us, myself included).

 

It should be (relatively) easy to spot the issue with your Shift Registers if we can see the entire extent of the "wire" that seems to be associated with them.  If I were to "guess", I would say there's a "broken wire" hidden somewhere on your Block Diagram, or, my usual mistake, a "missing wire" ...

 

Bob Schor


Also, I personally tend to ignore requests for help when the code is messy.

0 Kudos
Message 6 of 12
(329 Views)

@alainschaerer wrote:

alainschaerer_0-1716558049837.png

 

I have a timed loop and 2 shift registers (green and orange). The orange shift register is an array and the green shift register a boolean. For some reason, both the boolean and the array are not populated outside the timed loop when I probe it, but inside they are populated. I also tried connecting the shift register of the boolean directly to the case structure, but that also didnt work because the boolean wasnt populated.

 

Has anybody erver been in the situation where a value couldnt be populated outside a loop?

 


My guess here is that you're not understanding data flow.  Nothing comes out of a loop until it is finished looping; nothing comes out between iterations.

Message 7 of 12
(327 Views)

@paul_a_cardinale wrote:

My guess here is that you're not understanding data flow.  Nothing comes out of a loop until it is finished looping; nothing comes out between iterations.


And since there is nothing to tell the loop to stop, there should never be any data getting to that final case structure outside of the loop.

 

Now a general take: Timed Loops should not be used in a Windows application.  They are fine for RT, where determinism is important, and FPGA, where everything inside of the loop executes in a single clock cycle.  But on Windows, they just add overhead and cause a bunch of other issues with your system (everything inside is forced to a single thread, you are setting priorities such that Windows might not act right, etc.).  Use a simple While loop with a wait instead.  Further, this will actually force you to put a stop condition on your loop, even if it is just a simple Stop button.


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 8 of 12
(302 Views)

Got it. To my defense, its not my code. I was given that by the client, allthough it's my first time working with LabVIEW. Im a code guy.

 

That said, if I have to use a boolean outside the loop while the loop is still running, is there a way of doing that? Like maybe I can somehow create a "global variable" and then use it?

 

As far as timed loops go, that makes sense.

The situation is the following: Every 1000 iterations, I need to send an array to the save-data function outside of the loop, which means that the loop will still be running while I have to send data to outside of the loop, even if there is some sort of stop condition with a button.

 

Actually thinking about that, I might just be able to take the save data function inside the loop and use a case structure to only execute it on every 1000th iteration. 

0 Kudos
Message 9 of 12
(297 Views)
Solution
Accepted by topic author alainschaerer

@alainschaerer wrote:

Got it. To my defense, its not my code. I was given that by the client, allthough it's my first time working with LabVIEW. Im a code guy.

 

That said, if I have to use a boolean outside the loop while the loop is still running, is there a way of doing that? Like maybe I can somehow create a "global variable" and then use it?

 

As far as timed loops go, that makes sense.

The situation is the following: Every 1000 iterations, I need to send an array to the save-data function outside of the loop, which means that the loop will still be running while I have to send data to outside of the loop, even if there is some sort of stop condition with a button.

 

Actually thinking about that, I might just be able to take the save data function inside the loop and use a case structure to only execute it on every 1000th iteration. 


Better than a global variable would be a local variable.

But you might want to consider channel wires: https://www.ni.com/en/support/documentation/supplemental/16/channel-wires.html

0 Kudos
Message 10 of 12
(289 Views)