예제 #1
0
 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
예제 #2
0
    def motor_button_cmd(self, motor):
        '''
        Action for the move button
        '''
        if self.motor_on[motor]:
            self.motor_block[motor].grid_remove()
            if motor in self.motor_object:
                self.motor_object[motor].cleanup()
                del self.motor_object[motor]
        else:
            self.motor_block[motor].grid()
            self.motor_object[motor] = stp.Motor(self.PINS[motor])
            self.update_message(motor)

        self.motor_on[motor] = not self.motor_on[motor]
예제 #3
0
 def do_new(self, line):
     args = line.split()
     if not self._avaliable_ports() or not self._motor_arguments(
             args, listed=True):
         return False
     if not args:
         for i in range(len(self.PINS)):
             motor = 'm' + str(i)
             if motor not in self.motors:
                 self.do_new(motor)
                 return
     else:
         for motor in args:
             pins = self.PINS[motor]
             self.motors[motor] = stp.Motor(pins)
             print('New motor {0} at pins {1}'.format(motor, pins))
예제 #4
0
 def initializePower(self):
     with stp.Motor(self.M1_pins) as M1:
         M1.DELAY = 0.0015
         M1.move(2580)
     self.currentSetting = 100
예제 #5
0
 def stepDegrees(self, degrees):
     steps = int((degrees / 360) * 3096)
     with stp.Motor(self.M1_pins) as M1:
         M1.DELAY = 0.0015
         M1.move(steps)  #One rotation is 3096
예제 #6
0
M1_pins = [17, 27, 10, 9]
stepScale = 16000
turns = 50
camera = PiCamera()

# V1 Camera
# camera.resolution = (2592, 1944)
# camera.vflip = True
# camera.hflip = True

# V2 Camera
camera.resolution = (3280, 2464)

folder_time = str(int(time.time()))
os.mkdir(folder_time)
with stp.Motor(M1_pins) as M1:
    for i in range(turns):
        print(i)
        M1.move(int(stepScale / turns))
        M1.release()
        camera.start_preview()
        # Camera warm-up time
        time.sleep(2)
        photoName = '%s/%s.jpg' % (folder_time, str(int(time.time())) )
        camera.capture(photoName)

        # Opens a image in RGB mode 
        im = Image.open(photoName)   

        # Setting the points for cropped image 
        left = 295
예제 #7
0
'''
#______________________________________________________________________
# 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
예제 #8
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
RPistepper example
'''
#______________________________________________________________________
# 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