Trouble using linked PCA9685 boards

Hello all, this is my first time posting on the Arduino forum so please bear with me.

To give a brief description of my project, I am making a hexapod (6 legged robot) and have decided to chain two PCA9685 boards together to an Arduino Mega to be able to control all the motors I need. I've done a fair bit of research on the project from other people's tutorials and know all about not powering the servos directly from the board and so on. My issue is that servos that are connected to board 2 are for some reason being controlled by commands meant for board 1 servos. (To specify, I'm connecting the pwm pins from the PCA9685 boards to the servos themselves)

Below is how I've called both boards.

Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x40); // First board
Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x41); // Second board

Then, I denoted what leg has what servos in it for each board.

int servoPins1[legset] = {0,1,2,3,4,5,6,7,8}; // 3 legs, 9 servos
// Leg 1: 0,1,2 B1
// Leg 2: 3,4,5 B1
// Leg 3: 6,7,8 B1
// Leg 4: 0,1,2 B2
// Leg 5: 3,4,5 B2
// Leg 6: 6,7,8 B2

Next, I start both boards in void setup.

pwm1.begin(); // First board
  pwm1.setPWMFreq(SERVO_FREQ);  // Analog servos run at ~50 Hz updates
  pwm2.begin(); // Second board
  pwm2.setPWMFreq(SERVO_FREQ);  // Analog servos run at ~50 Hz updates

Finally, in void loop I'm using these commands to move the servos depending on an input from a joystick (that code is not shown here because I've isolated it and determined its not the problem).

for (int i =0; i < 9; i++) { // B1 servos
    if (i==0 || i==3 || i==6){
      pwm1.setPWM(servoPins1[i], 0, convert2angle(J1_Rest_B1));
    }
    else if (i==1 || i==4 || i==7){
      pwm1.setPWM(servoPins1[i], 0, convert2angle(J2_Rest));
    }
    else {
      pwm1.setPWM(servoPins1[i], 0, convert2angle(J3_Rest));
    }
  }
  delay(125);
for (int i =0; i < 9; i++) { // B2 servos
    if (i==0 || i==3 || i==6){
      pwm2.setPWM(servoPins1[i], 0, convert2angle(J1_Rest_B2));
    }
    else if (i==1 || i==4 || i==7){
      pwm2.setPWM(servoPins1[i], 0, convert2angle(J2_Rest));
    }
    else {
      pwm2.setPWM(servoPins1[i], 0, convert2angle(J3_Rest));
    }
  }

This code, in theory, should move all legs to a default standing position that I've done the math for.

Now comes the problem. I noticed that when I only power a leg connected to board 2 and comment out all board 2 code, the leg will then act on commands linked to board 1. Is this a built in feature with the PCA9685 Arduino code? I don't see how it could be, because I've specified that board 1 and 2 are different. There are only 2 issues I see is that it could be. A soldering issue as I'm very new to it and thus not that good. Below are pictures of my work.


*Board 2 binary pin soldered over, and shows board 2 is receiving power.

*Boards soldered together. Solder is NOT touching as far as I can tell.

Or, it could be a powering issue. Both boards are linked together and powered directly from the Arduino Mega. Could it be that the Arduino's 5V pin doesn't have enough ampage to power both boards at the same time? If so, why would the servos still move if they're wired to a different pwm signal than the one the code specifies?

Thank you for any future help!

Can you run the i2c_scanner sketch? If your solder worked, you'll see both boards.

Did you change the address on one of the boards themselves as well? Or do both PCA9685 boards still have their default address?

[edit]
nevermind, I see it now
[/edit]

If you click on, then zoom in on the first pic, the solder on the address pad is hazy, like a cold solder joint. It should have a chrome-like appearance.

Did you read the datasheet for addresses?


I found a scanner code online and it looks like the second board (0x41) isn't appearing like it should be. I also powered the board separately with 5V and 1A, which should be plenty for the two boards even at full ampage draw, and got the same reading. Could it be the solder isn't correct like you implied in your other comment? If so, how would I fix it?

