예제 #1
0
class StepperCommand(Command):
    def __init__(self, command_id):
        super().__init__(command_id, 'i16')

        self.delimiter_pin = pyb.Pin("Y2", pyb.Pin.IN, pyb.Pin.PULL_UP)

        self.stepper = Stepper(200, "Y3", "Y4", "Y5", "Y6")
        self.stepper.set_speed(25)

        self.calibrate()

    def callback(self, steps):
        self.stepper.step(steps)

    def calibrate(self):
        # print("calibrating stepper")
        # print(self.delimiter_pin.value())
        # while self.delimiter_pin.value():
        #     self.stepper.step(20)
        #     print(self.delimiter_pin.value())
        #
        # self.stepper.step(100)  # center steering
        # print("calibrated!")
        print("Skipping calibration")

    def reset(self):
        # recalibrate with delimiter
        self.calibrate()
예제 #2
0
    def __init__(self, command_id):
        super().__init__(command_id, 'i16')

        self.delimiter_pin = pyb.Pin("Y2", pyb.Pin.IN, pyb.Pin.PULL_UP)

        self.stepper = Stepper(200, "Y3", "Y4", "Y5", "Y6")
        self.stepper.set_speed(25)

        self.calibrate()
예제 #3
0
class StepperCommand(Command):
    def __init__(self, command_id):
        super().__init__(command_id, 'i16')

        self.delimiter_pin = pyb.Pin("Y1", pyb.Pin.IN, pyb.Pin.PULL_UP)

        self.stepper = Stepper(200, 25, "Y3", "Y4", "Y5", "Y6")

    def callback(self, steps):
        self.stepper.step(steps)

    def calibrate(self):
        print("Calibrating stepper... ", end="")
        while not self.delimiter_pin.value():
            self.stepper.step(-5)

        pyb.delay(10)  # if this isn't here the stepper won't switch directions

        self.stepper.step(150)  # center the steering
        print("done!")

    def reset(self):
        # recalibrate with delimiter
        self.calibrate()
예제 #4
0
    def __init__(self, command_id):
        super().__init__(command_id, 'i16')

        self.delimiter_pin = pyb.Pin("Y1", pyb.Pin.IN, pyb.Pin.PULL_UP)

        self.stepper = Stepper(200, 25, "Y3", "Y4", "Y5", "Y6")
예제 #5
0
import pyb
from libraries.stepper import Stepper

stepper = Stepper(200, "Y3", "Y4", "Y5", "Y6")
stepper.set_speed(25)

while True:
    steps = int(input("steps: "))
    stepper.step(steps)
    pyb.delay(500)
예제 #6
0
import pyb
from libraries.stepper import Stepper

stepper = Stepper(200, 25, "Y3", "Y4", "Y5", "Y6")

while True:
    steps = int(input("steps: "))
    stepper.step(steps)
    pyb.delay(500)