コード例 #1
0
 def handleIote2eResult(self, iote2eResult ):
     actuatorValue = iote2eResult.pairs['actuatorValue'];
     logger.info('actuatorValue {}'.format(actuatorValue))
     if 'off' == actuatorValue:
         MOTOR.dcSTOP(0,3)
     elif 'on' == actuatorValue:
         MOTOR.dcSTART(0,3)
コード例 #2
0
    def __init__(self, min_speed=25):
        # make the motor banks
        self._LEFT = [
            Motor(0, 1, 'cw', 'ccw'),
            Motor(0, 2, 'cw', 'ccw'),
            Motor(0, 3, 'cw', 'ccw')
        ]
        self._RIGHT = [
            Motor(1, 1, 'ccw', 'cw'),
            Motor(1, 2, 'ccw', 'cw'),
            Motor(1, 3, 'ccw', 'cw')
        ]

        # get the motors ready to run
        for m in self._LEFT:
            MOTOR.dcCONFIG(m._address, m._number, m.direction, 0,
                           m._acceleration)
            print("Starting motors at speed 0.")
            MOTOR.dcSTART(m._address, m._number)
            m._stopped = False
        for m in self._RIGHT:
            MOTOR.dcCONFIG(m._address, m._number, m.direction, 0,
                           m._acceleration)
            print("Starting motors at speed 0.")
            MOTOR.dcSTART(m._address, m._number)
            m._stopped = False
コード例 #3
0
ファイル: bulle_server.py プロジェクト: lemairec/bullepi
def motor(motor_number, value):
    print str(value)
    MOTOR.dcSPEED(2, motor_number, value)
    if (value > 20):
        MOTOR.dcSTART(2, motor_number)
    else:
        MOTOR.dcSTOP(2, motor_number)
    return render_template('home.html')
コード例 #4
0
def initMotor(FLdir,FRdir,RLdir,RRdir):
	#print("Setting: ",rotation)
	MOTOR.dcCONFIG(ctl,FL,FLdir,0.0,0.0)
	MOTOR.dcCONFIG(ctl,FR,FRdir,0.0,0.0)
	MOTOR.dcCONFIG(ctl,RL,RLdir,0.0,0.0)
	MOTOR.dcCONFIG(ctl,RR,RRdir,0.0,0.0)
	
	MOTOR.dcSTART(ctl,FL)
	MOTOR.dcSTART(ctl,FR)
	MOTOR.dcSTART(ctl,RL)
	MOTOR.dcSTART(ctl,RR)
	
	if   (FLdir == FRdir == RLdir == RRdir  == "cw") : 
		status = "forward"
		return
	elif (FLdir == FRdir == RLdir == RRdir  == "ccw"): 
		status = "reverse" 
		return
	elif (FLdir == RLdir == "cw"  and FRdir == RRdir == "ccw"):
		status = "left"
	elif (FLdir == RLdir == "ccw" and FRdir == RRdir == "cw"):
		status = "right"
	else:
		 status = 'something not right'
	
	return status 
コード例 #5
0
def right(FLspeed,FRspeed,RLspeed,RRspeed):
	status = initMotor('cw','ccw','cw','ccw')
	MOTOR.dcSTART(ctl,FL)
	MOTOR.dcSTART(ctl,FR)
	MOTOR.dcSTART(ctl,RL)
	MOTOR.dcSTART(ctl,RR)
	
	status = 'right'
	return status
コード例 #6
0
def reverse(FLspeed,FRspeed,RLspeed,RRspeed):
	#print("Reverse motion called. CTL: ")
	status = initMotor('ccw','ccw','ccw','ccw')
	MOTOR.dcSTART(ctl, FL)
	MOTOR.dcSTART(ctl, FR)
	MOTOR.dcSTART(ctl, RL)
	MOTOR.dcSTART(ctl, RR)
	
	status = "reverse"
	return status
