Shop OBEX P1 Docs P2 Docs Learn Events
RGB Led Control — Parallax Forums

RGB Led Control

ArchiverArchiver Posts: 46,084
edited 2001-04-26 23:38 in General Discussion
I've got 3 rgb led's here which i can easily control by just hooking
it up to the pins from the stamp, however I'm looking for some way to
vary the voltage going out (so i can do different shades of
red/blue/green). Is there any easy way to do this with an external
chip or something?

Thanks,
Nathan

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-04-26 13:12
    Would PWM do the trick? You might need a cap to provide an average voltage
    to the LED.

    Michael Clark Phone: (919) 468-9901 ext. 101
    IVC, Inc. mdc@i...


    >
    Original Message
    > From: immolation@h... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=BDcGY7JPApqaVTSsPQLgioTmovQyhPkyzc_S9CywuCM5oEVZX1fjlB2GdmyoZP3IFMqf7TiO7p-sfPujWA]immolation@h...[/url
    > Sent: Thursday, April 26, 2001 6:24 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] RGB Led Control
    >
    >
    > I've got 3 rgb led's here which i can easily control by just hooking
    > it up to the pins from the stamp, however I'm looking for some way to
    > vary the voltage going out (so i can do different shades of
    > red/blue/green). Is there any easy way to do this with an external
    > chip or something?
    >
    > Thanks,
    > Nathan
    >
    >
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-26 15:48
    At 08:12 AM 4/26/01 -0400, you wrote:
    >Would PWM do the trick? You might need a cap to provide an average voltage
    >to the LED.

    Yes, if you could assign three independent PWM values... And since you
    can't do this easily with the stamp by itself, the simplest way I can
    think of to do this with a Stamp is to use 3-OpAmps or comparators.
    First you must have a "triangle" or "saw" wave feeding into the inverting
    input of each Op-Amp set as your PWM base frequency. Second, for each
    non-inverting input you connect to a Stamp Pin through a series resistor,
    and a capacitor tied to GND.

    ie.

    circuit X3 for Red, Blue, and Green

    R
    Stamp I/O >
    /\/\----o
    > to non-inverting input
    |
    o--||--> GND
    C


    Now, with this setup, you apply a PWM signal through the Stamp pin
    to set an appropriate voltage level to the non-inverting Op-Amp input.
    The result of combining this voltage level with a triangle wave through
    an Op-Amp is a PWM signal with a duty cycle proportional to the input
    voltage and a frequency equal to that of the triangle wave applied.

    Note: - You will still need to update the stamp output regularly, but the
    R-C stage will buy you the time necessary to perceive a simultaneous
    multi-channel PWM control.

    - For this application, you don't really need an elaborate triangle
    or saw wave.

    R
    o--/\/\--o
    | |
    | 1|\ 2 |
    o--| \o--o 1/6th of a 74HC14
    | |/
    |
    o---||--->GND
    | C
    |
    o
    > pseudo triangle wave output


    ...you could even get tricky and produce a triangle wave with
    a 4th Comparator and use a SINGLE LM324 if you set one up to
    oscillate in a similar fashion.

    > >
    > > I've got 3 rgb led's here which i can easily control by just hooking
    > > it up to the pins from the stamp, however I'm looking for some way to
    > > vary the voltage going out (so i can do different shades of
    > > red/blue/green). Is there any easy way to do this with an external
    > > chip or something?
    > >
    > > Thanks,
    > > Nathan

    Beau Schwabe IC Mask Designer
    National Semiconductor Network Products Division
    500 Pinnacle Court, Suite 525 Mail Stop GA1 Norcross, GA 30071
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-26 16:35
    A PAK-V will control LEDs in this way. You shouldn't even need the RC since
    the visual persistence will make the LEDs look brighter or dimmer depending
    on the duty cycle. We have several customers that use the PAK-V to simulate
    different light effects using either LEDs or drivers and stage lights.

    With 8 channels, you could control 2 sets of RGBs and still have 2 spare
    channels.

    http://www.al-williams.com/awce/pak5.htm

    Regards,

    Al Williams
    AWC
    * Control 8 servos at once: http://www.al-williams.com/awce/pak8.htm


    >
    Original Message
    > From: Beau Schwabe [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=lpsbMMcjZ1fu6jGlsa-91T2fWQdQLuKx2ALYnTSXANMmdwRoqksq3b8VmVM8uCNt33UemjzkbfeBR0P98_lYrg]bschwabe@a...[/url
    > Sent: Thursday, April 26, 2001 9:49 AM
    > To: basicstamps@yahoogroups.com
    > Subject: RE: [noparse][[/noparse]basicstamps] RGB Led Control
    >
    >
    > At 08:12 AM 4/26/01 -0400, you wrote:
    > >Would PWM do the trick? You might need a cap to provide an
    > average voltage
    > >to the LED.
    >
    > Yes, if you could assign three independent PWM values... And since you
    > can't do this easily with the stamp by itself, the simplest way I can
    > think of to do this with a Stamp is to use 3-OpAmps or comparators.
    > First you must have a "triangle" or "saw" wave feeding into the inverting
    > input of each Op-Amp set as your PWM base frequency. Second, for each
    > non-inverting input you connect to a Stamp Pin through a series resistor,
    > and a capacitor tied to GND.
    >
    > ie.
    >
    > circuit X3 for Red, Blue, and Green
    >
    > R
    > Stamp I/O >
    /\/\----o
    > to non-inverting input
    > |
    > o--||--> GND
    > C
    >
    >
    > Now, with this setup, you apply a PWM signal through the Stamp pin
    > to set an appropriate voltage level to the non-inverting Op-Amp input.
    > The result of combining this voltage level with a triangle wave through
    > an Op-Amp is a PWM signal with a duty cycle proportional to the input
    > voltage and a frequency equal to that of the triangle wave applied.
    >
    > Note: - You will still need to update the stamp output regularly, but the
    > R-C stage will buy you the time necessary to perceive a
    > simultaneous
    > multi-channel PWM control.
    >
    > - For this application, you don't really need an elaborate triangle
    > or saw wave.
    >
    > R
    > o--/\/\--o
    > | |
    > | 1|\ 2 |
    > o--| \o--o 1/6th of a 74HC14
    > | |/
    > |
    > o---||--->GND
    > | C
    > |
    > o
    > pseudo triangle wave output
    >
    >
    > ...you could even get tricky and produce a triangle wave with
    > a 4th Comparator and use a SINGLE LM324 if you set one up to
    > oscillate in a similar fashion.
    >
    > > >
    > > > I've got 3 rgb led's here which i can easily control by just hooking
    > > > it up to the pins from the stamp, however I'm looking for some way to
    > > > vary the voltage going out (so i can do different shades of
    > > > red/blue/green). Is there any easy way to do this with an external
    > > > chip or something?
    > > >
    > > > Thanks,
    > > > Nathan
    >
    >
    > Beau Schwabe IC Mask Designer
    > National Semiconductor Network Products Division
    > 500 Pinnacle Court, Suite 525 Mail Stop GA1 Norcross, GA 30071
    >
    >
    >
    >
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-26 17:22
    Are your RGB leds common anode or common cathode?

    The combination of Stamp PWM and an op-amp providing proportional
    current-source (sink) drive to the leds would be versatile, because
    the stamp could be doing other things while the external circuitry
    holds on to the current color combination. Current sink drive, 0 to
    20 milliamps for PWM from 0 to 100%:
    +9
    100k |\| ;----|<---+9
    stamp PWM --/\/\--o----|+\ |/ led, common anode
    | | >---| 3904
    .1 === ;-|-/ |\>
    | | |/ | |
    Vss | Vss | 250
    `
    o--/\/\--Vss
    LM324 (four op amps in one dip)
    circuit x3 for 3 leds.

    Al's Pak chip does multiple PWM channels would be another solution.

    Just for fun, build DIY time division mux, no external circuit
    required except for current limiting resistors...

    ' common cathode leds active high on p0,p1,p2
    outA=%000
    loop: '
    pulsout 0,2500 ' 5 millisecond on
    pulsout 1,2500
    pulsout 2,2500
    goto loop

    To get approximately equal drive to all the colors. Adjust the
    current limiting resistors to compensate for time division mux.
    Adjust pulse times for different colors. It is a full time job for
    the stamp. An effect:

    ' leds active high on p0,p1,p2
    outA=%000
    i var word
    loop:
    i=i+1
    pulsout 0,abs sin i *20
    pulsout 1,abs cos i *20
    pulsout 2,abs sin (i/4) *20
    goto loop


    -- regards,
    Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-26 18:48
    I'm pretty sure that pulsing LED's vs. supplying continuous voltage
    increases their life span.

    On Thu, 26 Apr 2001, Al Williams wrote:

    > A PAK-V will control LEDs in this way. You shouldn't even need the RC since
    > the visual persistence will make the LEDs look brighter or dimmer depending
    > on the duty cycle. We have several customers that use the PAK-V to simulate
    > different light effects using either LEDs or drivers and stage lights.
    >
    > With 8 channels, you could control 2 sets of RGBs and still have 2 spare
    > channels.
    >
    > http://www.al-williams.com/awce/pak5.htm
    >
    > Regards,
    >
    > Al Williams
    > AWC
    > * Control 8 servos at once: http://www.al-williams.com/awce/pak8.htm
    >
    >
    > >
    Original Message
    > > From: Beau Schwabe [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=7GhyLIkZwVHH6MabcULHZjkWiOq6xx7m1ogHqbCtLY7uSGGrq0qhk08iekNN5i0ITZ5lOX8lKwyy0F5CEFRBkJVosA]bschwabe@a...[/url
    > > Sent: Thursday, April 26, 2001 9:49 AM
    > > To: basicstamps@yahoogroups.com
    > > Subject: RE: [noparse][[/noparse]basicstamps] RGB Led Control
    > >
    > >
    > > At 08:12 AM 4/26/01 -0400, you wrote:
    > > >Would PWM do the trick? You might need a cap to provide an
    > > average voltage
    > > >to the LED.
    > >
    > > Yes, if you could assign three independent PWM values... And since you
    > > can't do this easily with the stamp by itself, the simplest way I can
    > > think of to do this with a Stamp is to use 3-OpAmps or comparators.
    > > First you must have a "triangle" or "saw" wave feeding into the inverting
    > > input of each Op-Amp set as your PWM base frequency. Second, for each
    > > non-inverting input you connect to a Stamp Pin through a series resistor,
    > > and a capacitor tied to GND.
    > >
    > > ie.
    > >
    > > circuit X3 for Red, Blue, and Green
    > >
    > > R
    > > Stamp I/O >
    /\/\----o
    > to non-inverting input
    > > |
    > > o--||--> GND
    > > C
    > >
    > >
    > > Now, with this setup, you apply a PWM signal through the Stamp pin
    > > to set an appropriate voltage level to the non-inverting Op-Amp input.
    > > The result of combining this voltage level with a triangle wave through
    > > an Op-Amp is a PWM signal with a duty cycle proportional to the input
    > > voltage and a frequency equal to that of the triangle wave applied.
    > >
    > > Note: - You will still need to update the stamp output regularly, but the
    > > R-C stage will buy you the time necessary to perceive a
    > > simultaneous
    > > multi-channel PWM control.
    > >
    > > - For this application, you don't really need an elaborate triangle
    > > or saw wave.
    > >
    > > R
    > > o--/\/\--o
    > > | |
    > > | 1|\ 2 |
    > > o--| \o--o 1/6th of a 74HC14
    > > | |/
    > > |
    > > o---||--->GND
    > > | C
    > > |
    > > o
    > pseudo triangle wave output
    > >
    > >
    > > ...you could even get tricky and produce a triangle wave with
    > > a 4th Comparator and use a SINGLE LM324 if you set one up to
    > > oscillate in a similar fashion.
    > >
    > > > >
    > > > > I've got 3 rgb led's here which i can easily control by just hooking
    > > > > it up to the pins from the stamp, however I'm looking for some way to
    > > > > vary the voltage going out (so i can do different shades of
    > > > > red/blue/green). Is there any easy way to do this with an external
    > > > > chip or something?
    > > > >
    > > > > Thanks,
    > > > > Nathan
    > >
    > >
    > > Beau Schwabe IC Mask Designer
    > > National Semiconductor Network Products Division
    > > 500 Pinnacle Court, Suite 525 Mail Stop GA1 Norcross, GA 30071
    > >
    > >
    > >
    > >
    > >
    > >
    > > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    > >
    >
    >
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >

    Sean T. Lamont, CTO / Chief NetNerd, Abstract Software, Inc. (ServNet)
    Seattle - Bellingham - Vancouver - Portland - Everett - Tacoma - Bremerton
    email: lamont@a... WWW: http://www.serv.net
    "...There's no moral, it's just a lot of stuff that happens". - H. Simpson
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-26 19:18
    Sean,
    I'm interested to understand why this might be. Any references? (not
    challenging you .... I just don't understand it)
    Mike

    At 10:48 AM 4/26/2001 -0700, you wrote:

    >I'm pretty sure that pulsing LED's vs. supplying continuous voltage
    >increases their life span.

    _________________________________
    Mike Walsh
    walsh@i...
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-26 21:12
    I have done this by using the freqout command
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-26 21:22
    --- In basicstamps@y..., immolation@h... wrote:
    > I've got 3 rgb led's here which i can easily control by just
    hooking
    > it up to the pins from the stamp, however I'm looking for some way
    to
    > vary the voltage going out (so i can do different shades of
    > red/blue/green). Is there any easy way to do this with an external
    > chip or something?
    >
    > Thanks,
    > Nathan

    Actually you can do this with some software trickery in the stamp,
    assuming your stamp has nothing else to do with its time. Just turn
    all three on at the same time and set up three counters with three
    different values. Count down each counter in a loop and when each one
    reaches zero, turn the output off. After some predetermined length of
    time (using a fourth counter), repeat the cycle by turning all three
    on again. Basically you are doing PWM on three points in software.
    Only thing is, you have to do it pretty fast or the LEDs will blink
    visibly, so your stamp probably can't do anything else while all this
    is going on.

    Or, you can use one of our coprocessors or one of the other PWM
    coprocessors available on the market to do the PWM for you while your
    stamp goes on its merry way doing other things.

    Chuck Davis
    Oak Tree Systems
    www.oaktreesystems.com
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-26 23:38
    --- In basicstamps@y..., "Chuck Davis" <cdavis@o...> wrote:
    > --- In basicstamps@y..., immolation@h... wrote:
    > > I've got 3 rgb led's here which i can easily control by just
    > hooking
    > > it up to the pins from the stamp, however I'm looking for some
    way
    > to
    > > vary the voltage going out (so i can do different shades of
    > > red/blue/green). Is there any easy way to do this with an
    external
    > > chip or something?
    > >
    > > Thanks,
    > > Nathan
    >
    > Actually you can do this with some software trickery in the stamp,
    > assuming your stamp has nothing else to do with its time. Just turn
    > all three on at the same time and set up three counters with three
    > different values. Count down each counter in a loop and when each
    one
    > reaches zero, turn the output off. After some predetermined length
    of
    > time (using a fourth counter), repeat the cycle by turning all
    three
    > on again. Basically you are doing PWM on three points in software.
    > Only thing is, you have to do it pretty fast or the LEDs will blink
    > visibly, so your stamp probably can't do anything else while all
    this
    > is going on.
    >
    > Or, you can use one of our coprocessors or one of the other PWM
    > coprocessors available on the market to do the PWM for you while
    your
    > stamp goes on its merry way doing other things.
    >
    > Chuck Davis
    > Oak Tree Systems
    > www.oaktreesystems.com

    Hmm sounds like my best bet, the stamp isnt going to be doing anymore
    major asides from driving an lcd/some relay's neither of which will
    be contantly changing, just occasionally

    All those other people lost me in advanced electronics which i know
    absolutely nothing about =)
Sign In or Register to comment.