0

Help chaining PCA9685 servo driver boards
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Help chaining PCA9685 servo driver boards

by richddt on Thu Aug 08, 2019 3:19 am

Hi,

I'm trying to daisy chain multiple PCA9685 pwm servo driver boards (https://www.adafruit.com/product/815) using your tutorial example code: https://learn.adafruit.com/16-channel-p ... ng-drivers
I followed the tutorial and soldered the A0 jumper on the 2nd board to give it address 0x41. However specifying the addresses in the code results in no servo movement.
Even adding just 0x40 as a single address results in no movement.
Funny enough, I do get servo movement, and just on the 1st (nonsoldered, 0x40) board, if both the addresses are removed, just leaving () in their place.

How can I properly address these boards? Am I doing something wrong here?

Thanks in advance for your help!

Here's the code:
Code: Select all | TOGGLE FULL SIZE
/*
  Original source: https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library
  This is the Arduino code PAC6985 16 channel servo controller
  watch the video for details and demo http://youtu.be/y8X9X10Tn1k
*/

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x40);
Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x41);

// Depending on your servo make, the pulse width min and max may vary, you
// want these to be as small/large as possible without hitting the hard stop
// for max range. You'll have to tweak them as necessary to match the servos you
// have!
#define SERVOMIN  125 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX  575 // this is the 'maximum' pulse length count (out of 4096)

// our servo # counter
uint8_t servonum = 0;

void setup() {
  Serial.begin(9600);
  Serial.println("16 channel Servo test!");

  pwm1.begin();
  pwm1.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
  //yield();

  pwm2.begin();
  pwm2.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
  //yield();
}

// the code inside loop() has been updated by Robojax
void loop() {

  pwm1.setPWM(0, 0, 125 );
  delay(500);
  pwm1.setPWM(0, 0, 200 );
  delay(500);
  pwm2.setPWM(0, 0, 125 );
  delay(500);
  pwm2.setPWM(0, 0, 200 );
  delay(500);

}
Last edited by adafruit_support_bill on Thu Aug 08, 2019 5:47 am, edited 1 time in total.
Reason: Please use [code] tags when submitting code to the forums

richddt
 
Posts: 4
Joined: Mon Jan 23, 2017 9:49 pm

Re: Help chaining PCA9685 servo driver boards

by adafruit_support_bill on Thu Aug 08, 2019 5:52 am

That looks like it should work. If you post some photos showing your soldering and connections we can take a look.

adafruit_support_bill
 
Posts: 74639
Joined: Sat Feb 07, 2009 10:11 am

Re: Help chaining PCA9685 servo driver boards

by richddt on Thu Aug 08, 2019 6:43 pm

ok so adding &Wire to the address declaration in the code seems like the fix - notably, adding it before (and not after) the 0x40, contrary to the example code:

Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(&Wire, 0x40);
Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(&Wire, 0x41);

richddt
 
Posts: 4
Joined: Mon Jan 23, 2017 9:49 pm

Re: Help chaining PCA9685 servo driver boards

by adafruit_support_bill on Thu Aug 08, 2019 7:26 pm

Good to hear you've got that working. Thanks for the update.

adafruit_support_bill
 
Posts: 74639
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.