I’m using 3 MG996R servos that twitch under no load. I tested them individually to check if the problem was one of the servos. All servos worked without any twitching. I then added 2 Gear motors with the motor driver L298N and still no twitching. When I combine all 3 servos and the 2 Gear motors together, the twitching occurs. I’ve also done some research and found the jumper wires i’m using are too small for the servos as they are only 28 AWG which according to this chart, (What gauge wire should I use for my project? - #3 by Idahowalker ) the wires can only deliver 0.226A. However, the wires are enough to power 2 Gear motors and a single servo. So is it a power supply problem? Should I purchase bigger jumper wires?
Servo twitching is usually due to an inadequate power supply.
For 3xMG996R, the servo power supply should be rated for 8 Amperes minimum. As mentioned above, do not use a breadboard. Solder all connections, or use connectors rated for 3 Amperes minimum (each servo).
The ancient, extremely inefficient L298 should be tossed in the recycle bin. Pololu has the best selection of modern, efficient brushed D.C. motor drivers.
I used 3 50V 220uF capacitors as shown in the updated circuit. Before adding the gear motors, I placed the capacitors to regulate the voltage and current flow to the servos and it fixed the twitching. Only when I put everything together does the twitching re-occur.
If the servo needs to keep pressure on, it usually requires the constant repetition of the incoming pulses. if the problem is happening under "no-load", you could try turning off any pulses to a particulr servo once it has reached position. Twitching is usually because of external interference, placing the capacitors for each servo between the signal wire signal and GND (not the supply and ground) to shunt away any high frequency spikes on the signal wire.
Many servos also produce a 'kick' when they are first powered up. This is a feature of their internal electronics and is cleared in almost all cases by soldering a 10k resistor between the servo's signal wire and the +5V supply line, or the signal line and the 0V line.
You have no reverse diodes across those motors. This will result in a lot of interference being generated. As this is a H-bridge output you need four diodes not one for each motor output.
See the example schematic in this link:- L298N Motor Driver Data sheet PDF
Maybe the problem is the servo.h , it interferes with PWM output of pins 9+10.
Although the problem of the TE is more related to PWM for the motors not working, you find more information here:
Did you suggest 8 Amperes minimum for the servo power supply because of the stall current of the servo? The stall current of each servo is 2.5A at max load times 3 which is 7.5A total. Since, we can't go exactly 7.5A and want room for adjustments, round it off to 8 Amperes. Is this the right calculation?
Figuring out the right power supply for my project has been an ongoing issue for me. Based on what I've read, I chose the lipo battery and the buck converter but it seems like I messed up and I don't know where I made my mistake. What calculations are you using?