Пример #1
0
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')
Пример #2
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))
Пример #3
0
 def speed(self, msg):
     MOTOR.dcSPEED(config.ADDR, msg['motor'], msg['speed'])
Пример #4
0
 def SetSpeed(self,Speed):
     self.DutyCycle = Speed
     MOTOR.dcSPEED(0,self.Motor_Number,self.DutyCycle)
Пример #5
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))
Пример #6
0
 def motorChange(self, plate, motor, speed):
     MOTOR.dcSPEED(plate, motor, speed)
Пример #7
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)
Пример #8
0
def motorSpeed(FLspeed,FRspeed,RLspeed,RRspeed):
	MOTOR.dcSPEED(ctl,FL,FLspeed)
	MOTOR.dcSPEED(ctl,FR,FRspeed)
	MOTOR.dcSPEED(ctl,RL,RLspeed)
	MOTOR.dcSPEED(ctl,RR,RRspeed)