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
STEPS_PER_INCH = 2032
STEPS_PER_MM = 80
TIMESLICE_MS = 10
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_SPEED = 150
PEN_UP_DELAY = 0
PEN_DOWN_POSITION = 40
PEN_DOWN_SPEED = 150
PEN_DOWN_DELAY = 0
ACCELERATION = 12
MAX_VELOCITY = 6
CORNER_FACTOR = 0.01
ACCELERATION = 8
MAX_VELOCITY = 8
CORNER_FACTOR = 0.005
VID_PID = '04D8:FD92'
@ -88,7 +94,8 @@ class Device(object):
# motor functions
def enable_motors(self):
return self.command('EM', 1, 1)
m = MICROSTEPPING_MODE
return self.command('EM', m, m)
def disable_motors(self):
return self.command('EM', 0, 0)
@ -104,7 +111,7 @@ class Device(object):
time.sleep(0.01)
def run_plan(self, plan):
step_ms = 10
step_ms = TIMESLICE_MS
step_s = step_ms / 1000
t = 0
while t < plan.t:

View File

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