How to prevent the microcontroller reset?

Hi all, I have a problem with the l298 motor driving circuit, I use this circuit to drive 2 DC motors and a RC servo, but if I have input the duty circle of PWM over 60%, the microcontroller is reseted. How can I solve this problem? Thanks in advance. :(

Sounds like a power problem, drawing too much current at larger duty cycles. How are you powering the board. An external power supply is the most likely solution.


Thanks, I supply power by 8 batteries (1.2v-2200mAh) = 9.6v. I think the batteries are good enough. How abot the driving circuit with l298??

From the ATMega 168 datasheet

The ATmega48/88/168 has four sources of reset: ? Power-on Reset. The MCU is reset when the supply voltage is below the Power-on Reset threshold (VPOT). ? External Reset. The MCU is reset when a low level is present on the RESET pin for longer than the minimum pulse length. ? Watchdog System Reset. The MCU is reset when the Watchdog Timer period expires and the Watchdog System Reset mode is enabled. ? Brown-out Reset. The MCU is reset when the supply voltage VCC is below the Brown-out Reset threshold (VBOT) and the Brown-out Detector is enabled.

I'm assuming that the reset line isn't connected to anything except the normal connections, and the watchdog timer isn't tied to reset in the arduino (you'd know if you'd done this). This means that the only reset modes left are brownout and power on, these are both tied to power levels.

It's most likely that the voltage is falling below brownout level momentarily, causing a reset. Batteries have an inverse relationship between current and voltage, this is most pronounced when the demand rises quickly (circuit impedance falls quickly). My motor theory ain't that great, but if I remember correctly, the cheap DC motors can do this.

Try placing a largeish capacitor between the power supply rails close to the arduinos power pins, hopefully this should stop the power dropping too much. If not, you need a power supply which can cope with the load better (more batteries!). If it all stops working then you've changed the circuit reactance too much, but I don't think this would happen.

Also brownout levels can be changed or turned off entirely, but this needs an in system programmer.


Thanks Mr Halabut! :D I found that my circuit is reseted by brownout voltage, so I place some 1000uF capacitors between the voltage supply to circuits, but I don't understand your sentence "Batteries have an inverse relationship between current and voltage" Can you explain to me, thanks

the more current you draw from a battery the lower its voltage drops

the more current you draw from a battery the lower its voltage drops

That really depends on the type of battery and it's internal impedeance. Ni-cad and Ni-mh have pretty flat discharge curves while lead acid and Li have a pretty linear discharge curve. Of course any battery's terminal voltage will drop if you try and draw more current then it's designed to supply due to it's internal resistance.


the more current you draw from a battery the lower its voltage drops

It's not only batteries that have internal resistance, all power supplies exhibit this "source impedance" as it is correctly called. One of the jobs of a regulator circuit is to remove this effect.

Hello all. When I had problems with my chip resetting (It interfaces with a motor controller and the controller's current passes through it), I tried adding capacitance but that didn't solve the issue. I added ceramics as close to the pins as possible and I also added large electrolytics, and that wouldn't solve it. So, I was looking at some white papers which explained that a series inductor or ferrite bead might be needed for EMI reasons on the 5V line, and so I added a 600 ohm ferrite bead that I had hanging around and it worked! It no longer reset.

So, I'm just posting this just in case anyone has a similar issue. Ferrite beads might be what you need. ;) (This is one of the threads I stumbled upon when I was using google to find out others with a similar microcontroller resetting problem. It didn't, however, have the "ferrite bead" suggestion nor did any other thread I saw.)

Ferrite beads are only really useful against very high frequency interference, not the sort of thing you would get from a motor. It would be worth using some chokes in the decoupling circuits however as described here:-