
latest 1.1.823 | nixie project | matrix
This is a MyRobotLab service to support the Adafruit 16-Channel 12-bit PWM/Servo Driver attached to an Arduino or a Raspberry PI. It can be used with any board that use the PCA9685 circuit. It is dedicated to do PWM ( Pulse Width Modulation ) and it uses the i2c protocol. Since it can do PWM it can also be used to control a Motor driver. The pins can also be used as digital output pins or analog output pins. When used as analog output pins they are not true analog, but pwm.
Go to Adafruit product page for more descriptions on details of the driver.
Some examples of other boards that also can be used:
Adafruit 16-Channel PWM / Servo HAT for Raspberry Pi
Adafruit 16-Channel 12-bit PWM/Servo Shield for Arduino
8-Channel PWM or Servo FeatherWing Add-on For All Feather Boards
Steps to control Servo Driver using the Arduino.
Steps to use the Servo Driver using the Raspberry PI.
References
######################################### # Adafruit16CServoDriver.py # description: servo driver # categories: servo shield # more info @: http://myrobotlab.org/service/Adafruit16CServoDriver ######################################### # From version 1.0.2316 use attach instead of setController # An example of how to use the Adafruit16CServoDriver to # drive a motor. # # config port = "COM99" # Runtime.start("WebGui", "WebGui"); arduino = Runtime.start("Arduino", "Arduino"); arduino.connect(port) sleep(5) ada = Runtime.start("Ada","Adafruit16CServoDriver") # ada.setController(arduino,"1","0x40") ada.attach(arduino,"1","0x40") sleep(2) motor01 = Runtime.start("motor01", "Motor"); motor01.setPwmPins(0,1); motor01.attach(ada); motor01.move(0.3);
# From version 1.0.2316 use attach instead of setController # This script is if you use the GPOI pins of the Raspberry PI raspi = Runtime.start("raspi","RasPi") # adaFruit16c.setController("RasPi","1","0x40") adaFruit16c = Runtime.start("adaFruit16c","Adafruit16CServoDriver") adaFruit16c.attach(raspi,"1","0x40") # # This part is common for both devices and creates two servo instances # on port 3 and 8 on the Adafruit16CServoDriver # Change the names of the servos and the pin numbers to your usage thumb = Runtime.start("thumb", "Servo") # attach it to the pwm board - pin 9 thumb.attach(adaFruit16c,9) # When this script has been executed you should be able to # move the servos using the GUI or using python thumb.setVelocity(40) thumb.moveToBlocking(0) thumb.moveToBlocking(180) thumb.moveToBlocking(0) thumb.moveToBlocking(180)
#file : Adafruit16CServoDriver.py edit raw
######################################### # Adafruit16CServoDriver.py # description: servo control # categories: servo control # more info @: http://myrobotlab.org/service/Adafruit16CServoDriver ######################################### # This example shows how to use the Adafruit16CServoDriver # It can be used with Arduino, RasPi or Esp8266_01 # From version 1.0.2316 use attach instead of setController # # config port = "COM3" # Code to be able to use this script with virtalArduino if ('virtual' in globals() and virtual): virtualArduino = Runtime.start("virtualArduino", "VirtualArduino") virtualArduino.connect(port) # Start the Adafruit16CServodriver that can be used for all PCA9685 devices adaFruit16c = Runtime.start("AdaFruit16C","Adafruit16CServoDriver") # # This part of the script is for the Arduino # Comment it out the three lines below if you don't use the Arduino # Change COM3 to the port where your Arduino is connected arduino = Runtime.start("arduino","Arduino") arduino.connect(port) adaFruit16c.attach("arduino","0","0x40") # # This part of the script is if you use the GPOI pins of the Raspberry PI # Uncomment the two lines below if you use the RasPi # raspi = Runtime.createAndStart("raspi","RasPi") # adaFruit16c.attach("raspi","1","0x40") # # This part of the script is if you use the Esp8266_01 service # Uncomment it the two lines below if you duse the Esp8266_01 # esp = Runtime.start("esp","Esp8266_01") # adaFruit16c.attach("esp","1","0x40") # # This part is common for both devices and creates two servo instances # on port 3 and 8 on the Adafruit16CServoDriver # Change the names of the servos and the pin numbers to your usage thumb = Runtime.start("Thumb", "Servo") elbow = Runtime.start("Elbow", "Servo") # attach it to the pwm board - pin 3 & 8 thumb.attach(adaFruit16c,3) elbow.attach(adaFruit16c,8) # When this script has been executed you should be able to # move the servos using the GUI or using python
tested
AND APROVED !
I will test it more
thank you
Adafruit16CServoDriver
I finished updating and testing the Adafruit16CServoDriver today. So if you want, you can download an test in in the 'latest build'.
attach() and detach() should be working now.
I also updated it so that setVelocity and setAcceleration can be used.
Please test and report if you find anything strange,
Great news Mats ! thank about
Great news Mats ! thank about the work you ve done. I'm happy to test it soon on the little robot
Hi ! I have done some test ( raspy mrl 1893 )
Hi ! I have done some test , it is better ! This is the results
If I use somewhere servo.detach() , I can't attach anymore. But now if I restart MRL it worky again.
If I didn't use servo.detach() but I declare servo.autoAttach(1) an some sleep between servo declaration it seem works better
SCRIPT :
https://github.com/MyRobotLab/pyrobotlab/blob/master/home/moz4r/Marty/ma...
Attach() / Detach()
Hi Moz4r
I made a change in the 'lastest build' so that it should work now. But please test again.
If you still find a problem, please provide a small script showing the problem so that I can recreate it.
/Mats
just perfect. thank you so
just perfect. thank you so much
Hi Mats ! I think setVelocity
Hi Mats ! I think setVelocity is broken on last mrl . Speed always at full speed , can you confirm ?
setVelocity
I can confirm that it is/was broken. I found the reason and it's correced in 1932.
I tested a servo connected to the Arduino. I also found that something is broken with the combination of Servo >= Adafruit16CServoDriver => Arduino
I need to dig into that. I hope that it's just related to the Arduino so that it still works on the RasPi.
worky ! Thank again
worky ! Thank again