Using a capacitor to protect a circuit

Hi,

Sometime ago I was told to use a diode across a brushed motor so this diode could protect my circuit (including my arduino) against really high voltages that could be generated inside the motor when it is told to stop.

I studied it and it made a lot of sense, the diode would make that high voltage to be dissipated in only one direction cause if voltage would be applied in other direction it would not go inside diode but inside the motor, making it spin :)

Great, but today I was told to use a capacitor at VIN (12V) and GND of my A4988 driver which I am using to run a stepper to protect the chip if someone tries to spin the motor manually. Why a capacitor and not a diode? And why should it be placed in parallel with VIN and GND? Shouldnt I use it in the 4 wires that comes out of my servo to protect against high voltage?

I was told also to not turn my stepper manually when it's connected to the driver cause it could damage it. I know that for sure cause I already damaged 3 drivers without knowing I was causing that problem. After I placed the capacitor I turned manually the stepper and the driver didnt die. Why?

Hi, Think of it this way:

Capacitors Oppose a Change In Voltage. That means the voltage can change but not quickly. So "Spikes" (short time voltage peaks) can be controlled by a capacitor. And capacitors usually work for both positive and negative voltages.

Diodes have some forward voltage drop, which would not be good in the case of your driver.

batata004: I studied it and it made a lot of sense, the diode would make that high voltage to be dissipated in only one direction cause if voltage would be applied in other direction it would not go inside diode but inside the motor, making it spin :)

I don't agree with that last part, but anyway: yes, those flyback diodes will clamp down the voltage to the potential of the power rails, because if the voltage at the motor terminals is higher than the power line voltage, the diodes will be forward biased, and will therefore conduct the current (induced by the collapsing magnetic field in the motor's coils) to the power lines, without high voltages across the coils.

If on the other hand, the power is not connected, and you turn the motor, it will induce a current in the coils. The flyback diodes will be forward biased as well, meaning that these charges end up in the power lines. If power would have been connected, this would be handled by the power supply, that would keep the voltage constant anyway, but it is not connected, so the induced current results in a large potential difference across the power lines: this high voltage has the ability to kill all the electronics that it is connected to.

If you add a capacitor across the power lines, it will basically work like a low-pass filter, like Terry said, opposing rapid change in voltage. (The resistance and impedance of the wires and connections make up the resistor in your typical R-C low-pass circuit.)

If you are wondering where those clamping diodes are: they are inside the A4988. If you take a look at page 3 of the datasheet, you can see them: the body diodes of the 8 FETs in the H-bridges.

There are also other reasons why you should always add bypass capacitors across your power lines: they ensure that your circuit can cope with sudden load (current draw) changes, that your voltage regulator remains stable, and that you don't get noise from digital switching on your power lines. To find out more about bypass (or decoupling) capacitors, take a look at this thread, and this interesting video by Dave Jones.

Pieter

@terryking228 thanks man. So the capacitor makes the current goes more smooth right? But I still dont get how it protects the driver against high voltages of when I manually rotate the motor. Diodes surelly would do it.

@PieterP thank you too! Your reply was really nice, I learned a lot with it. But I still have a questio: if you say this driver already has diode protecting the input/output coils from the motor, why did my drive burn when I rotated it manually?

The diodes will conduct this high voltage from the motor to the power rails, so a high voltage across the Vcc and GND connections of the driver will kill it.

@PieterP so that why I should use a capacitor? When the motor is plugged to the power can I still rotate its shaft manually without destryoing the driver? I know that when the power is off I cant turn the shaft manually cause the drive is gonna die, but what happens when the motor is powered?

At first sight, I would say that it's safer when you turn it while the power is connected, because the induced currents can flow into and out of the power supply. But hey, don't shoot me if I'm wrong here, and it kills the chip anyway ;) .