PIC resets when motors work

microcontrollermotorpic

I'm using a PIC18F452 in my project, and L293d for driving motors. I'm using two completely separate power supplies for driving motors and driving the PIC. completely separate two power packs. a 12 v 1A one for driving motors. the circuit diagram is as below:

enter image description here

My problem is when motors work the PIC get reset. when motors are disconnected it works fine and when the motors input voltage is reduced to about 6v also it works fine but with less speed. I have three questions.

  1. When the motor supple is separate how can that voltage affect the MCU to reset?
  2. if I use only one supply (12v battery), and 7805 to regulate and supply 5v to PIC how should I modify the circuit to work properly without resiting? (I used separate supply because this method was unsuccessful first, but my second option also was unsuccessful.)
  3. I want to know whether L293D reduse the current flow and how to prevent it? the motors are enough powerful when I directly power it. but when it is driven from L293 and same power pack they are very poor. (I use 12v motors and when they are directly powered and with load it draws about 460mA )

please help me regarding this issue, I can't solve it myself…

Best Answer

You circuit lacks decoupling capacitors for the microcontroller. Try adding 100 nF / 1 uF ceramic capacitor as close as possible to each pair of Vdd/Vss pins.

Related question and great answer from Olin: PIC16f877A resets due to external noise