Multiple Adafruit 16ch pwm Servo Controllers

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
mmmbeeer
 
Posts: 2
Joined: Sat Feb 08, 2014 8:11 am

Multiple Adafruit 16ch pwm Servo Controllers

Post by mmmbeeer »

Hi,
I am using an Adafruit 16ch pwm Servo Controller and now I need to add more controllers. I am pretty happy with how to set up controller addressing but I can't find how to issue commands to servos on different controllers.

With one controller, the command to a servo is:

pwm.setPWM(15, 1024, 3072) where 15 is servo 15, 1024 is pwm signal rise time and 3072 pwm signal fall time.

How do I give commands to servos attached to different controllers?

Thanks in advance,
mmmbeeer

I had better add I'm using an Arduino Mega 2560 to drive the controller.

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple Adafruit 16ch pwm Servo Controllers

Post by adafruit_support_bill »

You declare an instance of Adafruit_PWMServoDriver for each board and specify the address:

Code: Select all

Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x40);
Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x41);
You will need to initialize all instances as well:

Code: Select all

  pwm1.begin();
  pwm2.begin();
  
  pwm1.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
  pwm2.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
Then you can send commands to the first board by referencing the first instance by name and to the second board by referencing the second instance by name.

Code: Select all

  pwm1.setPWM(n, 0, pulse);
  pwm2.setPWM(n, 0, pulse);

mmmbeeer
 
Posts: 2
Joined: Sat Feb 08, 2014 8:11 am

Re: Multiple Adafruit 16ch pwm Servo Controllers

Post by mmmbeeer »

Thanks indeed for that adafruit_support_bill, it is much appreciated.

Regards,
mmmbeeer

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”