Пример #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 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')
Пример #3
0
 def stop(self):
     for m in self._LEFT + self._RIGHT:
         MOTOR.dcSTOP(m._address, m._number)
         time.sleep(m._acceleration)
         m.speed = 0
         m._direction = m._forward
         MOTOR.dcCONFIG(m._address, m._number, m.direction, m.speed,
                        m._acceleration)
         m._stopped = True
         print("motor: {0}, {1}    speed: {2}    direction: {3}".format(
             m._address, m._number, m.speed, m.direction))
Пример #4
0
def MotorOff():
    #print("Stopping Motor")
    MOTOR.dcSTOP(ctl,FL)
    MOTOR.dcSTOP(ctl,FR)
    MOTOR.dcSTOP(ctl,RL)
    MOTOR.dcSTOP(ctl,RR)
        
    status = "stopped"
    return status
Пример #5
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))
Пример #6
0
 def stop(self, msg):
     MOTOR.dcSTOP(config.ADDR, msg['motor'])
Пример #7
0
 def Stop(self):
     MOTOR.dcSTOP(0,self.Motor_Number)
Пример #8
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))
Пример #9
0
 def motorStop(self, plate, motor):
     MOTOR.dcSTOP(plate, motor)
Пример #10
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)
Пример #11
0
 def right_stop(self):
     MOTOR.dcSTOP(0, self.RIGHT_TRACK)
Пример #12
0
 def left_stop(self):
     MOTOR.dcSTOP(0, self.LEFT_TRACK)
Пример #13
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)
Пример #14
0
 def stop(self):
     for m in self._LEFT + self._RIGHT:
         MOTOR.dcSTOP(m._address, m._number)
         m.speed = 0
         m._direction = m._forward
         m._stopped = True
Пример #15
0
 def right_stop(self):
     print(inspect.stack()[0][3])
     MOTOR.dcSTOP(0, self.RIGHT_TRACK)
Пример #16
0
 def left_stop(self):
     print(inspect.stack()[0][3])
     MOTOR.dcSTOP(0, self.LEFT_TRACK)