Calibrates the tanks. Sets the pump to max for filltime seconds, during which the flow is measured calpts times. The tank voltage is then measured, when they are presumably full. The pump is then set to min for emptytime and the flow is again measured calpts time. The tank voltage is then again measured, when they're presumably empty. These values are then used to set the parameters for the DoubleTank measure function and the DoubleTank.pump controller.
"""
function calibrate(p::DoubleTank)
print("Calibrating...\n")
print("Calibrating...\n")
filltime=40
emptytime=30
emptytime=30
calpts=20
#Override pump control
...
...
@@ -190,8 +190,8 @@ function calibrate(p::DoubleTank)
fulltanks=read.(p.measure)
venturimax=mean(measurements)
print("Upper Full Voltage: $(fulltanks[1])\n")
print("Lower Full Voltage: $(fulltanks[2])\n")
print("Upper Full Voltage: $(fulltanks[1])\n")
print("Lower Full Voltage: $(fulltanks[2])\n")
print("Venturi Avg max: $venturimax\n")
send(c,0.0)
...
...
@@ -201,9 +201,9 @@ function calibrate(p::DoubleTank)
end
emptytanks=read.(p.measure)
venturimin=mean(measurements)
print("Upper Empty Voltage: $(emptytanks[1])\n")
print("Lower Empty Voltage: $(emptytanks[2])\n")
print("Upper Empty Voltage: $(emptytanks[1])\n")
print("Lower Empty Voltage: $(emptytanks[2])\n")
print("Venturi Avg min: $venturimin\n")
p.uprange[1]=emptytanks[1]
...
...
@@ -214,8 +214,8 @@ function calibrate(p::DoubleTank)
#Return pump control
p.pump.control=c
print("Finished calibration\n")
nothing
print("Finished calibration\n")
nothing
end
function calibrate(p::DoubleTankSimulator)
...
...
@@ -223,13 +223,13 @@ function calibrate(p::DoubleTankSimulator)
end
function measure(p::DoubleTank)
#This should give an array of two values in the range [0,1]
minv=[p.uprange[1],p.lowrange[1]]
maxv=[p.uprange[2],p.lowrange[2]]
#This should give an array of two values in the range [0,1]