43 servo motors through transistors, jittering

I want to control 43 servo motors for a weird project I am working on.

The arduino mega does not have enough power to supply 43 servos. That's why I decided to use 2n3904 transistors, see schematic.

I only drew 4 servo's, the remainder of the servo's are wired up like this as well. one transistor per pin to control one servo. All of the servo motors share the same pwm signal. then by changing the high/low output I can decide which servos turn.

That should work...in theory. But as soon as I connect more than 20 servos all of them start to jitter, then it's only a matter of connecting a few more before none of the servos move.

I feel like I am missing something but I have no clue what. The power draw from the arduino is 0.1 ish amps which is not even close to the max of 0.8amps.

Here's a video of what happens.

Also, I know it's a mess of wires, I made a more compact pcb but I wanted to make sure that I didn't screwup soldering. hence the recreation of it on a breadboard. The wiring matches the schematic.
as I unplug some servos, they start to work again....until I plug a couple of them back in.

I also made some code just for the servos.

#include <Servo.h>
Servo myservo;

void setup() {
  Serial.begin(115200);
  myservo.attach(5);
  for (int i = 6; i <= 49; i++)
  {
    pinMode(i, OUTPUT);
    
  }
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH);
  digitalWrite(11, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(13, HIGH);
  digitalWrite(14, HIGH);
  digitalWrite(15, HIGH);
  digitalWrite(16, HIGH);
  digitalWrite(17, HIGH);
  digitalWrite(18, HIGH);
  digitalWrite(19, HIGH);
  digitalWrite(20, HIGH);
  digitalWrite(21, HIGH);
  digitalWrite(22, HIGH);
  digitalWrite(23, HIGH);
  digitalWrite(24, HIGH);
  digitalWrite(25, HIGH);
  digitalWrite(26, HIGH);
  digitalWrite(27, HIGH);
  digitalWrite(28, HIGH);
  digitalWrite(29, HIGH);
  digitalWrite(30, HIGH);
  digitalWrite(31, HIGH);
  digitalWrite(32, HIGH);
  digitalWrite(33, HIGH);
  digitalWrite(34, HIGH);
  digitalWrite(35, HIGH);
  digitalWrite(36, HIGH);
  digitalWrite(37, HIGH);
  digitalWrite(38, HIGH);
  digitalWrite(39, HIGH);
  digitalWrite(40, HIGH);
  digitalWrite(41, HIGH);
  digitalWrite(42, HIGH);
  digitalWrite(43, HIGH);
  digitalWrite(44, HIGH);
  digitalWrite(45, HIGH);
  digitalWrite(46, HIGH);
  digitalWrite(47, HIGH);
  digitalWrite(48, HIGH);
  digitalWrite(49, HIGH);

}

void loop() {
 
  Serial.print("waiting2");
  delay(300);
  myservo.write(90);
  Serial.println("waiting2");
  delay(300);
  myservo.write(0);
}

Everything should work...but it doesn't and I have no clue why. Any ideas?

Thanks in advanced :slight_smile:

That image does not make any sense :frowning:

Please supply a valid circuit diagram or explain the connections.

Sorry, I will only evaluate schematics that connect components in a standard way. You can't just "plop" a transistor symbol on top of a wire junction and "call it a day".

Therefore, "The wiring matches the schematic." is useless information.

Will do:
Yellow = base
red = collector
orange = emitter

Actually, that is asking us to do...

Each wire has 2 ends. Please describe all the wires for one servo.

Please just post a real schematic.

updated the post with a proper schematic.

Thank you, appreciate that. However in future, add updates in new posts so the replies don't seem weird.

D5 generates a PWM signal for the servo motors. This signal is connected to all the collectors.
D6 in is connected to the base of the transistor through a 1k ohm resistor.
The emitter of Q1 emits the PWM signal to the servo motor depending on the state of the D6 port.

Do the servos have an internal pull down? What about the phase reversal performed by the transistors?

These are sg90 servos, so I don't think so. I am also not aware of the phase reversal due to the transistor.
I hooked up the arduino pwm to an oscilloscope, the output before and after the transistor looks the same.

My mistake, in that configuration there isn't a phase reversal. You do need a collector load.

Those are NPN. Your diagram shows PNP.

Your circuit diagrams suggests emitters, not collectors.
This way the PWM pin has to serve all servos plus base currents. Too much I think :frowning:

And what pulls the servo inputs low?

That may be sufficient to drive the servo, regardless of the collector level. A transistor can behave as 2 diodes.

my bad, changed it.

Now you have common emitter amplifiers. What are the 1k resistors for?

Why not just use a logic "and" gate instead of discretes?

As aarg pointed out, I accidentally used NPN instead of PNP transistors.

I do not have a pulldown on the servo pwm pin.

Now you have common emitter amplifiers. What are the 1k resistors for?

common emitter amplifiers? I didn't have the 1k resistor there at first, the wiring was the same and it didn't work. there were plenty of schematics in which they used a 1k resistor...so I tried it, and it worked.

Why not just use a logic "and" gate instead of discretes?
Would you mind to elaborate?

For all I know, I thought that a transistor sort of functions as a relay but extremely small. small bit of power enables a bigger bit of power to run.

Translation.
I am using electronics as a toy, I have almost no idea how it works. Now that nothing I do works, I want someone to fix my toy.

Use an "and" gate. It will save you the effort of duplicating 75 years of transistor circuit design by trial and error.