Arduino Forum

Using Arduino => General Electronics => Topic started by: zaxarias on Jul 18, 2014, 08:58 pm

Title: Do i need capacitors
Post by: zaxarias on Jul 18, 2014, 08:58 pm
Hi all, my system consists of an arduino Uno, a motor driver, a Bluetooth module, a distance sensor an LCD and a servo motor..
Arduino is powered through a 9V battery and the motor driver with 12V battery... Bluetooth, LCD , distance sensor are powered from arduino's 5V, while DC motors and servo motor through the motor driver.. My question is: Do i need capacitors to protect the system from noise, surges ,spikes and generally make power more smooth ? Or it's ok if i don't use???.. If i have to use, in what components shall they be used? Or can i use one capacitor as "main" in the 5V line ? If you need more details please let me know .. Thanks a lot !!!!  :D :D :D
Title: Re: Do i need capacitors
Post by: retrolefty on Jul 18, 2014, 09:39 pm
Quote

Arduino is powered through a 9V battery and the motor driver with 12V battery... Bluetooth, LCD , distance sensor are powered from arduino's 5V,


Your main problem is that a small 9 volt battery will never be able to supply enough current for those devices, not enough current capacity. Even with a proper battery with enough current you will still be limited by the arduino 5V current capacity to power that much external stuff. You will need to use an external +5vdc power source with enough current capacity for all that stuff. How much current? Can't say without looking at the datasheets for each of the external devices to see what they require.

Title: Re: Do i need capacitors
Post by: zaxarias on Jul 18, 2014, 09:47 pm

Quote

Arduino is powered through a 9V battery and the motor driver with 12V battery... Bluetooth, LCD , distance sensor are powered from arduino's 5V,


Your main problem is that a small 9 volt battery will never be able to supply enough current for those devices, not enough current capacity. Even with a proper battery with enough current you will still be limited by the arduino 5V current capacity to power that much external stuff. You will need to use an external +5vdc power source with enough current capacity for all that stuff. How much current? Can't say without looking at the datasheets for each of the external devices to see what they require.



Thanks for replying.. Let me tell you again, only distance sensor , Bluetooth and LCD are powered through arduino, nothing else..It's certainly not "too much staff".. Arduino's current consumption,with everything on and working, is a total maximum of 100mA(measured with a multimeter). So my problem is not the battery, it's if i do need capacitors to protect my system..
Title: Re: Do i need capacitors
Post by: polymorph on Jul 18, 2014, 11:25 pm
A small 9V battery isn't up to putting out 100mA for very long. And they just aren't meant to supply that much current for any length of time. So the voltage is going to drop off much more quickly than the mAh ratings might indicate.

http://www.powerstream.com/9V-Alkaline-tests.htm

So, yes, the problem may very well be your battery.

Yes, you should have bypass capacitors around the circuit.

http://www.vagrearg.org/content/decoupling

Title: Re: Do i need capacitors
Post by: Grumpy_Mike on Jul 18, 2014, 11:41 pm
To answer your question:-
Quote
Do i need capacitors to protect the system from noise, surges ,spikes and generally make power more smooth ?

Yes you always need capacitors.
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 19, 2014, 12:25 am

A small 9V battery isn't up to putting out 100mA for very long. And they just aren't meant to supply that much current for any length of time. So the voltage is going to drop off much more quickly than the mAh ratings might indicate.

http://www.powerstream.com/9V-Alkaline-tests.htm

So, yes, the problem may very well be your battery.

Yes, you should have bypass capacitors around the circuit.

http://www.vagrearg.org/content/decoupling



Thanks for replying,
once again i don't have problem with my battery and i don't need my system to run for a long time..so i a m ok with that :D :D
Nice article about the capacitors!!! Can i have more details about the wiring of the capacitor?
Also, should i add a capacitor to each component or just to the power supply?


Grumpy_Mike thanks for replying  :D

For example ,this is how we should wire the capacitor ? https://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors/if-the-servo-misbehaves (https://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors/if-the-servo-misbehaves)
Title: Re: Do i need capacitors
Post by: polymorph on Jul 19, 2014, 01:21 am
As the article says, the capacitors act a bit like mini-UPSs to maintain voltage to things that draw current in spikes.

