Пример #1
0
    def __init__(self, in1, in2, in3, in4):

        self.step_count = 1
        self.last_time = 0
        self.in_progress = False
        self.startup_check = True
        pinon = 1
        pinoff = 0

        self.phase1pinblue = stepper(in1)
        self.phase2pinpink = stepper(in2)
        self.phase3pinyellow = stepper(in3)
        self.phase4pinorange = stepper(in4)

        self.halfstep1 = [(self.phase1pinblue, pinon), (self.phase2pinpink, pinoff), (self.phase3pinyellow, pinoff), (self.phase4pinorange, pinoff)]
        self.halfstep2 = [(self.phase1pinblue, pinon), (self.phase2pinpink, pinon), (self.phase3pinyellow, pinoff), (self.phase4pinorange, pinoff)]
        self.halfstep3 = [(self.phase1pinblue, pinoff), (self.phase2pinpink, pinon), (self.phase3pinyellow, pinoff), (self.phase4pinorange, pinoff)]
        self.halfstep4 = [(self.phase1pinblue, pinoff), (self.phase2pinpink, pinon), (self.phase3pinyellow, pinon), (self.phase4pinorange, pinoff)]
        self.halfstep5 = [(self.phase1pinblue, pinoff), (self.phase2pinpink, pinoff), (self.phase3pinyellow, pinon), (self.phase4pinorange, pinoff)]
        self.halfstep6 = [(self.phase1pinblue, pinoff), (self.phase2pinpink, pinoff), (self.phase3pinyellow, pinon), (self.phase4pinorange, pinon)]
        self.halfstep7 = [(self.phase1pinblue, pinoff), (self.phase2pinpink, pinoff), (self.phase3pinyellow, pinoff), (self.phase4pinorange, pinon)]
        self.halfstep8 = [(self.phase1pinblue, pinon), (self.phase2pinpink, pinoff), (self.phase3pinyellow, pinoff), (self.phase4pinorange, pinon)]

        self.fullstep1 = [(self.phase1pinblue, pinon), (self.phase2pinpink, pinon), (self.phase3pinyellow, pinoff), (self.phase4pinorange, pinoff)]
        self.fullstep2 = [(self.phase1pinblue, pinoff), (self.phase2pinpink, pinon), (self.phase3pinyellow, pinon), (self.phase4pinorange, pinoff)]
        self.fullstep3 = [(self.phase1pinblue, pinoff), (self.phase2pinpink, pinoff), (self.phase3pinyellow, pinon), (self.phase4pinorange, pinon)]
        self.fullstep4 = [(self.phase1pinblue, pinon), (self.phase2pinpink, pinoff), (self.phase3pinyellow, pinoff), (self.phase4pinorange, pinon)]
        self.fullstep5 = [(self.phase1pinblue, pinon), (self.phase2pinpink, pinon), (self.phase3pinyellow, pinoff), (self.phase4pinorange, pinoff)]
        self.fullstep6 = [(self.phase1pinblue, pinoff), (self.phase2pinpink, pinon), (self.phase3pinyellow, pinon), (self.phase4pinorange, pinoff)]
        self.fullstep7 = [(self.phase1pinblue, pinoff), (self.phase2pinpink, pinoff), (self.phase3pinyellow, pinon), (self.phase4pinorange, pinon)]
        self.fullstep8 = [(self.phase1pinblue, pinon), (self.phase2pinpink, pinoff), (self.phase3pinyellow, pinoff), (self.phase4pinorange, pinon)]
Пример #2
0
 def __init__(self, IN1, IN2, IN3, IN4):
     self.IN1 = stepper(IN1)
     self.IN2 = stepper(IN2)
     self.IN3 = stepper(IN3)
     self.IN4 = stepper(IN4)
     #Setting GPIO
     self.stepPins = [self.IN1, self.IN2, self.IN3, self.IN4]
     self.sequenceNumber = 0
     self.stepCount = 8
Пример #3
0
    def __init__(self, pins):
        """Initialise the motor object.

        pins -- a list of 4 integers referring to the GPIO pins that the IN1, IN2
                IN3 and IN4 pins of the ULN2003 board are wired to
        mode -- the stepping mode to use:
                1: wave drive (not yet implemented)
                2: full step drive
                3: half step drive (default)

        """
        self.IN1 = stepper(pins[0])    # pin11  
        self.IN2 = stepper(pins[1])  
        self.IN3 = stepper(pins[2])  
        self.IN4 = stepper(pins[3])
Пример #4
0
    def __init__(self, pin_array):
        # moves by angle in degrees
        # angle: degrees +/- [default: +45]
        # speed: milliseconds [default: 1000ms]
        # speed_func: string - ex: 'linear', 'cosine', etc... [default: 'linear']
        self.pin_array = [stepper(pin) for pin in pin_array]

        # minimum functional time between steps:
        self.min_wait = 0.00075
        # 4096 steps is 360 degrees
        self.steps_360 = 4096
        # sequence array
        self.seq = [[1, 0, 0, 1], [1, 0, 0, 0], [1, 1, 0, 0], [0, 1, 0, 0],
                    [0, 1, 1, 0], [0, 0, 1, 0], [0, 0, 1, 1], [0, 0, 0, 1]]
