PWM drop-out

Hi guys,

i have a setup of 8 DC motors (12V) im controlling via an Adafruit 16x12bit PWM shield. The arduino is receiving data over serial simple instructions of which motor and how fast it is to turn. The project works great with ONE motor i.e. sending instructions/fluctuations in speed for one motor - the problem comes in after i try to send instructions simultaneously for 4 motors, once the 5th motor’s instructions come in, the first motor stops/doesn’t respond.
Im wondering why there is a PWM dropout that seems like there isn’t enough power to run that from the shield, but im not sure. Hopefully i might be able to find some help here. :slight_smile:

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
String readString, fanNo, fanSpd;
int inByte = 0;
int rotSpd = 2000; 

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


void setup() {
  pwm.setPWMFreq(25000);  // This is the maximum PWM frequency
  // save I2C bitrate
  //uint8_t twbrbackup = TWBR;
  // must be changed after calling Wire.begin() (inside pwm.begin())
  //TWBR = 12; // upgrade to 400KHz!

void loop() {
   while (Serial.available()) {
   if (Serial.available() >0) {
     char c =;  //gets one byte from serial buffer
     readString += c; //makes the string readString
    if (readString.length() >0) {
     Serial.println(readString); //see what was received
     // expect a string like 72000 containing the fan number and speed      
     fanNo = readString.substring(0, 1); //get the first characters
     fanSpd = readString.substring(1, 5); //get the next 4 characters 
    int n1;
    int n2; 
     char carray1[2]; 
     fanNo.toCharArray(carray1, sizeof(carray1));
     n1 = atoi(carray1); 
    // Serial.print("the fan number is : ");
    // Serial.println(n1);
     char carray2[6]; 
     fanSpd.toCharArray(carray2, sizeof(carray2));
     n2 = atoi(carray2); 
      //Serial.print("the fan speed is :" );

Is this the Adafruit PCA9685 shield?
What are you using to PWM the motors. Mosfets, motor drivers?
What is the stall current of the motors, and current capability of the supply.
Post a full diagram, with values.

the problem comes in after i try to send instructions simultaneously for 4 motors, once the 5th motor's instructions

Well there's your problem. You're trying to send instructions to the fifth of four motors. It's a math issue.

If you think it may be a power issue, please post a schematic of your setup.


So you're trying to control computer fans.

Can't do.
The PCA9685 chip has a max PWM frequency of 1000Hz.

mmm okay if the PCA9865 chip cannot work above 1000Hz, but why would it be able to work with up to 4 fans (varying individual speeds), and not 5,6,7 or 8?

I don't know if the PCA9685 (or library) defaults to 1000Hz if you try to enter a higher number.
Or if it stays on the chip default of 200Hz.

I had some 4-pin fans running ok on a low PWM frequency.
But some might not like it, or some might have coil-whine.

Let's sort out the hardware first.
So are you using 4-pin fans, or 3-pin fans with mosfets.
High-side or low-side (diagram needed).
Are you using the PC supply, or someting else.