Go Down

Topic: Due + PCA9685 Servo board: it makes no servo work at all (Read 223 times) previous topic - next topic

dsyleixa

hi,
I have issues with my 2 Dues + PCA9685 Servo board: it makes no servo work at all!

Instead, trying the same Sketch with a Mega2560, it's all fine though.
With my Feather M4 the code is also working fine, by 3.3V Vc.

The PCA is designed for 3-5V Vc and signal levels, but even if I supply it from the Due by 5V Vc it still don't work.

This is the code, what's wrong with the Due?



Code: [Select]
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
#define MIN_PULSE_WIDTH 650
#define MAX_PULSE_WIDTH 2350
#define DEFAULT_PULSE_WIDTH 1500
#define FREQUENCY 50
uint8_t servonum = 0;



void setup() {
   Serial.begin(115200);
   Serial.println("16 channel Servo test!");
   pwm.begin();
   pwm.setPWMFreq(FREQUENCY);
}


int pulseWidth(int angle) {
   int pulse_wide, analog_value;
   
   pulse_wide = map(angle, 0, 180, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
   analog_value = int(float(pulse_wide) / 1000000 * FREQUENCY * 4096);
   Serial.println(analog_value);
   return analog_value;
}


void loop() {
   pwm.setPWM(0, 0, pulseWidth(0));
   delay(2000);
   pwm.setPWM(0, 0, pulseWidth(120));
   delay(2000);
   pwm.setPWM(0, 0, pulseWidth(90));
   delay(2000);
}

ard_newbie


There is this thread, however I don't understand why they add resistors to SDA/SCL since there is already a 1K resistor:

https://arduino.stackexchange.com/questions/29155/how-to-make-pca9685-work-with-arduino-due

dsyleixa

thank you, I added the pullups but still no success, no servo movement at all.
The serial monitor claims it's moving the servos, erroneously.

OTOH, the i2c scanner program finds the PCA at Due  at x40 (and 2nd at x70) either way though.

Just tested: on M4 it works also even without any added pullups (just to mention, the Mega has built-in ones like the Due, the M4 neither)

Go Up