Random sequence of 4 LEDs

Discussion in 'General Electronics Chat' started by rjjenkins, Sep 22, 2011.

  1. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2
    Hello

    I want to make a circuit that flashes four LEDs (or reed relays) in a pseudo-random sequence, with each flash lasting about half a second. It's important that only one LED is on a time, and I want it to be automatic (eg not triggered by pushing a switch). I feel that this ought to be fairly easy but I don't quite see how to do it and don't want to reinvent the wheel. Help appreciated, thanks
     
  2. iONic

    AAC Fanatic!

    Nov 16, 2007
    1,420
    68
    Sometimes divulging a little bit more of your intentions can be a help to those offering assistance. For example: There seems to be a hole lot of difference between turning on LED's "or" Reed relays.

    A 555 along with a 4017 counter IC might be a place to start. You might only have to modify the "wheel".

    Randome Dice
     
  3. #12

    Expert

    Nov 30, 2010
    16,246
    6,737
    A very quick first impression...(4) 555 timers (or other sort of oscillator) with a circuit that latches out all other LEDs if any one of them is using the available current. Kind of like a game show lockout circuit.

    Whaddaya think?
     
  4. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2
    Sorry, it's really the relays I want but I've spent so long reading about LED flashers that I was in LED mode when I started to type. Does it make a huge difference which it is? I'm thinking of those v small relays that you can drive straight from logic circuits.

    So I could use a 555 to generate a fast clock pulse going to the 4017 and then another 555 going at a slower clock rate to stop and start the first one ... ?


     
  5. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2
    Yes thanks I think that would work although uses more chips than I really want
     
  6. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Well, 555 timers tend to get into "lock step" with each other - and I have a feeling that it won't appear to be very random.

    I'm playing around with a LFBR (linear feedback register) driving a 2 to 4 mux. It has pretty good randomness and only one LED on at a time, but occasionally one LED will stay on for a number of clock cycles (2 or more) making it appear "stuck". I think our OP wants a different LED to show on each clock cycle.
     
  7. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Yep apart from the best choice (a microcontoller) that would be the next best way to do it. A 556 and a 4017.

    You will need to ensure the relays can't turn on when the 4017 is in fast mode, which should be easy enough with 4 drive transistors and RC networks so the average 50% (fast cycling) duty causes less than 0.4v at the transistor base and only when it stops will make about 0.8v at the transistor base to ensure turn on of that one transistor.

    This is all very clunky 1970's technology though, why not use a $1 microcontroller? Besides being cheaper it gives you total control of timing and exactly whatever random patterns or behaviour you prefer.
     
  8. k7elp60

    Senior Member

    Nov 4, 2008
    478
    69
    Here is a circuit I built a number of years ago that has 8 LED's, because of the three clocks it appears to be fairly random. It uses 2 IC's 1ea of 74AC14 and 1ea of a 74AC138
     
    Last edited: Sep 22, 2011
  9. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    I've attached a 555/4017 version, seems to do what was requested of it for the most part.

    The upper 555 runs at around 68kHz when the lower 555 lets it.
    The lower 555's output stays low for ~0.5 seconds, then goes high for ~1.1mS to get the next LED. If you want to try to increase the randomness, add a small pot (2k to 5k) in series with R7.

    Caps across power/ground pins aren't shown, but don't forget them. All need 100nF. The 555s should have a 10 to 100uF cap nearby.
     
  10. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2

    Thanks - that looks like it will do what I want. When you say "nearby" ... how near??
     
  11. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2
    Because all the little electronics I know I learned in the clunky 1970s. I know nothing about $1 microcontollers. Where would be a good place to start?
     
  12. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    By "nearby", I mean within an inch. The longer the wiring, the greater the inductance. You want the bypass capacitor wiring to be as short as possible.
     
  13. k7elp60

    Senior Member

    Nov 4, 2008
    478
    69
    I think SgtWookie's idea is better. I think that for parts reduction only 1 resistor is needed for all four LED's. That is remove the resistors from the anodes of the LED's. Connect all the cathodes together and place on resistor from the cathodes to ground.
     
  14. colinb

    Active Member

    Jun 15, 2011
    351
    35
    There are lots of ways to start.

    You could start with the bare-metal and work up: Get an AVR, PIC, or ARM Cortex-M0/M3 microcontroller, make a circuit, program it in assembly code. Then write C code. Then implement more complex programs and use more peripherals such as timers, power-save mode controls, UARTs, SPI, interrupts, etc.

    Or, you could start with a ready-to-rock and quick-start development board like Arduino, LeafLabs Maple, STM32VLDISCOVERY, etc., which provide examples and are basically ready to have you editing their “Hello, World” code right out of the box. Once you have the standard examples working, you can go lower level: use the AVR MCU registers directly instead of through the Arduino library API, write some assembly language code, play with interrupt handlers, timers, and learn about concurrent programming and state machines.

    Once you have a feel for microcontrollers, and have used a particular one on a dev board, you can use the bare chip in your own circuit easily. The dev boards are $10 to $50 but the microcontrollers themselves may cost only $1.00 to $5.00 depending on flash and RAM size, maximum clock speed, etc.

    The Arduino uses a “medium-size” ATmega328, but for your simple LED controller, you can go REALLY small with an ATtiny13 or something.
     
  15. Wendy

    Moderator

    Mar 24, 2008
    20,764
    2,534
    I think I could do better with qty 3 555, loosely based on this circuit...

    http://forum.allaboutcircuits.com/blog.php?bt=681

    Decoupling individual 555's isn't hard, though I won't make that claim for 556's (dual 555's).

    If the OP is interested I will post a circuit I think would work.
     
  16. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2
    Yes, he is interested, thanks
     
  17. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2
    Thanks. Sounds like something for the long winter evenings!
     
  18. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Bill,
    When you posted that link to your blog, it wasn't to a specific circuit - it was to the whole blog. Which one were you thinking of using?
     
  19. Wendy

    Moderator

    Mar 24, 2008
    20,764
    2,534
    Try clicking the link, then look at the schematic that comes up. It is "From 4 Twenty", Figure 8.1, which was intentional. The rest of the blog is there, unlike posts and threads, but it goes right to the location I meant it too.

    OK, I did a quick modification of Figure 8.1. This circuit has been built without decoupling the 555's with good results, but I included how to decouple it if needed.

    It has 6 LEDs, feel free to eliminate the two you don't like. Don't take one from two clusters though, the back to back LEDs are deliberate, and protect the LEDs from back voltage.

    [​IMG]

    I would be temped to replace R1-3 with two resistors, say 47KΩ and a variable 100KΩ. This would allow you to tweak the flash pattern. I thought of doing something like that for a busy box for a kid.

    The "From 4 Twenty" schematic would be great for a electronics Christmas tree.
    .
     
    Last edited: Sep 24, 2011
  20. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    That's basically "sort of" a Charlieplexing scheme; but missing the high impedance state.
    http://en.wikipedia.org/wiki/Charlieplexing

    If a pair of LEDs is removed, you'll wind up with all of the LEDs being off about 1/3 of the time. Also, without the high impedance state, you'll wind up with more than one LED lit fairly frequently; 1 & 4 or 2 & 3.

    Have a look at the attached; it's basically figure 8.1 with R14, D11 and D12 removed, and a simulation of the circuit. I left most components at the values Bill set (except C4-C6; they're not terribly critical).

    I somewhat arbitrarily selected 9v for Vcc; the values Bill chose would work OK up to around 13v.
     
    Last edited: Sep 24, 2011
Loading...