Hi, recently I bought 2 PCA9685 controllers to control servos, but after running I2C test I got addresses: 0x03 and 0x70, and PWM doesn't work. I tried running it on Uno and 2 different Nanos, but the result it still is the same. The schematic is the same as in the picture. Is there something wrong with the circuit, or are those 2 bards faulty?
Welcome to the forum
Have you considered that the problem might be in the sketch that you have not posted ?
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
while (!Serial); // Wait for serial port to connect
Serial.println("\nI2C Scanner");
}
void loop() {
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ ) {
// The I2C scanner uses the return value of the Write.endTransmisstion
// to determine if a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4) {
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // Wait 5 seconds for next scan
}
I tried other codes similar to that, but the result was still the same.
That code scans for I2C devices and reports the address of any that are found. It does not attempt to control the PCA9685 in any way
Have you tried the examples from the Adafruit library ?
By I2C test, did you mean an I2C scanner sketch?
The Adafruit documentation suggests that the default address should be 0x40.
There are no on-board I2C devices on an UNO so any addresses will be for off-board devices - i.e. your servo board. The scanner should pick up only one address.
Did you have both boards connected when you ran the scanner? If so, did you change the address of the second board?
Yes, I meant I2C scanner sketch.
I find it weird, that I didn't get 0x40 address and that's why I'm seeking for help.
There was only 1 board connected and PCA9685, I tried changing wires, but it didn't help. Without PCA9685 there were no devices found.
Yes, I tried to control servos or LEDs, but output on PWM is constant 4,7 V.
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver srituhobby = Adafruit_PWMServoDriver(0x70);
#define servoMIN 150
#define servoMAX 600
void setup() {
Serial.begin(9600);
srituhobby.begin();
srituhobby.setPWMFreq(60);
}
void loop() {
for (int servo = 0; servo < 4; servo++ ) {
srituhobby.setPWM(servo, 0, servoMIN);
Serial.println(servo);
delay(300);
}
for (int servo = 3; servo >= 0; servo-- ) {
srituhobby.setPWM(servo, 0, servoMAX);
Serial.println(servo);
delay(300);
}
}
I run that sketch to test servos. I did try changing address to: 0x40, 0x03, 0x70, but I got none response. I tried connecting servo to pins 0-3.
Could you please show a photograph of your setup that shows clearly how everything is connected?
Looks reasonable; have you tried adding pullups to SCL and SDA? I'd suggest 4k7 or so.
The device responding at 0x70 is the PCA9685 too. Taken from the Adafruit PCA9685 board FAQ:
The PCA9865 chip has an "All Call" address of 0x70. This is in addition to the configured address.
Just tried after adding 5k, still same result.
Also, for what it's worth: I've so far ONCE received counterfeit chips from China that really didn't work (some other counterfeits that worked at least to some extent, and usually well enough): these were a couple of PCA9685's. No matter what I tried, I couldn't breathe life into them. But these were bare chips, no module/board. The modules I've also bought on occasion all worked fine. Although I have to admit that these counterfeit PCA9685's locked up the I2C bus entirely; I2C scanner wouldn't run - in fact merely calling Wire.begin() would lock up the microcontroller. So different behavior than what you're getting.
Sorry, this is probably of little help.
I tried setting address to 0x70, but I got no response on servo. Then after I ran I2C scanner sketch, the only addres I got was 0x03. Only after turning power off and then on I could find addresses: 0x03 and 0x70 again.
As a data point, i dug out and wired up a 16 channel PWM clone board, a couple of servos and a 5V supply with an Uno.
The I2C scanner sketch picked up the PCA9685 at addresses 0x40 and 0x70.
Next, I compiled and uploaded a simple servo sweep example. The Adafruit_PWMServoDriver
instance was declared without an address passed to the constructor, so it got the default of 0x40. When power was applied to the PWM board, the servos moved.
No problems, no gotchas, no "oh you have to remember to do this"... just slapped everything together and it worked.
Oh, and the PWM board should have 10K pullups already on SDA and SCL. I checked and my clone board has them, so yours likely does too.
I can assume then, that I got 2 faulty PCA9685 boards.
One bad board, I have no trouble believing. Two bad boards... that kind of thing has happened to me, but at two I'm looking really hard for the head slapper that I've overlooked. Which has also happened to me. Sometimes I find it. Sometimes, it's just two bad boards.
Just noticed this; that ought to be 50, not 60.
And just for one last stab at it, before you set the PWM frequency, try adding this:
srituhobby.setOscillatorFrequency(27000000);
Try disconnecting the blue wire that goes from the Nano to V+ on the module board
I see several "cold" solder joints on the Nano.
Try to leave the soldering iron a few seconds longer on there, so the solder has time to flow.
Remove that blue wire (don't connect anything to V+ of the PCA).
Servos should receive power from the screw terminal, not from the Nano.
Leo..