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