Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
powering an inductive load from the pi directly can cause a voltage spike to flow back on the 5v rail
Use of decoupling capacitors can negate such problems

You are mixing up two things there.

Decoupling capacitors are required to keep the supply voltage stable when lots of transistors inside the controller switch simultanously and parasitic capacitors inside the controller are forced to change their charge. The PCB tracks to the supply pins behave like a resistor or inductor, so even a very good, nearly ideal power supply simply can not keep the voltage at the supply pins constant. The decoupling capacitors can, because their track to the supply pins is extremely short. As a welcome side-effect, the decoupling capacitors also short high frequency noise to ground.

Inductive loads switched to DC suppiles create a more or less large voltage spike with reversed polarity. This voltage is usually large enough to kill nearby semiconductors, typically the switching transistor. To get rid of the voltage, connect a fast diode in parallel to the inductive load, but with reversed polarity. This is commonly called a flyback diode. While the load is powered, the diode is passive. Because the voltage spike has reversed polarity, the diode becomes conductive and shorts out the voltage from the load, converting the energy to heat in the diode and the load's wire. The remaining circuit sees a reverse voltage of about 0.7 V across the load that does not harm usual Si semiconductors.

Another thing: Yes, the I/O pins of AVR microcontrollers have a significant capability to sink and source current. The ATmega328 (datasheet), commonly found on Arduino boards, can sink and source at least 20 mA @ 5 V, 10 mA @ 3 V, abs. max. 40 mA (see datasheet page 365 and following). But the total current must not exceed 100 mA per port, and it must not exceed 200 mA total. Other AVR processors have very similar ratings, and I would expect similar performance from PIC chips. But for anything but a simple LED or a TTL/CMOS compatible input, I would use a driver transistor. I/O pins also have a pair of diodes (see page 97), but those diodes are just clamping diodes that prevent killing the controller by ESD. They are not designed to discharge an inductive load.

Oh, and don't expect other, younger microcontrollers to have similar driving capabilities. Let's look at the SAM4S series (datasheet), an ARM Cortex M4 with a lot of peripherals, more I/Os, more flash, more RAM, and faster than AVRs. The I/O pins can sink and source max. 2 mA (see page 1143), a few pins can sink and source 4 mA, and only two pins can sink and source 30 mA. Abs. max. total current is 100 mA for 64 pin devices, 150 mA for 100 pin devices. All of that at an I/O voltage of 3.3 V typ. Other ARM-based microcontrollers have similar limits. They can directly drive a low-current LED, or CMOS compatible logic inputs, but for everything else, you need a driver transistor.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^2: Using a controllerless servo on the Raspberry Pi with Perl by afoken
in thread Using a controllerless servo on the Raspberry Pi with Perl by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (3)
    As of 2017-10-20 04:11 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My fridge is mostly full of:

















      Results (258 votes). Check out past polls.

      Notices?