def execute_s_spiral_cmd(self): mx = 'm'+str(self.s_spiral_frame['checkbox']['var_x'].get()) my = 'm'+str(self.s_spiral_frame['checkbox']['var_y'].get()) ax = int(self.s_spiral_frame['amp_x'].get()) rx = int(self.s_spiral_frame['rep_x'].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.square_spiral(*motors, (ax, rx)) for motor in motors: motor.cleanup() del motor
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 M1.reset() M2.reset()