According to Pete - February Edition

Check out this month's version of "According to Pete."

Favorited Favorite 0

If you're not familiar with our video series "According to Pete," this is a monthly video where Pete Dokter, the SparkFun Director of Engineering, visits various engineering topics and answers user submitted questions. In this month's video, our Pete talks a bit about OpAmps, LEDs, and answers a few other questions. Check it out:

There you have it! As always, feel free to leave any additional comments, questions, or suggestions in the comments below. We are always looking for more fodder for the "According to Pete" video series, so questions you might want answered in the future are welcome as well. Cheers!


Comments 56 comments

  • Nice work Pete! Good to hear some history on driving vs pulling LEDs. That and what Thor might take into battle. Poetry.

    • clever / about 12 years ago / 1

      my idea on the LED's is that AVR's default to having the pull-ups on

      so LED's to ground will be on dimly whenever the chip is held in reset or starting up

  • samman946 / about 12 years ago / 2

    Its videos like these that keep me coming back to sparkfun. It would be sweet if you guys did this on a weekly basis.

  • Colin.I / about 12 years ago / 2

    Does that make me feel free and easy like I'm walking through the meadows? Yes. It does.

    Touche

  • Bunk / about 12 years ago / 2

    Question: How do decoupling capacitors work and how do you choose the value?

    • sgrace / about 12 years ago / 2

      His first video goes over it pretty well, but I can give you a jist if you don't have the time.

      Decoupling capacitors are what their name says, decoupling. They are used between parts of a circuit to help reduce noise further on in the circuit.

      So lets say in one part of a circuit I have an OpAmp. Depending on the OpAmp circuit, you might get some noise that needs to be reduced so the remaining part of the circuit doesn't have switching issues. What I mean about switching issues is if a transistor is suppose to be "off" but becomes "on" for a short period due to noise.

      Identifying where you can use a decoupling capacitor is pretty easy once you know what to look for. There are some calculations out there that you can use (mainly LPFs) to help you identify how much noise you want to reduce (this is a complex topic and requires a bit of math). For the most part you don't need to worry about the capacitance.

    • TimCole / about 12 years ago * / 1

      The basic concept is that capacitors pass high frequency signals and block low frequency signals. For digital circuits, the usual intent is noise reduction. If you put a capacitor between a power line and ground, high-frequency signals -- and most noise is relatively high-frequency -- have a low-impedance path to ground.

      Determining the precise value of capacitance would require knowing the frequencies you want to keep, the frequencies you want to reject, impedance, and no doubt a few things I've long since forgotten. But fear not! Most noise-decoupling capacitor values are chosen by rules of thumb and experimentation. Most IC vendors have done the experimenting for you, so your best resources are datasheets and application notes.

      The old standby for digital ICs was a 0.1 uF ceramic capacitor across Vcc and ground, but that rule of thumb has evolved over the last 20-odd years. (Editted for clarification and to remove brain-dead carelessness.)

      • Mahdi Olfat / about 12 years ago * / 2

        Hmm. @TimCole, sorry but your post is very misleading. You are describing high/low pass filters. Ideal capacitors alone are NOT high/low pass filters. There are other parameters that let the decoupling caps to act as such (i.e. their form factors or packages - which is somewhat useless if you are using through-hole packages).

        Also, DO NOT USE CAPACITORS ON SIGNAL LINES (i.e. capacitor from signal to GND) unless EXPLICITLY demanded by the datasheet. Why would you wanna voluntarily introduce capacitance on a signal line? Capacitance will most likely kill the digital logic your trying to transmit (mess up the falling/rising edges). For example, capacitance on I2C signal line (SDA) would kill communication. And guess what limits the number of devices on I2C? Capacitance.

        100nF, 1uF, 4.7uF, and 10uF decoupling capacitors are used frequently between VDD (IC power) and VSS (IC GND) and are placed as close to the power pins as possible (if you're designing a PCB, USE SMD caps, the smaller the better, 0402 or 0603 packages are recommended). But, if your circuit is working, and the datasheet has not explicitly recommended any decoupling caps, just do not use them (especially on breadboards and simple low HZ 2-ly PCBs).

        Lastly, I can tell you from experience that these "rules of thumb" are almost always wrong. If you want to use decoupling caps, follow the datasheet. If you want to know exactly what's happening with decoupling caps, take some time to study the underlying principles.

        • TimCole / about 12 years ago / 1

          Oh crud! I did say signal lines, didn't I? Remind me to never type without my brain engaged.

          Power lines! Not signal lines! (Except for specialized signal conditioning applications.)

          I do understand the principles, and my apologies for not checking my post before hitting submit.

          • Mahdi Olfat / about 12 years ago / 1

            It's all good.

            I was really addressing whoever was reading the comment. By "you", I didn't really mean you :). Sorry for not checking my post before submitting it.

        • sgrace / about 12 years ago / 1

          I fully agree.

          The only time I've decoupled is for VCC to GND and analog circuits that don't touch an MCU.

      • You just described a high-pass filter then said it was low-pass.

        • PresidentOfAwesomeness / about 12 years ago / 2

          Yeah, I thought that's what he described first as well... but then I realized that in the setup that was described, the high frequency signals are being passed through the capacitor to ground. The (relatively) low frequency signals are not, for the most part, passed through the capacitor to ground. So a capacitor is a high pass filter, but when used to ground a signal line, it becomes a low pass filter.

      • Bunk / about 12 years ago / 1

        Thanks for the response. Assuming you are using an 16MHz microcontroller, and pulseing a line high and low so the frequency on the output line is 4MHz, what value cap should I use? Also, What are some of these rules of thumb?

        • Mahdi Olfat / about 12 years ago / 1

          @Bunk, do not use a decoupling capacitor on you signal line. What are you trying to achieve with decoupling caps here? is your circuit not working? Does it have a lot of noise on it that you are observing?

          Let me know, perhaps I can help.

          • Bunk / about 12 years ago / 1

            the cap isn't attached to a signal line. I am using an Arduino to drive a shift register and I want to know what the value of the cap between VCC and GND should be. I forgot to add that. The shift register is receiving data at 4MHz. I was told to put a 1uF cap on it so I would avoid noise, but I would like to know how that value was derived.

            • Mahdi Olfat / about 12 years ago * / 1

              1uF is fine. But chances are, if you put it there and take it out, you won't see a difference. The link @trophosphere recommended is fine.

              The easiest way I can explain to you how the values are chosen is this:

              By characterizing the "system" (your circuit, filters, decoupling caps) at hand, you'll end up with a capacitor impedance vs. frequency plot. You may then look at that plot, and point to a frequency range (bandwidth), and determine that a particular capacitor with certain capacitance would block (not pass) those frequencies.

              The reason that you were "recommended" decoupling capacitor values instead of being asked to characterize you circuit, is that at low frequencies (low speed designs or DC power lines), those general values (100nF, 1uF, 4.7uF, and 10uF) work relatively fine.

              If you really really want to learn what's going on, check this out (no spaces): www . speedingedge . com / rtft_book . htm

            • trophosphere / about 12 years ago / 1

              All you wanted to know and more here

    • Dopey / about 12 years ago / 1

      He talked about this in one of the first According to Petes

  • Member #15009 / about 12 years ago * / 1

    ditto

  • Member #15009 / about 12 years ago / 1

    Pete you need to change that Icon pic, it looks like a pic of bin laden :) lol maybe i need glasses? ;0 I guess it's a glass of beer?

  • An easy way to do the "backwards" LED driving with "non-counter-intuitive control" is to hook the anode of the LED to the voltage you want and the cathode to the emitter of an NPN. The collector should be connected to ground. Then run the IO line to the base. Ding!

    • PresidentOfAwesomeness / about 12 years ago / 2

      Erm... do you mean the emitter to ground, and collector to the load? You've got it backwards. And don't forget a current limiting resistor between the base and the I/O pin. And the resistor in series with the LED. Else, you'd have some interesting things happen...

  • You guys are still flying with flybars ... Go flybarless, I'll never come back to flybar, and you'd like what's inside a flybarless unit ;)

    Thomas.

    • I doubt my level of ability would warrant going without flybars. And besides, the whole mechanical mixing thing is kinda cool. I dig it the same way I dig old clocks. And it flies!

  • PhilipH / about 12 years ago / 1

    Hey Pete,

    Your vids and tutorials are awesome, I enjoy watching them, it's kinda nostalgic for me. I have a question, correct me if I'm wrong; since electrons are negatively charged, and they are "sourced" from the cathode, wouldn't an IO in low state source current and a HIGH IO sink current?

    • In electrical engineering "current" is defined as the flow of lack of electrons (hole flow), not electron flow. So since lack-of-electrons are sourced from the anode, an IO in a low state sinks current and a high state sources. Hope that helps :)

    • Think in terms of conventional current flow. Then yer zen.

  • microtherion / about 12 years ago / 1

    I'm not sure I buy the argument that if you drive an LED by pulling a controller pin to GND, you can use a higher Vcc than the controller could supply: It would seem to me that if your controller can supply e.g. 3.3V and you're using an external 9V supply on the LED, you can no longer turn the LED off because even when the controller pin is high, you still have ample voltage between the pin and Vcc. Is there anything mistaken about this reasoning?

    • Jgarc063 / about 12 years ago / 1

      That's where the open-collector open drain configuration comes into play like I mentioned in a post above.

      hth, Jorge Garcia Cadsoft Support

    • In that case, you don't pull the pin to 3.3V (or whatever), you make it an input (hi Z).

      • cctsm / about 12 years ago / 1

        Yes, but most chips have ESD diodes, which is why your absolute maximum ratings are what they are, usually -0.3V to VDD+0.3V.

        This means that the (say) 9V going into your hi-Z pin gets clamped to VDD+0.3V (ESD diode forward voltage), and your LED turns on. And you cannot turn it off, because the ESD diodes are always going to be there.

        If you need to drive LEDs from a higher voltage, use an external NPN/NMOS transistor.

        As for why pulling LEDs low (as opposed to driving them high) is so common, some chips still have higher sinking capability than sourcing, because NMOSes are just plain better than PMOSes. Did some quick googling and found a DAC board specced at 8 mA sink and only 0.4mA source, which proves the point beautifully. Yes, I imagine it had a NMOS and a pullup as opposed to a full half bridge output, but hey.

      • Cal_Eng / about 12 years ago / 1

        But there still has to be a point at which you are transitioning the pin from Hi-Z, to an output, and then to a ground path.

        I guess the issue is that in those microseconds when the pin state is changed and the path to ground is opened, is there any chance of damage from a far higher voltage than Vmax for the MCU?

        Just an observation...

        • Bunk / about 12 years ago / 2

          I never like to allow voltages higher than VCC (such as 9V) to enter my microcontroller because if you make a mistake with the programming so that the pin becomes an output high, it will kill your microcontroller. I guess this is because it connects the 9V to VCC but im not sure. All I know is the one time I did it, I killed my atmega328. To control a larger voltage, I just use an NPN transistor or N channel MOSFET.

      • microtherion / about 12 years ago / 1

        Ah yes, now I understand. Thanks!

  • How would i pull an LED to ground with an Arduino?, would i have to use a Transistor?

  • Jgarc063 / about 12 years ago / 1

    Another reason to drive an LED on the low-side(cathode into the microcontroller pin).

    Many microcontrollers have open-drain(open-collector) output settings.Basically the pin can be set to behave as a single NPN(NMOS) Transistor. This takes care of voltage translation if the LED is to be driven from a higher voltage then the micro's supply voltage without having to use an external transistor..

    Just thought that was worth mentioning.

    Best Regards, Jorge Garcia Cadsoft Support

  • samman946 / about 12 years ago / 1

    Its videos like these that keep me coming back to sparkfun. It would be sweet if you guys did this on a weekly basis.

  • Hair_of_the_Dog / about 12 years ago / 1

    Impact drivers are great! I got one for Christmas and used it to build my work bench. @ Amazon

  • cmlburnett / about 12 years ago / 1

    What are the [analog-side] design considerations when increasing the resolution of an ADC to something like 24-bit (or anything significantly higher than the usual 8- or 10-bits)? What if combined with an amplifier with a modest gain (x1000)?

    • BB / about 12 years ago / 1

      Read through the (analog) circuit board layout techniques in the text Op Amps for Everyone. Here is a link of the relevant chapter from Texas Instrument's copy:

      http://www.ti.com/lit/ml/sloa089/sloa089.pdf

    • wpmcnamara / about 12 years ago / 1

      What the others said is quite correct. For a good run down of the challenges associated with high-precision and/or high-speed ADCs, check out Robert Lecoste's article in this months Circuit Cellar. Fundamentally an ADC is only as accurate as it's reference voltage. For a 2.048V reference accurate to 0.04%, the best you will ever get is about 11 bits of accuracy out of the ADC, and that's in a carefully temperature controlled environment.

      For your input amplifier, your noise level has to be below the smallest measurable level (1LSB). For a 10bit ADC that theoretical ADC SNR is around -62dB. For a 24bit ADC, it is around -146dB. The practical noise floor is always higher which will give you some leeway in your amplifier, but we are still talking about extremely low noise amplifiers.

    • TimCole / about 12 years ago / 1

      Well, Wasted, I've got to applaud your succinctness!

      Analog side design for ADCs and DACs gets tricky. Component layout and PCB trace routing are very important. For 8 to 10 bits at low data rates, you can get away with using broad guidelines, which are usually described in the datasheets. As your bit count and data rate increase, the design gets more critical, and you're well advised to get a skilled layout specialist involved.

      In general, keep the analog and digital sides separate. Avoid having digital traces cross analog traces. If you can, use multilayer boards and use ground planes to isolate analog and digital sections. Use the smallest bit count and lowest data rate you can get away with.

    • wasted / about 12 years ago / 1

      noise everywhere :)

      • True enough. In my book, x1000 gain isn't modest (at least in a single stage). And once I'm looking at mV or less, lower than the noise floor on my scope, I expect I'm going to have to be clever before I trust the numbers. Spectrum analyzer, much calibration, etc.

  • Super awesome excellent video, as always Pete. Love the style, honesty, and pragmatism. Teach us more!

  • Wylly / about 12 years ago / 1

    Really great as usual. Already waiting for next month episode :)

Related Posts

Recent Posts

Tags


All Tags