Hallo liebes Forum,
Ich möchte mir einen, wie im Titel erwähnt, Roboter mit visueller Intelligenz bauen.
Ich habe schon mehrere Roboter auf arduino Basis gabaut und programmiert.
Dieses Mal soll es auf Basis des Raspberry Pi sein. Dabei möchte ich eine Menge über OpenCV und Python lernen, was beides noch Neuland ist. Mit mehreren Raspberrys arbeite ich schon über Jahre in meinem Smarthome.
Daher ist der Umgang mit Elektronik und linux gegeben.
Nun zu meiner Frage:
Ich vergeude jetzt nun schon den 3. Abend damit ein PCA9685 zum laufen zu bekommen. Ich habe sämtliche Anleitungen und Beispielscripts die das Netz so hergibt durch.
Um auf Nummer sicher zu gehen habe ich heute noch mal das Raspian Bullseye neu aufgesetzt und Python3 und Adafruit circuit Python und Blynka nach Vorgabe von Adafruit aufgesetzt.
Das PCA9685 habe ich an SDA 5 und SCL 3 sowie 3,3 V und GND angeschlossen. Es wird am I2C an 0x40 erkannt.
Den Raspberry versorge ich über ein Step-down-Converter mit 5 V. Einspeisung ist ein Netzteil mit 7,5 V und 3 A. Später soll das ein RC-Akku mit 7,2 V übernehmen. Der Akku/Netzteil geht außerdem auf einen L298N welcher mit einem 5 V Ausgang den PCA9685 versorgt. GND geht hier ebenfalls zum Akku.
Wie gesagt zuckt sich nichts an den Servos. Python zeigt keine Fehler und die Skripte laufen durch.
Ein OLED läuft erfolgreich am I2C.
Ich vermute dass ich hier einen generellen Fehler mache und ohne Hilfe nicht weiter komme.
Ich hoffe daher, dass jemand mir meine Denkfehler aufzeigen kann. Die Suche habe ich bemüht, allerdings nichts passendes gefunden.
Hier noch die beiden Beispiele von Adafruit.
Vielen Dank für eure Mühe.
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""Simple test for a standard servo on channel 0 and a continuous rotation servo on channel 1."""
import time
from adafruit_servokit import ServoKit
# Set channels to the number of servo channels on your kit.
# 8 for FeatherWing, 16 for Shield/HAT/Bonnet.
kit = ServoKit(channels=8)
kit.servo[0].angle = 180
kit.continuous_servo[1].throttle = 1
time.sleep(1)
kit.continuous_servo[1].throttle = -1
time.sleep(1)
kit.servo[0].angle = 0
kit.continuous_servo[1].throttle = 0
Alles anzeigen
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import time
from board import SCL, SDA
import busio
# Import the PCA9685 module. Available in the bundle and here:
# https://github.com/adafruit/Adafruit_CircuitPython_PCA9685
from adafruit_motor import servo
from adafruit_pca9685 import PCA9685
i2c = busio.I2C(SCL, SDA)
# Create a simple PCA9685 class instance.
pca = PCA9685(i2c)
# You can optionally provide a finer tuned reference clock speed to improve the accuracy of the
# timing pulses. This calibration will be specific to each board and its environment. See the
# calibration.py example in the PCA9685 driver.
# pca = PCA9685(i2c, reference_clock_speed=25630710)
pca.frequency = 50
# To get the full range of the servo you will likely need to adjust the min_pulse and max_pulse to
# match the stall points of the servo.
# This is an example for the Sub-micro servo: https://www.adafruit.com/product/2201
# servo7 = servo.Servo(pca.channels[7], min_pulse=580, max_pulse=2350)
# This is an example for the Micro Servo - High Powered, High Torque Metal Gear:
# https://www.adafruit.com/product/2307
# servo7 = servo.Servo(pca.channels[7], min_pulse=500, max_pulse=2600)
# This is an example for the Standard servo - TowerPro SG-5010 - 5010:
# https://www.adafruit.com/product/155
# servo7 = servo.Servo(pca.channels[7], min_pulse=400, max_pulse=2400)
# This is an example for the Analog Feedback Servo: https://www.adafruit.com/product/1404
# servo7 = servo.Servo(pca.channels[7], min_pulse=600, max_pulse=2500)
# This is an example for the Micro servo - TowerPro SG-92R: https://www.adafruit.com/product/169
# servo7 = servo.Servo(pca.channels[7], min_pulse=500, max_pulse=2400)
# The pulse range is 750 - 2250 by default. This range typically gives 135 degrees of
# range, but the default is to use 180 degrees. You can specify the expected range if you wish:
# servo7 = servo.Servo(pca.channels[7], actuation_range=135)
servo7 = servo.Servo(pca.channels[7])
# We sleep in the loops to give the servo time to move into position.
for i in range(180):
servo7.angle = i
time.sleep(0.03)
for i in range(180):
servo7.angle = 180 - i
time.sleep(0.03)
# You can also specify the movement fractionally.
fraction = 0.0
while fraction < 1.0:
servo7.fraction = fraction
fraction += 0.01
time.sleep(0.03)
pca.deinit()
Alles anzeigen
VG Chris