So anything that is electrically noisy. Motors, of course. CMOS ICs draw current in spikes at each change of state of a gate, so they need bypass capacitors. As close to the offending component as possible.

Someone here has a page on the proper application of bypass capacitors, and I don't recall who.

In general, larger value capacitors (10uF and up) work better at lower frequencies while not working well at high frequencies due to increased internal parasitic inductance and series resistance. Where lower value capacitors (0.1uF and below) don't work as well at lower frequencies, but get better at higher frequencies due to less internal parasitic inductance and series resistance.

Edit - sorry that is so big, I've downloaded and resized, see it attached below in a more reasonable size.
(http://i.cmpnet.com/planetanalog/2007/10/C0238-Figure1.gif)

http://www.planetanalog.com/document.asp?doc_id=527551

This one goes into a bit more detail, note that sometimes you get unwanted interaction between bypass capacitors:

http://www.intersil.com/content/dam/Intersil/documents/an13/an1325.pdf

It is important to pay attention to where the ground lines run, too, not just Vcc.

(http://i.stack.imgur.com/rRCDN.png)

As to your 9V battery, are you monitoring the voltage? It can sag under load to the point that Vcc can no longer be maintained at 5V.

Title: Re: Do i need capacitors
Post by: zaxarias on Jul 19, 2014, 01:32 am
Yes i ve monitored the voltage, never less than 4.95V.. So you suggest me add capacitors to the servo motor and the DC motors?
I power arduino through the barrel jack, does it need a capacitor before that ? Is it a good idea to add a capacitor to the Bluetooth module ? Thanks again !!

Also, because the DC motors are mounted, and i don't really want to take everything apart, can i do something like the photo attached ? place the capacitors right to the motor driver's output A and B..
Title: Re: Do i need capacitors
Post by: MarkT on Jul 19, 2014, 02:06 am


It is important to pay attention to where the ground lines run, too, not just Vcc.

(http://i.stack.imgur.com/rRCDN.png)


All of those 6 images are poor as the traces between IC pins and decoupling
capacitor are narrow signal traces, not low-inductance wide traces.   This is
more important than where you route the wires to the regulator, there must be
as low-inductance a path from chip to the fast decoupling cap as possible.  At least
they are short traces, but it shows a lack of understanding of Maxwell and Heaviside's
equations...

Also its perfectly fine to use planes in place of traces for GND and/or Vcc.  Planes
are as low-inductance as you can get!
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 19, 2014, 02:21 am



It is important to pay attention to where the ground lines run, too, not just Vcc.




All of those 6 images are poor as the traces between IC pins and decoupling
capacitor are narrow signal traces, not low-inductance wide traces.   This is
more important than where you route the wires to the regulator, there must be
as low-inductance a path from chip to the fast decoupling cap as possible.  At least
they are short traces, but it shows a lack of understanding of Maxwell and Heaviside's
equations...

Also its perfectly fine to use planes in place of traces for GND and/or Vcc.  Planes
are as low-inductance as you can get!

Can you please take a look at the image i posted on my previous post and tell me if i can wire the caps that way ? thanks a lot !!!
Title: Re: Do i need capacitors
Post by: Grumpy_Mike on Jul 19, 2014, 07:22 am
You can place them like that but they won't do as much good as if you soldered them on the motor.

Those capacitors you show are polerised, that is no good if the motor can change direction.
Title: Re: Do i need capacitors
Post by: TomGeorge on Jul 19, 2014, 09:32 am
Hi, I hate to repeat what everybody has asked, but , what SIZE is your 9V battery?

A picture of your project would help us to see what you have and provide accurate information.

Tom..... :)
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 19, 2014, 12:14 pm

Hi, I hate to repeat what everybody has asked, but , what SIZE is your 9V battery?

A picture of your project would help us to see what you have and provide accurate information.

Tom..... :)

6*AA ALKALINE batterries.. I rarely run the project on batterrties, most tests happen on usb..
I wikl post a picture later on the day..

Grumpy Mike, so its better to solder them on the motor, what capacitors should i use then??


Thanks a lot
Title: Re: Do i need capacitors
Post by: Zapro on Jul 19, 2014, 02:41 pm
Ahh, a battery-holder with 6 AA-cells. That is much, much better than a 9-volt block battery that we thought you were using.
Like this: http://en.wikipedia.org/wiki/Nine-volt_battery (http://en.wikipedia.org/wiki/Nine-volt_battery)

Actually, you could do yourself a favor. Only put 5 batteries in the holder, then you will not waste as much power in the voltage regulator on the Arduino, and your batteries will actually last longer! - Solder a wire across one position in the battery holder, or make a "dummy" battery out of a dowel wrapped in tinfoil, or whatever you can come up with.

// Per.
Title: Re: Do i need capacitors
Post by: Grumpy_Mike on Jul 19, 2014, 04:06 pm
Quote
so its better to solder them on the motor,

Yes, as a rule it is best to get it as close to the source of interference as possible.
You need both a 0.1uF ceramic capacitor for high frequencies and a large one for the low frequencies. If the motor runs in both directions you need a non polarised  capacitor, otherwise an electrolitic will do. The larger the better.
Title: Re: Do i need capacitors
Post by: Paul__B on Jul 19, 2014, 04:08 pm
So we got the battery sorted out, people were concerned you just might be using a "PP4" battery.   :D

OK, so you are not that silly!

If you are not using PWM, a 0.1µF ceramic capacitor soldered directly across the motor terminals.  YOu will notice this as standard in radio controlled toys.  (Serious models use ESC.)

If you are using PWM, you can still do this, but will need to provide an inductor in series with one or each of the motor terminals - I will "bow out" at this point, of explaining how you should calculate the value.
Title: Re: Do i need capacitors
Post by: Zapro on Jul 19, 2014, 06:26 pm
Regarding capacitors on motors for noise-dampening, all you need to know is here:
http://www.beam-wiki.org/wiki/Reducing_Motor_Noise (http://www.beam-wiki.org/wiki/Reducing_Motor_Noise)

// Per.
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 19, 2014, 08:40 pm
Sure i wouldn't use a solid 9V battery !!!  :D :D :D

Thanks everyone for the useful replies !!!
Quote

Only put 5 batteries in the holder, then you will not waste as much power in the voltage regulator on the Arduino, and your batteries will actually last longer!
// Per.

That can be easily done...


Quote
so its better to solder them on the motor,

You need both a 0.1uF ceramic capacitor for high frequencies and a large one for the low frequencies. If the motor runs in both directions you need a non polarised  capacitor, otherwise an electrolitic will do. The larger the better.

Thanks Mike...



If you are using PWM, you can still do this, but will need to provide an inductor in series with one or each of the motor terminals - I will "bow out" at this point, of explaining how you should calculate the value.

i do use PWM, so can you tell me more about the inductor ? :smiley-eek:
it wont work if i use a polarized or electrolytic capacitor as Mike said ?


Up to now i hear about capacitor on motors, no need to add bypass capacitors anywhere else?
LCD,Bluetooth and distance sensor are powered through arduinos 5V, maybe i should add a bypass capacitor on the 5V output ?
Also should i add a bypass capacitor to the power supply of arduino?


Thanks again !!! :D :D :D


Title: Re: Do i need capacitors
Post by: Grumpy_Mike on Jul 19, 2014, 09:14 pm
Quote
maybe i should add a bypass capacitor on the 5V output ?

You should have a capacitor on each of your three modules, as close to the module as possible.
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 20, 2014, 12:40 am

Quote
maybe i should add a bypass capacitor on the 5V output ?

You should have a capacitor on each of your three modules, as close to the module as possible.

Mike really thanks for replying again.. So one capacitor in each module, electrolytic or ceramic and what capacity?
Also Paul said that PWM won't work if i use a capacitor ..why?

Here is a really quick diagram of the wiring, please let me know if i did something wrong to the bypass capacitors..
Title: Re: Do i need capacitors
Post by: Grumpy_Mike on Jul 20, 2014, 09:37 am
Yes that is the idea, although you. Although you might  get away with not having them on the lower current devices like the LCD.

I am not sure why Paul said that. In general you do not want to make the capacitor that big wired directly across the motor, just a 0.1 uF ceramic. You want the large one across the motor supply not the motor itself. That is the motor and the driver be it simple FET or h- bridge. When you do then you can put an inductor in seriese with the supply and a capacitor the other side. This is known as a pi filter because it resembles the symbol for the maths constant. Google for an example.


There was a question recently about how to claculate it's value and things got rather over heated. Basically every one was right but some were arguing from mistaken premmisis. (that is probbly a spelling joke - a dyslexic on an iPad is not a good combination as the spell corrector is rubbish )
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 20, 2014, 02:19 pm


I am not sure why Paul said that. In general you do not want to make the capacitor that big wired directly across the motor, just a 0.1 uF ceramic. You want the large one across the motor supply not the motor itself. That is the motor and the driver be it simple FET or h- bridge. When you do then you can put an inductor in seriese with the supply and a capacitor the other side. This is known as a pi filter because it resembles the symbol for the maths constant. Google for an example.



So up to now i 've learned that i have to use a 0.1?F ceramic capacitors soldered on the dc motors and an electrolytic capacitor for each of the other modules(but what about their capacity? electrolytic or ceramic :~ :~ :~ :~ :~ :~ :~ :~ :~)..

Also i think i understand now why i will have problems if i use capacitors with PWM, however PWM is essential to my project so i don't really know what to do !!!
I think here says that a RC(resistor capacitor) filter can make the PWM wotk fine, right ? http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/ (http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/)
Title: Re: Do i need capacitors
Post by: Grumpy_Mike on Jul 20, 2014, 09:30 pm
Quote
(but what about their capacity? electrolytic or ceramic

Not sure what you mean? Use 47uF for the large capacitors.

Quote
I think here says that a RC(resistor capacitor) filter can make the PWM wotk fine, right ?

No. That is not suitable for a motor. It produces a varying DC voltage, that is not the way to drive a motor and have good speed control.

Read about PWM here:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html (http://www.thebox.myzen.co.uk/Tutorial/PWM.html)
For a motor you must apply it directly to the motor.
Read this on motors:-
http://www.thebox.myzen.co.uk/Workshop/Motors_1.html (http://www.thebox.myzen.co.uk/Workshop/Motors_1.html)

For the motor Pi filter read this, it is the last schematic on the page:-
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html (http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html)
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 20, 2014, 10:30 pm

Quote
(but what about their capacity? electrolytic or ceramic

Not sure what you mean? Use 47uF for the large capacitors.

Quote
I think here says that a RC(resistor capacitor) filter can make the PWM wotk fine, right ?

No. That is not suitable for a motor. It produces a varying DC voltage, that is not the way to drive a motor and have good speed control.

Read about PWM here:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html (http://www.thebox.myzen.co.uk/Tutorial/PWM.html)
For a motor you must apply it directly to the motor.
Read this on motors:-
http://www.thebox.myzen.co.uk/Workshop/Motors_1.html (http://www.thebox.myzen.co.uk/Workshop/Motors_1.html)

For the motor Pi filter read this, it is the last schematic on the page:-
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html (http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html)

Mike thanks again, your help is so important !!!  :D :D :D

--Each module(Bluetooth,Distance sensor,LCD) as you said should have a 47uf capacitor ,right? Should it be Electrolytic or ceramic? or it doesn't matter?

--I am familiar with the way PWM works, i saw the schematic you told me and i think it doesn't worth trying to add 4 capacitors and an inductor to each of the four DC motors i use... Otherwise, is there anything else i can do ? Really, PWM ,in practice,wont work at all if i just add a ceramic capacitor to each motor?

Title: Re: Do i need capacitors
Post by: Grumpy_Mike on Jul 20, 2014, 10:33 pm
Quote
a 47uf capacitor ,right? Should it be Electrolytic or ceramic?

You have no choice, you can't get 47uF ceramic capacitors.

Quote
Really, PWM ,in practice,wont work at all if i just add a ceramic capacitor to each motor?

Just adding a 0.1uF capacitor across a motor will not make PWM stop working.
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 20, 2014, 11:41 pm

Quote
a 47uf capacitor ,right? Should it be Electrolytic or ceramic?

You have no choice, you can't get 47uF ceramic capacitors.

Great !!!
Quote
Really, PWM ,in practice,wont work at all if i just add a ceramic capacitor to each motor?

Just adding a 0.1uF capacitor across a motor will not make PWM stop working.
[/quote]
Nice to hear that.. So where was the problem? ??? :smiley-eek: :smiley-eek: :smiley-eek:
Title: Re: Do i need capacitors
Post by: Grumpy_Mike on Jul 20, 2014, 11:54 pm
Quote
So where was the problem?

You tell me?
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 21, 2014, 12:01 am

Quote
So where was the problem?

You tell me?

if i remember right Paul said that PWM wouldn't work if i use a capacitor...
Title: Re: Do i need capacitors
Post by: Grumpy_Mike on Jul 21, 2014, 12:02 am
That was if you used a big capacitor not a 0.1uF.
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 21, 2014, 12:10 am

That was if you used a big capacitor not a 0.1uF.

OK, so in summary :
..DC motors: ceramic 0.1uF
..Each other module(Bluetooth,LCD,Distance sensor): electrolytic 47uf
..Servo motor: ????
Title: Re: Do i need capacitors
Post by: Grumpy_Mike on Jul 21, 2014, 12:30 am
Servo motor.
100uF to start with but if you get trouble use a Pi filter.
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 21, 2014, 01:57 am

Servo motor.
100uF to start with but if you get trouble use a Pi filter.

it's a Tower pro micro servo..
Take a look here,https://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors/if-the-servo-misbehaves (https://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors/if-the-servo-misbehaves) , suggests a 470uf capacitor..
Also, servo acts as a dc motor(needs a non polarized capacitor) ? i mean can we add an electrolytic capacitor to a servo ? or it needs one with no polarization(ceramic) ??
Title: Re: Do i need capacitors
Post by: Grumpy_Mike on Jul 21, 2014, 07:51 am
There is not much difference between the two values of capacitor in practice. There are no precise answers when it comes to large decoupling capacitors because it depends on too many factors that can not be calculated, or they are more difficult to calculate than to just try. Having too much capacitance is no trouble, having too little is.

You only need non polierised capacitors when the voltage across that capacitor changes polarity. With a servo the supply is constant all the polarity reversing is inside the servo, your capacitor will never see this.
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 21, 2014, 10:12 am
Mike ,how about the voltage rating of the capacitor? The modules work at 5V, can i use 16,25,50,63 or 100V capacitor ?
I guess it should be something close to 5V right ?
Title: Re: Do i need capacitors
Post by: TomGeorge on Jul 21, 2014, 11:46 am
Hi, use 16V caps, any higher voltage and you will only be wasting space, just make sure you fit them with the polarity the right way.

Tom..... :)
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 21, 2014, 12:01 pm

Hi, use 16V caps, any higher voltage and you will only be wasting space, just make sure you fit them with the polarity the right way.

Tom..... :)

Are there any electrolytic capacitors less than 16V? I can't find one!!!
Title: Re: Do i need capacitors
Post by: Grumpy_Mike on Jul 21, 2014, 02:58 pm
A voltage rating is just the maximum voltage you can use. You must not exceed this voltage but it is good practice to use a capacitor at 80% or less below the rated voltage.
Yes you can get 5.6V capacitors but 16V will do just fine.
Title: Re: Do i need capacitors
Post by: TomGeorge on Jul 21, 2014, 03:10 pm
Hi, if you dig, like E14 or RS parts suppliers you can get 10V caps.

Don't use 5.6V on 5V, to close to rated tolerance.

I have the job of repairing 3phase current monitors, they have a 5V rail and all the 6V electrocaps have got bigger and failed.
No skin of my nose, 6 caps per monitor times 150 monitors, good earner for me, pain in rear end for customer.

Tom..... :)
Title: Re: Do i need capacitors
Post by: zaxarias on Jul 21, 2014, 07:37 pm
Thanks for the replies, so i will get the 16V capacitors...