LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

change input depending on while loop content

Hi everyone, I'm currently automating a test stand.

We have a working function (attached image) to control the motor manually and I would like to add a secondary input that allows the same function to be automated.

For this I would need to have a secondary input for "MC Program" and "RUN Program". The secondary input should be picked only if the automation while loop is running.

I tried using a case structure with "MC Program" inside it if false and a passthrough of the automation if true (true and false depending if the automation is running) however if the automation isn't running I'm not able to run the motor manually as it's not able to gather data from inside the while loop.

I'm also struggling to get a Boolean signal depending if the while loop is active or not.

 

Any suggestion is welcome.

Regards,

Andrea

0 Kudos
Message 1 of 14
(559 Views)

Your picture does not really help to explain your problem.

 

What is your definition of a while loop that is "active"?

0 Kudos
Message 2 of 14
(539 Views)

I'm talking about a loop that is going through iterations, I would like to show the whole code but as this is only 5% of everything and it's an absolute mess from the original guy that made it I think its going to create more questions than anything.

 

The problem I think I'm having is that as the automation while loop does not run at start-up the variable inside it doesn't get initialized. And if it's not initialized it doesn't like it. I basically need a way to completely ignore a non-initialized connection however both using a case structure or a "select" logic box even if I'm using a specified variable.

I'm going to attach a photo which should summarize the issue. The disconnected connection is the output of my problem, from there everything works. The bottom loop only runs when it's required to run, the top loop (same as the one in the original post) runs almost constantly.

I just need to get the data from the bottom loop into the top one only when it runs, however the top one should be able to work even before the bottom loop has run, currently if I try to use the top loop before I run the bottom loop it just freezes. However if I run the bottom loop then the top one works even after the bottom loop has stopped.

0 Kudos
Message 3 of 14
(527 Views)

You have a basic data flow problem. The upper loop cannot start until the lower on is finished.

 

There are plenty of ways to run loops in parallel, but we probably need more details.

0 Kudos
Message 4 of 14
(524 Views)

The top loop was already done, it get's user input and communicates with the motor controller.

The bottom loop is the automation, each iteration of the loop runs the next step of the automation. All I want to do is input the data from variables contained in the automation loop (bottom loop) into the top loop instead of the manual variables found on the interface.

 

These secondary variables should only be taken when the bottom loop is running. So a rough sequence should be:

1) bottom loop first iteration

2)top loop runs trough all iterations

3)bottom loop waits specified time

4)bottom loops second iteration

...

 

0 Kudos
Message 5 of 14
(515 Views)

As I said, you need to do a few basic LabVIEW tutorials and understand the basic principles of dataflow. This is not it!

 

altenbach_0-1705303700957.png

 

 

I can't see any "variables" anywhere. Just diagram constants, wires and controls. 

What's your definition of "all iterations".

 

Maybe all you need is exactly one loop and a simple state machine architecture.

0 Kudos
Message 6 of 14
(494 Views)

I have done a few Labview tutorials but they were time consuming and a huge waste of time. Right now I just have a few more weeks to have everything working.

 

How would you suggest I do it? I believe I'm already using state machine architecture, both the automation loop (bottom) and transmission loop (top) are state machines. 

 

I've added the top and bottom loops screenshots, as said I have to replace the "MC Program" input with the other input when the bottom loop is active. How do I go about doing that?

 

Thank you,

Andrea

Download All
0 Kudos
Message 7 of 14
(407 Views)

Also if there is a box that allows me to set a static value if the correct value is not initialized yet I can probably get it to work.

0 Kudos
Message 8 of 14
(405 Views)

Everybody here agrees that diagram pictures are useless to debug anything. Your architecture is still glaringly bad and I agree with you that if that's all you learned, the tutorials were really(!!!) a waste of time (This does not mean that you should now waste our time posting truncated pictures and very little useful information.)

 

Did you look at some random questionable YouTube channels or study the learning resource listed at the top of this forum?

 


@Nizzo wrote:

Also if there is a box that allows me to set a static value if the correct value is not initialized yet I can probably get it to work.


What is a "box"?

 

As we already said, the upper loop cannot start until the lower loop has completed. If you trigger any events (e.g. press "Run program"), while the lower loop is still running, the front panel will be locked until the event completes (by default) and nothing else can be done. Catch 22!. Can you explain the logic behind "OR FALSE"? A plain wire would do exactly the same!

0 Kudos
Message 9 of 14
(396 Views)

I got it working. For anyone running into the same issue you will need to use local variables to communicate between loops. Dragging a line between them does not work work if your situation is like mine.

 

 

0 Kudos
Message 10 of 14
(350 Views)