Binary Counter with RGB LED - How can I add cycling function?

Discussion in 'The Projects Forum' started by lilrips1, Nov 29, 2010.

  1. lilrips1

    Thread Starter Member

    May 7, 2010
    44
    0
    Hello!

    I am currently working on the following project from scratch:

    A circuit with JK flip flops which act as a 3-bit binary counter. The circuit has an RGB LED which is controlled by the 3 outputs from the flip flops. The counter counts from 0 to 7. The three outputs manipulate which colors are on in order to create different color combination. The circuit is advanced with a push button as the clock. Each push changes the RGB LED's color. I put in a switch after the LED to enable a 50 Hz clock pulse to blink the LED.

    My question is this: How can I change my circuit to enable another function onto the single step clock and the blinking: a function that would, after the binary counter outputs a 111 and before going back to 000, cycle through the colors continuously at 50 Hz, until the push button is pushed again.

    So, the circuit would do this:

    push #1: Red
    #2: Green
    #3: Yellow
    #4: Blue
    #5: Magenta
    #6: Cyan
    #7: White
    #8: Cycle through the colors
    #9: Off

    Would I need a 4-bit counter?

    I attached a schematic.
     
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    This is actually built into some RGB LEDs that have 3 leads (power, gnd, control), and do just about the exact functions you listed.

    To "fade" between colors you will need a variable PWM, which is most easily obtained by using a microcontroller (PIC, AVR, Arduino, etc). A discrete component color mixing RGB circuit would need 3 PWM generators with logic to direct what level each generator should be at.
     
  3. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
  4. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,170
    395
    Use the reset of 3rd stage to set a flip-flop,FF, then use output via gating to switch counter clock input from PB to 50 Hz & a gate to enable PB to reset FF
     
  5. lilrips1

    Thread Starter Member

    May 7, 2010
    44
    0
    I thought I had subscribed to this thread, so I was checking my inbox for notifications, but it turns out I didn't, so sorry for my late reply here:

    thatoneguy

    I tried some searching for 3-pin RGB LEDs, but I could only find RG LEDs with three pins, no RBGs that have those inputs. Where did you hear about those? They sound great!

    However, referring to your microcontroller suggestion, I do not need the circuit to fade among the seven colors. I just need it to clock through them automatically.

    Bill

    Yeah, I don't need it to slowly transition through the colors, even though it would be cool.

    Bernard

    I tried something very similar to that once, but the circuit ended up going through the colors on the clock and then stopping. I wasn't sure what was happening. It was probably different from what you describe. I tried using an exclusive OR gate to switch between the PB and clock, and the flip-flop latched on to 111 (ANDed together). Will you please elaborate a bit on that, though? The 3rd stage of the counter, do you mean?

    Thanks!!
     
  6. lilrips1

    Thread Starter Member

    May 7, 2010
    44
    0
    One option I have is to use the 50z clock by itself as the clock input and then use some type of switch, such as a push-push switch, so that it can be pushed down slightly (but not into the locked position yet) to cycle through the colors so a user can select a color. Then, to let it cycle continuously the user could push the button into place.

    Would that work?
     
  7. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,170
    395
    " The 74LS76 is a negative edge triggered flip-flop" per Signetics. Looks like clock should be tied high via 4.7k to +5V, & PB SW shorts clock line to ground. Short delay, need to fix schematic. but will use other FF stage 2 ANDs & an OR.
     
  8. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,170
    395
    'not sure if this works- simulated by eye ball. I see another problem but will continue. Starting with all reset: D is enabled, [ should be NAND or add invertor]. PB pressed & released, D out lo-hi-lo E same. On 8th press 3rd stage goes lo, B enabled allows FF to toggle, Q hi allows C to pass 50 Hz to clock. A-notQ blocks 3rd stage Q so count continues untill PB is again pressed, resetting A.
     
  9. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    I got a dozen off ebay a few years back for my kid to play with when he was first learning microcontrollers.

    They were similar to the 5 leaded RGB available from Radio Shack. The ones I have just have the 3 pins, clear lens, anode marked, no documentation. I figured out the control by trial and error (came from china).

    Radio Shack no longer shows their version on their website either.
     
  10. lilrips1

    Thread Starter Member

    May 7, 2010
    44
    0
    Bernard

    That's a little bit different than what I've been trying. It seems to me that that would indeed work. I will give it a try and post the results later. Thank you!

    thatoneguy

    It's a bummer they aren't around anymore
     
  11. lilrips1

    Thread Starter Member

    May 7, 2010
    44
    0
    So, I've been working on this circuit, and I just can't seem to get it right.

    Bernard,
    I tried what you drew out, but couldn't get it to work. I may have made an error or two while setting it up, but I don't know. I feel bad that I couldn't make it work. It seemed good.

    This ALMOST worked: I made an attempt with a D-FF, turning it into a T-FF, clocking it when all of the counter stages are low. It then goes into an exclusive OR gate, and when the PB is pushed again, the T-FF turns off and the PB is back in charge. If the circuit is cycling and the PB is pushed, the circuit stops at about the time it is pushed. I can't seem to stop it at 001, red, though. Also, it would be best to have the second two stages clear when the PB is pushed the time after the cycle function, and I think I can figure that out.

    I attached a screen shot.
     
  12. lilrips1

    Thread Starter Member

    May 7, 2010
    44
    0
    I finally figured out one way that works. I attached it here.

    I am still going to work on what Bernard proposed, since that would be better than what I have. It would use less ICs and probably be more stable.

    However, would somebody be willing to point out any flaws in my current schematic? Like resistors?
     
  13. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    What is your 2.5V source and the 50Hz square wave source?

    The connections between logic gates and flip flops do not need resistors. They are mostly needed to limit current going through a junction that appears as an electrical short over a certain voltage (LEDs, Zener diodes, B-E junctions, etc).
     
  14. lilrips1

    Thread Starter Member

    May 7, 2010
    44
    0
    Thanks for checking it over!

    I actually am going to take those 2.5 V indicators out of the circuit. I just had those in there for purpose of simulation.

    As far as the clock, I'm not quite sure.

    I can't purchase a clock as it is shown in the screen shot; the clock is a separate circuit, right, with a 555 timer and such? So wouldn't that sub circuit just need a 5V source? Could I AND a 5V source and the Q logic level?
     
  15. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    A 555 could produce your clock, though a higher frequency might be desired, such as two schmitt inverters with RC Feedback so there wouldn't be noticeable flickering.
     
  16. lilrips1

    Thread Starter Member

    May 7, 2010
    44
    0
    I looked in to the Schmitt inverter oscillator, and I chose to go with it.

    Attached is a screenshot of my circuit somewhat close to its final stage.

    How do I replace the 5V VCC with a 9V battery?

    I'm also a little hazy on this concept: If the FFs are outputting a 0, hence all of the LEDs are off, then would there be a significant juicing of the battery during that time?

    Thanks!!!!!!
     
    Last edited: Dec 18, 2010
  17. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,170
    395
    Might not be a good idea of powering 5 V logic with 9 V, might convert to CMOS, like 4000 or 74C--. If FF are reset , should be a lower battery drain.
     
  18. lilrips1

    Thread Starter Member

    May 7, 2010
    44
    0
    {I changed the D FF to a JK FF.}

    I definitely didn't think about that. Do I even need 9V? I was thinking that I do since the LEDs each needs an average of 3V. But, I just looked at some other RGB circuits that just had 5V. But then I'm not sure how to change the 5V VCC to a 5V battery. Do the grounds just go to the negative end?

    It would be best to just have an on/off switch by the battery, though, correct? Or would it last for a year? I have an LED bike light that has one button that cycles through functions, and on one of the pushes it turns off. That's what I was going for on this circuit.

    I also sat down to see what NAND implementation would do. I figured it could reduce the 17 gates and 6 ICs (1 NOT, 1 XOR, 2 AND, 2 JK-FF) to 16 gates and 6 ICs (1 XOR, 3 NAND, 2 JK-FF). I suppose that would decrease the costs of mass production by purchasing 3 NANDS instead of 2 ANDs and 1 NOT.
     
  19. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    (previous reply was thinking of a different project)

    9V will allow more RGB LEDs to be controlled in series, otherwise, I don't see a benefit, as 9V batteries have a very limited capacity compared to AAs.

    3 AA batteries would power the logic fine at 4.5V, though you may want to ensure the LED functions at that low voltage.

    How many copies of this were you planning on creating? You mentioned mass production, so there might be different solutions for lower costs in lots of 100 or more.
     
    Last edited: Dec 19, 2010
  20. lilrips1

    Thread Starter Member

    May 7, 2010
    44
    0
    thatoneguy

    Even though that reply was for a different project, you introduced me to a different method of producing a clock! :)

    There will just be one RGB LED that operates at an avg 20 mA. Red: 2 V, green: 3.5V, and blue: 3.5 V, so the voltage changes depending upon which leads are logic high. That means I have to calculate the resistors to limit current and voltage to those numbers, right?

    I am only making one or two prototypes. It is for a presentation, and in the presentation it would be good to talk about mass production--for retail--to score some points. So that would be in the thousands of copies... only theoretically.
     
Loading...