PCA9685 Servo angle limited to about 90° (vs. 180°)

I used both a SG90 servo that I tested stand alone on Arduino UNO and know it works a range of 180° (approx) and a DM996 that is new. I use the library suggested by the vendor (NachtRaveVL (NachtRave) · GitHub)/**[PCA9685-Arduino]).

I have tested position 0of16 (DM996) and 1of16 (SG90 ) - the PCA9685 board is connected on I2C with an ARDUINO Nano (4&5 pin) but with a separate battery pack for the servos.

It's a while I'm out of the forum - hope to attach properly the code etc. . Tks. Flavio

#include <Wire.h>
#include "PCA9685.h"

PCA9685 driver;

// PCA9685 outputs = 12-bit = 4096 steps
// 2.5% of 20ms = 0.5ms ; 12.5% of 20ms = 2.5ms
// 2.5% of 4096 = 102 steps; 12.5% of 4096 = 512 steps

PCA9685_ServoEval pwmServo(100, 512); // (-90deg, +90deg)

void setup() {

 Wire.begin(); // Wire must be started first
 Wire.setClock(400000);// Supported baud rates are 100kHz,400kHz, and 1000kHz
 driver.resetDevices();// Software resets all PCA9685 devices on Wire line
 driver.init(); // Address pins A5-A0 set to B000000 init(B000000)
 driver.setPWMFrequency(50); // Set frequency to 50Hz
}

void loop() {
 driver.setChannelPWM(1, pwmServo.pwmForAngle(180));
 delay(1000);
 driver.setChannelPWM(1, pwmServo.pwmForAngle(0));
 delay(1000);
}

I've never used that library (the Adafruit library seems simpler) but from the website it seems to expect pwmForAngle values of -90 to 90 instead of 0 to 180. Have you tried that?

Steve

1 Like

Will try again. I used also the library Arduino suggests (Peter Polidoro) but it was not working due to an hw failure I have resolved. Will try that one also.

So, with the ADAFRUIT LIBRARY it worked at first try. I experimented with the MIN MAX values and it does even a bit more than 180°. Thks Flavio

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.