Jump to content

For Loops, State machines or something else?


Recommended Posts

My attached work in progress is a simulation of a pipe cleaning apparatus I use at work. This is neither homework, nor required for work. (I have not managed to generate enough interest in labview at work yet) My motive for designing this is to just improve my skills.

Once the supply tank is empty, and the collect tank full, I would like to be able to use booleons to make it run backwards. I feel I might be successful if I could get the tanks outside the for loops, but it seems they need to to be inside the for loops. I have had some practice using event structures but if I used event structures, the tanks would probably have to be outside them as well. Two questions: To solve my problem, should I study up on State Machines, or try something else? For Valves N1S1 & N2S2, I chose to use multi-state valves instead of two state valves, but I cannot tell the diference between the two. I tried my labview manuals. the forums and google for an answer but was unsuccessful. Please explain the difference between the two.

supply collect resized 5.1.vi

Link to comment

Once the supply tank is empty, and the collect tank full, I would like to be able to use booleons to make it run backwards.

I don't understand exactly what you're saying here. Looking at it from the user's point of view, how do you want the program to behave? Some questions off the top of my head...

- Do you want it to run backwards automatically when the collect tank is full?

- Do you want the user to press a button to make it run backwards?

- Should the user be able to change flow direction before the collect tank is full?

I have had some practice using event structures but if I used event structures, the tanks would probably have to be outside them as well.

Yes, that is correct. Event structures are designed for capturing front panel event from the user. (User Events too, but that's a more advanced concept.) Generally *everything* should be outside of the event structure except for code to send a message to a parallel loop that does the actual work. That way the user interface doesn't become unresponsive while the program is running. Look at the "Producer/Consumer Design Pattern (Events)" template included with Labview. (Found in the menu under File --> New...)

Two questions: To solve my problem, should I study up on State Machines, or try something else?

Since this is an exercise to help you learn Labview, yes, you should study up on state machines. You'll need to know it even if it doesn't help you solve this problem.

For Valves N1S1 & N2S2, I chose to use multi-state valves instead of two state valves, but I cannot tell the diference between the two. Please explain the difference between the two.

Can't help with this one. Is it part of an add-on toolkit?

Link to comment

chrichter,

Attached there is a VI that makes the tanks run backwards with both in a While loop instead of a For loop. There is lots to study up on in terms of events, state machines, etc.

This looks like a cool program. You are well on your way. Keep tinkering and making programs. That's the best way to learn. Hopefully you can convince your company LV is a tool they need.

There is a lot to point out, but one thing I'll say right now is that property nodes that only need to change a property once can be placed outside of your main loop. That way they only happen at startup. You can use your error wires to make sure they happen before entering the main loop.

Another thing I'll say is that in you'll find For loops are most often used to perfrom repetitive iterations on arrays of data. It's not that they don't have other uses, but that's where you'll see them most commonly used.

Application design is something that takes a lot of studying and understanding of most of the basic LV structures. I think all of us are always trying to become better at this. Read the message boards and get your hands on some of the more advanced LV programming books to help understand these things.

Regards,

Eric

supply collect resized 5.1-edit1.vi

  • Like 1
Link to comment

Guys,

Your replies are encouraging to me. Eric I cannot look at your attached file as I only have LV 7.0 but you must have done it well, since your file is 25k and mine 100k. Daklu, the user should be able to press a button to have the fluid forced back into the supply tank once the collect tank is full.

In the real life situation, nitrogen forces the fluid through and "rate" climbs rapidly just before the tank is full. The user must be ready for a rapid rate change and pull the bleed/blow-off valve. Then he presses a button to have the fluid flow back to the original tank. I could probably manage to simulate blow-off valve action on this VI.

Edited by crichter
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.