コード例 #7
0
def fwd(FLspeed,FRspeed,RLspeed,RRspeed):
	# print("Forward motion called. CTL: ",ctl)
	status = initMotor('cw','cw','cw','cw')
	MOTOR.dcSTART(ctl, FL)
	MOTOR.dcSTART(ctl, FR)
	MOTOR.dcSTART(ctl, RL)
	MOTOR.dcSTART(ctl, RR)
	
	status = "forward"
	return status
コード例 #8
0
 def reverse(self, increment):
     # decrease forward speed of both banks
     for m in self._LEFT + self._RIGHT:
         if m._stopped:
             MOTOR.dcCONFIG(m._address, m._number, m.direction, 0,
                            m._acceleration)
             MOTOR.dcSTART(m._address, m._number)
         tmp = m.speed - increment
         if tmp >= 0 and m.direction == m._forward:
             new_speed = min([100, tmp])
             MOTOR.dcSPEED(m._address, m._number, new_speed)
             time.sleep(m._acceleration)
             m.speed = new_speed
         if tmp >= 0 and m.direction == m._reverse:
             m.direction = m._forward
             new_speed = min([100, tmp])
             MOTOR.dcSTOP(m._address, m._number)
             time.sleep(m._acceleration)
             MOTOR.dcCONFIG(m._address, m._number, m.direction, new_speed,
                            m._acceleration)
             MOTOR.dcSTART(m._address, m._number)
             time.sleep(m._acceleration)
             m.speed = new_speed
         if tmp < 0 and m.direction == m._forward:
             m.direction = m._reverse
             new_speed = min([100, abs(tmp)])
             MOTOR.dcSTOP(m._address, m._number)
             time.sleep(m._acceleration)
             MOTOR.dcCONFIG(m._address, m._number, m.direction, new_speed,
                            m._acceleration)
             MOTOR.dcSTART(m._address, m._number)
             time.sleep(m._acceleration)
             m.speed = -new_speed
         if tmp < 0 and m.direction == m._reverse:
             new_speed = min([100, abs(tmp)])
             MOTOR.dcSPEED(m._address, m._number, new_speed)
             time.sleep(m._acceleration)
             m.speed = -new_speed
         print("motor: {0}, {1}    speed: {2}    direction: {3}".format(
             m._address, m._number, m.speed, m.direction))
コード例 #9
0
ファイル: dc.py プロジェクト: Jinthebandit/theshaker-git
 def start(self, msg):
     MOTOR.dcCONFIG(config.ADDR, msg['motor'], msg['dir'], msg['speed'],
                    msg['acc'])
     MOTOR.dcSTART(config.ADDR, msg['motor'])
コード例 #10
0
ファイル: Lidar_Main.py プロジェクト: IanMRoberts/Lidar-Code
 def __init__(self,MotorNumber):
     self.Motor_Number = MotorNumber
     MOTOR.dcCONFIG(0,self.Motor_Number,self.Direction,self.DutyCycle,self.Acceleration) # dcCONFIG(addr,motor,dir,speed,acceleration)
     MOTOR.dcSTART(0,self.Motor_Number) # dcSTART(addr,motor)
