Exemple #1
0
def buzzer_init():
    global obj_buzzer
    pwmObj = PWM()
    pwmObj.open("buzzer")
    print("buzzer inited!")
    obj_buzzer = buzzer.BUZZER(pwmObj)
    # define init freq and duty
    data_r = {'freq': 2000, 'duty': 99}
    obj_buzzer.setOptionDuty(data_r)
Exemple #2
0
from driver import PWM

print("-------------------pwm test--------------------")
pwm = PWM()
pwm.open("pwm1")
duty = pwm.getDuty()
freq = pwm.getFreq()
print(duty)
print(freq)
pwm.setConfig(3250000, 0.5)
duty = pwm.getDuty()
freq = pwm.getFreq()
print(duty)
print(freq)
pwm.setDuty(0.7)
pwm.setFreq(3260000)
duty = pwm.getDuty()
freq = pwm.getFreq()
print(duty)
print(freq)
pwm.close()
print("-------------------pwm end--------------------")
Exemple #3
0
#!/usr/bin/python

# RubpyxRobot Close Fingers Script
# By: Ryan Brazeal (and the I2C Club)
# Date: Started - Circa 2017

from driver import PWM
import os
import time

# Initialise the PWM device using the default address
pwm = PWM(0x40)
# Set frequency to 60 Hz
pwm.setPWMFreq(60)

#Hardware Definition Parameters
whiteClamp = 0
whiteTwist = 1
blueClamp = 2
blueTwist = 3
yellowClamp = 4
yellowTwist = 5
redClamp = 6
redTwist = 7

#Calibration Parameters
whiteClampClosed = 0
whiteClampOpen = 0
whiteTwistNeutral = 0
whiteTwistCCW = 0
whiteTwistCW = 0
# By: Ryan Brazeal (and the I2C Club)
# Date: Started - Circa 2017

from driver import PWM
import tty
import sys
import os
import termios

if __name__ == "__main__":

    orig_settings = termios.tcgetattr(sys.stdin)
    tty.setraw(sys.stdin)

    # Initialise the PWM device using the default address
    pwm = PWM(0x40)
    # Set frequency to 60 Hz
    pwm.setPWMFreq(60)

    #Hardware Definition Parameters
    white_clamp = 0
    white_twist = 1
    blue_clamp = 2
    blue_twist = 3
    yellow_clamp = 4
    yellow_twist = 5
    red_clamp = 6
    red_twist = 7

    #Calibration Parameters
    white_clamp_closed = 350
Exemple #5
0
#!/usr/bin/python

from driver import PWM

# Initialise the PWM device using the default address
pwm = PWM(0x40)
pwm.setPWMFreq(60)  # Set frequency to 60 Hz
pwm.softwareReset()
Exemple #6
0
#!/usr/bin/env python
import rospy
import pigpio
from driver import PWM
from pwm_driver.msg import *

rospy.init_node('pwm_driver')

i2c_address = int(rospy.get_param('~i2c_address', '0x41'), 0)

motor_left_channel = rospy.get_param('/pins/launcher_motor_left_channel', 13)
motor_right_channel = rospy.get_param('/pins/launcher_motor_right_channel', 14)

pi = pigpio.pi()
pwm = PWM(pi, address=i2c_address)

pwm.set_frequency(50)


def handle_duty_cycle(msg):
    print 'DutyCycle'
    print msg
    pwm.set_duty_cycle(msg.channel, msg.value)


def handle_pulse_width(msg):
    print 'PulseWidth'
    print msg
    pwm.set_pulse_width(msg.channel, msg.value)

Exemple #7
0
#!/usr/bin/python

# RubpyxRobot Open Fingers Script
# By: Ryan Brazeal (and the I2C Club)
# Date: Started - Circa 2017

from driver import PWM
import os

# Initialise the PWM device using the default address
pwm = PWM(0x40)
# Set frequency to 60 Hz
pwm.setPWMFreq(60)

#Hardware Definition Parameters
whiteClamp = 0
whiteTwist = 1
blueClamp = 2
blueTwist = 3
yellowClamp = 4
yellowTwist = 5
redClamp = 6
redTwist = 7

#Calibration Parameters
whiteClampClosed = 0
whiteClampOpen = 0
whiteTwistNeutral = 0
whiteTwistCCW = 0
whiteTwistCW = 0
blueClampClosed = 0
Exemple #8
0
from driver import PWM
import pigpio
import time

pi = pigpio.pi()
pwm = PWM(pi, 0x41)

pwm.set_frequency(50)

speed_motors = 750
angle = 55


def set_angle(x):
    pente = -10.422
    offset = 2159.2
    angle = pente * x + offset

    pwm.set_pulse_width(11, angle)


def set_speed(x):
    pwm.set_pulse_width(13, x)
    pwm.set_pulse_width(14, x)


# reset trigger
pwm.set_pulse_width(12, 2300)

time.sleep(1)