Let's Make Robots!

Capacitors

Hi y'all, just joined LMR, fantastic site, lovin' it already . . .

 

I am a bit of a beginner to robotics, I mean I can program and all that, and make these things, but I know not how or why they work.

One thing I have been wondering is about capacitors:

When designing a circuit, how does one know where to place capacitors, or why to have them, or how they function in that position?

With this circuit in particular (from here: http://letsmakerobots.com/node/2074), why the caps?

those two in the top-right, why do they both need to be there?

motor control circuit

I guess my three main questions are (focussing on this circuit):

1. Why are the capacitors there? (and what they do)

2. How do you know to stick them there?

3. How do you know what type/size, or whther they must be polarised?

 

Any light shed on this would be much appreciated.

 

 

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thanks heap, guys, this has actually helped and improved my understanding, especially Oddbot's, rik's and rogue's answers.

So basically,

- they fill in for dips in voltage

- they remove high spikes

- and the bigger the better

 

and arbarnhart, you're right, anyone know where to get a good flux capacitor?

Careful with the bigger/better philosophy. It depends on the kind of noise you are getting in your system. Bigger is better for large dips in voltage (motor starting up) whereas small ones are required for high frequency noise (crappy brushed motors running full speed). And if you want a flux capacitor you have to build a time machine first...

>>>(crappy brushed motors running full speed)

Is there another kind of brush motor or another speed to run them at?  ;^>

I am learning even more. I figured the trio of ceramic caps on motors was because you can't use polarized if you will reverse the motor.

No news on the flux source, but don't leave Prof. TeleFox out of the list of knowledgeable folks to thank. His explanation about the output capacitor on a VR was highly enlightening. I now have a better understanding of VRs also as a bonus.

1. Why are the capacitors there? (and what they do)

The 100uF caps are there to keep the power rail "stiff" (prevent voltage dips).  The larger the capacitor value the more charge can be stored and thus can supply current better.  The cap could be a farad but it would be expensive.  Just make sure the capacitor voltage rating is quite a bit higher than you need.  I suggest an electrolytic (which are polarized) capacitor for this purpose.

The 0.1uF caps are there to suppress noise, or more precisely act as a low pass filter (which passes only low frequency current).  Capacitors have a reactance (resistance) inversely proportional to frequency.  The [high frequency] noise effectively gets shorted to ground by the capacitor.  The basic idea is that the capacitor appears as an open circuit for DC (direct current) and a short circuit for high frequency AC (alternating current).  I suggest non-polarized ceramic capacitor for this as they are cheap.

2. How do you know to stick them there?

Because brushed motors are very noisy and can draw large currents.

3. How do you know what type/size, or whther they must be polarised?

I think you should first study R-C filters to gain an understanding.

 

 

Many a day capacitor values are chosen arbitrarily. Even the placement of a cap may seem a random choice by the circuit designer. The word "sprinkle" is even used sometimes.

"Caps" are small and cheap and do not consume power. So when in doubt, add some more capacitors. That is often the mantra that seems to rule the circuit design world. Most engineers call it a "Best Practise", but most of them are masking their incompetence. As am I right now.

When fearing for electrical noise, add some suppression caps.
When fearing for power dips, add some buffering caps.
When blocking a DC bias in an AC signal, put a coupling cap in series.

Etcetera.

Knowing when you are in one of those situations (there are more than three), is half the battle. Te other half consists of a few arbitrary rules of thumb. Like Oddbot's rule for buffer caps: "bigger is better". For filter caps, the rule would be something like "faster is better".

Most of the time, we choose whatever is available in the tackle box and check if it helped with our problem. Or there is no problem and we add the caps anyway. For good measure. Better safe than sorry. Because all the cool kids are doing it. That's the problem with best practises. You don't always know why it's The Right Thing, but you know that it is.

So here's my advice: learn! Read discussions of cap-remedied problems. Explore other people's work (crack open appliances and take a good look). Ask around (like you're doing right now). And experiment, experiment, experiment!

Keep an eye out for the easy answers: Why did the designer put caps in his circuit? Which problem is he solving by that?
Keep an eye out for standard scenarios: noise suppression is different from power buffering. They come with different standard solutions.
Keep an eye on your measuring thingey (multimeter or oscilloscope): change value, note difference in result. Revise.

Be a scientist. Be a sceptic. Be curious.

Best Practice = Can't remeber the formula and couldn't be bothered finding my calculator.

The only time I have needed to calculate precise capacitor values is for timing or filter circuits.

In robotics capacitors are most commonly used for power supplies. Larger electrolytic capacitors help your regulator to cope with sudden changes in load. Smaller capacitors are used for noise filtering.

Say for example you have a Sumo bot. It is sitting still. Suddenly it detects an opponent and charges forward. The current draw from the motors breifly peaks at a few amps and causes your battery voltage to drop by a volt or two during that time.

The electrolytics on the battery side of the regulator help feed the motors and limit the drop in battery voltage. The electrolytic capacitor on the output of the regulator can briefly continue to feed your logic and sensors if the battery voltage dips below the regulator's cutoff voltage.

In both cases the big electrolytics are acting like small batteries. They don't store a lot of power but they can charge / discharge much quicker than the battery to help smooth out the surges.

In the meantime your now screaming motors are pumping electrical noise out by the bucket full! Your small capacitors work to short this noise to ground. This happens because although a capacitor is essentially an open circuit and will not conduct DC it will conduct AC. This happens because the electrical charge on one capacitor plate induces an equal but opposite charge on the opposing plate. If the charge on one plate oscillates then it will induce oscillation on the other plate.

This is why you will see the little capacitors across motor terminals and near any circuit that either generates noise or could be affected by noise.

As for the actual values used. General rule of thumb is that bigger is better. Component cost and space limitations are big factor. There are formulas you can use to calculate minimum values necessary but in many cases it is easier just to slap in the biggest capacitor you can find.

In the example above you would need to know things like the batteries internal resistance and maximum current draw of the motors. In practice adding bigger capacitors than required could give the robot better accelleration as large capacitors can discharge quite large currents for short periods of time. Perfect for accelerating at your opponent.

 

OK, but why do I need on on the output side of a voltage regulator with no load when it has one on the input so there are no spikes? (details in earlier post)

I understand about spikes and put a cap across pretty much any incoming voltage from a battery or BEC (which I now think of as sloppy regulators) and at the point of high draw. What I don't understand is using one like I needed last night (if you saw my 7.4v o 5v thread). I had a cap across incoming current from a batter to a VR but not on the output and I was seeing too much voltage. TeleFox politely suggested I actually read the datasheet I posted a link to where it plainly states that the output needs a cap. So I capped it and the voltage was corrected. But why? There was no load and because the input was capped, I don't think there was a spike. I even had a 1AMP fuse in the circuit because I had not built a VR from scratch before (and it is a good idea in general) and it is still intact, so I didn't have any big spikes the first cap wouldn't handle.

I am from the software side of the fence that the Arduino (and other similar tech) bull dozed down. It is really easy to do a lot of stuff that I would never have attempted in the past because it required a lot of support circuitry and a deep understanding of electronics. Now many of the circuits are pure logic level connections and I can just wire them right together (Tx to Rx, PWM to servo control line, VCC to +5, GND to GND) but some need a small amount of circuitry. The trick is knowing when and what to do. The Arduino library is missing the function PutSmokeBackInChip()...

EDIT - and of course, no thread on capacitors will be complete without a request for a good source for flux capacitors... :)