I am trying to make a robotic car with two 12V dc motors(30 rpm) and an L293D and using PIC16F877A.
My problem is that when motors are disconnected,The voltage levels on on the output of L293D (already connected its inputs to outputs of PIC) is changing as per the sequence in the Program. But Once the motors are connected, The sequence sometimes change,may not change and may sometime stay constant and voltage levels not changing according to program.
For eg if ‘1’ ‘0’ is the condition for motor to rotate in anticlock wise direction.and suppose we change it to ‘0’ and ‘1’,If the motors are not connected,the program is working fine and output is behaving properly else not.
Actually what is the problem,Is there any solution??
Your problem seems to be with Power Supply. Hope you are using same power supply for powering DC Motor and PIC Microcontroller. There will be a sudden drop in the supply voltage when the motor is powered, this will reset the microcontroller and program starts from the beginning again and again.
Try the following,
Use separate 12V and 5V power supplies.
Make sure that every components used in the circuit is able to provide peak current required during motor switching
Increase the capacitance of both 12V and 5V rail. Eg : Put 1000µF for 12V and 100µF for 5V. Add 0.1uF near each ICs.