Showing posts with label poc. Show all posts
Showing posts with label poc. Show all posts

Monday, 27 October 2008

Digital LED brightness control

While working on the encoder-with-led-ring concept I figured it might be cool if I could control the brightness of each LED individually. For example, the led ring brightness could increase while turning a specific encoder, or the leds be brighter the further 'up' the ring they are.

I already intend to time multiplex the diodes to get away with a single resistor between 16 leds, so I thought, why not try using pulse width modulation (is that the correct term?) to control the LED brightness in software?

I just did a proof of concept, and although the picture below doesn't do the result justice, you can clearly see that it works :-D

the code for the test is dirt simple. Each led down the row is turned on twice as long as the previous one, exponentially increasing the time (but not the brightness):

Pseudo code of the program is as follows:

while(true){
PORTD = 1;
delay_us(10);
PORTD = 2;
delay_us(20);
PORTD = 4;
delay_us(40);
PORTD = 8;
delay_us(80);
PORTD = 16;
delay_us(160);
PORTD = 32;
delay_us(320);
PORTD = 64;
delay_us(640);
PORTD = 128;
delay_us(1280);
}


Monday, 5 November 2007

Initial tests

I started out developing a few proof-of-concept prototypes. I had previously bought a very nice development kit from MikroElektronika, the EasyPIC3 (http://www.mikroe.com), and the prototypes interfaced with the micro controller on that.

First I thought about integrating a LED with the buttons and bought some very standard switches allowing me to do exacly that:





I built a four-key keyboard prototype on a stip of vero-board. The prototype scans rows of keys one row at a time and returns the result on a 2 bit bus... The same bus is used for turning on and off the LEDs connected to the keys. The LEDs also use line scanning, so even though all leds in the picture below appear to be turned on at the same time, only two and two are.

To achieve row addressing, a 74HC154 demux ic is used. The bus is shared through a 74H08 AND and a 74HC125 tristate buffer.

The vero board also contained a midi interface, connecting to the USART on the MCU. At the time I had no real schematics or PCB editor, so all design drawings were done in Adobe Illustrator!







The prototype worked very well, and allowed me to identify a few logical mistakes.