This commit is contained in:
Michael Fogleman 2017-01-15 19:24:55 -05:00
parent 5dc7a11a2b
commit 44d5a3fcdf
2 changed files with 22 additions and 21 deletions

View File

@ -8,19 +8,25 @@ from serial.tools.list_ports import comports
from .planner import Planner from .planner import Planner
STEPS_PER_INCH = 2032 TIMESLICE_MS = 10
STEPS_PER_MM = 80
MICROSTEPPING_MODE = 1
STEP_DIVIDER = 2 ** (MICROSTEPPING_MODE - 1)
STEPS_PER_INCH = 2032 / STEP_DIVIDER
STEPS_PER_MM = 80 / STEP_DIVIDER
PEN_UP_POSITION = 60 PEN_UP_POSITION = 60
PEN_UP_SPEED = 150 PEN_UP_SPEED = 150
PEN_UP_DELAY = 0 PEN_UP_DELAY = 0
PEN_DOWN_POSITION = 40 PEN_DOWN_POSITION = 40
PEN_DOWN_SPEED = 150 PEN_DOWN_SPEED = 150
PEN_DOWN_DELAY = 0 PEN_DOWN_DELAY = 0
ACCELERATION = 12 ACCELERATION = 8
MAX_VELOCITY = 6 MAX_VELOCITY = 8
CORNER_FACTOR = 0.01 CORNER_FACTOR = 0.005
VID_PID = '04D8:FD92' VID_PID = '04D8:FD92'
@ -88,7 +94,8 @@ class Device(object):
# motor functions # motor functions
def enable_motors(self): def enable_motors(self):
return self.command('EM', 1, 1) m = MICROSTEPPING_MODE
return self.command('EM', m, m)
def disable_motors(self): def disable_motors(self):
return self.command('EM', 0, 0) return self.command('EM', 0, 0)
@ -104,7 +111,7 @@ class Device(object):
time.sleep(0.01) time.sleep(0.01)
def run_plan(self, plan): def run_plan(self, plan):
step_ms = 10 step_ms = TIMESLICE_MS
step_s = step_ms / 1000 step_s = step_ms / 1000
t = 0 t = 0
while t < plan.t: while t < plan.t:

View File

@ -1,7 +1,8 @@
from axi import Device, Planner import axi
from math import sin, cos, pi
import time import time
from math import sin, cos, pi
def circle(cx, cy, r, n): def circle(cx, cy, r, n):
points = [] points = []
for i in range(n + 1): for i in range(n + 1):
@ -12,21 +13,14 @@ def circle(cx, cy, r, n):
return points return points
def main(): def main():
planner = Planner(acceleration=10, max_velocity=5, corner_factor=0.001) # axi.reset(); return
path = [] path = []
path.append((0, 0))
for i in range(10): for i in range(10):
path.extend(circle(4, 4, (i + 1) * 0.2, 72)) path.extend(circle(4, 4, (i + 1) * 0.2, 3600))
path.append((0, 0))
plan = planner.plan(path)
d = Device() drawing = axi.Drawing([path]).simplify_paths(0.001)
d.pen_up() # drawing.render().write_to_png('out.png')
d.enable_motors() axi.draw(drawing)
time.sleep(0.2)
d.run_plan(plan)
d.wait()
d.disable_motors()
if __name__ == '__main__': if __name__ == '__main__':
main() main()