Go Down

Topic: How to get 5v from PCA9685 board? (Read 1 time) previous topic - next topic

143prasanths

Oct 30, 2017, 12:24 am Last Edit: Oct 30, 2017, 02:16 am by 143prasanths
I'm doing a project which requires 16 5v dc motors to be driven in PWM. So I have brought this board -
https://www.amazon.com/16-Channel-12-bit-Servo-Driver-Interface/dp/B00EIB0U7A


I'm using the #include <Adafruit_PWMServoDriver.h> library
My understanding was pwm.setPWM(0, 1, 4095) being setPWM(channel, on, off) will turn on pin 0 for most of the time and I will be getting around 100% of VCC. But I'm getting only around 1.5v from the PWM pin.

I need voltage in the range of 3v to 5v from the PWM pins for my motors. So now I am wondering what I am doing wrong and is it possible to get 100% of vcc from the PWM pins using the PCA9865 board?

This is my Arduino code :
Code: [Select]

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);

#if defined(ARDUINO_ARCH_SAMD)  
// for Zero, the output on USB Serial console, remove the line below if using programming port to program the Zero!
  #define Serial SerialUSB
#endif

void setup() {
#ifdef ESP8266
 Wire.pins(2, 14);   // ESP8266 can use any two pins, such as SDA to #2 and SCL to #14
#endif
 
 Serial.begin(9600);
 Serial.println("16 channel PWM test!");

 pwm.begin();
 pwm.setPWMFreq(1000);  // This is the maximum PWM frequency

#ifdef TWBR    
 // save I2C bitrate
 uint8_t twbrbackup = TWBR;
 // must be changed after calling Wire.begin() (inside pwm.begin())
 TWBR = 12; // upgrade to 400KHz!
#endif
}

void loop() {
  pwm.setPWM(0, 1, 4095);
}



Cheers



PaulRB

Did you see this on the AdaFruit tutorial?

Quote
The VCC pin is just power for the chip itself. If you want to connect servos or LEDs that use the V+ pins, you MUST connect the V+ pin as well. The V+ pin can be as high as 6V even if VCC is 3.3V (the chip is 5V safe). We suggest connecting power through the blue terminal block since it is polarity protected.

Wawa

The V+ connector block just connects to all the power pins of the servos (if servos are used).
For DC motors you need to add a logic level mosfet and kickback diode per channel.

The Adafruit site shows a big p-channel polarity protection mosfet that is not there on the Amazon/Adafruit board.
Leo..

Grumpy_Mike

#3
Oct 30, 2017, 12:44 pm Last Edit: Oct 30, 2017, 12:56 pm by Grumpy_Mike
When in doubt always consult the data sheet of the device PCA9685.PDF data sheet

You will see that the pin does not source very much current only a maximum of 10uA, but it will sink a lot more current about 20mA. So you can never get 5V from a pin to drive an LED. The output pin has a few modes it works in and you must pick the right mode for your application.


Wawa

The PCA9685 defaults AFAIK in totempole output mode (table on page 15).
Source 10mA, sink 25mA.

The boards have a 220ohm resistor in series with the outputs.
So it's ok to drive the gate of a logic level n-channel fet directly.
Leo..

Go Up