From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

filling one tank from two separate tanks.

im really stuck at that level. i dont know where to go from here. please guide me. thanks,

0 Kudos
Message 11 of 19
(1,027 Views)

Please post what you have tried based on my description of how the program could work. Be explicit about explaining what you are trying to do with various parts of the program.  Also identify as clearly as possible the areas where you are still having problems.

 

"im really stuck at that level." This is not specific and tells us nothing about what you do not understand.  Say something like "I tried to decrement the number of steps remaining, but it incremented." 

 

Lynn

0 Kudos
Message 12 of 19
(1,018 Views)

sorry i thought i attached the file.

 

ok so . ill try explain everything.

 

i have 4 tanks, each contain an ingredient. i want to add percentages of those ingredients into the glass (300 ml).

now i assumed that each 0.2 seconds, 5 ml is subtracted from tank1. the amount subtracted will be added to the glass. (the large tank)

 

so, for example, for the first loop. the user inputs a percentage. now this percentage is multiplied by 60

(since if 0.2 sec ---> 5 ml  

to fill 300 ml ----> ?? sec )

 

cross multiplication, and that amount is divided by 100. 

 

so repeating this process for the 4 tanks, the user can see how these amounts are being deducted from the tanks.

 

now everything is working as planned. the glass is filling as intended. ( i hope so) .

but there is a problem with the animation of the tanks and the glass. the animation is not synchronized, that is u can see how the tanks water level stop animating, but the water level of the glass keeps on adding.

 

now i believe the issue is with the logic of filling the glass. 

 

i hope my explanation is enough. 

i would like some hints on how to go on from there.

 

best regards johnsold.

0 Kudos
Message 13 of 19
(1,010 Views)

You need to put everything into a single loop.  That way everything is happening together.  Your tank should be adding by the total that was subtracted from the others.  This would also make it so you only need 1 timing source.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 14 of 19
(986 Views)

there cannot be 1 timing source because each tank will be decremented by an amount depending on a certain time.

 

maybe im approaching this project from a wrong way.

0 Kudos
Message 15 of 19
(984 Views)

In your VI the 5 loops run in parallel. Nothing wrong with that in general but here it does no do exactly what you want.

 

Let's make a little table. (You can do something similar on the VI by making the Digital Display visible on the tanks.)

 

Time    Removed       Removed         Removed                     Total in (desired)    (actual)

             from Tank1    from  Tank 2      from Tank n                     Tank 3

0                 0                        0                           0                                     0                              0

200 ms      5                        5                           5                                   15                              5

400 ms      5                        5                           5                                   30                             10

600 ms      0                        5                           5                                   40                             15

800 ms      0                        0                           5                                   45                             20

1000 ms    0                        0                          5                                    50                             25

1200 ms    0                        0                           0                                   50                             30

1400 ms    0                        0                           0                                   50                             35 .....

 

You can see that the bottom tank does not get the amount removed from each of the other tanks in any time interval. It does end up with the correct amount but not until much later.  This is because the tank being filled does not get information from the other loops about how much was removed from those tanks during each interval. Try running the VI with Highlight Execution (the light bulb on the block diagram toolbar) turned on. 

 

The prefered way to communicate between parallel loops is via queues.

 

However, as I pointed out earlier, this can be done with a single loop. By working with arrays and possibly subVIs it could be done in a single loop and the number of source tanks could be changed arbitrarily. You could also allow different flow rates from each tank.  By doing everything in one loop the amounts flowing out of the source tanks can be wired to and Add to represent the amount flowing into the destination tank on each iteration.

 

Because all the time intervals are the same, everything can be in one loop. I used a while loop and determined the exit condition by  waiting for all the booleans representing the flow to be false.  You could probably determine the number of iterations from the maximum of the N values fed to the source tank loops (in your VI) and use that as the N value for a single for loop. With either type of loop you will need to keep track of the number of dispense iterations for each tank (or the total amount dispensed) since not all tanks will dispense on every iterations. Use case structures and shift registers.

 

Lynn

0 Kudos
Message 16 of 19
(967 Views)

Here is a version using arrays. This allows different tank increments - the amount dispensed from each source tank on each iteration. The total  block diagram space is about 80% of the space that the code for one of your source tanks requires. The number of source tanks can be changed by expanding the arrays. The only change required in the code is to add values to the constant array holding the defaults. There are straightforward ways aroud that also.

 

This one is also password protected. 

 

When you show that you have mastered some of the concepts, I will remove the passords.

 

Lynn

0 Kudos
Message 17 of 19
(953 Views)

ok thanks , will try my best.

 

is it possible to make a subvi which takes percentage as input and outputs quantity needed to be taken from tank.

 

then make an array of the subvi's 

 

then i can use that array in one loop

 

is it possible? thx

0 Kudos
Message 18 of 19
(945 Views)

You really cannot make an array of subVis in the sense that you describe. Arrays are for data, not the processes that apply to the data.

 

You can make arrays of various kinds of data. For example the VI I posted has three arrays on the front panel. The Tank increments and Fill percentages arrays contain ouble precision floating point numeric values (DBL). The Tanks and Valves indicaotr is an array of clusters. Each cluster contains one source tank, the pipe (valve) boolean, and a string to hold the caption with the tank identification.

 

On the block diagram is an array constant with initial values for the Tansk and Valves display.  It connects to a shift register on a while loop. The Fill percentages array is multiplied and divided the same way you did for the Numeric controls. Most Math functions work on arrays just as they do for scalars. This is called polymorphism and is a very powerful part of LV. Inside the while loop is a for loop which autoinidexes the elements in the arrays. Inside the for loop the code is similar to what you have in each of your for loops except that the destination tank (Tank 3) is also added in the same case structure and the iteration count for each source tank is managed separately. There is some code to determine when all the pipe (valve) booleans have become false to stop the VI.

 

Lynn

0 Kudos
Message 19 of 19
(927 Views)