PCA9865 16 servo controller board using I2C.

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
User avatar
gcarver
Posts: 34
Joined: Sun Oct 26, 2014 4:07 am
Location: New Market, Maryland
Contact:

PCA9865 16 servo controller board using I2C.

Post by gcarver » Wed Feb 28, 2018 6:22 pm

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.
End of line...

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: PCA9865 16 servo controller board using I2C.

Post by OutoftheBOTS_ » Wed Feb 28, 2018 9:27 pm

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)

User avatar
gcarver
Posts: 34
Joined: Sun Oct 26, 2014 4:07 am
Location: New Market, Maryland
Contact:

Re: PCA9865 16 servo controller board using I2C.

Post by gcarver » Wed Feb 28, 2018 10:52 pm

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.
End of line...

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: PCA9865 16 servo controller board using I2C.

Post by OutoftheBOTS_ » Thu Mar 01, 2018 5:21 am

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 25862 times
Last edited by OutoftheBOTS_ on Thu Mar 01, 2018 6:38 am, edited 2 times in total.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: PCA9865 16 servo controller board using I2C.

Post by OutoftheBOTS_ » Thu Mar 01, 2018 5:28 am

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

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: PCA9865 16 servo controller board using I2C.

Post by deshipu » Thu Mar 01, 2018 1:34 pm


User avatar
gcarver
Posts: 34
Joined: Sun Oct 26, 2014 4:07 am
Location: New Market, Maryland
Contact:

Re: PCA9865 16 servo controller board using I2C.

Post by gcarver » Thu Mar 01, 2018 3:17 pm

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.
End of line...

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: PCA9865 16 servo controller board using I2C.

Post by OutoftheBOTS_ » Thu Mar 01, 2018 8:40 pm

@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.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: PCA9865 16 servo controller board using I2C.

Post by OutoftheBOTS_ » Fri Mar 02, 2018 4:51 am

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

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: PCA9865 16 servo controller board using I2C.

Post by deshipu » Fri Mar 02, 2018 1:26 pm

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?

Post Reply