Even more success
LED PWM control
- OK, so I had quite a few random, odd bugs in my code... nothing enough to make the individual PWM control not work, but certainly not helping my cause either.
- The real cause of the problem was that I had 2 "if" statements at the beginning of my code that were needed for intializing the driver chip (2 separate registry entries needed to be written to in order to get the driver chip into the correct mode). The first one was getting executed fine (sometimes), but the second one rarely (read: never) got run because the TWI operates on interrupts and the code blows by it before the interrupt from the 1st "if" block gets properly taken care of.
- Anyway, I set it up differently, using a series of "while" loops between each step, waiting for the interrupt section to get finished before continuing on to the next config step. Then, the final step is as I had before, which is continually writing random (literally) values into each of the eight 8-bit registers (each register controls 2 LEDs).
- By taking out all the wait loops in the interrupt code, I get quite a fast pulsing effect that's almost too much to stomach (makes my eyes hurt looking at it).
- So now, my next steps for the code are:
- Wire in an output port from the uC to the address pin of the driver chip to see if I can properly control the addressing of individual driver chips
- Write up some framework for dealing with sending certain "classes" of messages to the driver chips more efficiently and programmatically.
- Wire in an output port from the uC to the address pin of the driver chip to see if I can properly control the addressing of individual driver chips
- I actually sat down and calculated how big the resistors for each color should be (based on the voltage drop across each LED) and hooked up a test circuit to see if I could get the colors to blend again.
- I grabbed my wonderful diffusing acrylic sheet, as well as a blank sheet of white paper, and turned the lights off to see if I could actually get all 3 colors to successfully blend into white. My first attempts weren't very good, but they were promising. The blue was WAY too powerful and the green WAY too weak (even though I was using 2 green LEDs to make up for it). I ended up basically doubling the calculated resistance for blue, as well as adding about 10% to the resistance for red, before I actually got something that wasn't an over-powered blueish white. Once I get LED's that actually match in luminosity, I think I'll be in good shape.
Labels: Coding
0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home