0

New PWM library problem
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

New PWM library problem

by jdelcamp11 on Tue Jun 25, 2019 9:56 pm

I just updated the #include <Adafruit_PWMServoDriver.h>
But it generates an error if I try to start it with any address
Board feather MO - code from servo example in library

This works:
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

This generates the error message posted below:
// you can also call it with a different address you want
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);

In file included from C:\Users\grizl\AppData\Local\Temp\arduino_modified_sketch_714991\servo.ino:21:0:
C:\Users\grizl\Documents\Arduino\libraries\Adafruit_PWM_Servo_Driver_Library/Adafruit_PWMServoDriver.h:51:3: error: initializing argument 1 of 'Adafruit_PWMServoDriver::Adafruit_PWMServoDriver(TwoWire*, uint8_t)' [-fpermissive]
Adafruit_PWMServoDriver(TwoWire *I2C = &Wire, uint8_t addr = 0x40);
^
exit status 1
invalid conversion from 'int' to 'TwoWire*' [-fpermissive]

jdelcamp11
 
Posts: 155
Joined: Mon Nov 17, 2014 12:30 am

Re: New PWM library problem

by jdelcamp11 on Tue Jul 23, 2019 12:45 pm

Still no answer from Adafruit on this.
Can't use PWM board with alternate address.

jdelcamp11
 
Posts: 155
Joined: Mon Nov 17, 2014 12:30 am

Re: New PWM library problem

by relaxing on Fri Jul 26, 2019 11:38 am

The error message tells you how you need to call it, like this: Adafruit_PWMServoDriver(TwoWire *I2C = &Wire, uint8_t addr = 0x40);
Because you gave it the address first, it's telling you it can't convert that int to a Wire object ("invalid conversion from 'int' to 'TwoWire*'")
It's confusing because someone made a mess of the library earlier this year so the examples Adafruit provides are wrong.
(Also the "Wire" object is created inside Wire.h where it's not at all obvious.)

For now, change your code to this:
Code: Select all | TOGGLE FULL SIZE
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(&Wire, 0x41);


You might want to update your library to get the latest bug fixes, but then you'll have to flip the order of the arguments... See here https://github.com/adafruit/Adafruit-PW ... /issues/50

relaxing
 
Posts: 59
Joined: Thu Mar 24, 2005 11:22 am

Re: New PWM library problem

by jdelcamp11 on Fri Jul 26, 2019 4:28 pm

Thanks for the reply. For now I will hold onto version 1.02 which works just fine. If I update I will have to go back to a number of sketches to make them compliant with the new library.

Just a note: It would be nice if they could include a readme file in the library that documented these types of changes.

jdelcamp11
 
Posts: 155
Joined: Mon Nov 17, 2014 12:30 am

Re: New PWM library problem

by Marada on Wed Jul 31, 2019 10:16 pm

Glad I ran across this. I'm a novice self teaching myself after retiring and getting into model railroading. The last couple days I have been working with code using the adafruit servo driver. When placing the default address, 0x40 within the (), the sketch would not function. Without it, the sketch would work. So I will revert back to a prior update for now.
I do not know if suggestions are allowed since in my case it would be self serving but is so, a couple things that would help in my integration with model railroading. A change in the library to allow speed adjust. The Arduino servo.h was modified by a 3rd party to allow this but that will not work on PCA9685 boards. The second idea is to add the ability to cascade boards, maybe something like this. Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x40,0x41,0x42); Allow up to 4 boards and it will create the corresponding pin assignments. 0 to 31, 0 to 48, 0 to 63. Sure would help model railroaders.

Marada
 
Posts: 1
Joined: Wed Jul 31, 2019 10:03 pm

Please be positive and constructive with your questions and comments.