Connect with us

LED Flasher help.

Discussion in 'LEDs and Optoelectronics' started by WaterWalker, Sep 21, 2013.

Scroll to continue with content
  1. WaterWalker

    WaterWalker

    15
    0
    Sep 21, 2013
    Good day all

    Ok, I am an electronic novice. So, for circuits, I borrow from the 'net. So here's the circuit that I borrowed and adapted to my needs - http://1stproject-circuit.blogspot.com/2010/08/discrete-running-flashing-led-circuit.html

    I have modified it to suit my needs. And, it all works as planned. But, I wanna take some clutter away from my build. So, a short and sweet question. I have four of these circuits. Three smaller builds controlling just two LEDs, and 1 main build controlling all LEDs.

    All of these smaller builds are isolated from each other via a dip switch selector being used as power switches.

    I want to take the dip switch selector away, and replace it with a pushbutton switch that is normally open. I would also like the following to happen, when the button is pressed, "circuit 1" activates. When the button is pressed again, "circuit 1" de-activates and "circuit 2" activates. When the button is pressed a third time, "circuit 1" activates while "circuit 2" remains active. If the button is pressed the fourth time, "circuit 1" and "circuit 2" both de-activate and "circuit 3" activates. You can see the pattern? Button press number 7 will be power off.

    My question is this, How can I accomplish this without a complete redesign of my build? Is there a way?

    Thanks for any help you can give me.
     
  2. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    If you want to de-clutter your build, you should take a step back and define exactly what you want to do. The best option to minimise clutter and maximise the ease of making future changes would be to use a microcontroller such as a PIC. A 40-pin device might be able to drive all your LEDs directly, or you might need expansion and/or driver circuitry, depending on how many LEDs you have and how much current you're running through them.

    If you want to keep the existing LED "chaser" circuits but add a control circuit, you are increasing clutter, not reducing it. But it can be done fairly easily using a CD4017 decade counter. This IC needs a power source in the range 3~15V DC and can be configured to cycle through any number of steps from 2 to 10. On each step, the relevant output goes high (positive voltage). This can be used to turn on a transistor to supply power to your other circuitry.

    If you want two or more circuits to be activated on certain steps, you can use diode (or resistor) gating to combine outputs.

    Your description of what you want is not clear, but if you want an eight-step sequence giving all possible combinations of three control signals, you can use a binary counter such as a CD4024 instead of the CD4017. This gives the following output sequence:

    Code:
    Press   Out#1   Out#2   Out#3
      1       ON     OFF     OFF
      2      OFF      ON     OFF
      3       ON      ON     OFF
      4      OFF     OFF      ON
      5       ON     OFF      ON
      6      OFF      ON      ON
      7       ON      ON      ON
      8      OFF     OFF     OFF
      9 back to 1
    I think the way to get the optimal design for your needs is for you to describe exactly what you want - how many LEDs, what they're used for, what patterns you want, etc - and let us suggest the best way to control them.

    Also you could consider whether you want to get into microcontroller programming. There are various options, many of which are more complicated and powerful than you need for this project. Suitable devices would be the Microchip PIC and the PICAXE. Another user of these forums, CDRIVE, can tell you all about the PICAXE.
     
  3. WaterWalker

    WaterWalker

    15
    0
    Sep 21, 2013
    Thanks KrisBlueNZ for the reply.

    Well, I guess I should have been a bit more specific. I just want to take away the clutter at the dip switch. But, everything else is basically what I want. I do have a CD4017 decade counter, but not sure about the 4024.

    Ok, I'll try to explain what the build should do. So, here's the back story.

    My one friend asked me to build a circuit for him that he can use inside his PC. He is a Need For Speed Undercover fan. So, he wanted something that mimicks the police lights inside his PC. So, I built the circuit, and it worked. Is still working, for that matter. I just wanted to "improve" on my own build.

    I have attached a very, very, very, very, very, very simple diagram of the circuit I built. The circuit runs on 12VDC from a Molex plug inside the PC. I modified a CD Drive to house the built. Now, "A", "B", "C" and "D" are the LED driver circuits. Circuit "D" is connected to all the LEDs. Circuit "A" is only connected to Blue LEDs. Circuit "B" is connected to only Red LEDs. Circuit "C" is connected only to White LEDs.

    Except for circuit "D", the individual circuits all run 13 LEDs each. Circuit "D" runs all of the LEDs when activated.
     

    Attached Files:

  4. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    I'm afraid that description is far too vague for me to follow confidently. It sounds like you have a number of red LEDs, a number of blue LEDs and a number of white LEDs, and you have arranged for circuit D to drive them all, while circuits A~C only drive one set each. The diagram of the LED chaser does not show how multiple drive circuits can be commoned to drive the same LEDs. You need to show that.

    Without a clear specification I would probably end up wasting a lot of time.

    Please draw up a complete schematic of the current design. That means, show every transistor, every LED, the DIP switch, the power connector... Everything. A hand-drawn diagram, scanned or photographed, will be fine. If it's too large to upload here, put it on dropbox or somewhere like that, and post a link to it.

    Please define exactly what behaviour you want for each step of the pushbutton.
     
  5. WaterWalker

    WaterWalker

    15
    0
    Sep 21, 2013
    Hi KrisBlueNZ

    I have made a schematic of what I did. I hope you can follow it. I've put in symbols for where there are connections so as to clear some confusion. Wires criss-crossing everywhere. Hope this helps you to understand what I would like to do.

    Thanks.
     

    Attached Files:

  6. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    Hi WaterWalker,

    Thanks for making an effort to clarify things.

    Criss-crossing wires is no problem.

    Unfortunately that schematic is still not clear.

    You seem to have five groups of LEDs at the bottom right, identified with three symbols - square, diamond and star.

    Then you have three alternating flasher circuits and a one-of-three circuit; these four circuits are enabled by four DIP switches. That part is clear to me.

    In the three alternating flasher circuits, you have referenced the square, diamond and star, but also shown single or double LEDs next to them. And you have also marked "To white LED", "To red LED" and "To blue LED". Those markings don't tell me anything.

    To me, it is not at all clear what those markings mean, and what is connected to what. I understand if you don't want to draw a huge spider-web of lines, but you need to clarify your design.

    Perhaps you could identify all individual connection points with a letter - for example, the first red LED block could use "A" for the anode end and "B" for the cathode end, then the blue LED block could use "C" for the anode end and "D" for the cathode end, and so on. Then you add the letters to the oscillator circuits to show what connects to what.

    It's also not clear to me whether the three-way chaser circuit shares any of the LEDs that are used by the other oscillators.

    Please revisit your diagram and see how you can make it clear enough for me to understand.
     
  7. WaterWalker

    WaterWalker

    15
    0
    Sep 21, 2013
    hi KrisBlueZN

    Yeah, I thought I'd use the symbols to show the shared connections. But I have redone the schematic. It's a bit of a rats nest, so shout where you need clarification.

    I have added red lines to the three circuits on the left to show an extra shared circuit. Don't worry to much about this.

    Just some more clarity. The LED sets at the bottom of the schematic is "outside" the build. Meaning, they can be removed, moved and replaced as necessary. Can call them "floating LEDs" if you want. The LED's that are in the circuit, is built into the housing of the project. If you want a photo of how this looks, I am happy to upload that as well, however, at the moment I'm stuck at work. Will be home in the next 5-6 hours.

    Thanks.
     

    Attached Files:

  8. WaterWalker

    WaterWalker

    15
    0
    Sep 21, 2013
    Sorry, forgot to upload this as well. This is what the individual parts looked like before completion. It should give a better viewpoint of how it all looks.
     

    Attached Files:

  9. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    OK... Now, what are the red lines supposed to mean?

    An "extra shared circuit"? Can you draw what you actually have? You've done a good job with the other LEDs.
     
    Last edited: Sep 25, 2013
  10. WaterWalker

    WaterWalker

    15
    0
    Sep 21, 2013
    Hi KrisBlueNZ

    I have just checked my actual build again. And I have to aoplogise profusely. I made a mistake. One that I cannot say sorry enough for. The red lines should be omitted. They should not be in the schematic at all. I'm terribly sorry.

    I thought I had them connected with the "external" LEDs running from the three-way chaser circuit. But they are not. If you have a look at the pictures i uploaded with this message, you'll note than there are 5 LEDs on the front of the housing. Those 5 LEDs are the LEDs that are "in-line" in the schematic. They will be off when the three-way chaser circuit is activated. Just the "floating" LEDs will be on with that circuit. However, the front LEDs will be on with the rest of the circuits.

    Thanks
     

    Attached Files:

  11. WaterWalker

    WaterWalker

    15
    0
    Sep 21, 2013
    So, this is what it should look like. Again, I am terribly sorry.
     

    Attached Files:

  12. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    1. OK, the second photo in your last post shows a hacked CD-ROM drive with nine LEDs in it. You said earlier that your circuitry goes in the CD-ROM drive case, so I guess these are the LEDs in the left part of the diagram, correct?

    2. Your diagram shows five LEDs in the left section, but there are nine on the CD-ROM drive. Can you correct the schematic if it's wrong?

    3. The photo in post #8 shows the four boards with six LEDs each, but it doesn't seem to show the middle board, with four white LEDs. But that board is just like the other four, except that it has fewer LEDs on it, correct?

    4. In the long paragraph in post #1 you describe a control sequence but you don't define it fully and I don't see a pattern to it. Can you write out a control sequence in this format:
    Button press 1: Circuit A enabled
    Button press 2: Circuit B enabled
    Button press 3: Circuits A and B enabled
    Button press 4: Circuit C enabled
    Button press 5: Circuit D enabled
    or whatever it is, exactly, that you want.

    5. I understand that circuits A, B and C are on the left side of the schematic, and the three-way chaser circuit at the top right is called circuit D. You could mark these names on the schematic to clarify this.

    Please answer ALL of these questions.
     
  13. WaterWalker

    WaterWalker

    15
    0
    Sep 21, 2013
    1) That is correct.

    2) The schematic is correct. I wanted to add more LEDs to the housing, but only got as far as inserting them, not connecting them, yet.

    3)That is also correct. It has four white LEDs on it.

    4)Well, this is what I would like to have the circuit do:
    Button Press 1 - Circuit A enabled (all other circuits off)
    Button Press 2 - Circuit B enabled (all other circuits off)
    Button Press 3 - Circuit C enabled (all other circuits off)
    Button Press 4 - Circuits A+B enabled (all other circuits off)
    Button Press 5 - Circuits B+C enabled (all other circuits off)
    Button Press 6 - Circuits A+C enabled (all other circuits off)
    Button Press 7 - Circuits A+B+C enabled (circuit D off)
    Button Press 8 - Circuit D enabled (all other circuits off)
    Button Press 9 - All circuits off. Next button press returns to Button Press 1.

    5)I have attached the updated schematic.
     

    Attached Files:

  14. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    Great! You have now given me a clear specification.

    I have one more question. The three flasher circuits are independent and their frequencies will not be exactly the same, because of component tolerances. When they are enabled in pairs, the flashing of the different colours will not stay in sync for long. Is this a good thing or a bad thing?

    I suggest redesigning the circuit to combine the four oscillators into one, and using gating to control how the outputs are used. This would mean that when two alternating LED sets are enabled, they would flash in unison. Or it could be arranged that they would alternate.

    OK, here comes the advice. There are two problems with the circuit as it stands. I'll start with the simple one.

    LEDs are not supposed to be paralleled the way you have done. When you parallel them like that, this forces them to have the same voltage across them, and because of manufacturing tolerances and temperature variations, this causes them to draw different amounts of current and to illuminate at different brightnesses.

    At higher currents you can have a problem called thermal runaway, where one LED draws too much current and gets hot, which makes it draw more current, which makes it hotter, and so on. This makes the other LEDs dim, and it can damage the LED that's drawing the heavy current or even make it fail. This is not likely to happen with the low current you're using though.

    The recommended way to drive multiple LEDs is to connect them in series strings, with a current limiting resistor in series with each string. These strings are then connected in parallel with each other.

    The number of LEDs in each string, and the value of the resistor, is calculated depending on the forward voltages of the LEDs in the string, and the total voltage that's applied to the string. In your application, the 12V supply voltage will be very well regulated, so you can get very good control of the brightness of the LEDs.

    To be honest though, if they're working OK with even brightness connected all in parallel like that, they'll probably continue to do so for a while yet. LED characteristics do change as they age, but I don't know whether this will cause a problem or not. If all paralled LEDs are from the same batch, you might be alright.

    There is a good article on LED driving in the tutorials section of the Electronics Point web site. I suggest you have a look at it, and see whether you can follow it.

    The second problem is that connecting those independent circuits to the same LEDs will actually cause unwanted currents to flow. It may not cause any visible problem but it's not good practice. This is the main reason why I think it would be better to start from scratch with the design.

    I am happy to design a circuit to do what you want, and I will write up an explanation of how it works, if you want to go that way. It would use several CMOS ICs and various small components. I would include suggestions for new wiring for the LEDs.

    If you just want to replace the switch, I can design a circuit to do that as well. I would use a CD4017 as a nine-step counter, with the outputs gated together, probably using diodes, to drive four buffer transistors which switch the power supply to the four existing circuits.

    The simplest version of this circuit would introduce about 1.5V of voltage drop between the power supply and each circuit, which will make the LEDs dimmer than they currently are. It is possible to avoid this voltage drop but it would mean quite a few more small components.

    Please have a think about whether you would like a redesign of the circuit, and consider whether you want to change how the LEDs are connected.
     
  15. WaterWalker

    WaterWalker

    15
    0
    Sep 21, 2013
    Well, that is kinda what I want. It must not flash in unison or alternate. I wanted to go for a spuedo-random flash-type circuit. In other words, it must look like it's random, but should not really be. That is also why the caps are of different types/sizes.

    As stated above, I would like it to look random.

    Thanks for pointing out that tutorial to me. That was very enlightning. Especially the links that are referenced in the tutorial. I learned a lot from that. However, I'm not really too worried about the longevity or britghness of the LEDs. This is just a request build from a friend. And I took the oppertunity to learn a few things as well. :D

    From what I have read on this, I believe a redesign might be good option, true? Also, as i have stated before, I'm not really too worried about the LEDs. I have a couple thousand lying around, so it isn't too much of a headache. But if you believe the wiring should be different, I cannot argue with that. I don't have the knowledge to do that. (Yet) :cool:

    It would also be quite interesting to see what a different circuit will look like that does almost the same as what I have made.

    I thank you in advance.

    Oh, and I have only veroboard on which to put the final product, so if it can be kept as simple as possible, I would appreciate that greatly.
     
  16. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    Don't worry, I haven't forgotten you!

    I'm working on a design and a long circuit description. I hope you want to learn - if you don't, no problem; others may find it useful.

    I'm trying to make the circuit simple, but I suspect you'll say it's too complicated.

    I'm going to post it anyway, but it will be a few more days.
     
  17. WaterWalker

    WaterWalker

    15
    0
    Sep 21, 2013
    Hahahaha... I figured it might take a while. So no problem on that.

    I do want to learn electronics. I have a sort of fascination with electricity. And not to mention the fact that I need to learn about electronics for work. ;)

    I have built a few working circuits and a few that was not so successful. But all was from open circuits on the net. And I have no clue why they didn't work. A long description might help me to further understand why not. Who knows, maybe I can get them to work.

    Simple and complicated isn't the real problem. But in all honesty, I would prefer a relatively complicated circuit. That way, all my attention is on the circuit, and not how(if any) way I can improve, adjust or modify it. My mind tends to wander off without me in situations like that.

    So, in short, I appreciate it and thank you very much.
     
  18. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    OK, I'm only part-way through the text, but I've got a lot written up, so it makes sense to post what I have so far.

    Here's the schematic:

    [​IMG]

    It's not really as complicated as it looks at first sight. The D-shaped things (2-input NAND gates) are only 1/4 of an IC each. And there are a lot of markings there that are referred to in the text.

    You might want to build it on a breadboard initially. This makes it easier to change things around to fix errors or try new ideas.

    CIRCUIT DESCRIPTION AND TUTORIAL

    This design is a good opportunity for me to write a detailed tutorial on a number of subjects. This tutorial will be helpful for other Electronics Point users, and I will be referring them to the appropriate section(s) in the future. So don't think that I wrote all this just for you!

    I've used standard terminology here. More information on all of these subjects can be found on Wikipedia (which I recommend, although some of the descriptions there are rather intellectual and/or highly mathematical), and found all over the web using a Google search with the relevant keywords (although some of the "information" you'll find is poorly explained and somewhat inaccurate; avoid instructables.com, for example).

    CIRCUIT FUNCTION AND OVERVIEW

    The circuit produces alternating and sequenced display patterns on groups of LEDs, shown at the right. It's designed to be built inside a PC to provide visual stimulation for a guy who's a fan of the Need for Speed Undercover game.

    The circuit is controlled by a pushbutton (top left area) and generates eight (slightly) different illumination patterns. It uses a mixture of CMOS logic ICs and discrete components.

    CMOS CD4000 LOGIC IC FAMILY

    The circuit uses five ICs (integrated circuits) from a family called the CD4000 CMOS logic family. The CD4000 devices were developed during the 1970s and 1980s and are still widely used by hobbyists because they are easy to use. They have low power consumption and can tolerate a wide power supply voltage range (normally 3~15V) so they're well suited to this application. (Other logic families require 5V or 3.3V supply voltages.)

    These ICs are available in 14-pin and 16-pin DIP (dual in-line package) rectangular plastic packages, with pins emerging from two sides. They plug directly into a breadboard and can also be used with stripboard for permanent construction.

    In this circuit, U2 and U5 are shown as rectangles with 16 pins, but the remaining ICs are shown as individual "logic gates" - D-shaped symbols with two inputs and one output. There are four of these gates in one IC. They are called NAND gates and are described later. They are named U...A, U...B, U...C and U...D.

    This design uses two different CMOS ICs. You can download the data sheets for them from the following locations:

    CD4093B: http://media.digikey.com/pdf/Data Sheets/Fairchild PDFs/CD4093BC.pdf
    CD4017B: http://media.digikey.com/pdf/Data Sheets/Fairchild PDFs/CD4017BC, CD4022BC.pdf

    POWER SUPPLY (VDD AND 0V) AND LOW AND HIGH

    The whole circuit operates from a 12V supply. The positive supply rail is called VDD, and (conventionally) runs along the top of the circuit; the negative supply rail is called 0V ("zero volts") and (by convention) runs along the bottom of the circuit.

    All points marked VDD on the schematic are connected together. Ditto with all points marked 0V.

    The 0V rail is also called "GND" (ground) and "VSS". By default, voltages at all points in the circuit are measured relative to the 0V rail.

    Voltages are always measured between two points - like distance, measured with a ruler or tape measure.

    All points that are connected together are at the same voltage. (That's not absolutely true, because all conductors have resistance, but it's a good enough approximation.)

    In digital logic circuits like this one, the voltage at most points in the circuit is either equal to (or near) VDD, i.e. +12V relative to the 0V rail, or at (or near) 0V. These two logical states are called "high" and "low" respectively. Logical states are used to describe most of the signals in this design and I will use "high" and "low" a lot in this description.

    High and low are also called 1 and 0, respectively.

    RP (PULLUP RESISTOR) AND THE PUSHBUTTON

    The first part of the design is the pushbutton, debouncing circuit, and mode counter.

    You can think of resistor RP as a weak spring that pulls the voltage at point "A" up towards VDD. In other words, RP "pulls" point "A" high. It is called a "pullup resistor". That's why I called it RP. (Usually, component references are numbered: R1, R2, etc. I've used letters in this design.)

    SW1, the pushbutton, is a normally-open momentary pushbutton. When it is pressed, it forces the voltage at point "A" firmly down to 0V, i.e. low.

    So point "A" is normally high, but is forced low while the button is being pushed.

    RD AND CD (RC DELAY CIRCUIT)

    You can think of RD as another weak spring that gently tries to pull point "B" to the voltage at point "A". But capacitor CD prevents the voltage at point B from changing quickly.

    I'm now going to explain the behaviour of the resistor and the capacitor using an analogy which I came up with. It's called the DTS model, and it's good for explaining resistors and capacitors, and a few other things, but it's different from the hydraulic model that is normally taught.

    Imagine a capacitor as being like a piston in a cylinder. The end of the cylinder is closed, with only a small hole, through which air can get in and out of the cylinder. If you apply a force to the piston, i.e. pull it or push it, its position in the cylinder will change, but not quickly, because the air flow is restricted. More force makes it move more quickly; with no force applied, it won't move (relative to the cylinder).

    In the DTS model, position (or distance) is voltage, and force (or tension) is current. The piston-in-a-cylinder analogy defines the behaviour of a capacitor. Apply a force (current) (either positive or negative), and the piston will move within the cylinder (the voltage across the capacitor will change).

    The direction of the change in position (voltage) depends on the polarity of the force (current), and the speed of the position (voltage) change depends on the amount of force (current), in conjunction with the characteristics of the piston-cylinder arrangement. This characteristic corresponds to the capacitance of the capacitor. With a fixed amount of current, a higher capacitance means that the voltage will change more slowly. You could imagine that a higher capacitance means a smaller hole in the cylinder end for the air to move through.

    So you can see that CD tends to keep point B at a constant voltage (relative to 0V, because the other side of CD is connected to 0V). When point A jumps from high to low, in response to the pushbutton being pressed, point B will follow slowly.

    RC CIRCUITS

    This arrangement - a series resistor, and a capacitor connected to 0V (or any fixed voltage) - is called an RC network or RC circuit. It is sometimes called an "RC integrator" but this is a bit of a misnomer. RC circuits are widely used in electronics, as filters, delays, pulse generators and smoothing circuits.

    In general terms, their function is to slow down a change in the input signal. Changes at the input (point A) are delayed and smoothed out at the output (point B). This is why I named them RD and CD - the "D" stands for "delay".

    A larger resistance is modelled as a thinner, weaker spring, and a larger capacitance is modelled as a smaller air hole in the cylinder. Therefore, both a larger resistance, and a larger capacitance, cause the output to respond more slowly. Specifically, the timing of the delay is proportional to the resistance of RD and the capacitance of CD multiplied together. The product of RD (expressed in ohms) and CD (expressed in farads) is called the "time constant" of the circuit. I'll come back to this shortly.

    SI ENGINEERING UNITS

    In that last paragraph I mentioned that 'C' in electronic formulas represents capacitance and it is measured in farads.

    Most quantities in electronics (and all the other sciences) have an associated unit - for example, volts, amps, watts, ohms, farads, henrys, joules.

    Quantities in these (and other) units are expressed using prefix letters that represent submultipliers and multipliers, which are standardised for all units:

    k (kilo) × 1000 [× 10<sup>3</sup>]
    M (mega) × 1,000,000 [× 10<sup>6</sup>]
    G (giga) × 1,000,000,000 [× 10<sup>9</sup>]
    T (tera) × 1,000,000,000,000 [× 10<sup>12</sup>]

    m (milli) ÷ 1000 [× 10<sup>-3</sup>]
    µ (micro) ÷ 1,000,000 [× 10<sup>-6</sup>]
    n (nano) ÷ 1,000,000,000 [× 10<sup>-9</sup>]
    p (pico) ÷ 1,000,000,000,000 [× 10<sup>-12</sup>]

    The values in square brackets [] are scientific notation. For more information see Wikipedia.

    Edit: The "sup" tags are supposed to make the numbers in between them show as superscripts, but this doesn't seem to be supported by the Electronics Point forum software :-(

    When a prefix is combined with a unit, they form an "engineering unit" such as µF (microfarads) (1 µF is one millionth of a farad) or kV (kilovolt) (1 kV is one thousand volts).

    In the case of farads (capacitance), the unit represents a very large quantity, and typical capacitors are measured in µF, nF and pF.

    TIME CONSTANT CALCULATION

    The quantity that characterises an RC circuit is the "time constant" which is defined by the formula t = RC, where:
    t is the time constant, measured in seconds;
    R is the resistance, measured in ohms, and
    C is the capacitance, measured in farads.

    The values I used for RD and CD are:
    R = 100 kilohms = 100 × 10<sup>3</sup> ohms
    C = 100 nanofarads = 100 × 10<sup>-9</sup> farads

    The product of those numbers is 0.01 seconds, or 10 ms (milliseconds). This is the time constant of that circuit, which relates to (but is not necessarily equal to) the amount of delay that it introduces. I won't go into any further detail here.

    CONTACT BOUNCE AND DEBOUNCING

    So why is the RC delay needed? Because of a phenomenon called contact bounce. When you press and release the pushbutton, its contacts to not make and break cleanly. They actually "bounce" and generate several, sometimes dozens or more, short, random-looking pulses, over a period of around 10 ms.

    When you're controlling an LED with it, you can't see the bounce, so it doesn't matter, but when you're using the signal to clock a counter (U2), which responds to very short pulses, this contact bounce will cause the counter to advance by an unpredictable number of steps on each button-press (and release).

    RD and CD perform this "debouncing" function, in conjunction with the input to U1A (on pin 2). This input - actually, all of the inputs on a CD4093B - has a feature called a "Schmitt trigger".

    SCHMITT TRIGGER INPUTS

    A Schmitt trigger is a circuit that is used to "clean up" a signal that is poorly defined or noisy. It takes an input voltage that may be anywhere between 0V and VDD (i.e. a voltage that is not clearly high or low) and converts it into a well-defined logic-level signal that IS either high or low.

    High and low logic levels are defined as voltages relative to the 0V rail. In CMOS logic, a voltage that's between 0V and one third of the supply voltage is regarded as low, and a voltage between two thirds of the supply voltage and VDD is regarded as high. In this circuit, VDD is +12V, so low and high are defined as:

    Low: 0V to +4V
    High: +8V to +12V

    There's a no-man's land between 4V and 8V where the signal is neither clearly high nor low - it is "undefined". All digital logic circuits that use voltages to represent high and low states have voltage thresholds like these, with an undefined voltage range. Signals have to cross through the no-man's land as they change from high to low and low to high, but they must cross very quickly and cleanly, otherwise all sorts of problems occur.

    One way of converting a poorly defined 0~12V voltage into a clearly defined high/low voltage is to compare it against a reference voltage of say +6V, using a circuit called a voltage comparator. If the input to the comparator is less than 6V the comparator output is low; if the input is 6V or higher, the output is high.

    HYSTERESIS

    This comparator circuit converts an undefined voltage into a clean logic level, but if the input voltage is close to 6V, small variations in the input voltage would cause the output to jump around. A better way is to add a quality called hysteresis ("hiss-tur-EE-siss"). When applied to a comparator, hysteresis causes the threshold to change depending on the output state. This is how a comparator would work with hysteresis, with an input voltage that starts at 0V and increases towards +12V.

    When the input is 0V (clearly low), the comparator's output is low. This condition (output low) causes the comparator to use a threshold voltage of 8V. As the input voltage rises past 4V, then past 6V, nothing happens, because the 8V threshold has not been reached.

    When the input reaches the 8V threshold, the output of the comparator flips high, and this action immediately causes the input threshold voltage to change to 4V. The input voltage is now much higher than the threshold, so the output remains high.

    Now if the input voltage starts to drop, nothing happens as it goes below 8V, then below 6V. Nothing happens until it goes below the new threshold voltage of 4V. When that happens, the comparator output flips low and the threshold voltage immediately jumps back to 8V.

    This produces an immediate, clean, well-defined snap-like response to input voltage changes and avoids indecision around the threshold (which was the problem with using a fixed 6V threshold). Once the input voltage goes past a threshold, and the output changes state, the input threshold changes immediately, so the input voltage has to go back further in the other direction to cause another change.

    Hysteresis occurs in the real world. If you hold a piece of springy plastic or metal between your finger and thumb and squeeze it slightly so it bends into a "(" shape, and push the middle of it sideways with your other hand, at a certain point it jumps to a ")" shape. Mechanical thermostats use the same trick to achieve clean switching; for them, the input is temperature, not voltage.

    In the electronics world, a circuit whose input has hysteresis is called a Schmitt trigger.

    THE CD4093B SCHMITT NAND GATE IC

    The CD4093B contains four identical circuits called NAND gates. Each NAND gate has one output and two inputs, and each input has a Schmitt trigger built into it.

    A NAND gate performs a logic function called NAND, which comes from "not" and "AND". An AND gate produces a high output only if all of its inputs are high. It can be defined as Output = Input1 AND Input2. Any other combination of input states causes the output to be low. A NAND is an AND gate followed by an inverter (also called a NOT gate), which simply flips the signal to its opposite state: a low input causes a high output, and vice versa.

    Here is the "truth table" for a NAND gate. It shows the four possible combinations of input states, and the corresponding output state.

    Code:
    Input1   Input2   Output
      0        0        1
      0        1        1
      1        0        1
      1        1        0
    So a NAND gate drives its output high unless both inputs are high, in which case it drives its output low.

    Also notice that if one of the inputs is tied permanently high, the NAND gate becomes an inverter; that is, the output is the opposite of the remaining input. This connection converts a NAND gate with Schmitt trigger inputs into an inverter with a Schmitt trigger input.

    My earlier description of a Schmitt trigger using a comparator with a moving threshold voltage described a non-inverting Schmitt trigger - the output would be high when the input was high, and vice versa. Because of the inverter stage in the NAND gate (which is represented by the circle on the output in the schematic diagram), the Schmitt trigger formed by a NAND gate is an inverting Schmitt trigger - its output is the opposite of the input.

    DEBOUNCING USING RC CIRCUIT AND SCHMITT TRIGGER

    So to recap. Pushbutton SW1 feeds an RC circuit formed by RD and CD, which produces an output voltage that follows the input with a delay, because of the smoothing effect of the capacitor which ensures that the voltage across it cannot change quickly. This signal is fed into one input of U1A, a NAND gate with Schmitt trigger inputs. The other NAND gate input, pin 1 of U1, is tied high; this converts the NAND gate into an inverter. The resulting output signal is a cleaned-up, debounced indication of the pushbutton state at point C in the circuit, which is normally low (since point B is normally high) and goes high while the pushbutton is pressed. Therefore I have named that node PRESSED; it's high while the pushbutton is pressed, and low otherwise.

    RISING AND FALLING EDGES

    Each time the pushbutton is pressed, the PRESSED node changes from low to high; this is called a "rising edge". When the pushbutton is released, point C returns low; this is called a "falling edge".

    This signal is used as a clock input to U2, a CD4017B counter IC, which responds to a rising edge on its clock input by advancing its count by one.

    U2 (CD4017B) - MODE COUNTER

    This circuit has nine operating modes, numbered M0 to M8. It starts up in mode 0 which has no LED activity. A press of the pushbutton advances the mode to M1, then M2, and so on up to M8. At M8, a pushbutton press causes the 4017 to returns to M0.

    The mode counting and selection is done by U2, a CD4017B decade counter with decode logic. It accepts a clock input on pin 14, and has ten outputs, numbered Q0~Q9.

    At any time, ONE of those ten outputs is high, and the others are low. Each one of these outputs, when high, enables a particular combination of LED display animations.

    I have connected outputs Q1~Q8 to circuit points ("nodes") called M1~M8 by simply adding the marking M1, M2, M3 etc to them. This is a convention used in schematic diagrams when signals are used at multiple places; it avoids lots of wires on the diagram. Any other point in the schematic with the same node label is connected to that node.

    Most of the M... nodes connect into the three groups of four diodes in the next part of the schematic. M8 connects to Q4 at the bottom right corner of the "3-WAY CHASER" circuit block below the mode circuit block.

    You'll see that I've listed the nine modes below U2 in the schematic. I've also marked the major sections of the schematic with brief descriptions. This is all helpful to anyone reading the schematic and I strongly recommend the use of brief explanatory text throughout a schematic diagram.

    The Q0 output, which represents mode M0, is not used; when the mode is M0, none of the other outputs will be high, and this will disable all of the indications.

    ACTIVE-HIGH AND ACTIVE-LOW SIGNALS

    The PRESSED signal, and the eight mode control signals, M1~M8, are active-high. When a particular mode is active, the corresponding M... signal is high, and the others are low.

    Some signals (nodes) in this circuit are active-low, i.e. the state or condition named by the node is active when the node is low; when the node is high, the condition is inactive.

    Active-low nodes and active-low inputs on ICs are indicated in several ways. The universal way of indicating an active-low signal is with an overbar. U2 pin 13 is named CEN with an overbar. This means that its function, CEN (clock enable), is active when the pin is low.

    To be exact, an overbar actually indicates inversion. That is, a signal called PRESSED with an overbar would be an inverted version of the PRESSED signal, and it would go low when the pushbutton was pressed. Therefore it would be an active-low signal.

    In this schematic, active-low nodes are named with an initial minus sign. There are three nodes called -W, -R and -B which are active-low signals that control the main LED arrays. When the -W node is low, the white LED array lights up; when -W is high, the white LEDs are OFF. Ditto for -R (red) and -B (blue).

    I could have used an initial plus sign for active-high signals. For example, I could have called the PRESSED signal +PRESSED. I will often do this if a signal exists in both forms. So if there was also a -PRESSED signal in the design, I would have renamed PRESSED to +PRESSED.

    Other schematics may use other conventions to indicate active-low signals. I've seen an initial 'n' which is short for NOT (for example, nRESET would be an active-low reset signal) and a final backslash (for example, RESET\ would be an active-low reset signal).

    OTHER MODE COUNTER SIGNALS AND RESET

    U2, the mode counter, has three other pins. Pin 13 is an active-low clock enable input, and it is tied low, so the clock is permanently enabled.

    U2 pin 12 is an output called "carry out". It is used if another CD4017B needs to be cascaded from this one, to form a 100-count counter. It's not used in this design.

    U2 pin 15 is the reset input. It's active-high (no overbar on the pin definition), so whenever pin 15 is high, the device will be reset. In fact the device will be held in the reset state while this pin is held high. In the reset state, the count is reset to 0 (so Q0 will be high and the other Q... outputs will be low). Once the reset state is removed (pin 15 low), U2 can begin to count in response to rising edges on the clock input.

    The circuit that drives the reset input combines a power-up reset (RR and CR) with a reset on Q9 (so that in mode M8, the next pushbutton press will return to M0).

    When power is initially applied to the circuit, CR will be discharged, so the voltage at point D will be zero. CR will charge up through RR, but initially, point D is low. This forces U1B's output high (see the NAND gate truth table earlier). This ensures that U2 starts off in mode M0 when power is initially applied.

    Once CR has charged up, point D is high and U1B becomes an inverter. Since U1D is also wired as an inverter, U2's reset input is effectively driven from its Q9 output. This output is initially low. Once U2 reaches mode M8 (U2's Q8 output high), the next rising edge on PRESSED causes it to advance to Q9 high. As soon as this occurs, U2's reset input goes high (because of the action of 1D and U1B) and U2 resets. When this occurs, Q0 goes high and Q9 returns low. The reset input then returns low.

    All of this happens in a very short time - around 1 µs, because the delays (called propagation delays) through U1D, U1B and U2 are less than 1 µs each. So effectively, the mode advances directly from M8 to M0.

    POWER CONNECTIONS AND DECOUPLING CAPACITORS

    All active devices, such as the CD4000 family of ICs, need a power source for their internal operation. On U2 and U5, which are 16-pin ICs, pins 16 and 8 connect to VDD and 0V respectively; on U1, U3 and U4, which are 14-pin ICs, pins 14 and 7 are used. This convention of using diagonally opposite pins for VDD and 0V (VSS) was common for slow and medium-speed logic ICs.

    Logic ICs also need their supply voltage to be clean and stable at all times, but their current drain from the power supply rails can be significant and can occur in short, intense bursts. CMOS circuitry is known for this problem; the bursts of current occur when logic inside the IC is switching between low and high, because of how CMOS logic works internally. When many circuits switch simultaneously inside an IC, this can cause significant currents to flow for very short periods of time.

    These bursts of current into the power supply pins can cause noise on the supply rails at the IC, because wires and PCB tracks are not perfect conductors. You can imagine them as very small, strong springs. A strong burst of current can actually cause a measurable dip in the voltage across the power supply pins of the IC. These dips can in turn cause the IC itself, or other ICs powered from the same supply rails, to misbehave.

    The solution is to connect a capacitor directly across the VDD and VSS pins of the IC. This capacitor is called a "decoupling" or "bypass" capacitor because it decouples (couples to 0V) the supply rail.

    Remember the DTS model for a capacitor: a cylinder with a piston in it. Once the piston is settled within the cylinder, a brief push or pull on the piston will not move the piston much; even a strong force will have little effect if it's brief enough. Similarly, short bursts of current will not change the voltage across the capacitor much. This is how decoupling capacitors work. They act as a local current reservoir for the IC, and provide the brief bursts of current demanded by the IC directly into its VDD and VSS pins.

    The rest of the power rail circuit only needs to provide an average current to keep the decoupling capacitor charged to the right voltage. All of the short heavy current flow, and the noise associated with it, is contained within the loop formed between the decoupling capacitor and the IC.

    Therefore, decoupling capacitors must be connected as close as possible to the IC that they're decoupling, and as much as possible, directly across its VDD and VSS pins.

    I have shown a decoupling capacitor for each IC in the circuit. They are not marked (all unmarked capacitors are 0.1 µF ceramic, as noted on the schematic) but they are placed near to the respective IC, and connected across its VDD and VSS pins. This is supposed to imply that they are decoupling capacitors and must be connected directly between the VDD and VSS pins of the IC.

    I have also shown the VDD and VSS connections for U1, U3 and U4 connecting to one gate from each IC. This is not always done in digital schematics; if there are rails called VDD and VSS (or for other types of logic, usually VCC and GND), the power supply pins of logic ICs may not be shown; in this case they are assumed to be connected to those rails.

    Also, some schematics may show all of the decoupling capacitors in one area. They may or may not be labelled as decoupling capacitors. It's up to you, when you build the circuit (or convert it from a schematic into a PCB (printed circuit board) layout), to realise that they are decoupling capacitors and to connect one across each IC's power pins. It's conventional to use a separate decoupling capacitor for each IC.

    Some ICs actually require many decoupling capacitors. Usually, they have many power pins spread around the package (but connected internally). These decoupling capacitors are usually indicated in some way on the schematic.

    BACK TO THE CIRCUIT

    OK, that's a lot of ground covered. But there's still plenty more.

    The next section is the three oscillators in the middle of the schematic, which generate the alternating displays on the white, red and blue LEDs.

    DIODE OR GATE

    Each oscillator is enabled in certain modes only. This is done using the four diodes, which are connected as a "diode OR gate". This is a cheap and simple way to make a logic gate with just diodes and a pulldown resistor. Here's how it works.

    A diode conducts current in one direction only - in the direction of the arrow. That is, from anode (marked "A" on the first diode) to the cathode (marked K on the first diode).

    This is true for "conventional current", which flows from positive to negative. Electrons actually flow the opposite way, but conventional current is the... uh, convention, because arrows on component symbols only make sense when current flows from positive to negative. So, I think conventional current is easier to understand. Electron flow is only important if you get into the physics of the components.

    If you apply a voltage to the anode of a diode, current will flow through the diode and will pull the cathode up to slightly less than the anode voltage. The voltage drop is called the forward voltage of the diode and is usually between 0.6V and 1.0V depending on the size of the diode and the amount of current flowing.

    So when the M1 signal is high (+12V), the first diode will pull its cathode (which is connected to the ENW node) up to about +11.3V. Also, if M4 is high, its diode will pull ENW high, and the same for M6 and M7. But if M1 is high and the first diode is pulling ENW high, the other three diodes have no effect, because their anodes are low, and diodes don't conduct when their anode voltage is lower than their cathode voltage.

    This means that if M1, M4, M6 OR M7 is high, ENW will be high too. Therefore those diodes implement a logical OR gate - the output (ENW) is high if any of the inputs are high. In other words, Output = Input1 OR Input2 OR Input3 OR Input4. The inputs can be extended simply by adding more diodes. It's a quick and dirty way to create an OR gate.

    The pulldown resistor below the fourth diode is needed so that when none of those four modes are active, ENW is pulled down to 0V. But it's a weak spring, because it's a fairly high resistance (100k - all unmarked resistors are 100k as noted on the schematic), and the diodes are easily able to pull ENW high when the appropriate modes are active. So ENW is an active-high enable signal for the "white alternating" oscillator, which is driven high in modes 1, 4, 6 and 7.

    ... To be continued...
     

    Attached Files:

    Last edited: Oct 8, 2013
  19. BobK

    BobK

    7,682
    1,686
    Jan 5, 2010
    Kris,

    Nice tutorial!

    If I had the time (maybe someday I will) I might do the same design with a PIC micro for comparison. The hardware gets a lot simpler, so the tools and the programming would be the thrust of my tutorial.

    Bob
     
  20. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    Thanks Bob :)

    That's a really good idea.

    It would be a good example to contrast discrete design against microcontroller-based design. Hardware-wise, a microcontroller-based solution would be very simple - apart from the pushbutton and the LEDs, I think all you'd need would be a 14-pin PIC, three MOSFETs, and current-limiting resistors. It could be powered from the 5V output of the power supply.

    All the complexity and design would be in the firmware.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-