LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Complicated function: I need functions to switch or become opposite if 3 criteria is true.

Solved!
Go to solution

Hi, I am building a program to control an experimental setup testing the response of fish to sediment loaded water (called the shuttle box method).

 

I have two connected tanks (C and D) a fish can swim between. If the fish is in Tank D the sediment will increase in both tanks but with a set differential and if the fish is in tank C the sediment will decrease. Tank D always have more sediment than Tank C. For this I am controlling 4 pumps that pump in clean or dirty water to each tank separately. However, I need a function implemented where if the fish is in Tank C, the sediment level reaches less than 1 and it has been there for a set amount of time, the functions need to flip around. Essentially Tank C needs to become Tank D and Tank D becomes Tank C in terms of which have the highest sediment load. Then again if the fish is in goes to Tank D the sediment level reaches less than 1 and it has been there for a set amount of time, the functions need to flip back again and so on.

 

I have tried many things but not gotten very far. I have attached a very simple version of my code where I have successfully been able to switch between Tank C and D, but it flips back as soon as the fish goes from Tank C to Tank D.

 

I hope my explanation is clear enough otherwise please just ask.

NOTE for the VI: set "simulated Tank C turbidity" to 0 and "Simulated Tank D turbidity" to 2 and press the "Simulated fish going to tank C" Boolean switch, to see the switch in pumps.

 

Thank you for your help.

0 Kudos
Message 1 of 4
(1,743 Views)

Are you familiar with using State Machine?

 

1 state can be "normal", the other can be "inverted"

 

You could create a set of subvis that have defined functions

You could run the same set of subvi in both of your cases, with the output of the case determining what the pumps should do.

 

In the normal state you would have a monitor that is waiting for the trigger to switch states to "inverted" in the inverted case you would monitor the opposite pump, and the wire outputs would change to the opposite pump as well.  

 

This case structure would likely have everything inside the while loop in it except the outputs. 

 

----------------------------------------------------
Studying for CLA.
LabVIEW, inherit from social media habits!
Message 2 of 4
(1,721 Views)
Solution
Accepted by topic author Math808

I got you started with something that might be less overwhelming than what you had.  I added one subvi using your pre-existing function as an example. You will have to convert the rest over  (I reccomend using subvi for your functions so that they can be used repeatedly, and to make it more easy to read)  Let us know if you are able to complete the project

CDuck_0-1599873337466.png

 

----------------------------------------------------
Studying for CLA.
LabVIEW, inherit from social media habits!
Message 3 of 4
(1,711 Views)

Thank you so much, that seems to work.

 

Appreciate the help.

0 Kudos
Message 4 of 4
(1,701 Views)