Switzerland
Asked
Resolved Resolved by Dave Schulpius!

ESP32 And A PCA9685 To Control 16 Servomotors With ARC

Good day, my problem is this: I want to build a robot myself. I already have the following servo control components: ESP32 and a PCA9685 to control 16 servomotors.

I have already installed the ESP32 DOIT Dev Kit v1 EZ-B and the firmware for Synthiam and a control with 1 servo via WIFI works.

how can I connect the PCA9685 to the ESP32 so that I can control all of my 16 servos? (probably via the UART connection RX / TX). How can I link and control the whole thing with ARC?

could someone please help me with the programming? Regards Plokber


Related Hardware Esp32 DevKit v1

ARC Pro

Upgrade to ARC Pro

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.

PRO
USA
#1   — Edited

I used ARC with the ESP32 or Arduino and the the PCA9685

https://synthiam.com/Community/Robots/ESP32-and-ARC-Arduino-and-PCA-9685-20320

here it is with the Arduino with the PCA9685 - to control each servo individually

Downloaded Mickeys and DJ's firmware from here https://synthiam.com/Support/Hardware/Adafruit-16-Servo-Shield

I modified their code, added: Adafruit_PWMServoDriver pca9685 = Adafruit_PWMServoDriver(0x40);

for one PCA9685, if you want 2 PCA9685 just change the hex to (0x41) or 3 PCA9685 (0x42) and on and on...

in setup I added:

// Initialize PCA9685 pca9685.begin();

// Set PWM Frequency to 50Hz pca9685.setPWMFreq(50);

ARC connect Arduino at 57600 in settings

If your Arduino does not have a SDA or SCL

use: Analog 4 -> SDA Analog 5 -> SCL

GND to GND

VCC to 5v from Laptop computer

make sure you add a separate power supply - 5 - 7.5 V to the PCA9685 for the servos

easy connection

works very good

EzAng

PRO
Synthiam
#2   — Edited

Use this firmware instead: https://synthiam.com/Firmware/EZ-ESP32-with-PCA9685-O3HKWLPWOIO

Also, the PCA9685 does not use UART. It only uses i2c.

Switzerland
#3  

Thank you for the help, I have one more question:

how should I proceed so that I (instead of an Arduino) only have an ESP32 with a PCA9685 want to connect?

I had already installed EZ-B and the firmware for Synthiam on the ESP32 DOIT Dev Kit v1 and the control with 1 servo via WIFI worked happily :D

Now I just want to connect the PCA9685 to the ESP32 and then control my 16 servos with the ARC program.

Is there also an (Arduino code) for the ESP32 (like the Dev v1 EZ-B)? How can I use the firmware (https://synthiam.com/Firmware/EZ-ESP32-with-PCA9685-O3HKWLPWOIO ?

  1. Is it enough if I use the connections (RX / TX) on the ESP and (TX / RX) on the PCA9685?

  2. Which (settings) have to be set in the ARC for the servos? Regarts plokber

#4  

According to DJ the PCA9685 does not use UART. It only has a i2c interface. You need to connect the two boards (PCA9685 to the ESP32) through their 12c interfaces.

Here's a good article that will show you how to set up the ESP32 for I2C Communication: ESP32 using i2c

Here's your pinouts on the PCA9685: Pinouts on the PCA9685

BTW, I've never used either of these boards. I simply pulled up the info on google and the respective manufacturers websites.

Have fun!

PRO
Synthiam
#5  

Not sure what the complications are all about:) but the firmware page that has been linked to numerous times in this discussion answers every question, including diagram schematic...

here it is again: https://synthiam.com/Firmware/EZ-ESP32-with-PCA9685-O3HKWLPWOIO

Switzerland
#6  

Good day, Many Thanks!! Yes, the connection with ARC via the two (PCA9685 with the ESP32) has now worked perfectly:D:D I am really happy and motivated that I was able to carry out the various actions with my self-made robot.

Now I realized that I could use more than 16 servo connections for another robot project.

I also have a 32 servo controller (VER 3.2 from rtrobot) in my component box, which I have already used for another project. Now I would like to be able to control this with 32 servo controllers with the ARC. I tried to connect the connections to the ESP32 via TX / RX, but it didn't work that way. Do you have a solution for the connection of the otherwise well-functioning 32 servo controller with the ARC program? Greeting plokber

#7   — Edited

Update, I am sorry to have bothered you.  I think I have it sorted now.  D0-D5 while represented on ARC under the Auto Position as being part of the board, it looks like they represent the 0-5 positions of the motor driver.  Once I figured that out it was easy to get them functioning.

So for the record.  I am good to go. ----end update I hate to buzz by and ask a stupid question...but since when has that stopped me?!  lmao.

I am new to ARC not to iot or other software such as Blynk.   BUT I am having difficulty and cannot find a solid answer.  Downloaded the latest firmware and install/uploaded it to the esp32 dev kit.  connected my pca9685 via pins next to the RX/TX pins, on my dev kit it says 22 and 21.  To test the communication via i2c, I used the pca9685 example in ide.  BUT when I go to make something move I am not having any luck.  I added a servo via settings, set it to v0 and created a frame and action...execute it and nothing happens.  Oddly enough when I click "Stop" the servo will jitter a little.

