On / Off / Flashing LED circuit help

Discussion in 'General Electronics Chat' started by aac52, Dec 16, 2014.

  1. aac52

    Thread Starter New Member

    Dec 16, 2014
    28
    2
    I am looking to make what I believe should be a simple circuit, but unfortunately I am really struggling to understand the process of how I go about figuring it out!

    I often have ideas for circuits, but my lack of understanding with regards to the process of working out what I need, and the best way to go about it really holds me back. I have a keen interest in electronics and I feel now is the time to start doing something about it - hence my first post here!

    As a bit of background information I took electronics at A level where I received a B grade, quite how I managed that I do not know since I seem to lack the understanding of how many components work in detail. I have no problem physically creating circuits from schematics, but I do not always understand exactly how/why they work.

    So, on to the specifics of my little starter project.

    I have two 3.3v outputs (I will call them A and B), in this case they will be from a Raspberry Pi. Depending on the state of these two outputs I want a single LED to be in one of three states; on, off, or flashing.

    The states should be determined as such

    If A = 0, B = 0 Then LED Off
    If A = 0, B = 1 Then LED Off
    If A = 1, B = 0 Then LED Flashing
    If A = 1, B = 1 Then LED On

    When I say flashing I mean fading in and out, which I believe can be accomplished using a 555 timer circuit such as this one.

    Since the Raspberry Pi is powered by 5v I think this would be a sensible choice to use as my source voltage.

    Giving it some thought I believe it could be broken down into two "switches". By this I mean output A decides whether the LED is on or off, then output B decides whether the LED is solid on, or flashing.

    And to be honest that is as far as I have really got. I don't know *how* to go about designing these "switches" using components.

    Maybe my idea is completely wrong and there is a better way to achieve my desired result?

    Basically any help would be very much appreciated, but rather than just being given a circuit diagram, some kind of guidance in the right direct would be great, then hopefully I can draw the diagram myself.
     
  2. #12

    Expert

    Nov 30, 2010
    16,298
    6,810
    If A = 1, then fader has power applied to it and it runs.
    If fader has power applied to it, then the B sensor circuit has power applied to it.
    If B = 1, then short the power past the fader, straight to the LED.
     
  3. aac52

    Thread Starter New Member

    Dec 16, 2014
    28
    2
    Thank you, that makes a lot of sense, and seems so simple!

    I think this next question may show my lack of knowledge, but if 5v is applied to the LED (the case of A = 1, B = 1), which would be the same connection point as the emitter of the transistor from the flashing circuit, would the voltage not go "into" the emitter? I feel stupid just typing this question actually...
     
  4. #12

    Expert

    Nov 30, 2010
    16,298
    6,810
    If Ve > Vb then the transistor is in the zener function and will not allow a reverse current until about 5 volts. See datasheet for your transistor to see exactly what the reverse breakdown voltage is from emitter to base.

    If all else fails, use 2 diodes to allow either of two sources to drive the LED.

    If that isn't convenient, flip the polarity of the drivers so the LED is on their collectors.
     
  5. #12

    Expert

    Nov 30, 2010
    16,298
    6,810
    It comes from experience. All engineers chronically practice stripping problems down to their essence.
     
    cmartinez likes this.
  6. aac52

    Thread Starter New Member

    Dec 16, 2014
    28
    2
    I see, thanks again.

    I think I'm nearly there, but I definitely want to do a bit more reading about the fading circuit, and transistors. Whilst I studied transistors as part of my A level I never really did grasp the details, and I would very much like to understand exactly how the circuit is working.

    Hopefully tomorrow after a bit more research I can complete the circuit diagram and post back here.

    Once again, thank you for your help it has been really appreciated.
     
  7. #12

    Expert

    Nov 30, 2010
    16,298
    6,810
  8. JWHassler

    Member

    Sep 25, 2013
    201
    33
    Do you have one more output from the Raspberry Pi with which you could drive the LED? You could do it in code.
     
  9. aac52

    Thread Starter New Member

    Dec 16, 2014
    28
    2
    Thank you, I've spent some time reading through a lot of that, it's been very interesting and informative, but unfortunately a lot of it confuses me too.

    I do, but my aim is not to use coding as to further my knowledge of components instead.

    I've been trying to understand the fading circuit a little more. The one I linked to originally, and the one demonstrated in the link from #12 both mention that the source voltage has to be 9v or more, but I cannot really understand why such a high voltage is required.

    There is mention that it is due to the max output voltage being 2/3 of the input, but 2/3 of 5v is 3.33v which is enough to light an LED - am I missing something here?

    I'm also confused as to the importance of the duty cycle, I think I understand what it is, but I don't get why it is so important?

    I am certainly very confused about all of it despite the large amount of reading I have done today!
     
  10. #12

    Expert

    Nov 30, 2010
    16,298
    6,810
    Some LEDs use nearly all of 3.3 volts to start up, so you would be expecting to use a LED connected to the collector of a transistor. Red LEDs require less voltage than any other color.

    I think you're referring to a fader that uses the sawtooth shape of the 555 time constant side.

    The TLC 555 can operate down to 2 volts, but 2/3 of that won't fire up an LED very well. You're going to have to add a transistor or two to get some gain going. I expect you would drive an npn transistor with a resistor in the emitter side to turn it into a variable current driver instead of a variable voltage driver.

    Instructables: WTF? All those photos and no schematic??? That's like photos of driving somewhere, but no map. :mad:
    No wonder half the people on this site hate Instructables.

    Duty cycle is just, "how much time increasing compared to how much time decreasing".

    Please respond with specific questions. I don't think I addressed everything you wanted.
     
  11. KJ6EAD

    Senior Member

    Apr 30, 2011
    1,425
    363
    :( Destructables,
    :confused: the teaching site
    :mad: of the
    :eek: damned.
     
    cmartinez likes this.
  12. aac52

    Thread Starter New Member

    Dec 16, 2014
    28
    2
    Yes, Instructables isn't the best website, and that article goes a long way to prove it. It was just one of the first links on Google.

    I believe the circuit they use is the following http://www.555-timer-circuits.com/up-down-fading-led.html

    This seems a lot simpler than other circuits I've seen which apparently all do the same job, fading an LED in and out.

    As for more specific questions, I have a few.

    1. With regards to the duty cycle, what is so important about have one less than 50% with the 555 timer? This point seems to be raised on various sites on how to achieve such a thing, but I don't get why it is so important, especially with fading an LED???

    2. You've (#12) mentioned in this thread about connecting the LED to the collector or emitter, but what determines the decision as to which you use, is there a better one to use, what is the different between using the two?

    3. This circuit use a BC547, and many others use a 2N2222. Then this one uses a BC337 and a 2N2222. But for what characteristic is the transistor being changed, like in the second link, why not use two 2N2222 transistors?

    4. Relating to question 2, and the second link in question 3, the second transistor is wired to the collector of the first transistor, then the LED is wired to the emitter of the second transistor, is there a reason for this, can the LED simply be switched to the collector instead?

    As you can tell I don't really understand transistors fully despite trying to do some reading about them :(
     
  13. #12

    Expert

    Nov 30, 2010
    16,298
    6,810
    1) Duty cycle is not important unless your eye is calibrated to milliseconds and you have Obsessive Compulsive Disorder or Aspberger's Syndrome..

    2) Look at your reference in the third line of post #12. The LED in that circuit would do exactly the same thing if it was on the collector side of the transistor. As long as you have plenty of volts to work with, it works in the emitter side. When you are trying to do this with 5V, you don't have enough voltage to waste waiting for the capacitor to charge to maybe 3.8 volts before the LED begins to light up.

    3) a) I don't know.
    b) It just depends on which transistor you have a drawer full of. Ten volts and 20 ma is within the abilities of every small npn transistor that I know of.

    4) I think it's a mistake to wire it that way because the collector of T1 has to be above 3 volts for the LED to do anything. Again, wasting most of the 5 volts in a dead zone.

    You need to quit taking every circuit you see as an impeachment of your intelligence. There's a lot of crap circuits on the internet. We make mistakes here, but we usually sort them out quickly.
     
  14. cmartinez

    AAC Fanatic!

    Jan 17, 2007
    3,573
    2,541
    Yeah... and our mistakes here are of a far higher quality than elsewhere too... :D
     
  15. WBahn

    Moderator

    Mar 31, 2012
    17,748
    4,796
    The reason that so many sites get hung up on a duty cycle under 50% with a 555 is because the simplest way of getting the 555 to run as an AMV (astably multivibrator -- basically a free-running rectangular wave) results in the constraint that it will have less than a 50% duty cycle. Hence the caution is really for those that need a square wave -- a rectangular wave with a 50% duty cycle -- or even a rectangular waveform form with greater than 50% duty cycle. Some sites will claim that these can't be achieved with a 555. They can, but the circuit topology is just a bit more involved.

    Each application has various concerns and constraints and those generally can be used to rule out topologies that, for one reason or another, are not good choices for that particular application. At the end of the day you may have a few acceptable choices left and the decision of which to use may be based on technical merits or it might be based on which one is easier to route on a circuit board or it might be based on the personal preference of the designer.

    Many designers have preferred transistors for certain jobs and those often start out as a transistor that they got a really good price in bulk for many years ago. For lots of applications there are dozens, if not hundreds, of transistors that will work just fine and you can't really tell the difference between them in terms of performance in those applications. As you gain experience with transistor circuits you will start encountering circuits that need transistors that meet certain specs that some, if not all, of the common general purpose transistors can't cut. That's when you learn what some of the myriad parameters on the data sheet mean and how to tell if a given transistor is good enough for your purposes. Don't be surprised if you never learn what all of the parameters mean, because you probably will never encounter a reason to deal with the majority of them.
     
    #12 likes this.
  16. aac52

    Thread Starter New Member

    Dec 16, 2014
    28
    2
    Thanks again, I'm sure these basic questions can be quite tedious to answer!

    I'm extremely impressed how helpful you guys have been already. It is rare to find such a wonderful community these days. I really do appreciate it.

    Okay so let me see if I get this right...

    Using this circuit again.

    The 555 timer, resistor, and capacitor are used to create a sawtooth waveform (I am thinking this because the capacitor will discharge a lot quicker than it charges, so won't be a triangle waveform?) by charging/discharging the capacitor. When the capacitor reaches 2/3 of the voltage it starts discharging down to 1/3, then starts charging again.

    But then I get kind of confused as to what is happening with the transistor.

    What it is acting as - a switch? If so, the 9v source is going from the collector to the emitter through a current limiting resistor to the LED. This seems right as the 470ohm resistor would be far too limiting for the ~6V from the capacitor. So how is the LED being faded?

    Is there a recommended reading material to help me understand transistors more? I've been searching online but cannot really find anything that fully explains them.
     
  17. #12

    Expert

    Nov 30, 2010
    16,298
    6,810
    Pin 3 of a 555 is a hard current source. It slaps Vcc to the 33k resistor and that limits the current flow to the capacitor. Yes, the capacitor charges in a curve that starts fast and slows down. As the voltage on the capacitor rises, it raises the base voltage, which raises the emitter voltage, and the current through the LED slowly increases.

    When pins 2 and 6 of the 555 detect 2/3 of Vcc on the capacitor, the output pin switches hard to being a ground connection. The 33k resistor slows down the discharge of the capacitor and the transistor slowly reduces the current in the LED.

    When the voltage on the capacitor gets down to 1/3 Vcc, the chip snaps back to a high output voltage.

    Rinse and repeat.

    The product of 33k and 100 uf is 3.3. That means 3.3 seconds, but this circuit only uses the center third of the voltage range, so the speed of this is probably about 1 second per half cycle.

    One peculiar part of this circuit is that the capacitor spends its life between 3 and 6 volts. The LED in the emitter circuit plus the base to emitter circuit require about 2.9 volts to start up when using a red LED, so that eliminates any convoluted design work to shift the voltage and current to the right range for the LED. That is called some nice word like, "elegant" in engineering terms because the arrangement of the components eliminates the need for several components that would be necessary if the supply voltage was, let's say, 5 volts.
     
    Last edited: Dec 19, 2014
  18. cmartinez

    AAC Fanatic!

    Jan 17, 2007
    3,573
    2,541
    Why don't you download LTspice and simulate the circuit? My area of expertise has always been digital electronics and I didn't need to explore much into the analog field until a few months ago. Back then the members of this forum suggested that I started using it, and I have to admit that it was a little hard at first... but then I suddenly learnt TONS of new concepts and things, and my understanding of what goes on in an analog circuit simply exploded. Trust me, it's worth the effort.
     
  19. #12

    Expert

    Nov 30, 2010
    16,298
    6,810
    The book that this site is based on goes into great and meticulous detail about bipolar transistors. So much that it renders the dissertation almost useless to a beginner.

    In the words of a shade tree mechanic: A transistor is a 3 legged animal such that a higher voltage on the collector is controlled by a lesser voltage applied from the base to the emitter. This lesser voltage varies only a little as the current through the base changes, so you can usually expect the base to emitter voltage to be about 0.6 to 0.9 volts in any but high power applications. The result of changing the base to emitter current is that the capability of the collector to allow current flow is in the same direction, but much greater. This is where the logic splits in two directions.

    The collector logic is that a little change in the base current can turn the collector on and it will drain the current coming through a collector resistor so that (almost) all the power applied is inflicted on the collector resistor and the collector voltage becomes very small, like a few tenths of a volt.

    Meanwhile, the emitter current equals the base current plus the collector current. If you have a resistance in the emitter circuit, the voltage on that resistance will always be a few tenths of a volt below the base voltage. This effect is reinforced by the fact that the collector will pass quite a lot of current to support the voltage across the emitter resistor.

    This is a crude description, the first stage of understanding bipolar transistors. This description depends on the idea that the circuit is constructed correctly, the transistor is in its survivable range for voltage, current, and power dissipation, and such as that.
     
  20. cmartinez

    AAC Fanatic!

    Jan 17, 2007
    3,573
    2,541
    There you go... I've attached the LTspice file, and I've verified that it does certainly work... Now it's up to you to check it out.

    Capture 01.JPG

    Capture 02.JPG
     
Loading...