LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

filling one tank from two separate tanks.

hi guys,

 

new around here. 

i have a project on labview

i have two tanks, and a third tank that will be filled with certain quantities from the two tanks. everything is working fine. 

 

in order to have some sort of animation, i made the first two tanks to decrease in quantity every 0.2 seconds.

 

the problem that i am facing is that im not able to apply the same for the third tank, which is to add the quantities to the third tank using the same animation . the quantities add correctly and everything works, but when i try to apply the same method for the third tank, it doesnt start filling until both for loops of the first two loops finish iterating. 

 

i want it to animate at the same time.

 

Regards.

 

file attached.

0 Kudos
Message 1 of 19
(4,375 Views)

The issue is basic dataflow. LabVIEW programs run under what is called a dtaflow paradigm. That means that any node can begin executing as soon as data is present at all its inputs and that its outputs will be available only after everything within the node completes execution.  A node is essentially any part of the program which has a border around it.

 

So the two Multiply functions can begin running as soon as the program starts because their inputs are constants and Numeric control terminals.  Either one could run first and they might not always run in the same order on different runs of the VI.

 

Similarly the two For loops can start running as soon as the calculations for their respective N terminals are complete. Their outputs are not available to the rest of the program until they have completed running. Since Tank 3 is wired to the output of the Add which is connected to the outputs of the For loops, the value of Tank 3 cannot change until both For loops have completed.

 

Since this sounds like an exercise to help you learn LV, I will not give you the fix. Hint: Since data flow keeps it from working the way you have wired it, try to use dataflow to get what you want.  This means that all the indicators need to be inside the same node.

 

Lynn

0 Kudos
Message 2 of 19
(4,361 Views)

it is a project ( an idea ) i came up with for the course , but it is graded..

 

anyways, i dont think i can put all indicators at the same node since each tank its separate quantity that needs to be deducted from, so each for loop has its separate N and a separate timing, even separate booleans which act as pumps...

 

can u give me some more hints? im new to labview but I want to learn..

best regards.

0 Kudos
Message 3 of 19
(4,353 Views)

Look at using a queue to send the values to a third loop.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 19
(4,333 Views)

It can easily be done in one loop with no property nodes, no queues, and no local variables.

 

Think shift registers and case structures.

 

The block diagram on my version is about 2/3 the size of your attempt. (Although I removed the icon view on the control terminals which saves some space). I could make it even smaller by converting some code which is very similar in two places to a subVI.

 

The attached VI is password protected so you cannot see the block diagram, but you can run it to see if it does what you are trying to do.

 

Lynn

0 Kudos
Message 5 of 19
(4,330 Views)

What about a separate vi for the animation using shared variables for tank levels and an event structures to recalculate the third tank level and adjust the animation?

0 Kudos
Message 6 of 19
(4,323 Views)

to jhon, that is exactly what i want it to do.. why is it password protected?

0 Kudos
Message 7 of 19
(4,317 Views)

It is password protected so that you will try to figure out how to do it yourself. You will learn much more that way thna if I just gave you a working VI. 

 

I have given you several clues about the types of structures you can use to implement this. Several other posters have also provided suggestions. I think many of those will work but they are more complicated to put together.

 

My suggestion is to write down on paper exactly what should happen at each time interval.

 

For example

Time 0. Set tanks 1 and 2 Full and tank 3 empty. Set booleans to Off. Read numeric controls and calculate the number of steps for each tank.

Time 200 ms. (Tank 1) Remove Increment 1 from Tank 1 and add it to Tank 3. Decrement number of steps remaining for Tank 1. Set Boolean 1 to ON. (Tank 2) Remove Increment 2 from Tank 2 and add it to Tank 3. Decrement number of steps remaining for Tank 2.  Set Boolean 2 to ON. (Note: in your code Increment 1 and 2 are unnamed constants with value = 5. They could be different.) The approach I described here is more general and allows the vlaues to be different or even to change while the program is running. 

...

...

Time x + 200 ms. If number of steps remaining for Tank 1 > 0, then repeat (Tank 1) procedure as described at Time 200 ms, else do not change Tank1 or Tank 3 and set Boolean 1 to OFF. Repeat for Tank 2.

If both booleans are OFF, stop the program.

 

That is really more than I should probably have done. If that description of your algorithm is what you want to do, then figure out how to implement it in LV.

 

Please post your attempts to do so and ask specific questions. We will help you learn how to use LV, but not do your assignments for you.

 

Lynn

0 Kudos
Message 8 of 19
(4,303 Views)

ok, but what kind of loops do i use? im already using shift registers for loops.

0 Kudos
Message 9 of 19
(4,261 Views)

You can probably make it work with either kind of loop, but the while loop is more flexible for something like this.

 

Lynn

0 Kudos
Message 10 of 19
(4,243 Views)