I think I may be missing something within ARC that I just don't see.  BUT it looks like I create a servo object then add actions to it that I can exectute but that is not working.  As I understand the firmware's description digital pins are for servo use when connected to the ESP directly, so I am assuming Virtual pins are via the i2c connection?

Any ideas, or advice...much appreciated!

PRO
USA
#8  

I don't know if will help.

Nothing would move for me until I added a "separate" 5 to 7.5 v power supply, I use into the PCA 9685

PRO
Synthiam
#9  

Vx ports are only virtual ports for robot skills that connect directly to hardware that isn’t an ezb

Ezb firmware devices can only use Dx ports

so you just use Dx ports and not Vx ports for your setup

#10  

Thanks DJ.  I have everything moving and such.  The goal is to be able to program it to do things.  Nothing special, just a few pre-programmed movements, and maybe a manual control from the app joystick interface.  I have loaded the Auto Position skill, but no matter what I do, I cannot get it to move fluidly.  They move fast, and stop abruptly... I don't want anyone to do this for us, but I would love to see some sample projects that use a servo or several servos.  It looks like I can load sample/example things.  Gonna research more on it.  I would like smooth fluid movement, without the jerking, and ability to be more precise...which is possible with the hardware because I did the arduino IDE tests.

I am also being told I should be using Steppers for more precision, but I know these can do similar...anyway.

If anyone has a project that they could share similar to this that would be sweet.  The incorporating of the various things to get a good finished product is not clear from what I have been reading...and sadly youtube does not have a lot of ARC content. Thanks for existing though.

:)

#11  

To get your servos to move smoother you need to adjust your steps and servo speeds in the Auto Position control. Look in the toutoral for how to do this.

PRO
USA
#12  

On my crane robot https://youtu.be/zoUA-PuaPfE

I used DJ's new Global servo positioning feature for the smoothness of the moves for the servos watch video

https://synthiam.com/Products/ARC/Releases/ARC-2021-03-24-00-Early-Access-Runtime-20451

#13  

Yes, following DJ's Global servo positioning feature that EzAng mentions should smooth out servo movements. It's worth a try. I really helpped myt servos move nicer.

However to expand on my above comment, you may want to look into the Step/Delay and Speed Settings in the Action section sence you're using the AutoPosition panel. Adjusting these settings may give you the results you are looking for. They are not really intuitive and require some fiddling around to find the right settings.

Here is a link to how to use and adjust the movements in the AP. Scroll down for the Step/Delay Settings instructions: AP Instructions

PRO
Synthiam
#14   — Edited

The Auto Position action should have a small servo increment and more considerable delay, giving you more smoothness. And if the PCA supports a servo speed feature (Which I don't believe it does), then you would also be able to use servo speed for extra smoothness that depends on the hardware controller. The Auto Position manual explains more about the options I just mentioned: https://synthiam.com/Support/Skills/Servo/Auto-Position-Gait?id=20314

It might take a bit of reading, but once you get it, you get it :)

The accuracy of servos will not compete with stepper motors. The stepper motor may use the same programming interface in ARC, but the accuracy is much higher.

The global servo position option is in the top menu Project -> My Robot -> Properties. See more here: https://synthiam.com/Support/ARC-Overview/Project%20Menu/My%20Robot.

#15   — Edited

Thanks DJ. I should have said "the AP setting  are not really intuitive for me". LOL. Sometime I have a hard time wrapping my brain around things. Your explanation really helped me to understand better.

PRO
Synthiam
#16  

Anytime, Dave :)

by the way, if stepper motors are to be considered, here’s the robot skill manual: https://synthiam.com/Support/Skills/Servo/Stepper-Servo?id=21134

#17  

Thank you all for the suggestions.  Will be doing some homework after this work week to see what I can do with what you all mentioned.

I do have some steppers from my upgrades printer.  Might try integrating them once I have a handle on the use of ARC a little better.

I think I ran across the mentioned Auto Position Gait heading but it did not occur to me it was for what I was seeking.  Will dig more.

Thanks again!

#18  

I got the afternoon off from work so we dug into this for a couple hours.  Once you made that suggestion I read over the manual aspects concerning it.  Then I realized we were under powering the controller board by enough to make most of the jerkiness a problem.  Proper power supply is essential.  #notmyfaulttheylookthesame...lol.

After that, and messing with steps and speed, it works.  Pretty smooth.  Smoother if I go slow with a little delay...and moving multiple motors works well.

Love it.

Now I gotta figure out how to build more stuff wanna make this battery powered and since I have a continuous servo for the base motor gotta figure out how to mount everything inside the movement zone...100% wireless...and able to rotate without tangling...which IS NOT the case currently.

Thanks so much. Once we have this where we can use it...we will upload it for ARC's community to play with.

PRO
Synthiam
#19  

That’s super great to hear it’s coming together. The feeling of success is unbeatable!

There’s a decent write up about types of batteries and such. Here’s the link, it’s not a long read: https://synthiam.com/Support/Get-Started/how-to-make-a-robot/power

i generally use 7.4v lipo batteries for all my robots. If the robot has an onboard pc, I use a high amp battery backup charger that you’d normally carry in a bag for charging phones on the go. They have high amperage and output 5 or 12 volts. I don’t use them for motors, I only use them for the pc. The motors i power with the 7.4v lipo