def execute_zig_zag_cmd(self): mx = 'm'+str(self.zig_zag_frame['checkbox']['var_x'].get()) my = 'm'+str(self.zig_zag_frame['checkbox']['var_y'].get()) ax = int(self.zig_zag_frame['amp_x'].get()) ay = int(self.zig_zag_frame['amp_y'].get()) rx = int(self.zig_zag_frame['rep_x'].get()) ry = int(self.zig_zag_frame['rep_y'].get()) if mx == my : self.dialog_window('error', 'You can\'t control two motors in the same port') return else: motors = (stp.Motor(self.PINS[mx]), stp.Motor(self.PINS[my])) stp.zig_zag(*motors, (ax, rx), (ay, ry)) for motor in motors: motor.cleanup() del motor
''' #______________________________________________________________________ # imports import RPistepper as stp #______________________________________________________________________ # main test # Motor Pins: BCM M1_pins = [17, 27, 10, 9] M2_pins = [14, 15, 23, 24] with stp.Motor(M1_pins) as M1, stp.Motor(M2_pins) as M2: M1.VERBOSE = True M2.VERBOSE = True #__________________________________________________________________ # zig_zag stp.zig_zag(M1, M2, (5, 10), (5, 10)) #__________________________________________________________________ # square_spiral stp.square_spiral(M1, M2, (5, 10)) #__________________________________________________________________ # some movement for i in range(10): # repeat 10 times print(M1) # show M1 data M1.move(20) # move 20 steps print(M1) # show M1 data M1.steps = -20 # move to position -40 M1.zero() # recalibrates the reference position print(M1) # show M1 data M1.steps = 0 # move to position #__________________________________________________________________ # reset motors to original position
''' #______________________________________________________________________ # imports import RPistepper as stp #______________________________________________________________________ # main test # Motor Pins: BCM M1_pins = [17, 27, 10, 9] M2_pins = [14, 15, 23, 24] with stp.Motor(M1_pins) as M1, stp.Motor(M2_pins) as M2: M1.VERBOSE = True M2.VERBOSE = True #__________________________________________________________________ # zig_zag stp.zig_zag(M1, M2, (5, 10), (5, 10)) #__________________________________________________________________ # square_spiral stp.square_spiral(M1, M2, (5, 10)) #__________________________________________________________________ # some movement for i in range(10): # repeat 10 times print(M1) # show M1 data M1.move(20) # move 20 steps print(M1) # show M1 data M1.steps = -20 # move to position -40 M1.zero() # recalibrates the reference position print(M1) # show M1 data M1.steps = 0 # move to position #__________________________________________________________________ # reset motors to original position