Well the thing is that 6 months ago i couldn't finish my project because of something wrong with the circuit.
I'm controlling 2 DC motors (Gearbox 200:1) with a L298N, where the logic part is recieved by a signal from a pic16f876A, the code is simple, it starts with sending logic 1 to the enable pins, then it sends 1 and 0 to the input pins, and every second the motor's direction changes. The problem is, each time the motors change its direction the voltage Vo of my LM2940CT-05 goes up and down (about 700mV (multimeter measure)) and the battery as well, so that affects the Sharp sensor and the PIC. I can solve that problem using 2 battery sources one for the logic and sensors and the other only for motors voltage , but one of the rules that were given to me was to use only one Voltage source. I have tried almost everything, i regulated my source like this post https://www.robotshop.com/letsmakerobots/node/3880 and i noticed a little change now it only goes up and down (500 mV) then i decided to increase the capacitors to 1000 uF even 1000 uF + 470 uF, and no change.
My power supply was 6V, acid battery then change to 9 V and still have the same problem.
I put diodes on the L298N and also capacitors somthing like this (this is not my schquematic , i dont have one right now) the motor's voltages is 6V form my battery and the logic 5V from the LM2940CT-05 (same source).
I have tried with a new l298n and motors and still the same problem.
I dont know what to do, all .1 uF capacitors are ceramic instead of monolithic.
I put .1 uF ceramic capacitors on the motor's terminals.
Note: I put a LED in my circuit with a 300 resistor and every time the motor change it's direction the led turns on and inmediatally turns on.
My conclusion is that, there's some noise from the motors and i can't filter it. I need some help please i really want to finish this project.
People will probably help you quicker if you reword your post. Most people that see “What am I doing wrong” are going to pass over it. Try re-naming it to something like “trouble running motor, IR sensor, and PIC on same voltage source”. That way people that are interested in electric systems will be interested.
that you show us what your circuit really looks like? I find it hard to believe that a PIC has any issue with +/- .05v or even .07v. Sharp sensors are outside of what I would even begin to guess about, but, a cap on the power and ground for the sensor can’t hurt anything can it?
place a capacitor (100nf) directly parallel over the pic’s + and -. As close to the pic as possible.
another problem can be the way you’ve wired everything. for example if you have a wire from the negative battery pole to 1 of the motors, and then from there attached a 2nd wire to power the pic, that could cause power dips if your motor turns on.
I think Birdmun suggestion will help you. Put a rather large capacitor like a 3300uF electrolytic on the power rail to handle the voltage drop when the motors kick in.
hello… wasn’t here since a year almost but I found this topic…
Before giving an answer, let me ask a question: have you ever sit in a car, start the radio than start the car? Did you observed that the radio shuts up until the engine start? that’s the same thing happening here…
When you swtich on a motor, the voltage drops and your microcontroller will reset… That’s why I hate Arduino and development boards like this… I usually use a simple 100mA 7805 in front of AVR and use a plumb-acid battery… problem solved…