PCA9685 with the propeller?
in Propeller 1
Hey guys, noob here.
Is there any way to use the PCA9685 i2c port expender with the propeller?
https://www.adafruit.com/product/815
Thanks!
Is there any way to use the PCA9685 i2c port expender with the propeller?
https://www.adafruit.com/product/815
Thanks!

Comments
Yes. I2C is used often on the propeller. Several objects in the OBEX.
@anybody
or if possible: Jérôme Decock
I found code on the obex for a PCA9685.
Going to try it soon. No instructions as to supposedly control individual servos.
Any simple ideas?
Thank you in advance.
Martin
@jeromelab
Hello. I have downloaded your code for the PCA9685. Wondering If you are still around and
If you could give me some simple instructions as to get started. I will be using two servos
on this device.
Thank you.
Martin
If you're only needing to control two servos -- and you have cog to spare -- you can easily do that in Spin (or any other P1 language). The CTRx module (in every cog) has two counters which will let your run two servos (without reconfiguring), and you get nice precision with your pulses (1us in this simple code). I've attached an easy, 2-servo object. it uses the PWM/NCO mode of the counter to create the servo pulses. The code as is lets you set the position in microseconds, but with the resolution of the system counter you could do sub-microsecond (e.g., 0.1) pulses if you like.
Here's quick check of the object output setting servo channel 0 to 1000us and servo channel 1 to 2000us.
If you're set on the PCA9685 you should start with downloading the datasheet. You'll need to learn the register assignments for controlling the PWM frequency and the settings for each pin/channel. I think I found the object you reference (which handles the gory details -- and is based on an Adafruit library that has documentation/examples); with the datasheet you should be able to suss out how things work, and get confirmation from an AI agent.
Link to my PCA9685 chat: https://chatgpt.com/share/6976dc93-4fd0-8006-97ca-524d29b35fb3
One thing to notice in that chat: with the PCA9685 your position resolution is 4.88us, roughly 5x chunkier than the 1us you can have with easy P1 code. In some applications this won't matter, but if you're looking for very fin control, you may not want to use the PCA9685.
Edit (26 JAN 26): Over coffee this morning I made some minor improvements to the simple 2-servo object (version is now 1.0.1).
There is a hint in the demo code.
The problem is that pulselen is not in microseconds as we're used to when dealing with servos. If I were going to use the PCA9685 I'd be inclined to add this method to simplify code conversion