planktoscope/Focus_actuation.py

31 lines
663 B
Python
Raw Normal View History

2019-12-10 21:06:56 +01:00
from adafruit_motor import stepper
from adafruit_motorkit import MotorKit
from time import sleep
2019-12-11 00:20:42 +01:00
2019-12-10 21:06:56 +01:00
kit = MotorKit()
stage = kit.stepper1
stage.release()
2019-12-11 00:20:42 +01:00
def focus(steps,orientation):
#0.25mm/step
#31um/microsteps
2019-12-10 21:06:56 +01:00
stage.release()
2019-12-11 00:20:42 +01:00
if orientation == 'up':
2019-12-10 21:06:56 +01:00
for i in range(steps):
stage.onestep(direction=stepper.FORWARD, style=stepper.MICROSTEP)
sleep(0.001)
2019-12-11 00:20:42 +01:00
if orientation == 'down':
2019-12-10 21:06:56 +01:00
for i in range(steps):
stage.onestep(direction=stepper.BACKWARD, style=stepper.MICROSTEP)
sleep(0.001)
stage.release()
2019-12-11 04:56:05 +01:00
focus(1000,'up')
focus(1000,'down')