Exemplo n.º 1
0
class motor(NAVIO_RCOUTPUT):
	navio.util.check_apm()
	NAVIO_RCOUTPUT += 2
	
	#drive Output Enable in PCA low
	pin = navio.gpio.Pin(27)
	pin.write(0)

	PCA9685_DEFAULT_ADDRESS = 0x40
	frequency = 50

	#NAVIO_RCOUTPUT_1 = 3
	SERVO_MIN_ms = 1.250 # mS
	SERVO_MAX_ms = 1.750 # mS

	#Convertir mS a rango 0-4096:
	SERVO_MIN = math.trunc((SERVO_MIN_ms * 4096.0) / (1000.0 / frequency) - 1)
	SERVO_MAX = math.trunc((SERVO_MAX_ms * 4096.0) / (1000.0 / frequency) - 1)

	pwm = PWM(0x40, debug=False)

	#Set frecuencia
	pwm.setPWMFreq(frequency)
	
	def MotorOn:
		pwm.setPWM(self.NAVIO_RCOUTPUT, 0, self.SERVO_MAX);
	def MotorOff:
		pwm.setPWM(self.NAVIO_RCOUTPUT, 0, self.SERVO_MIN);
Exemplo n.º 2
0
    def __init__(self, hdwr):
        # ---- Setup PWM Generator ----
        self.pin = navio.gpio.Pin(27)  #Enable OE pin output.
        self.pin.write(
            0
        )  #Drive the PCA9685BS model HVQFN28's OE pin #20 (27 RPI2) to "LOW"

        self.frequency = 45.05  #This frequency prioritizes use of the ESC and plays well with the servo.
        self.period = 1.0 / self.frequency
        """
		Please use 45.05Hz to properly operate the ESC controller.
		Please use frequencies 50Hz OR 300Hz for this code to reliably operate the steering servo.
		Other intermittent frequencies like 60,90,100 may or may not work. There doesn't appear to be a pattern.
		"""

        self.PCA9685_DEFAULT_ADDRESS = 0x40  #Adresses the PCA9685BS register controlling LED14_OFF_L
        self.pwm = PWM(
            0x40, debug=False
        )  #Send the PWM register address to be used by internal modules adafruit_pwm_servo_driver.py, adafruit_i2c.py, and ultimately smbus.py
        self.pwm.setPWMFreq(
            self.frequency)  #Set output pulse frequency of the PCA9685.
        # ---- End PWM Generator Setup ----

        # ---- Set Separate PWM Constants ----
        if (hdwr == "servo"):
            self.servoInit()
            self.rest()
        elif (hdwr == "esc"):
            self.escInit()
            self.stop()
        else:
            sys.exit("Specify the hardware to use vehiclePWM")
Exemplo n.º 3
0
class rele:
	def __init__(self, NAVIO_RCOUTPUT):
		self.NAVIO_RCOUTPUT = NAVIO_RCOUTPUT + 2 
		self.inicial = inicial
		
	navio.util.check_apm()
	
	
	#drive Output Enable in PCA low
	pin = navio.gpio.Pin(27)
	pin.write(0)

	PCA9685_DEFAULT_ADDRESS = 0x40
	frequency = 50

	#NAVIO_RCOUTPUT_1 = 3
	SERVO_MIN_ms = 1.000 # mS
	SERVO_MAX_ms = 2.000 # mS

	#Convertir mS a rango 0-4096:
	SERVO_MIN = math.trunc((SERVO_MIN_ms * 4096.0) / (1000.0 / frequency) - 1)
	SERVO_MAX = math.trunc((SERVO_MAX_ms * 4096.0) / (1000.0 / frequency) - 1)

	pwm = PWM(0x40, debug=False)

	#Set frecuencia
	pwm.setPWMFreq(frequency)
	
	def ReleOn:
		pwm.setPWM(self.NAVIO_RCOUTPUT, 0, self.SERVO_MAX);
	def ReleOff:
		pwm.setPWM(self.NAVIO_RCOUTPUT, 0, self.SERVO_MIN);
Exemplo n.º 4
0
navio.util.check_apm()

#drive Output Enable in PCA low
pcaPin = 27
GPIO.setmode(GPIO.BCM)
GPIO.setup(pcaPin, GPIO.OUT)
GPIO.output(pcaPin, GPIO.LOW)

PCA9685_DEFAULT_ADDRESS = 0x40
frequency = 50

NAVIO_RCOUTPUT_1 = 3
SERVO_MIN_ms = 1.250  # mS
SERVO_MAX_ms = 1.750  # mS

#convert mS to 0-4096 scale:
SERVO_MIN = math.trunc((SERVO_MIN_ms * 4096.0) / (1000.0 / frequency) - 1)
SERVO_MAX = math.trunc((SERVO_MAX_ms * 4096.0) / (1000.0 / frequency) - 1)

pwm = PWM(0x40, debug=False)

# Set frequency to 60 Hz
pwm.setPWMFreq(frequency)

while (True):
    pwm.setPWM(NAVIO_RCOUTPUT_1, 0, SERVO_MIN)
    time.sleep(1)
    pwm.setPWM(NAVIO_RCOUTPUT_1, 0, SERVO_MAX)
    time.sleep(1)