From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-02-2020 04:42 PM
Hi all,
New to LV. I have a system of relays driving pneumatic solenoids with limit switch feedback to show that each relay has actually completed what it was commanded. They are dependent on each other, i.e. they follow each other in a sequence. There is timing, checks for user inputs, and safety sensors along the way. I would like the program to bail out IMMEDIATELY if any of the user inputs, i.e. Stop condition, prior relay status mismatch, or safety relay conditions occur.
I am having the hardest time trying to visualize how to do this. Here is a small piece of what I am doing. The For Loop will not exit upon the first false condition. Essentially if I trip a condition during the test I default to a false state. This causes the program to just cascade false states until the program is complete. I need to be able to exit immediately.
Right now I am strong-arming the limit switch feedback since I don't have the test fixture built up yet and I am working from home 🙂
I have shown a true and false case, both cases have essentially the same false case shutting things down safely.
Any help is much appreciated!
Solved! Go to Solution.
04-02-2020 04:54 PM
LabVIEW operates on the Dataflow Principle. If you remember two main rules, you will know what runs and when.
1. A structure, node, subVI, will not execute until all inputs to it are available.
2. A structure, node, subVI will not finish until all code inside of it has completed.
Structures include the For Loop and the flat sequence structure inside your code. So although the first frame of your flat sequence is complete and is telling the loop to stop, you still need to wait for the 2nd frame of the sequence to complete. At that time the OR function will have both of its inputs then will pass the True to stop terminal of the For Loop and then it can complete.
What you need is a state machine architecture. It is a loop with a case structure. Each case of the structure represents a state, or an action to do. When a state is complete, it can signal to itself through a shift register what is the next action to take. Whether that is to stop, go to step 2, go back to step 1 and also increment a counter.
PS: Your control and indicators for # of shots should be an integer not a floating point value since it is a straight up count, never fractional.
04-03-2020 08:03 AM - edited 04-03-2020 08:09 AM
@RavensFan wrote:
LabVIEW operates on the Dataflow Principle. If you remember two main rules, you will know what runs and when.
1. A structure, node, subVI, will not execute until all inputs to it are available.
2. A structure, node, subVI will not finish until all code inside of it has completed.
Structures include the For Loop and the flat sequence structure inside your code.
No, unfortunately, strictly speaking, that's not true.
A flat sequence structure will not wait until all inputs are available..
A flat sequence structure frame will fire when it's inputs are available.
The reverse is also true. A flat sequence structure frame output is available when the frame is done. It won't wait until the structure is finished.
In itself a reason not to use a flat sequence structure...
Both popups fire after 1 second. Long before the structure is finished or completely started!
04-03-2020 08:21 AM - edited 04-03-2020 08:23 AM
Yes. Wiebe is correct.
A flat sequence "structure", while singular, is really a series of frames where each is a structure in itself with a an inherent dataflow dependency is assigned that frame 2 can't execute until after 1 is done, and so on.
It really doesn't change the explanation to why your code behaves the way it does as the loop still requires the output from the 2nd frame in order to evaluate the stop condition.
The rules I stated are correct, it is just that a flat sequence "structure" is a special entity that is really a series of "structures".
04-03-2020 08:35 AM
wiebe@CARYA wrote:
A flat sequence structure frame will fire when it's inputs are available.
The reverse is also true. A flat sequence structure frame output is available when the frame is done. It won't wait until the structure is finished.
In itself a reason not to use a flat sequence structure...
Spoiler
Both popups fire after 1 second. Long before the structure is finished or completely started!
If you add that a previous frame is considered an input i agree. 🙂 The 2nd frame wont start until the 1st is finished, but the outputs don't need to wait for the following ones to output results, unless they're wired through.
04-03-2020 08:42 AM
@Yamaeda wrote:
wiebe@CARYA wrote:
A flat sequence structure frame will fire when it's inputs are available.
The reverse is also true. A flat sequence structure frame output is available when the frame is done. It won't wait until the structure is finished.
In itself a reason not to use a flat sequence structure...
Spoiler
Both popups fire after 1 second. Long before the structure is finished or completely started!
If you add that a previous frame is considered an input i agree. 🙂 The 2nd frame wont start until the 1st is finished, but the outputs don't need to wait for the following ones to output results, unless they're wired through.
Yes, indeed! It might help to think of flat sequence structure frames as structures, forced in sequential expectation.
Or, as a monstrosity 👺.
04-03-2020 02:31 PM
Thank you all for the clarification and help, also the integer tip. I was looking into the state machine architecture a little bit, but the only other LV colleague at my location recommended against it. I am going to go with my gut and what you all have said.
Thank you very much! Have good weekends!
04-03-2020 03:23 PM
😆
Definitely go with your gut on that.