I did a little, but honestly I'm not too versed in how to really understand datasheets at a technical level. I see the "All Call" function it mentions, could that be what's applying to my boards?

First take care of main address, if scanner didn't find them both, it means they have same address set.
"hardware address pins"

Hi, @redstone2020
Welcome to the forum.

Can you please post images of the two 9685 boards so we can see the programming pads that you have soldered?

Do you have a DMM? Digital MultiMeter?

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
You do not have to show all the servos, but your power supply, Mega and 9685 connections would be fine.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Your soldering looks very dodgy!

Do you see those solder joints that were on the boards when they arrived? That's what your solder joints should look like, or very close.

Suggest you re-solder all the joints you made. Use a solder sucker to remove all the solder, then re-make the joints.

Soldering_Results

Absolutely, and yes I do have a DMM.


*This circuit shows legs 1 and 4. Each is wired to a different PCA9685 board. The external power supply is a desk setup I have that can give any combination of volts and amps needed for a project like this. Because two legs are attached here, I would change it to 5V with 13 Amps. (2 Amps per servo and 1 Amp for both PCA9685 boards to use)


Front of PCA9685 boards with board 2 having solder over its first binary connection.

Yes I know my soldering skills leave much to be desired. Are their any soldering attachments that could help me get a better look or standard soldering tools you'd recommend to have? I only have a standard Ryobi soldering iron now, no other attachments with it.

A quick Google search shows that there are at least 5 different soldering iron models sold by Ryobi and none of them are called "standard". Suggest you post the model number.

For electronics use, you want a low power iron, for example 15W. If you have a high power iron, it must be temperature controlled, otherwise it will get too hot and damage delicate electronic components.

I prefer a chisel bit. 1mm for delicate work and 2.5mm for larger joints.

0.5mm or 1mm solder with a flux core.

A solder sucker is very useful for undoing joints that went wrong so you can try again.

Sorry, I didn't realize their were so many types. This is the exact type I have.

Obviously this is stronger than the 15W ones you're talking about. How would I go about temperature controlling mine so I don't damage the boards I have? And thank you for the tool recommendations, Ill look into getting some attachments for future work.

You can't make it temperature controlled as far as I can see. It's clearly not intended for use as an electronics soldering iron. They make a claim that it reaches up to 900C like it's a good thing, but for electronics, that's a bad thing!

My iron is 50W and I normally use it set for 350~375C. It's maximum temp is 450C. It's an Antex but there are many good brands. All the experienced forum members here will probably recommend a different brand or model.

71Hi-DdPuRL._AC_SY300_SX300_QL70_ML2

But your solder joints don't look like the problem is that the iron is too hot. If anything, the opposite problem. They look like you are adding too much solder and working the joint after the flux has all burned off.

Another important tool is something to clean the tip of the iron frequently during use. My iron's stand has a built-in place for a small damp sponge. Other types are like a tiny cave filled with curly brass shavings.

Gotcha. Thank you for the clarification. Do you think the soldering is most likely the issue then? I know the soldering connecting the two boards isn't that great but the second board is getting power and sending signals to the servos so I think those joints are "good enough" for now. The binary pin for the second board definitely has the worse soldering job out of all of them though. Should I take off the solder and try again? Or maybe just try to solder the second binary pin next to it and designate the board as 0x42?

No, but definitely one of the likely issues.

Yes

Worth a try.

I wouldn't normally recommend doing this, but just as a test, get the i2c scanner sketch running, then use a suitably small screwdriver, carefully short one of the other address pad pairs and see if you can get the second board to get picked up on any address. Just be really careful not to let the screwdriver slip and short something else out, because that could cause damage (assuming that board isn't already damaged, which is clearly also a possibility).

Thank you for all the help. I tried the I2C scanner again and found the 0x44 pin connection still worked. I did a better, but admittedly still not great, solder across these pins and got the connect to work just fine. The legs are now working as intended! Thank you for the soldering advice as well, moving forward I'll be getting some more soldering tools and will hopefully get better over time.