Пример #5
0
    def __init__(self, mode=1, pins=[12,16,20,21]):
        self.mode = mode
        self.pins=pins
        self.IN1 = stepper(pins[0])
        self.IN2 = stepper(pins[1])
        self.IN3 = stepper(pins[2])
        self.IN4 = stepper(pins[3])   
        self.stepPins = [self.IN1,self.IN2,self.IN3,self.IN4]
        if self.mode:              # Low Speed ==> High Power
            self.seq = [[1,0,0,1], # Define step sequence as shown in manufacturers datasheet
		             [1,0,0,0], 
		             [1,1,0,0],
		             [0,1,0,0],
		             [0,1,1,0],
		             [0,0,1,0],
		             [0,0,1,1],
		             [0,0,0,1]]
        else:                      # High Speed ==> Low Power 
            self.seq = [[1,0,0,0], # Define step sequence as shown in manufacturers datasheet
		             [0,1,0,0],
		             [0,0,1,0],
		             [0,0,0,1]]

        self.stepCount = len(self.seq)
Пример #6
0
from gpiozero import OutputDevice as stepper
import time

#horizontal motor
step1_1 = stepper(12)
step1_2 = stepper(16)
step1_3 = stepper(20)
step1_4 = stepper(21)
step1 = (step1_1, step1_2, step1_3, step1_4)

stepping = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [1, 0, 0, 1]]

busy = False


def rotate(num):
    #rotates motor; positive for counterclockwise
    busy = True
    loopCtrl = 200
    stepCounter = 0
    stepPins = step1

    while loopCtrl > 0:
        for pin in range(0, 4):
            thisPin = stepPins[pin]
            if stepping[stepCounter][pin] != 0:
                thisPin.on()
            else:
                thisPin.off()
        stepCounter += num
        if (stepCounter >= len(stepping)):
Пример #7
0
import time
import sys
from gpiozero import OutputDevice as stepper
IN1 = stepper(12)
IN2 = stepper(16)
IN3 = stepper(20)
IN4 = stepper(21)
stepPins = [IN1, IN2, IN3, IN4]  # Motor GPIO pins</p><p>
stepDir = -1  # Set to 1 for clockwise
# Set to -1 for anti-clockwise
mode = 0  # mode = 1: Low Speed ==> Higher Power
# mode = 0: High Speed ==> Lower Power
if mode:  # Low Speed ==> High Power
    seq = [
        [1, 0, 0,
         1],  # Define step sequence as shown in manufacturers datasheet
        [1, 0, 0, 0],
        [1, 1, 0, 0],
        [0, 1, 0, 0],
        [0, 1, 1, 0],
        [0, 0, 1, 0],
        [0, 0, 1, 1],
        [0, 0, 0, 1]
    ]
else:  # High Speed ==> Low Power
    seq = [
        [1, 0, 0,
         0],  # Define step sequence as shown in manufacturers datasheet
        [0, 1, 0, 0],
        [0, 0, 1, 0],
        [0, 0, 0, 1]
pi = pigpio.pi('PI IP ADDRESS', 8888)
if not pi.connected:
    print('Could not connect to Pi.')
factory = PiGPIOFactory('PI IP ADDRESS')

FRAME_THICKNESS = 3

encodings = []
locations = []

#set () to 1 so it would use external webcam
video_capture = cv2.VideoCapture(1)

#horizontal motor
step1_1 = stepper(12, pin_factory=factory)
step1_2 = stepper(16, pin_factory=factory)
step1_3 = stepper(20, pin_factory=factory)
step1_4 = stepper(21, pin_factory=factory)
step1 = (step1_1, step1_2, step1_3, step1_4)

stepping = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [1, 0, 0, 1]]


def rotate(num):
    #rotates motor; positive for counterclockwise
    loopCtrl = 20
    stepCounter = 0
    stepPins = step1

    while loopCtrl > 0:
Пример #9
0
#data from database
cellnum = ''
em = ''
trapid = '8165010001'
# end data from database

#
trapdata = {}

detector = Button(23)

flashone = LED(26)
flashtwo = LED(19)

p1 = stepper(12)  # orange
p2 = stepper(16)  # purple
p3 = stepper(20)  # red
p4 = stepper(21)  # brown  

cam = PiCamera()



def ftpupload():
    server = 'ftp.zachariahferguson.com'
    username = '******'
    password = '******'
    ftp_connection = ftplib.FTP(server, username, password)
    fh = open(trapid + '.jpg', 'rb')
    ftp_connection.storbinary('STOR ' + trapid + '.jpg', fh)
Пример #10
0
 def __init__(self):
     self.motor = [stepper(23), stepper(25), stepper(22), stepper(24)]
Пример #11
0
import time
from gpiozero import OutputDevice as stepper

IN1 = stepper(23)
IN2 = stepper(24)
IN3 = stepper(7)
IN4 = stepper(11)
StepPins = [IN1, IN2, IN3, IN4]

# Define sequence as shown in manufacturers data sheet
Seq = [
    [1, 0, 0, 1],
    [1, 0, 0, 0],
    [1, 1, 0, 0],
    [0, 1, 0, 0],
    [0, 1, 1, 0],
    [0, 0, 1, 0],
    [0, 0, 1, 1],
    [0, 0, 0, 1],
]

StepCount = len(Seq)
StepDir = 1
WaitTime = 0.01
StepCounter = 0

while True:

    print(StepCounter)
    print(Seq[StepCounter])
    for pin in range(0, 4):