RGB-LED - Brightness control not understood
garyg
Posts: 420
in Propeller 1
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.
..
Thanks in advance for advice/help/words of wisdom.
Garyg
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.
..
Thanks in advance for advice/help/words of wisdom.
Garyg
Comments
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.
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
There are 256 levels, so 64/256 is 25%, 192 would be 75%
While this is 3/4 brightness, it probably won's look like 3/4 brightness since we perceive brightness on a logarithmic scale.
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
What an absolutely fantastic project! All the best with it, shout out if you need more help.
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.
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.
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).
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
- 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 ...
Andy
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.
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.
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.
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
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.
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/
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.
or, output=(Brightness)^2*255! Cool