RadioLocman.com Electronics ru
Advanced Search +
  

05-20-2011

Basics of LED dot matrix display. Part 2. Circuit Setup and Software

Part 1. Theory

Circuit Setup

The circuit setup for this experiment is quite simple. You need seven 330 Ω resistors in series with rows R1 through R7 to limit the current through the LEDs. Then the rows are driven by RB0 through RB6 pins of PIC18F2550. The columns are connected to the five outputs of ULN2003A. The corresponding five input pins of ULN2003A IC are controlled by RA0 through RA4 pins of PIC18F2550. The microcontroller will, therefore, scan across the column by sending appropriate bits to PORTA. For example, setting RA0 to 1 and clearing RA1 through RA4 bits, will select the first column. The microcontroller will wait for about 1 ms before switching to the next column. At each column, the microcontroller will output the corresponding row value at PORTB to turn on the appropriate LEDs in the column that are required to display the specific character. The switching between columns is fast enough to deceive the human eyes and a steady character is displayed.

Circuit diagram for interfacing a 5x7 LED dot matrix with PIC18F2550

Software

The major part of this experiment is the software routine to scan the columns and feed the rows with appropriate values. The column-specific row values for display characters can be either defined in RAM or stored in the program memory in case the on-board RAM is not sufficient enough. In mikroC, the variables are saved in RAM and constants are stored in program memory. So, if your PIC does not have enough RAM, you can define a constant array to store the row values so that a part of the program memory is occupied by it to free up the on-board RAM. PIC18F2550 has quite a bit of RAM (2 KB), so I have used RAM to store the row values for alphabets A through Z. Here’s how I define it in mikroC,

unsigned short Alphabets[130]=
{
0x7e, 0x09, 0x09, 0x09, 0x7e, // A
0x7f, 049, 049, 049, 036, // B
0x3e, 041, 041, 041, 022,
0x7f, 041, 041, 022, 0x1c,
0x7f, 049, 049, 049, 063,
0x7f, 009, 009, 009, 001,
0x3e, 041, 041, 049, 0x7a,
0x7f, 008, 008, 008, 0x7f,
000, 041, 0x7f, 041, 000, // I
020, 040, 041, 0x3f, 001,
0x7f, 008, 014, 022, 041,
0x7f, 040, 040, 040, 060,
0x7f, 002, 004, 002, 0x7f,
0x7f, 004, 008, 010, 0x7f,
0x3e, 041, 041, 041, 0x3e,
0x7f, 009, 009, 009, 006,
0x3e, 041, 051, 021, 0x5e,
0x7f, 009, 019, 029, 046,
046, 049, 049, 049, 031, // S
001, 001, 0x7f, 001, 001,
0x3f, 040, 040, 040, 0x3f,
0x1f, 020, 040, 020, 0x1f,
0x3f, 040, 030, 040, 0x3f,
063, 014, 008, 014, 063,
007, 008, 070, 008, 007,
061, 051, 049, 045, 043 // Z
}

And this is how mikroC allows you to store arrays in the program memory.

const unsigned short characters[30]=
{
024, 0x2A, 0x7f, 0x2A, 012, // $ 
008, 014, 022, 041, 000, // <
041, 022, 014, 008, 000, // > 
014, 014, 014, 014, 014, // =
036, 049, 055, 022, 050, // &
044, 0x3c, 004, 0x7c, 044, // PI
};

I have written a simple program in mikroC to display the alphabets A through Z sequentially, and some special characters too. You can watch the video below to see how they look like on the dot matrix display. 

Downloads

Source Code (mikroC) - download

embedded-lab.com

Slices ↓
Radiolocman facebook Radiolocman twitter Radiolocman google plus