Page 1 of 2

PCA9865 16 servo controller board using I2C.

Posted: Wed Feb 28, 2018 6:22 pm
by gcarver
https://github.com/GuyCarver/MicroPytho ... pca9865.py

ESP32:
https://github.com/GuyCarver/MicroPytho ... pca9865.py

Really just a PWM signal generator with external power supply so it could be used for LED control as well.

Re: PCA9865 16 servo controller board using I2C.

Posted: Wed Feb 28, 2018 9:27 pm
by OutoftheBOTS_
Thanks a lot for the driver it is a chip that I use a lot on my robots. Your driver is nice and light weight but very functional and easy to use.

Is it MIT?

Also 1 change that I will make when I use it is add the option to choose the slave address as PCA9865 has a select-able address which I very occasionally use in order to chain 2 PCA9865 controllers together for robots that use more than 16 servos (like a hexapod robot uses 18 servos see https://www.youtube.com/watch?v=98wfZPm2mes&t=132s)

Re: PCA9865 16 servo controller board using I2C.

Posted: Wed Feb 28, 2018 10:52 pm
by gcarver
I have never slaved I2C yet but I'm sure in the future I will have to. So I'd be interested in that change.

Re: PCA9865 16 servo controller board using I2C.

Posted: Thu Mar 01, 2018 5:21 am
by OutoftheBOTS_
currently the address that you use for the PCA9865 is _ADDRESS = 0x40 but this address is select-able for the PCA9865. Most servo boards that use this chip will have solder pad that you jump to change the slave address (they work like binary numbers). If you want to use more than 1 board at a time then you just change the slave address of each board with the solder jumpers and in your software you just have to address each board. Most of these servo boards also have 2 sets of pins for connecting the I2C so that it is easy to daisy chain them together see attached pic
PCA.jpg
PCA.jpg (153.26 KiB) Viewed 2145 times

Re: PCA9865 16 servo controller board using I2C.

Posted: Thu Mar 01, 2018 5:28 am
by OutoftheBOTS_
you would just need to change a couple of lines of code for the address to be select-able

Code: Select all

def __init__(self, aSDA, aSCL, slave_address=0x40)
  self._ADDRESS = slave_address
This would then use the default address of 0x40 but allow the user to use a different address if they need

Re: PCA9865 16 servo controller board using I2C.

Posted: Thu Mar 01, 2018 1:34 pm
by deshipu

Re: PCA9865 16 servo controller board using I2C.

Posted: Thu Mar 01, 2018 3:17 pm
by gcarver
deshipu wrote:
Thu Mar 01, 2018 1:34 pm
What's wrong with https://github.com/adafruit/micropython ... it-pca9685 ?
Nothing, other than not knowing it existed. When I wrote this nothing popped up in google searches.

Re: PCA9865 16 servo controller board using I2C.

Posted: Thu Mar 01, 2018 8:40 pm
by OutoftheBOTS_
@deshipu

Also a very nice driver too. It is handy that it can take position in radians as all Python trig function return radians.

The driver that I wrote for the PCA9865 for the RPi I wrote using degrees but then when I made my quadraped robot that was a pain because I use python Trig functions to convert the Cartesian x,y,z position of the foot into angles of the 3 servos on the 3 joints of each leg. The python trig functions return radians which I then had to convert to degree for my servo driver.

Re: PCA9865 16 servo controller board using I2C.

Posted: Fri Mar 02, 2018 4:51 am
by OutoftheBOTS_
I may end up porting across the RPi driver that I wrote as well for anyone that wants to use it because it makes use of the PCA9865 ability to stagger the pulses so that no 2 of the 16 servo are kicking at once. This greatly reduces the huge spike in current that is caused when 16 servo all try to re-position them selves all at the same time that trips the over current protection on batteries. A nice little write up here about the spikes in current from servos by pololu https://www.pololu.com/blog/17/servo-co ... -in-detail

Re: PCA9865 16 servo controller board using I2C.

Posted: Fri Mar 02, 2018 1:26 pm
by deshipu
Thanks. I first wrote the code for the robots, and then isolated it into a separate driver — that's why I knew to use radians. Mind me if I steal the idea of staggered pulses and add it to the Adafruit driver?