Update pump.py
This commit is contained in:
parent
0652cb95ca
commit
c9fc2cb07c
|
@ -9,9 +9,9 @@ from time import sleep
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
vol = int(sys.argv[1])
|
volume = int(sys.argv[1])
|
||||||
flowrate = float(sys.argv[2])
|
flowrate = float(sys.argv[2])
|
||||||
dir = str(sys.argv[3])
|
action = str(sys.argv[3])
|
||||||
|
|
||||||
kit = MotorKit()
|
kit = MotorKit()
|
||||||
|
|
||||||
|
@ -19,27 +19,28 @@ pump_stepper = kit.stepper2
|
||||||
|
|
||||||
pump_stepper.release()
|
pump_stepper.release()
|
||||||
|
|
||||||
def pump(vol, flowrate, dir):
|
def pump(volume, flowrate, action):
|
||||||
|
|
||||||
if dir == "foward":
|
if action == "foward":
|
||||||
dir=stepper.FORWARD
|
action=stepper.FORWARD
|
||||||
if dir == "backward":
|
if action == "backward":
|
||||||
dir=stepper.BACKWARD
|
action=stepper.BACKWARD
|
||||||
|
|
||||||
nb_step=vol*507 #if sleep(0.05) in between 2 steps
|
nb_step=volume*507 #if sleep(0.05) in between 2 steps
|
||||||
#35000steps for 69g
|
#35000steps for 69g
|
||||||
|
|
||||||
#nb_step=vol*460 if sleep(0) in between 2 steps
|
#nb_step=vol*460 if sleep(0) in between 2 steps
|
||||||
duration=(vol*60)/flowrate
|
duration=(volume*60)/flowrate
|
||||||
|
|
||||||
delay=(duration/nb_step)-0.005
|
delay=(duration/nb_step)-0.005
|
||||||
|
|
||||||
for i in range(nb_step):
|
for i in range(nb_step):
|
||||||
pump_stepper.onestep(direction=dir, style=stepper.DOUBLE)
|
pump_stepper.onestep(direction=action, style=stepper.DOUBLE)
|
||||||
sleep(delay)
|
sleep(delay)
|
||||||
|
|
||||||
sleep(1)
|
sleep(1)
|
||||||
pump_stepper.release()
|
pump_stepper.release()
|
||||||
|
|
||||||
#volume, flowrate (from 0 to 20), direction (foward or backward)
|
#volume, flowrate (from 0 to 20), direction (foward or backward)
|
||||||
pump(vol, flowrate, dir)
|
pump(volume, flowrate, action)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue