05-13-2010 06:55 PM
Hello Labview Forumites,
I know there have been a few very similar questions asked here recently as to the one I am about to ask now, so apologies in advance for any inconvenience caused. I am also aware that some of you have attached working examples along with your answers but unfortunately I could not open them as I am using Labview 8.5 Student edition and I could not open the newer edition examples. I have attached a VI from a project I am working on and what I want to learn is how to get the correct sequence of operation for this VI. Basically I would hope to get pipes 1,2,3,4,and 5 along with valves 1 and 2 and pump1 to energise and start filling my mixer tank. Then when this tank has filled I would like for pipes 6 and 7 along with pump 2 and valve 3 to open, the mixer tank to start emptying and the product tank to start filling. Again when the product tank has filled pipes 8 and 9 along with valve 4 open. Also if it would be possible to shut off the preceding pipes, valves and pumps as the mixer tank empties. Again apologies for the very long winded post and the subject matter that has no doubt been covered endless times before. I am new to Labview and have no programming experience whatsoever so feel way out of my depth here. All replies will be very much appreciated.
Regards,
Dave.
Solved! Go to Solution.
05-13-2010 07:43 PM
You are so close. Your efforts are much better than others that have posted here, asking for help without even having tried to write any code at all. I don't have LV 8.5 so I can't make corrections and send it to you. Because you made a good effort, if I had 8.5, I would make the corrections for you. But since I just have 2009, I will try to explain what to do.
First, you should create a while loop at the beginning of your code. Put the Start Process control inside the while loop. Wire the control to the stop sign. Also wire the control to the flat sequence structure, through the wall of the while loop. Add a delay inside the while loop with an input of 100. Here is what will happen. The loop will run every 100mS. As long as the Start Process is not pressed, the loop will run again. When the button is pressed, the loop will stop and the button data will go to the flat sequence. The flat sequence will not start until it sees the button data input. To see this, turn on the light bulb and watch the execution flow. The 100mS delay is a good idea so that the CPU time is not being used 100% by Labview.
Since the Start Process data will be true when the flat sequence starts executing, the pipes and valves specified in the first frame will all turn on. In your original VI, if you ran the program without first pressing the button, the valves and pipes were all off. Now the first frame will execute, and the loop will continue until the mixer is full. If you want to shut off some pipes and valves at this point, right click on the ones you want to shut off and select Create - Local Variable (you must do this one at a time). Put the local variables in frame 2. Wire a False constant to each one. Put this before the loop in frame 2. This will turn off the items and then the loop will continue until the product tank is full. If you want the mixer to empty as the product fills, create a local variable for the mixer and put it in frame 2 while loop. Subtract 100 - i and wire the output to the mixer local. This will cause the mixer to empty as the product fills.
At the beginning of your code, you should return all pipes, tanks, and valves to the default (off or empty) state. Look in the Application Control palette and select Invoke Node. Put it on your block diagram before the new while loop you created for the Start Process button. Wire the error out to the while loop border so that it can execute first. Point to the word App in the top half of the Invode Node, right click and select Select Class - VI Server - VI - VI. The word App will change to VI. Then point to the word Method in the bottom half. Left click and select Default values - Reinitialize all to default. Now when you start your program, all controls and indicators will go to the default state.
If you need further help, just ask.
05-14-2010 03:24 AM
Thank you very much tbob,
I have just implemented your recommendations and it is working now as I had intended and as you said it would. I really do appreciate your help, it was badly needed. Thanks again.
Regards,
Dave.
05-14-2010 09:45 AM
Hello again folks,
As you can see I have attached the updated Vi complete with the advice given to me by tbob, which was a great help. Im just wondering if it would be possible for me to alter the Vi in such a way as to be able to see the two tank volumes decrease gradually as opposed to instantly as they are now. Again all help will be very much appreciated.
Regards,
Dave.
05-14-2010 09:52 AM - edited 05-14-2010 09:53 AM
05-14-2010 11:01 AM
Hi folks,
I changed the code around in the second sequence as instructed and thought i had done it correctly in the third sequence but alas not so. Im 90% there and now my Product tank will not empty. I think im overlooking something relatively simple but I can't be sure. Again I have attached the Vi so if anyone could point me in the right direction that would be great.
Thanks for your patience,
Regards,
Dave.
05-14-2010 11:08 AM
Here are a couple more items to refine your VI:
You could start your vi by having the Prompt for User Input's OK output connected to the first frame boolean input, instead of the Start Process button (change the message to something appropriate). When the user clicks OK in the message box, the process starts. No need for a Start Process button. Move the Reinit All to Default to the end of the program. Create a new frame at the end and put the Reinit there.
You 2nd tank is not emptying. You had a blue wire from the second frame to the third frame subtract fucntion. Delete this, it is wrong. In the third frame, wire the bottom subtract input to the i of the while loop, and the top subtract input to 100. This will produce the proper emptying levels.
In the third frame, you had the boolean input wired to the stop sign in that while loop. The loop will stop immediately and the tank won't get emptied. Two ways to solve this. Add a LessThan or Equal to 0 to the tank level, and wire the output to the stop sign, similar to your fist frame. Or change the while loop to a for loop and wire 100 to N, similar to the 2nd frame (stick with one method for all frames, either the for loop or the while loop). Either method will force the loop to execute 100 times to show the tank being emptied. With the Reinit All function in the new last frame, all valves and pipes will go off and you won't have to wire a False to Pipe 8 and 9 and Valve 4.
You have made a very good effort for a beginner. Pat yourself on the back.
05-14-2010 11:56 AM
Hello again,
Thank you very much again tbob and Tim, for the feedback, some good stuff there to help smarten up my Vi. I really do hope this will be the last time I have to seek more guidance on this particular issue, however, now that the last tank is emptying albeit instantly can I slow it down to the same speed as the first tank. I think you guys may have answered this already but if you could go through it again i'd be chuffed and may finally be able finish this particular chapter and move on to another Vi to test myself. I have also attached the Vi again with the new improvements.
Regards,
Dave
05-14-2010 11:58 AM - edited 05-14-2010 12:01 PM
You need to put a 100mS delay in your last while loop. This will make it empty slowly.
What the delay does is this: The loop runs one time, then there is a 100mS delay before the next loop iteration. The loop runs a 2nd time, with another 100mS delay. To the eye, this makes it seem like the tank is emptying slowly. Try changing the delay time, try 50, try 500. You will notice the time to empty changes.
05-14-2010 12:24 PM
Fantastic.
Its great to get that Vi completed somewhat successfully, Kudos where its due. Cant believe I overlooked the Next ms Multiple. Well I guess everyday's a school day.
Many Thanks
Dave.