Servo SG90 restarting arduino

I'm using 2 atmegas328 and 3servos, a Master and slave thru I2C, I'm using a homemade circuit with a modified joystick pots x,y with nRF to transmit the data to the Master after that thru I2C from master to slave and I wrote a code to get the values from the pots and maped them to control the servos but there is a problem, after few seconds of operation the servos turn in random degrees and restart the chips and no longer working.

I put a separated regulator for the servos from the atmega's, tried to change the code creating a if statement because I thought pot values are jumping around and they are not, use 2 leds to see what exactly the chips are doing tried to work with a single servo, same problem.

I can't understand what's causing the problem

Domino60:
I put a separated regulator for the servos from the atmega's,

Okay, schematic? What powers the ATmega's? Decoupling caps? etc.

Okay, schematic? What powers the ATmega's? Decoupling caps? etc.

Photo, a 8v battery, caps? for what?

You do the power regulator part okay (making diagrams is another story ::slight_smile: ). But the devil here (as in, devil is in the details) is the battery. What kind of battery? A couple of AA's is going to have a hard time. You have a diode and a regulator in line for the 5V. That leaves 8V - 5V - 0,7V (diode) - 1V (regulator) = 1,3V spare over the regulator. So when the battery drops below 6,7V the 5V isn't stable anymore. I would give the uC power supply more buffer. Up C3 to 100uF or more.

And I don't see any 100nF ceramic decoupling capacitors....

I use a 2cell LiIon battery 7.4v max 8.4v I don't think voltage is a problem, about the regulator you suggest to change the 10uF caps to 100uF? what about decoupling caps can you explain please :slight_smile:

So I followed this tutorial about decapling capacitors

I added a 0.1uF electrolitic cap to pin VCC-GND of the master chip from the led looks like it's working but i still got the problem with the servos

You should use ceramic as decoupling, they are "faster".

But I still think it is voltage. A servo can draw up to 1A when you sweep it (which can happen a bit at start). So the voltage of the lipo will drop quite a bit for a while.

You should use ceramic as decoupling, they are "faster".

But I still think it is voltage. A servo can draw up to 1A when you sweep it (which can happen a bit at start). So the voltage of the lipo will drop quite a bit for a while.

Can I use 22pF as decouplers ?

I use a 5v 800mA regulator for 4servos is this ok or ... ? :smiley:

I still got the problem, can i solder a 1uF as decoupler? decouplers are used only for arduino or i can put them on the servos as well?

Can I use 22pF as decouplers ?

No. Try 2200 uF.

I use a 5v 800mA regulator for 4servos is this ok

No. Servos draw up to 1 ampere EACH.

So what I done till now, changed the C3 from 10uF to 100uF, soldered a 0.1uF Master vcc-gnd as decoupler and a 1uF as well to slave, run some tests and it's true as you said

But I still think it is voltage. A servo can draw up to 1A when you sweep it (which can happen a bit at start). So the voltage of the lipo will drop quite a bit for a while.

Run some small tests, tested the servo moving it slowly everything works fine but after doing fast/agressive movement the circuit stalls, everything stops, looks like the servos draw more voltage/current than i thougt, need to make a separated circuit and power up the servos and just using the signal connected to the main PCB. If that's the problem looks like i wasted 2 days for nothing :smiley:

Gonna make that kind of board to power up the servos

btw should i connect the grounds on the PCB as well?

Always power servos and motors separately from logic circuitry, then you don't get resets on high load
or any risk of inductive damage to the chips.

Always power servos and motors separately from logic circuitry, then you don't get resets on high load
or any risk of inductive damage to the chips.

I'm thinking to create a shiled for the servos, use only the singnal pin for the atmega and use a AMS1117 5v 800mA for each servo, is that a good idea?