I'm looking for some help with a simple circuit i'm trying to build.
I'm trying to control the below DC motor using a PIC (16F870). I am not interested in controlling speed, just simply turning it on and off. I have set the circuit below up and it works except for the fact that when the motor turns on the LEDs start to flicker. Eventually I intend to swap other things in for the LEDs but want to get the circtui right first.
I'm guessing the motor is causing interference somewhere but i'm not sure how to stop this. Can anybody make a suggestion?
You will probably want to wait for a reply from someone who actually knows what they are talking about, but it struck me that perhaps moving the LEDs closer to the power supply, or using a bigger power supply capable of handling the power drain might help...
The way it is drawn makes it look as though the 12V is generated from the 5V through the regulator. That is possible, using a boost regulator (https://en.wikipedia.org/wiki/Boost_converter) but it is unusual.
The more normal thing to do is to produce the 12V from a battery or transformer, and regulate down to 5V from that. That is much easier. In your circuit the 12V does not need to be accurately regulated as it will only affect the motor speed and LED brightness a bit.
I think that your 12V line is not at 12V, and particularly when the motor is on, the voltage is so low that the LEDs don't have enough voltage to run.
As you are running the 5V supply in a conventional way, I can't see what would make the LEDs flicker.
However, motors can be very noisy, so I would look at your layout and capacitors sizes. You should always have ceramic capacitors close to the PIC. It could be useful to feed the regulator through a diode, and add a big capacitor to ground after the diode. That will let the regulator ride dips in power caused by the motor.
Please describe your 12V battery. How much current can it deliver?
Your motor might require 5A or more when it first starts.
As I understand it, you have no indication that the PIC is being bothered by the motor, it's just the LEDs, correct? If that's the case, then a huge capacitor on 12V might help.
Firstly, I'll apologise for my poor diagram. I drew it in a hurry and now looking back can see all the errors! oops.
I'll try putting a big capacitor on the supply a shot to see if that will help.
At present it now seems to be working properly. I added a resistor on the line into the motor controller transistor and this seems to make a difference. But i'd like to make it as robust as possible so will try some of the other suggestions as well.
Diver300 mentioned having capacitors as close to the PIC as possible. Do you mean the capacitors from the power supply or do you mean adding new capacitors?
Once again, thanks to everyone for their help above.
I managed to get the circuit working well from my battery but wanted to change it to run from a mains supply.
I bought a 2.5A variable 0 - 15V volt supply.
But this is causing me more problems. The circuit works until I swithc the motor on. It then runs for around 20 secs before just cutting out and the PIC resetting. This happens anytime I try it.
Any ideas why this happens and what I can do about it?
I have attached an updated version of my circuit since the last one was rubbish
Excuse my ignorance but 'overloading' in what way?
I have checked the current of the motor and when running it's roughly 0.5A while the supply is rated at 2.5A. The motor runs fine at this current for around 30 seconds before simply cutting out.
Maybe your new 2.5A power supply is sensing the peak current pulses of the motor, instead of the lower average current that you measured.
Maybe the power supply is defective so that it cannot supply 500mA continuously.
Then its voltage drops.
The circuit pulses power to the motor. Then the peak current is much higher than if the motor is connected all the time. Maybe that is why the power supply fails.
The big capacitor across the power supply will provide the peak current and the power supply will provide the average current.