コード例 #11
0
    def right(self, increment):
        # decrease speed of right bank
        for m in self._RIGHT:
            if m._stopped:
                MOTOR.dcCONFIG(m._address, m._number, m.direction, 0,
                               m._acceleration)
                MOTOR.dcSTART(m._address, m._number)
            tmp = m.speed - increment
            if tmp >= 0 and m.direction == m._forward:
                new_speed = min([tmp, 100])
                MOTOR.dcSPEED(m._address, m._number, new_speed)
                time.sleep(m._acceleration)
                m.speed = new_speed
            elif tmp < 0 and m.direction == m._forward:
                m.direction = m._reverse
                new_speed = min([abs(tmp), 100])
                MOTOR.dcSTOP(m._address, m._number)
                time.sleep(m._acceleration)
                MOTOR.dcCONFIG(m._address, m._number, m.direction, new_speed,
                               m._acceleration)
                MOTOR.dcSTART(m._address, m._number)
                time.sleep(m._acceleration)
                m.speed = -new_speed
            elif tmp < 0 and m.direction == m._reverse:
                new_speed = min([abs(tmp), 100])
                MOTOR.dcSPEED(m._address, m._number, new_speed)
                time.sleep(m._acceleration)
                m.speed = -new_speed
            elif tmp >= 0 and m.direction == m._reverse:
                m.direction = m._forward
                new_speed = min([tmp, 100])
                MOTOR.dcSTOP(m._address, m._number)
                time.sleep(m._acceleration)
                MOTOR.dcCONFIG(m._address, m._number, m.direction, new_speed,
                               m._acceleration)
                MOTOR.dcSTART(m._address, m._number)
                time.sleep(m._acceleration)
                m.speed = -new_speed
            print("motor: {0}, {1}    speed: {2}    direction: {3}".format(
                m._address, m._number, m.speed, m.direction))

        # increase speed of left bank
        for m in self._LEFT:
            if m._stopped:
                MOTOR.dcCONFIG(m._address, m._number, m.direction, 0,
                               m._acceleration)
                MOTOR.dcSTART(m._address, m._number)
            tmp = m.speed + increment
            if tmp >= 0 and m.direction == m._forward:
                new_speed = min([tmp, 100])
                MOTOR.dcSPEED(m._address, m._number, new_speed)
                time.sleep(m._acceleration)
                m.speed = new_speed
            elif tmp >= 0 and m.direction == m._reverse:
                m.direction = m._forward
                new_speed = min([tmp, 100])
                MOTOR.dcSTOP(m._address, m._number)
                time.sleep(m._acceleration)
                MOTOR.dcCONFIG(m._address, m._number, m.direction, new_speed,
                               m._acceleration)
                MOTOR.dcSTART(m._address, m._number)
                time.sleep(m._acceleration)
                m.speed = new_speed
            elif tmp < 0 and m.direction == m._reverse:
                new_speed = min([abs(tmp), 100])
                MOTOR.dcSPEED(m._address, m._number, new_speed)
                time.sleep(m._acceleration)
                m.speed = -new_speed
            elif tmp < 0 and m.direction == m._forward:
                m.direction = m._reverse
                new_speed = min([abs(tmp), 100])
                MOTOR.dcSTOP(m._address, m._number)
                time.sleep(m._acceleration)
                MOTOR.dcCONFIG(m._address, m._number, m.direction, new_speed,
                               m._acceleration)
                MOTOR.dcSTART(m._address, m._number)
                time.sleep(m._acceleration)
                m.speed = -new_speed
            print("motor: {0}, {1}    speed: {2}    direction: {3}".format(
                m._address, m._number, m.speed, m.direction))
コード例 #12
0
 def motorStart(self, plate, motor, dir, speed, accel):
     MOTOR.dcCONFIG(self.plate, motor, dir, speed, accel)
     MOTOR.dcSTART(self.plate, motor)
コード例 #13
0
import RPi.GPIO as GPIO
import time
import piplates.RELAYplate as RELAY
import piplates.MOTORplate as MOTOR

MOTOR.dcCONFIG(2, 1, 'ccw', 0.0, 2.5)
MOTOR.dcSTART(2, 1)
time.sleep(5)
MOTOR.dcSPEED(2, 1, 80.0)
MOTOR.dcSTART(2, 1)

RELAY.getID(0)
print "on"
RELAY.relayON(0, 3)
time.sleep(3)
print "off"
RELAY.relayOFF(0, 3)
MOTOR.dcSTOP(2, 1)
コード例 #14
0
 def move_track(self, motor_number, direction, speed):
     MOTOR.dcSTOP(0, motor_number)
     MOTOR.dcCONFIG(0, motor_number, direction, speed, 0)
     MOTOR.dcSTART(0, motor_number)