Shop OBEX P1 Docs P2 Docs Learn Events
RGB-LED - Brightness control not understood — Parallax Forums

RGB-LED - Brightness control not understood

Hi
Awhile back, I received at no cost to me, an RGB-LED parallax #28085.
I connected it on my test platform using a 2200 ohm resistor in series with the signal line.
That did not work when I ran the example program, so I connected the signal line directly to P14 on my Quickstart board.
I was able to run the example program that makes the LED change color and cycle through the different colors.
..
Now, I'm attempting to get the LED's at 75% brightness.
The sample code is set for 25% brightness.
I don't know what to change to get the brightness at 75%.
..
I just started this small project and need some help getting started.
I'll attempt to attach the code I'm using.
The only thing I changed is that I made the string 1 instead of 6.
jm_ws2812_demo%20-%20Archive%20%20%5BDate%202016.06.06%20%20Time%2018.06%5D.zip
..
Thanks in advance for advice/help/words of wisdom.
Garyg

Comments

  • Try it without the 2200 ohm resistor Garyg, but make sure you're driving the SI pin.

    I've found you only get away with a hundred ohms or so before having issues. Its to do with the ~800kHz clocked signal driving the ws2812, too much series impedance affects the waveforms.
  • Thanks Tubular
    When I elimated the 2200 ohm resistor everything started working.
    I would imagine I will not damage the QuickStart board by eliminating the resistor.
    ..
    Now
    I need to get 75% brightness out of the LED's.
    ..
    code[ pub main | pos

    strip.start_b(LEDS, STRIP_LEN) ' start led driver
    strip.off

    repeat 10
    color_chase(@Chakras, STRIP_LEN, 100)

    repeat
    repeat pos from 0 to 255
    strip.set_all(strip.wheelx(pos, 64)) ' 1/4 brightness
    pause(20)

    ]code
    ..
    In the above code snippet - note the comment that says 1/4 brightness.
    Where does that come from and how do I control it?
    It appears that this loop is repeated 255 times. I do not understand what it exactly does.
    I'm thinking that if I change the (pos, 64)) to pos, 191)) that should give me 75% brightness.
    I'll test that!

    Thanks for your help so far
    Garyg
  • Francis BauerFrancis Bauer Posts: 366
    edited 2016-06-07 00:12
    Yes, the second parameter of the 'wheelx' routine controls the brightness (see code excerpt below).

    There are 256 levels, so 64/256 is 25%, 192 would be 75%
    strip.set_all(strip.wheelx(pos, 64))                      ' 1/4 brightness
    
    pub wheelx(pos, level)
    
    '' Creates color from 0 to 255 position input
    '' -- colors transition r-g-b back to r
    '' -- level is brightness, 0 to 255
    
  • To go along with Francis Bauer's post, this is what you'll want to use with calling the "wheelx" method.
    strip.set_all(strip.wheelx(pos, 192)) ' 3/4 brightness
    

    While this is 3/4 brightness, it probably won's look like 3/4 brightness since we perceive brightness on a logarithmic scale.
  • Thank you, Thank you, Thank you!

    Everyone who commented made bits of my understanding become more clear.

    Tubular: It took a bit of time, but I figured out that the SI pin is on the LED and not the Quickstart.
    This was helpful, as I'm planning on purchasing the 10 pack of these from Parallax.
    ..
    Francis: Your post with code snippet helped to make this part of the code more clear than what I had noticed.
    I only do a couple of projects per year, so I tend to miss some things I should see right away.
    ..
    Duane: Your post made me realize why, when I attempted to adjust the (pos,64)) part, that I did not see any intensity
    change in the lights. At one time I learned that brightness is on a logarithmic scale, but sometimes
    it takes a reminder to wake up memories from the past.
    So - I would imagine that light intensity will change quite a lot between 5% and 25% and not much from 50%
    to 90%.

    This is the beginnings of a UFO Bird Feeder with Deer Deterrent that I've been thinking about for a while now.
    I started with the mechanical design, but needed to include what will be needed for control.
    So far, I'll need to purchase:
    1 - Ten pack of the 28085 LED's
    1 - Propeller Mini
    1 - 5 AA battery holder
    1 - 5V voltage regulator of some kind
    6 - 3wire plug in connectors to interconnect the LED's.-from Parallax.
    I already have a PIR motion detector and sound card from another project that has outlived it's 1st life.
    ..
    Things get confusing to me when doing projects that combine mechanical passive things along with a microcontroller
    project, but I will endeavor to persevere.

    I'm sure I'll have more questions in the near future.

    Thanks again for all your help.
    Garyg



  • ElectrodudeElectrodude Posts: 1,657
    edited 2016-06-07 03:04
    The RGB LED you have isn't just an LED - it has built-in circuitry that controls the LED. Its input pin does not power the LED - it's just a signal to some onboard circuitry that controls the LED. It gets its power from a separate power pin. That's why you don't need a resistor. I guess there's an internal resistor or something between the onboard circuitry and the actual LED.
  • garyg wrote: »
    UFO Bird Feeder with Deer Deterrent

    What an absolutely fantastic project! All the best with it, shout out if you need more help.
  • garyg wrote: »
    1 - 5V voltage regulator of some kind

    The WS2812 LEDs can be powered from 3.3V. I think they work better when powered from 3.3V since the chips used in the WS2812 LEDs don't always work well when powered with 5V and controlled with 3.3V logic. If you power the LEDs with 5V, I suggest you use a level shifter on the signal line.

    The WS2812 LEDs can work reasonably well with a 5V supply and 3.3V logic if the 5V supply is very clean.

    Here's a video with three 16 pixel rings. You can see some flashes which don't match the color pattern every so often. This is one of the side effects of powering the LEDs with 5V and using 3.3V logic.



    There's some additional information about these LEDs in this thread.

    The small WS2812B boards Parallax sells can be linked together with jumpers.

    Here are seven small PCBs linked this way.

    attachment.php?attachmentid=111440&d=1413235351

    The above boards were ones I made but the Parallax boards can also be linked this way. There are lots of places online where you can purchase jumpers for about a penny each so don't pay much for your jumpers if you decide to use this technique.

    Here's another WS2812B thread.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    Duane Degn wrote: »
    The WS2812 LEDs can be powered from 3.3V. I think they work better when powered from 3.3V since the chips used in the WS2812 LEDs don't always work well when powered with 5V and controlled with 3.3V logic. If you power the LEDs with 5V, I suggest you use a level shifter on the signal line.

    The WS2812 LEDs can work reasonably well with a 5V supply and 3.3V logic if the 5V supply is very clean.

    Duane, how stable is the WS2812B at 3.3V? It is not only outside the supply range in the datasheet, but most sites seem to indicate you do't want to go below 4V. Even SparkFun mentions this in their tutorials on the chip.
  • Duane, how stable is the WS2812B at 3.3V? It is not only outside the supply range in the datasheet, but most sites seem to indicate you do't want to go below 4V. Even SparkFun mentions this in their tutorials on the chip.

    I don't remember which WS2812B projects I used 3.3V power. I remember being surprised to learn they should work at 3.3V and I was skeptical about this but when I tried it, it worked.

    Adafruit's "Uberguide" suggests using a single cell LiPo when controlling these LEDs with 3.3V logic.

    I'm not sure where I saw the suggestion to use 3.3V power but it may have been in this forum. I seem to recall Tubular powered a WS2812 only from the data line connected to a Propeller (here's a link).

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    Interesting...Well, I may try it at some point.
  • AribaAriba Posts: 2,690
    edited 2016-06-07 17:29
    Tubular wrote: »
    garyg wrote: »
    UFO Bird Feeder with Deer Deterrent

    What an absolutely fantastic project! All the best with it, shout out if you need more help.

    Maybe someone can explain to me the sense of "UFO Bird Feeder with Deer Deterrent".

    - What is an UFO Bird? If you know the flying object is a bird it's no more an UFO. Just an unknown bird :smile:
    - What has bird feeding to do with deers? Do they eat birds in America? Deterrenting cats would make more sense.
    - Or is the problem that deers eat the birds food? Then just hang it higher. And why are hungry birds more valuable than hungry deers?

    Question upon question ... :smile:

    Andy
  • I'll attempt to attach a photo of the UFO Birdfeeder design.
    General idea will be to Make the outer segments of the saucer glow with a rotating pattern of LED's.
    Most of this will be 3D printed.
    If it works out, the UFO will be about 16" diameter.
    The seed carrying part will be a 2 liter bottle with bottom cut out.
    Birds can stand on the lower platform.
    Seed should be shielded somewhat from the weather.
    Deer should be scared off by the glowing LED and sound board.
    Deer destroy lots of things in my area.
    My wife likes the little birdies.


    UFO%20BirdFeeder-withDeerDeterrent.jpg
  • I have the main outer Green part design completed.
    Since I can control the Color and Brightness of the LED I'm using for testing and
    I was able to make Natural Color PETG material glow quite well, I can get the major part
    of the design 3D printed. I know a mulitpart 3D printed assembly will tend to grow a bit.
    I'll need to Assemble that 1st, then work on the interior brown part to fit LED's.
    Plan is to incorporate the PropMini, SoundBoard and batteries under the bottom platform.
    ...
    And
    I'll try the LED using 3.3Vdc

    Thanks again for the discussion, I'm learning a lot.

  • It's worth mentioning that LEDs, like tv's and lots of other things, don't have a linear relationship between power and brightness. When you set the LEDs to '128', you're setting them to 1/2 power, but that's not necessarily half the perceptual brightness because people perceive brightness in a non-linear way.

    A "simple" way to convert your desired brightness to the actual number you want is this:

    Output = (Brightness * Brightness) * 255

    ...where Brightness is a number from 0 to 1.

    So that means to make your LED to appear "half brightness" you output a value of 64:

    64 = (0.5 * 0.5) * 255

    For most things this isn't necessary, but if you want to make a nice pulsing effect that smoothly fades off & on, it looks better to encode with this non-linear curve, otherwise the LEDs will appear to be fairly bright most of the time, only dipping into "dark" briefly in between.
  • AribaAriba Posts: 2,690
    garyg,

    Thanks, now I get it: A bird feeder with the shape of a flying saucer.
    Looks good, I hope you make a video when it's ready.

    Andy
  • Interesting...Well, I may try it at some point.

    Definitely worth trying, Chris.

    You can run the strips ok at 3v3. They get a slightly pink color cast due to the green and blue leds being a little starved of voltage, but its not too bad. Of course when you light up a strip full white the leds at the end of the strip are running off a lower voltage than those at the start, so sometimes you see the same effect even with proper 5v supply

    In some of my circuits i run the prop at 3v6, driving 5v strips, this gets the drive voltage above the 0.7vdd worst case threshold.

    Garyg don't get too distracted by this right now. Your 3d model looks great.
  • I'm never someone to discourage a good time tinkering away at a project, but...the whole deer-proof and squirrel-proof bird feeder problem has been solved. In metal.

    For deer, you need a physical barricade - hang the feeder too high for them to reach. They are smart and persistent and will quickly learn to ignore things designed to scare them (such as motion sensors that trigger a sprinkler). Until we fenced in our yard, they ate all the apples they could reach on the apple tree. Plus any other plants that were tasty.

    For squirrels, use a feeder that closes when they jump on it.

    http://www.backyardwildbirds.com/Deer-Proof-Bird-Feeder-Pole_p_2562.html

    http://www.bromebirdcare.com/products/classic/
  • Hi again

    Jason-- I'll use your brightness formula when I string the LED's together. Thanks
    ..
    Tubular-- I'll try to not get distracted. It happens and sometimes causes my project to drop out before finishing.
    ..
    Jeff -- Every now and then, I jump down a rabbit hole type of project.
    My last project was --- http://forums.parallax.com/discussion/143909/questions-about-how-cold-temperature-affects-parallax-pir-sensor-555-28027
    The project was fun.
    I learned a lot
    AND
    It was the best Deer Deterrent Mousetrap contrivance I ever contrived.
    I would watch the Deer freak out at night when they were attacked by BillyBones.
    Thanks for your comments and links.
    But I will endeavor to persevere on this project.
    ..
    Ariba-- Your Welcome
    When this project is completed, I Will attempt to do a video.
    At minimum, I'll share photos.





  • Here's a video to go with JasonDorie's explanation of how we perceive brightness.

  • Cool video!
  • JasonDorie wrote: »
    It's worth mentioning that LEDs, like tv's and lots of other things, don't have a linear relationship between power and brightness. When you set the LEDs to '128', you're setting them to 1/2 power, but that's not necessarily half the perceptual brightness because people perceive brightness in a non-linear way.

    A "simple" way to convert your desired brightness to the actual number you want is this:

    Output = (Brightness * Brightness) * 255

    ...where Brightness is a number from 0 to 1.

    So that means to make your LED to appear "half brightness" you output a value of 64:

    64 = (0.5 * 0.5) * 255

    For most things this isn't necessary, but if you want to make a nice pulsing effect that smoothly fades off & on, it looks better to encode with this non-linear curve, otherwise the LEDs will appear to be fairly bright most of the time, only dipping into "dark" briefly in between.


    or, output=(Brightness)^2*255! Cool
Sign In or Register to comment.