New Project LEDCube2009

I’m working on a new project at school. This time it’s all about an Embedded system. Programmable in C18 ( Microchip’s ripoff of regular C99? ) on the PIC 18f4550 the same device I’ve used for my PONG on glcd.

For this project I’m going to build a LED cube. Here suppose to be a boring text about LED cubes, but instead i’ve searched YouTube for some awesome video’s. Video1, Video2, Video3.

I’m building a Cube of 5×5x5 RGB multi color LED’s.

Targets for this project are: figuring out a lot about the microcontroller. How: timers, interrupts, and a lot of other features work.

Project Thus far

Connecting LED’s to a microcontroller can be done in a variety of way’s. Problem I’m having is there are a lot of LED’s in my LED cube. So the 24 default outputs of the mc are not enough. Using a Multiplexer a MC can be extended to control more  out- and inputs.  To hookup the LED’s in a matrix 16 LED’s will produce only eight controlling pins. Only drawback is only four LED’s can be turned on simultaneously. Solution: switching very fast between the LED’s. When the frequency is high enough a human-being cannot make out it the LED is actually burning or not.

Playing with Interrupt Vectors

Theoretical knowledge about interrupts has been provided many times by my professor, but i’ve never actually used it. There is a first time for everything so: here goes. The PIC 18f series has a very compacted library, and the documentation is very poor as well. So after spending hours on destroying by boot-loader. I finally figured it out.

The boot-loader is a peace of software providing for USB flashing of the MC. So I do not need a programmer, and can work on it from home. This boot-loader starts at code block 0 of a MC. Interrupts are remapped by the boot-loader to you program block. So you first need to catch this interrupt at that specific location. And redirect it to your C function.

Here is an example:
#pragma code
#pragma code _HIGH_INTERRUPT_VECTOR = 0x000808
void _HIGH_INTERRUPT_VECTOR (void) { _asm goto handleHighISR _endasm }

To invoke a timer interrupt i’ve used the following code:

//disable global and enable TMR0 interrupt
INTCON = 0x20;
//TMR0 high priority
INTCON2 = 0x84;
//enable priority levels
RCONbits.IPEN = 1;
//clear timer high
TMR0H = 0;
//clear timer low
TMR0L = 0;
//set up timer0 - prescaler 1:32
T0CON = 0x84;
//enable interrupts
INTCONbits.GIEH = 1;

Media: pictures of setup & interrupt clip

The fast switching LED’s are located in one infinite loop, the slower flashing LED is invoked via an interrupt. Sorry for the poor focus/ quality.

Misc pictures

LEDcube2009_1_low LEDcube2009_2_low

Leave a Reply