Problem Description

To Simulate The Water System a System Simulator is created. The Simulator simulates all the valves, pumps and their respective levels in the tanks. The main thing to consider is that the calculated water levels in the water tanks are based on Torricelli's Law and the Volumetric Flow Rate Equation, (White, 2011). Simplified these two equation were utilized:

v = sqrt(2gh)

Q = v * A

Where g is the gravity constant, h is the height of the water above exit hole, A is the area of the water tube. Additionally the flow rate of the pump is utilized for emptying the main tanks, and to fill the growth tanks. The flow rate of the pump is calculated by taking a maximum flow rate and devide it by the maximum voltage and multiplying with the desired running voltage. For this system the pump will be controlled by a boolean, which means that the maximum voltage will be one in the simulator.

When the fill valves for both growth tanks are opened the flow rate into each is half of the total flowrate from the pump. When drain valves are opened, the simplifaction makes it so that the drainage of the growth tanks are based on the exit flow rate Q. When the maximum height of the tanks are reached, the level sensor is going to trigger a true Boolean.

Since the simulator is supposed to simulate the system the inputs on the simulator is going to be the samme as the real system. Additionally there has been added the posibility of adding addatives and fertilzers to the main tank, to simulate the addition of those. Reduce the amount of inputs, all valves are added togheter as an array before being sendt to the simulator.  To stop, start or reset the simulator three boolean inputs are needed.

To make the simulator run consistently, delta time is utilized. 


This gives the following inputs, 

INPUTS:

  • startSimulator → BOOL
  • stopSimulator → BOOL
  • resteSimulator → BOOL
  • valveSignalss → ARRAY [0..8] OF BOOL
  • pumpSignal → REAL


OUTPUTS:

  • valvePos → ARRAY [0..8] OF BOOL
  • mainTankLevel → REAL
  • growthTankLevels → ARRAY [0..1] OF REAL
  • growthTankLevelSensor → ARRAY [0..1] OF BOOL
  • addativesLevels → ARRAY [0..3] OF REAL
  • pumpAnimator → INT



Coded Solution

Variable Decleration:


Code:

With the final function block looking like this:




References:

White, F.M., 2011. Fluid Mechanics. 7th ed. New York: McGraw-Hill Education. Available at: http://ftp.demec.ufpr.br/disciplinas/TM240/Marchi/Bibliografia/White_2011_7ed_Fluid-Mechanics.pdf [Accessed 27 May 2024].

  • No labels