Update and rename pump_volume.py to pump_volume_flowrate.py
This commit is contained in:
parent
19ce5a6f73
commit
580a3f0df2
|
@ -1,21 +0,0 @@
|
||||||
from adafruit_motor import stepper
|
|
||||||
from adafruit_motorkit import MotorKit
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
kit = MotorKit()
|
|
||||||
|
|
||||||
pump = kit.stepper2
|
|
||||||
|
|
||||||
pump.release()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def pump_volume(vol):
|
|
||||||
nb_step=vol*507 #35000steps for 69g with sleep(0.05) in between 2 steps
|
|
||||||
for i in range(nb_step):
|
|
||||||
pump.onestep(direction=stepper.FORWARD, style=stepper.DOUBLE)
|
|
||||||
sleep(0.05)
|
|
||||||
pump.release()
|
|
||||||
|
|
||||||
|
|
||||||
pump_volume(5)
|
|
43
pump_volume_flowrate.py
Normal file
43
pump_volume_flowrate.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
from adafruit_motor import stepper
|
||||||
|
from adafruit_motorkit import MotorKit
|
||||||
|
from time import sleep
|
||||||
|
from datetime import datetime
|
||||||
|
import time
|
||||||
|
|
||||||
|
kit = MotorKit()
|
||||||
|
|
||||||
|
pump = kit.stepper2
|
||||||
|
|
||||||
|
pump.release()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def pump_volume(vol, flowrate):
|
||||||
|
nb_step=vol*507 #if sleep(0.05) in between 2 steps
|
||||||
|
#35000steps for 69g
|
||||||
|
#nb_step=vol*460 if sleep(0) in between 2 steps
|
||||||
|
duration=(vol*60)/flowrate
|
||||||
|
delay=(duration/nb_step)-0.005
|
||||||
|
#flowrate is about 2.2ml/min
|
||||||
|
for i in range(nb_step):
|
||||||
|
pump.onestep(direction=stepper.FORWARD, style=stepper.DOUBLE)
|
||||||
|
sleep(delay)
|
||||||
|
print(delay)
|
||||||
|
sleep(1)
|
||||||
|
pump.release()
|
||||||
|
|
||||||
|
volume=1
|
||||||
|
|
||||||
|
flowrate=1 #20 is the max
|
||||||
|
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
|
pump_volume(volume, flowrate)
|
||||||
|
|
||||||
|
end = time.time()
|
||||||
|
|
||||||
|
duration = end-start
|
||||||
|
|
||||||
|
print(duration)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue