コード例 #1
0
ファイル: ignition.py プロジェクト: Laurenceb/BBB_Launcher
def ignite(debuglevel):
	threshold=340 #150mv threshold
	threshigh=1024 #450mv upper threshold
	ADC.setup()
	ADC.read_raw("AIN4") #Flush this
	baseline=ADC.read_raw("AIN4")
	GPIO.setup("P8_14",GPIO.OUT) #This pin fires the ignition
	GPIO.output("P8_14",GPIO.LOW)
	PWM.start("P8_19",15,49500) #works best with an 11 turn primary
	time.sleep(0.05) #50ms Settling time for the analogue front end
	ADC.read_raw("AIN4")
	selftest=ADC.read_raw("AIN4")
	if selftest>threshold and selftest<threshigh and baseline<128:
		GPIO.output("P8_14",GPIO.HIGH)
		if debuglevel:
			print "Igniting"
		time.sleep(2) #plenty of time for ignition
		failure=0		
	else:
		if debuglevel:
			print "Failed"
		failure=1
	GPIO.output("P8_14",GPIO.LOW)
	PWM.stop("P8_19")
	PWM.cleanup()
	#Debug output
	if debuglevel:
		print baseline
		print selftest
	return {'failure':failure, 'baseline':baseline ,'selftest':selftest }
コード例 #2
0
ファイル: gui.py プロジェクト: githubssj/Underwater-ROV
 def shutdown(self):
     """ stop motors and PWM signals """
     print 'Signals Stopped'
     PWM.stop(Motor.motor1)  # stop the motor
     PWM.stop(Motor.motor2)
     PWM.stop(Motor.motor3)
     PWM.cleanup()  # stop all pwm
コード例 #3
0
 def Speaker_enable(self, status=True):
     if status:
         PWM.start(self.channel, 0)
     else:
         PWM.set_duty_cycle(self.channel, 0)
         PWM.stop(self.channel)
         PWM.cleanup()
コード例 #4
0
def motor_setup(dir1_pin, dir2_pin, pwm_pin):
    """
    Sets up context for operating a motor.
    """
    # Initialize GPIO pins
    GPIO.setup(dir1_pin, GPIO.OUT)
    GPIO.setup(dir2_pin, GPIO.OUT)

    # Initialize PWM pins: PWM.start(channel, duty, freq=2000, polarity=0)
    PWM.start(pwm_pin, 0)

    def run_motor(speed):
        if speed > 100:
            speed = 100
        elif speed < -100:
            speed = -100

        if speed > 0:
            GPIO.output(dir1_pin, GPIO.LOW)
            GPIO.output(dir2_pin, GPIO.HIGH)
            PWM.set_duty_cycle(pwm_pin, abs(speed))
        elif speed < 0:
            GPIO.output(dir1_pin, GPIO.HIGH)
            GPIO.output(dir2_pin, GPIO.LOW)
            PWM.set_duty_cycle(pwm_pin, abs(speed))
        else:
            GPIO.output(dir1_pin, GPIO.LOW)
            GPIO.output(dir2_pin, GPIO.LOW)
            PWM.set_duty_cycle(pwm_pin, 0)

    yield run_motor

    GPIO.cleanup()
    PWM.cleanup()
コード例 #5
0
 def shutDown(self):
     #shutdown PWM cleanly
     PWM.stop(pan_pin)
     PWM.stop(tilt_pin)
     PWM.cleanup()
     #shutdown cherrypy cleanly
     cherrypy.engine.exit()
コード例 #6
0
 def shutdown(self):
     #print ('System Shutdown')
     #Kill both motor and signals
     PWM.stop(Motor.motor1)
     PWM.stop(Motor.motor2)
     PWM.stop(Motor.motor3)
     PWM.cleanup()
コード例 #7
0
def launchBaby(distance):
    # GPIO.wait_for_edge(startButton, GPIO.RISING) #no turning back
    # GPIO.cleanup()
    RPM = 586.5670268*math.sqrt(distance)
    print RPM
    dutyCycle = (0.0002114464417*RPM+0.03844561492)*100
    dutyCycle = dutyCycle*3.5*2
    dutyCycle = int(round(dutyCycle))
    if dutyCycle > 100:
        dutyCycle = 99
    print dutyCycle
    if dutyCycle <= 60:
        PWM.start(motorPin, dutyCycle, 20000)
    else:
        # thing = dutyCycle-60
        remainder = dutyCycle%10
        tens = dutyCycle//10
        # x = []
        # for i in range(0,tens):
        #     x.append(10)

        for i in range(0,dutyCycle-60,10):
            PWM.start(motorPin,60+i,20000)
            time.sleep(1)
            finalDutyCycle = 60+i
        PWM.start(motorPin, finalDutyCycle+remainder, 20000)
    # PWM.start(motorPin, dutyCycle, 20000)
    time.sleep(5)
    PWM.start(loaderPin, 4, 60)
    time.sleep(3.5)
    PWM.stop(motorPin)
    PWM.stop(loaderPin)
    PWM.cleanup()
コード例 #8
0
ファイル: motorControl.py プロジェクト: 00000111/beaglecar
def listener():
    rospy.init_node('listener', anonymous=True)
    rospy.Subscriber("turn_rate", Float32, callback)
    rospy.spin()
    print ("test")
    PWM.stop(pwm_pin)
    PWM.cleanup()
コード例 #9
0
ファイル: common.py プロジェクト: Annath/tankbot-python
def finish():
    for pin in motor_pins:
        PWM.stop(pin)

    PWM.cleanup()

    sys.exit(0)
コード例 #10
0
def listener():
    rospy.init_node('listener', anonymous=True)
    rospy.Subscriber("turn_rate", Float32, callback)
    rospy.spin()
    print("test")
    PWM.stop(servo_pin)
    PWM.cleanup()
コード例 #11
0
    def test_start_pwm_with_polarity_one(self):
        PWM.cleanup()
        PWM.start("P9_14", 0, 2000, 1)

        pwm_dir = get_pwm_dir()

        assert os.path.exists(pwm_dir)
        if kernel >= '4.1.0':
            duty = open(pwm_dir + '/duty_cycle').read()
        else:
            duty = open(pwm_dir + '/duty').read()
        period = open(pwm_dir + '/period').read()
        polarity = open(pwm_dir + '/polarity').read()
        assert int(duty) == 0
        assert int(period) == 500000

        # TEMPORARY FIX: disable polarity check
        # due to issue in 4.9.x+ kernels
        # refer to issue #170:
        # https://github.com/adafruit/adafruit-beaglebone-io-python/issues/170
        # and commit c35e4cb from pull request #173:
        # "source/c_pwm.c: disable pwm_set_polarity (broken in v4.9.x/v4.14.x)"
        # https://github.com/adafruit/adafruit-beaglebone-io-python/pull/173/commits/c35e4cb98a1f14c85aca7259132bcc97e93d78f8
        #if kernel >= '4.1.0':
        #   assert polarity == "inversed\n"
        #else:
        #   assert int(polarity) == 1
        PWM.cleanup()
コード例 #12
0
ファイル: actuators.py プロジェクト: brianpinto91/GeckoBot
    def cleanup(self):
        """Stop pwm services."""
        print(
            'stop PWM duty cycle 0 Prportional Valve ', self.name)

        PWM.stop(self.pwm_pin)
        PWM.cleanup()
コード例 #13
0
async def handle_alarm():
    while True:
        # Wait for one of the two events
        h = asyncio.ensure_future(smoke_event.wait())
        b = asyncio.ensure_future(button_event.wait())
        done, pending = await asyncio.wait({h, b},
                                           return_when=asyncio.FIRST_COMPLETED)
        # Cancel the other waiting task
        for task in pending:
            task.cancel()

        # If there is smoke, set the alarm
        smoke_event.clear()
        async with smoke_lock:
            smoke = is_smoke
        if smoke:
            print("Fire!")
            PWM.start("P8_13", 25, 1000)
        else:
            # Otherwise, check to see if the button has been pressed,
            # and if so clear the alarm
            if button_event.is_set():
                print("Reset!")
                PWM.stop("P8_13")
                PWM.cleanup()
                button_event.clear()
コード例 #14
0
def shutItDown():
    #turn pump off
    PWM.start(SERVO_PIN, MINDUT, SERVO_FREQUENCY, 0)
    PWM.stop(SERVO_PIN)
    GPIO.output(OUT_PIN, GPIO.LOW)
    GPIO.cleanup()
    PWM.cleanup()
コード例 #15
0
ファイル: 493.py プロジェクト: dgcarneiro/493
def avoid_():

	

def readfile_coordinates():
	global line
	f = open('temp.txt', 'r')
	temp = f.readlines(line)
	f.close()
	latitude = temp.split("")[0]
	longitude = temp.split("")[1]


while True:
	try:
		while True:
			readfile_coordinates(line)
			scheduler()
			arbiter()
			
	except KeyboardInterrupt: # pressing ctrl C stops operation and cleans up

		PWM.stop(left_wheel)	
		PWM.stop(right_wheel)
		PWM.cleanup()
		GPIO.cleanup()
		ADC.cleanup()
コード例 #16
0
ファイル: motor.py プロジェクト: Anusri27/Minnow
 def exit_signal(self, sig, frame):
     print('You pressed Ctrl+C!')
     PWM.stop("P9_21")
     PWM.stop("P9_22")
     PWM.stop("P9_16")
     PWM.cleanup()
     sys.exit(0)
コード例 #17
0
def exit_gracefully(signum, frame):
    global pan_servo_pin
    global tilt_servo_pin

    pwm.stop(pan_servo_pin)
    pwm.stop(tilt_servo_pin)
    pwm.cleanup()
コード例 #18
0
ファイル: qb_test_motor.py プロジェクト: delijati/qb_test
def motor_setup(dir1_pin, dir2_pin, pwm_pin):
    """
    Sets up context for operating a motor.
    """
    # Initialize GPIO pins
    GPIO.setup(dir1_pin, GPIO.OUT)
    GPIO.setup(dir2_pin, GPIO.OUT)

    # Initialize PWM pins: PWM.start(channel, duty, freq=2000, polarity=0)
    PWM.start(pwm_pin, 0)

    def run_motor(speed):
        if speed > 100:
            speed = 100
        elif speed < -100:
            speed = -100

        if speed > 0:
            GPIO.output(dir1_pin, GPIO.LOW)
            GPIO.output(dir2_pin, GPIO.HIGH)
            PWM.set_duty_cycle(pwm_pin, abs(speed))
        elif speed < 0:
            GPIO.output(dir1_pin, GPIO.HIGH)
            GPIO.output(dir2_pin, GPIO.LOW)
            PWM.set_duty_cycle(pwm_pin, abs(speed))
        else:
            GPIO.output(dir1_pin, GPIO.LOW)
            GPIO.output(dir2_pin, GPIO.LOW)
            PWM.set_duty_cycle(pwm_pin, 0)

    yield run_motor

    GPIO.cleanup()
    PWM.cleanup()
コード例 #19
0
def zelda_Sun_Song():
    """Plays the Sun's Song from The Legend of Zelda."""
    play_note(NOTE_A4, 0.15)
    play_note(NOTE_F4, 0.15)
    play_note(NOTE_D5, 0.3)
    PWM.stop(piezo_pin)
    time.sleep(0.3)
    play_note(NOTE_A4, 0.15)
    play_note(NOTE_F4, 0.15)
    play_note(NOTE_D5, 0.3)
    PWM.stop(piezo_pin)
    time.sleep(0.3)
    play_note(NOTE_G4, 0.1)
    play_note(NOTE_A4, 0.1)
    play_note(NOTE_B4, 0.1)
    play_note(NOTE_C5, 0.1)
    play_note(NOTE_D5, 0.1)
    play_note(NOTE_E5, 0.1)
    play_note(NOTE_F5, 0.1)
    play_note(NOTE_G5, 0.125)
    play_note(NOTE_G5, 0.125)
    play_note(NOTE_G5, 0.125)
    play_note(NOTE_G5, 0.125)
    play_note(NOTE_G5, 0.125)
    play_note(NOTE_G5, 0.125)
    play_note(NOTE_G5, 0.125)
    play_note(NOTE_G5, 0.125)
    PWM.stop(piezo_pin)
    PWM.cleanup()
コード例 #20
0
ファイル: Servo.py プロジェクト: TouchTheFishy/CombeLabo
    def SetAngle(self,input):
        """
        Recieve an input from 0 to 100 and sets the position following this input
        """

        PWM.set_duty_cycle(self.__pin, input)
        PWM.stop(self.__pin)
        PWM.cleanup()
コード例 #21
0
ファイル: Servo.py プロジェクト: TouchTheFishy/CombeLabo
 def __init__(self,pin):
     """
     When started, the library puts the servo at -90°
     """
     self.__pin=pin
     PWM.start(self.__pin, 0) #PWM set at 0% so the servo goes to -90° (50% = 0° and 100%= 90°)
     PWM.stop(self.__pin)#Close the PWM connection
     PWM.cleanup()
コード例 #22
0
ファイル: flow.py プロジェクト: dotsonlab/AWSC-Toilet
 def triggerStepper(self):
     time.sleep(0.5)
     PWM.start("P9_16", 25, 100, 1)
     time.sleep(2)
     PWM.set_frequency("P9_16", 250)
     time.sleep(90)
     PWM.stop("P9_16")
     PWM.cleanup()
コード例 #23
0
ファイル: testpwm.py プロジェクト: Laurenceb/BBB_Launcher
def testp:
	while 1:
		PWM.start("P8_19",15,49500)
		time.sleep(2)
		PWM.stop("P8_19")
		time.sleep(0.15)
		PWM.cleanup()
		time.sleep(0.1)
コード例 #24
0
    def cleanup(cls):
        PWM.stop(PWMA)
        PWM.stop(PWMB)
        PWM.cleanup()

        GPIO.cleanup()

        GPIO.output(STBY, GPIO.LOW)
コード例 #25
0
    def cleanup(cls):
        PWM.stop(PWMA)
        PWM.stop(PWMB)
        PWM.cleanup()

        GPIO.cleanup()

        GPIO.output(STBY, GPIO.LOW)
コード例 #26
0
ファイル: collector.py プロジェクト: JDGETS/machine2014
    def stop(self):
        print "[Collector.run] Collector stopped"
        self.is_running = False

        for c in self.components:
            c.stop()

        PWM.cleanup()
コード例 #27
0
ファイル: QuickBot.py プロジェクト: kingfishar/quickbot_bbb
 def cleanup(self):
     print "Clean up"
     self.setPWM([0, 0])
     self.robotSocket.close()
     GPIO.cleanup()
     PWM.cleanup()
     #         tictocPrint()
     self.writeBufferToFile()
コード例 #28
0
def cleanup():
    """Cleanup the hardware components. Returns 'dead' if cleaned up"""

    # Set Display to something fun to show program is complete
    PWM.cleanup()
    HT16K33.display_set_digit(0, 13)  # "D"
    HT16K33.display_set_digit(1, 14)  # "E"
    HT16K33.display_set_digit(2, 10)  # "A"
    HT16K33.display_set_digit(3, 13)  # "D"
コード例 #29
0
    def clear(self):
        """Cleans and disables the PMW channel"""
        PWM.stop(self.piezzo)
        PWM.cleanup()

    # End def


# End class
コード例 #30
0
 def shutdown(self):
     self.stopAllMotors()
     self.backLeftMotor.disable()
     self.frontLeftMotor.disable()
     self.backRightMotor.disable()
     self.frontRightMotor.disable()
     PWM.cleanup()
     GPIO.cleanup()
     return
コード例 #31
0
def zelda_Serenade_of_Water():
    """Plays the Serenade of Water from The Legend of Zelda."""
    play_note(NOTE_D5, 0.5)
    play_note(NOTE_F5, 0.5)
    play_note(NOTE_A5, 0.5)
    play_note(NOTE_A5, 0.5)
    play_note(NOTE_B5, 1.0)
    PWM.stop(piezo_pin)
    PWM.cleanup()
コード例 #32
0
def readCtrlLoop():
    PWM.start(PWM_VENTILO, 0)
    try:
        while True:
            val = ADC.read(AIN)  # read_raw()
            PWM.set_duty_cycle(PWM_VENTILO, val * 100)
            time.sleep(.001)
    except KeyboardInterrupt:
        print('Ok, end')
    PWM.cleanup()
コード例 #33
0
ファイル: config.py プロジェクト: alyyousuf7/RollE
def cleanup(signum, frame):
	global exitStatus
	print "\nRollE, signing out."
	exitStatus = True

	sleep(0.2)
	GPIO.cleanup()
	PWM.cleanup()

	exit()
コード例 #34
0
ファイル: ctrlVentilo.py プロジェクト: Miaou/BBB
def showTacky():
    GPIO.setup(IN_TACKY, GPIO.IN)
    PWM.start(PWM_VENTILO, 100)
    try:
        while True:
            print(GPIO.input(IN_TACKY))
            time.sleep(.5)
    except KeyboardInterrupt:
        print('Ok, end')
    PWM.cleanup()
コード例 #35
0
ファイル: ctrlVentilo.py プロジェクト: Miaou/BBB
def readCtrlLoop():
    PWM.start(PWM_VENTILO, 0)
    try:
        while True:
            val = ADC.read(AIN) # read_raw()
            PWM.set_duty_cycle(PWM_VENTILO, val*100)
            time.sleep(.001)
    except KeyboardInterrupt:
        print('Ok, end')
    PWM.cleanup()
コード例 #36
0
def showTacky():
    GPIO.setup(IN_TACKY, GPIO.IN)
    PWM.start(PWM_VENTILO, 100)
    try:
        while True:
            print(GPIO.input(IN_TACKY))
            time.sleep(.5)
    except KeyboardInterrupt:
        print('Ok, end')
    PWM.cleanup()
コード例 #37
0
def zelda_Requiem_of_Spirit():
    """Plays the Requiem of Spirit from The Legend of Zelda."""
    play_note(NOTE_D5, 0.75)
    play_note(NOTE_F5, 0.375)
    play_note(NOTE_D5, 0.375)
    play_note(NOTE_A5, 0.75)
    play_note(NOTE_F5, 0.75)
    play_note(NOTE_D5, 1.5)
    PWM.stop(piezo_pin)
    PWM.cleanup()
コード例 #38
0
def zelda_Minuet_of_Forest():
    """Plays the Minuet of Forest from The Legend of Zelda."""
    play_note(NOTE_D5, 0.225)
    play_note(NOTE_D6, 0.225)
    play_note(NOTE_B5, 0.9)
    play_note(NOTE_A5, 0.225)
    play_note(NOTE_B5, 0.225)
    play_note(NOTE_A5, 0.9)
    PWM.stop(piezo_pin)
    PWM.cleanup()
コード例 #39
0
def zelda_Zelda_Lullaby():
    """Plays Zelda's Lullaby from The Legend of Zelda."""
    play_note(NOTE_B4, 1.2)
    play_note(NOTE_D5, 0.6)
    play_note(NOTE_A4, 1.8)
    play_note(NOTE_B4, 1.2)
    play_note(NOTE_D5, 0.6)
    play_note(NOTE_A4, 1.8)
    PWM.stop(piezo_pin)
    PWM.cleanup()
コード例 #40
0
ファイル: servo.py プロジェクト: bresch/buggybbb_ros
def callback(data):
    rospy.loginfo(rospy.get_caller_id() + "I heard %s", data)
    angle = data.angular.z
    if angle == 42:
        PWM.stop(servo_pin)
        PWM.cleanup()
        return
    angle_f = float(angle)
    duty = ((-angle_f/2 + 0.5) * duty_span + duty_min)
    PWM.set_duty_cycle(servo_pin, duty)
コード例 #41
0
ファイル: snake_ctl.py プロジェクト: casprice/motor-control
def shutdown(sig, frame):
    if 'bbb_test' in build_params:
        GPIO.output(pin_map["enable"], GPIO.LOW)
        PWM.stop(pin_map["pwm"])
        PWM.cleanup()
        GPIO.cleanup()
    curses.nocbreak()
    curses.echo()
    curses.endwin()
    sys.exit(0)
コード例 #42
0
 def cleanup(self):
     sys.stdout.write("Shutting down...")
     self.setPWM([0, 0])
     self.robotSocket.close()
     GPIO.cleanup()
     PWM.cleanup()
     if DEBUG:
         # tictocPrint()
         self.writeBuffersToFile()
     sys.stdout.write("Done\n")
コード例 #43
0
def listener():
	rospy.init_node('joint_target_listener', anonymous=True)
	rospy.Subscriber("servo_angle_target", JointTarget, sendArmCommand)

	rospy.spin()

	#shutdown channels and cleanup
	PWM.stop("P9_14")
	PWM.stop("P9_16")
	PWM.cleanup()
コード例 #44
0
def zelda_Preulde_of_Light():
    """Plays the Prelude of Light from The Legend of Zelda."""
    play_note(NOTE_D5, 0.25)
    play_note(NOTE_A4, 0.75)
    play_note(NOTE_D5, 0.25)
    play_note(NOTE_A4, 0.25)
    play_note(NOTE_B4, 0.25)
    play_note(NOTE_D5, 1.25)
    PWM.stop(piezo_pin)
    PWM.cleanup()
コード例 #45
0
ファイル: pwm_test.py プロジェクト: MbedTinkerer/T-Bone
 def test_multiple_PWM(self):
     try:
         PWM.start("P9_16")
         PWM.start("P9_14")
         PWM.start("P8_19")
         PWM.set_duty_cycle("P9_16", 0.1)
         PWM.set_duty_cycle("P9_16", 0)
         PWM.set_duty_cycle("P9_14", 0.1)
         PWM.set_duty_cycle("P9_14", 0)
     finally:
         PWM.cleanup()
コード例 #46
0
ファイル: base.py プロジェクト: Muminisko/quickbot_bbb
 def cleanup(self):
     """ Clean up before shutting down. """
     sys.stdout.write("Shutting down...")
     self.set_pwm([0, 0])
     self.robotSocket.close()
     GPIO.cleanup()
     PWM.cleanup()
     if DEBUG:
         pass
         # tictocPrint()
         # self.writeBuffersToFile()
     sys.stdout.write("Done\n")
コード例 #47
0
def servo(whichDevice, where):
    # This function activates the servo motor

    # Import important libraries
    import Adafruit_BBIO.PWM as PWM
    import time
    import os
    from animals import animal
    from random import randint
    
    os.system('clear')

    # Time at which the servo starts to work
    cur_time = time.time()    

    # Set pin    
    if whichDevice == 1:
        servo_pin = "P8_13"
    elif whichDevice == 2:
        servo_pin = "P9_14"
    
#    print whichDevice
#    print servo_pin    
    
    # Set duty cycle parameters
    duty_min = 3
    duty_max = 14.5
    duty_span = duty_max - duty_min
    
    # Set duty cycle and frequency to pin
    PWM.start(servo_pin, (100-duty_min), 200.0)
    
    # Give direction/angle and a random animal to display
    if where == 'open':
        angle = 90
        print('\n\nOpening device!\n\n')
        animal_out = randint(1, 6)
        animal(animal_out)
    else:
        angle = 0
        print('\n\nClosing device...\n\n')
        animal_out = randint(1, 6)
        animal(animal_out)

    # Activate servo for 3 seconds    
    while True:
        angle_f = float(angle)
        duty = 100 - ((angle_f / 180) * duty_span + duty_min)
        PWM.set_duty_cycle(servo_pin, duty)
        if time.time() > (cur_time + 3.1):
            PWM.stop(servo_pin)
            PWM.cleanup()
            break
コード例 #48
0
ファイル: ignition.py プロジェクト: Laurenceb/BBB_Launcher
def simple_ignite(debuglevel):
	GPIO.setup("P8_14",GPIO.OUT) #This pin fires the ignition
	GPIO.output("P8_14",GPIO.LOW)
	PWM.start("P8_19",15,49500) #works best with an 11 turn primary
	GPIO.output("P8_14",GPIO.HIGH)
	if debuglevel:
		print "Igniting"
	time.sleep(2) #plenty of time for ignition
	GPIO.output("P8_14",GPIO.LOW)
	PWM.stop("P8_19")
	PWM.cleanup()
	failure=0
	return {'failure':failure}
コード例 #49
0
ファイル: listener.py プロジェクト: amalzaga/ros_servo_test
def listener():


    rospy.init_node('listener', anonymous=False)
    
    PWM.start(servo_pin,93, 60.0,1)

    rospy.Subscriber('angle', Float32, callback)

    # spin() simply keeps python from exiting until this node is stopped
    rospy.spin()
    PWM.stop(servo_pin)
    PWM.cleanup()
コード例 #50
0
 def test_start_pwm_ecap0(self):
     print("test_start_pwm_ecap0\n");
     PWM.cleanup()
     PWM.start("P9_42", 0)
     pwm_dir = get_pwm_dir()
     assert os.path.exists(pwm_dir)
     if kernel >= '4.1.0':
         duty = open(pwm_dir + '/duty_cycle').read()
     else:
         duty = open(pwm_dir + '/duty').read()
     period = open(pwm_dir + '/period').read()
     assert int(duty) == 0
     assert int(period) == 500000
     PWM.cleanup()
コード例 #51
0
ファイル: blower.py プロジェクト: Caligatio/smokematic
    def __init__(self, blower_pin):
        """
        Initializes the controller for a blower and sets the blower speed to 0

        :param blower_pin: The BBB PWM to use, e.g. P9_14
        :type blower_pin: str
        """
        self._blower_pin = blower_pin
        self._speed = 0
        self._low_speed_handle = None

        PWM.start(blower_pin, 0)
        PWM.stop(blower_pin)
        PWM.cleanup()
コード例 #52
0
    def test_start_pwm(self):
        PWM.start("P9_14", 0)

        files = os.listdir('/sys/devices')
        ocp = '/sys/devices/'+[s for s in files if s.startswith('ocp')][0]
        files = os.listdir(ocp)
        pwm_test = ocp+'/'+[s for s in files if s.startswith('pwm_test_P9_14')][0]

        assert os.path.exists(pwm_test)
        duty = open(pwm_test + '/duty').read()
        period = open(pwm_test + '/period').read()
        assert int(duty) == 0
        assert int(period) == 500000
        PWM.cleanup()
コード例 #53
0
def main():
    
    #print 'Enter source co:ordinates \nEnter Xi:'
    #Xi = input()
    Xi = 0.0
    #print 'Enter Yi:'
    #Yi = input()
    Yi = 0.0
    #print 'Enter Thetai:'
    #Thetai = input()
    Thetai = 0.0
    print 'Intital steering orientation taken to be zero'
    psi = 0.0
    intl = [Xi,Yi,Thetai]
    
    #print 'Enter destination co:ordinates \nEnter Xf:'
    #Xf = input()
    Xf = 7.0
    #print 'Enter Yf:'
    #Yf = input()
    Yf = 7.0
    #print 'Enter Thetaf:'
    #Thetaf = input()
    Thetaf = 3.14
    dsrd = [Xf,Yf,Thetaf]
    
    print 'Creating trajecory\n'
    conpoints = path(intl,dsrd)

    print 'Auto Drive engaged:::\n'
    prev = intl
    for mov in range(1,np.size(conpoints,1)):

        print '\nCon.point :',conpoints[0,mov],' : ',conpoints[1,mov]

        jntvar = invkin2(prev,[conpoints[0,mov],conpoints[1,mov]])
        attnd = fwdkin(prev,jntvar)
        print 'Attained :',attnd[0],' : ',attnd[1]

        srvdrv(jntvar[1])
        motodrv(jntvar[0])
        
        prev = attnd
    
    PWM.cleanup()   

    return
コード例 #54
0
def exit_gracefully(signum, frame):
    global pan_servo_pin
    global tilt_servo_pin
    global original_sigterm
    global original_sigabrt
    global original_sigint

    signal.signal(signal.SIGTERM, original_sigterm)
    signal.signal(signal.SIGABRT, original_sigabrt)
    signal.signal(signal.SIGINT, original_sigint)

    pwm.stop(pan_servo_pin)
    pwm.stop(tilt_servo_pin)
    pwm.cleanup()

    signal.signal(signal.SIGTERM, exit_gracefully)
    signal.signal(signal.SIGABRT, exit_gracefully)
    signal.signal(signal.SIGINT, exit_gracefully)    
コード例 #55
0
ファイル: main2.py プロジェクト: wallamejorge/miOso
def MotorLoop():
	global PWM_frequency
    	PWM.cleanup()
	PWM.start("P8_13",0,PWM_frequency,0)
	PWM.start("P9_14",0,PWM_frequency,0)
	PWM.start("P9_21",0,PWM_frequency,0)
	PWM.start("P9_42",0,PWM_frequency,0)
	while True:
		global Angle1
		global Angle2
		global Angle3
		global Angle4
		global Angle5
		global Angle6
		PWM.set_duty_cycle("P8_13",Angle1)
		PWM.set_duty_cycle("P9_14",Angle2)
		PWM.set_duty_cycle("P9_21",Angle3)
		PWM.set_duty_cycle("P9_42",Angle4)	
コード例 #56
0
def pwmcontrol ():
	global input_percentage
	global changed
	global kill
	changed = False
	PWM.cleanup()
	start_freq = 300.0
	start_duty = 0.0

	period = 1.0 / start_freq
	minimum = 100.0 * (.001 / period)
	maximum = 100.0 * (.002 / period)

	print "Frequency:" + str(start_freq)
	print "Period:" + str(period)
	print "Minimum:" + str(minimum)
	print "Maximum:" + str(maximum)

	PWM.start("P9_14",start_duty,start_freq)
	PWM.start("P8_13",start_duty,start_freq)
	PWM.start("P9_21",start_duty,start_freq)
	PWM.start("P9_42",start_duty,start_freq)

	print "Start"

	while input_percentage >= 0:
		if changed == True:
			changed = False
			duty_cycle = ((0.01*input_percentage) * (maximum - minimum)) + minimum
			print "Duty Cycle: " + str(duty_cycle)
			PWM.set_duty_cycle("P8_13",duty_cycle)
			PWM.set_duty_cycle("P9_14",duty_cycle)
			PWM.set_duty_cycle("P9_21",duty_cycle)
			PWM.set_duty_cycle("P9_42",duty_cycle)
		else:
			time.sleep(0.1)
	PWM.stop("P9_14")
	PWM.stop("P8_13")
	PWM.stop("P9_21")
	PWM.stop("P9_42")
	PWM.cleanup()
	quit()
	return
コード例 #57
0
    def test_start_pwm_with_polarity_one(self):
        PWM.cleanup()
        PWM.start("P9_14", 0, 2000, 1)

        pwm_dir = get_pwm_dir()

        assert os.path.exists(pwm_dir)
        if kernel >= '4.1.0':
            duty = open(pwm_dir + '/duty_cycle').read()
        else:
            duty = open(pwm_dir + '/duty').read()
        period = open(pwm_dir + '/period').read()
        polarity = open(pwm_dir + '/polarity').read()
        assert int(duty) == 0
        assert int(period) == 500000

        if kernel >= '4.1.0':
            assert polarity == "inversed\n"
        else:
            assert int(polarity) == 1
        PWM.cleanup()
コード例 #58
0
ファイル: _indicator.py プロジェクト: downwith/bouncer-demo
def _init():
    global _cathode, _anodes
    try:
        _cathode = _PWM('P9_22')
        _anodes = (_PWM('P9_16'), _PWM('P8_19'), _PWM('P9_14'))
        _cathode.duty = 1.0
    except:
        pwm.cleanup()
        raise
    try:
        _thread.daemon = True
        _thread.start()
    except:
        _cathode.duty = 0.0
        pwm.cleanup()
        raise
    try:
        atexit.register(_exit)
    except:
        _exit()
        raise