Arduino-I2C-Port-Expander icon indicating copy to clipboard operation
Arduino-I2C-Port-Expander copied to clipboard

using to emulate a PCA9685

Open dlarue opened this issue 6 years ago • 7 comments

I'm building a Donkey2 autonomous RC car(DIYRoboCars.com) and they use an rPi controlling the 2 RC servos via a PCA9685( I2C PWM driver). It works great except to train the neural network we have to drive the vehicle manually and record video and the PWM/Servo signals. How it's done now is it requires driving the car va WiFi connection to the rPi using a table/phone/webpage. ugh.

I want to replace the PCA9685 board with an Arduino which emulates the PCA9685 driver but can also be switched so the Arduino reads PWM signals from the real RC receiver and maps those to the same servo outputs normally driven vi the I2C interface. I'll have to add a change to the rPi/Donkey code to poll/read the PWM values from the emulator with an added method to read the current PWM settings/values.

Adafruit's library for their PCA9685 board: https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library

If you're interested in any of this let me know.

dlarue avatar Aug 13 '17 18:08 dlarue

Hi @dlarue I'm working on the same project. I was able to get the passthrough from the original controller working and now I was going to emulate the PCA9685 so minimum change is required on the Donkey code. Have you made any progress?

juano2310 avatar Aug 26 '18 17:08 juano2310

@juano2310 I've not gone any further since the option for using the Sony PS3 controller was added and works great. Once we start going out doors and on larger tracks the RC transmitter option would probably be required. But I'm spoiled by all the buttons on the PS3 controller and would probably have to work on adding the ability for RC channels to be used for buttons/triggers to the rPi. Something you might consider as you develop the I2C API.

dlarue avatar Aug 26 '18 17:08 dlarue

Hi @dlarue, I was able to efficiently emulate the PCA9685 and bridge the RC receiver which can also take control if the RC Controller is turned on. I will publish as soon as I get some time to write the tutorial. I might even make a Raspberry Pi hat removing the need from having the PCA9685.

juano2310 avatar Aug 28 '18 15:08 juano2310

That's great! Hat's are fine and can be a place to add even more features but they also add cost. Which Arduino are you using and can't it be used in the "dead bug" configuration so anyone wanting to try it needs only a few jumper wires( like the PCA9685 )?

dlarue avatar Aug 28 '18 15:08 dlarue

I had made a couple of PCBs in the past. I can get 3 for 1 dollar now plus a esp8266 for an other 2,5 and a couple of headers so a total of 4 dollars that is very competitive considering that this would replace the PCA9685 completely. I tested with the Particle Photon because I like to flash the code remotely but definitely can be used with a couple of jumpers. I posted a picture here of the complete setup. https://twitter.com/juano2310/status/1034455168899862531 Which other connectors would you add to the hat besides more I2C connectors to connect more sensors?

juano2310 avatar Aug 28 '18 15:08 juano2310

I had made a couple of PCBs in the past. I can get 3 for 1 dollar now plus a esp8266 for an other 2,5 and a couple of headers so a total of 4 dollars that is very competitive considering that this would replace the PCA9685 completely. I tested with the Particle Photon because I like to flash the code remotely but definitely can be used with a couple of jumpers. I posted a picture here of the complete setup. https://twitter.com/juano2310/status/1034455168899862531 Which other connectors would you add to the hat besides more I2C connectors to connect more sensors?

Hello John. Did you get to publish the emulation code of the PCA9685 chip? Right now I'm working on emulating it for a project with a Jetson Nano and an Mbot robot, and it would be helpful not to have to start from zero...

eliasedgar99 avatar Dec 01 '21 21:12 eliasedgar99

FWIW, there was work done on PCA9685 for a project which used a Teensy and I recall having used it so it was operational. But it was 2 year ago so not sure what the state of it is or if anyone is using it. Google for teensy_hat_firmware

For RC control use what I did was take an Arduino Leonardo based board(32u4) and read the RC receivers PWM then created a joystick HiD device and map the RC PWM to joystick movement. Almost no code changes required in the donkey software. That was added to the v3.2 codebase of donkey as an input controller type. I have no idea if it's included in the v4.x codebase.

Oh ya, I added customizations for buttons and forked the repo - here is my repo https://github.com/dlarue/donkey_stuff/tree/master/teensy_hat_firmware

dlarue avatar Dec 01 '21 22:12 dlarue