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)
Beispiel #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')
Beispiel #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))
Beispiel #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
Beispiel #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))
Beispiel #6
0
 def stop(self, msg):
     MOTOR.dcSTOP(config.ADDR, msg['motor'])
Beispiel #7
0
 def Stop(self):
     MOTOR.dcSTOP(0,self.Motor_Number)
Beispiel #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))
Beispiel #9
0
 def motorStop(self, plate, motor):
     MOTOR.dcSTOP(plate, motor)
Beispiel #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)
Beispiel #11
0
 def right_stop(self):
     MOTOR.dcSTOP(0, self.RIGHT_TRACK)
Beispiel #12
0
 def left_stop(self):
     MOTOR.dcSTOP(0, self.LEFT_TRACK)
Beispiel #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)
Beispiel #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
Beispiel #15
0
 def right_stop(self):
     print(inspect.stack()[0][3])
     MOTOR.dcSTOP(0, self.RIGHT_TRACK)
Beispiel #16
0
 def left_stop(self):
     print(inspect.stack()[0][3])
     MOTOR.dcSTOP(0, self.LEFT_TRACK)