Calibrates the tanks. Sets the pump to max for caltime 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 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.
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)
caltime=40
print("Calibrating...\n")
filltime=40
emptytime=30
calpts=20
#Override pump control
...
...
@@ -175,7 +184,7 @@ function calibrate(p::DoubleTank)
send(c,10.0)#just a number > 10
foriin1:calpts
sleep(caltime/calpts)
sleep(filltime/calpts)
measurements[i]=measure(p.pump)
end
fulltanks=read.(p.measure)
...
...
@@ -187,7 +196,7 @@ function calibrate(p::DoubleTank)
send(c,0.0)
foriin1:calpts
sleep(caltime/calpts)
sleep(emptytime/calpts)
measurements[i]=measure(p.pump)
end
emptytanks=read.(p.measure)
...
...
@@ -205,6 +214,7 @@ function calibrate(p::DoubleTank)
#Return pump control
p.pump.control=c
print("Finished calibration\n")
nothing
end
...
...
@@ -214,8 +224,8 @@ end
function measure(p::DoubleTank)
#This should give an array of two values in the range [0,1]