Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

5x7 Led Dot Matrix using 8051 (Programming in C )

Status
Not open for further replies.

jibranjin

Newbie level 3
Newbie level 3
Joined
Dec 10, 2010
Messages
3
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,283
Activity points
1,312
Guys i m making a Scrolling text using 5x7 display with 8051 but i m having a problem that i m unable to figure out that how to scroll a text i wrote this test code but it keeps displaying 'A' .. plz can sumbody tell me what is the prob with this code...... i ll very thankful.....




Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<reg51.h>
int count[5]={0x08,0x10,0x20,0x40,0x80};
int A[5]= {0x7F,0x98,0x98,0x7F,0x00};
int Blank[5]=  {0x0F,0x00,0x00,0x00,0x00};
int c;
int i,j ;
int z;
 
 
void delay(unsigned int msec)  // Function to provide time delay in msec.
{
 
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
 
}
 
void scroll() interrupt 1
{
 
 TL0=0x36;        //Reloading Timer0
 TH0=0xA6;
     for(z=0;z<5;z++){
 
P2=~A[z];
P3=count[z];
delay(1);
P2=0xFF;
}
 
}
 
 
void main ()
{
TMOD=0x11;        //Intialize Timer 0
    TL0=0x36;        //Reloading Timer0
    TH0=0xA6;
    IE=0x82;        // Enable Timer 0 interrupt
   TR0=1;        //Start Timer 0
 
 
 
while(1){
 
 
 
 
for (c=0;c<5;c++){
        delay(100);
        for (z=0;z<4;z++){
            A[z]=A[z+1];
                        }
    
        A[4]=Blank[c];
                }
}
}



**broken link removed**
View attachment ISIS Professional - C__Documents and Settings_Administrator_Desktop_counter_matrix_4.DSN.pdf

i also Attached Schematic's proteus file ...... and its pdf
 
Last edited by a moderator:

There are a couple problems

You're calling delay() in your isr and the main loop. It's using the same memory locations for looping in both invocations. They're going to step on each other.

Do you have your logic backwards?
The while(1) loop should display the current picture, and the timed isr change the picture to the new scrolled version.

Once all the blanks are shifted in, the picture will be empty. This will happen very fast.
 
Thanks mate but now the problem is that the text is scrolling very fast is there any way to control its speed...

here is the code:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include<reg51.h>
int count[5]={0x08,0x10,0x20,0x40,0x80};
int A[5]= {0x00,0x00,0x00,0x00,0x00};
int Blank[5]=  {0x7F,0x98,0x98,0x7F,0x00};
int c=0;
int i,j ;
int x,y;
int z;
 
 
 
 
void delay(unsigned int msec)  // Function to provide time delay in msec.
{
 
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
 
}
 
void delay1(unsigned int msec1)  // Function to provide time delay in msec.
{
 
for(x=0;x<msec1;x++)
for(y=0;y<1275;y++);
 
}
 
void scroll() interrupt 1
{
 
 TL0=0x00;        //Reloading Timer0
 TH0=0x00;
 
delay1(5);
 
        
        for (z=0;z<4;z++){
            A[z]=A[z+1];
        
                        }
        if (c<5){   
        A[4]=Blank[c];
        }           
 
        c++;
 
}
 
 
void main ()
{
TMOD=0x11;        //Intialize Timer 0
    TL0=0x00;        //Reloading Timer0
    TH0=0x00;
    IE=0x82;        // Enable Timer 0 interrupt
   TR0=1;        //Start Timer 0
 
 
 
while(1){
 
 
 
 
     for(z=0;z<5;z++){
 
P2=~A[z];
P3=count[z];
delay(1);
P2=0xFF;
}
}
}

 
Last edited by a moderator:
I'm shooting from the hip here, but go through the datasheet for your device and read about the registers associated with timer0. Things you want to look for is the 'Timer reload value', the clock source for the timer, and make sure the timer is configured as a 16 bit timer.
 
I'm shooting from the hip here, but go through the datasheet for your device and read about the registers associated with timer0. Things you want to look for is the 'Timer reload value', the clock source for the timer, and make sure the timer is configured as a 16 bit timer.

again thanks
 

Hii you need your ISR some thing like this where you need assign some values to TH0 and TL0 ....check the code below-

Code:
static bit pwm_flag = 0; // define global
volatile unsigned int  count=0; // define global


void timer0(void) interrupt 1  using 1
{
        if(!pwm_flag) { //Start of High level
                pwm_flag = 1;   //Set flag
                PWMPIN = 1;     //Set PWM o/p pin
                TH0 = 0xFF;        //Load timer
                TL0= 0xFD;
                if(count<=250)
                {
                 count =count+1;
                }
                else
                {
                 count =0;
                }

                TF0 = 0;                //Clear interrupt flag
                return;         //Return
        }
        else {  //Start of Low level
                pwm_flag = 0;   //Clear flag
                PWMPIN = 0;     //Clear PWM o/p pin
                TH0 = 0xFF;  //Load timer
	       TL0= 0xFD;
                TF0 = 0;        //Clear Interrupt flag
                return;         //return
        }

}

Good Luck
 
Last edited:
hello,
I want to test all alphabets from A to Z using a 5x7 led display in 8051.
here is the code with errors: plz help me to rectify. I am using a Keil as my compiler and PROTEUS as my simulator


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <reg51.h>
 
unsigned char code LED_Alphabets[130]={
0x7e, 0X09, 0X09, 0X09, 0x7e, // A
0x7f, 0X49, 0X49, 0X49, 0X36,  // B
0x3e, 0X41, 0X41, 0X41, 0X22,
0x7f, 0X41, 0X41,0X22, 0x1c,
0x7f, 0X49, 0X49, 0X49, 0X63,
0x7f, 0X09, 0X09, 0X09, 0X01,
0x3e, 0X41, 0X41, 0X49, 0x7a,
0x7f, 0X08, 0X08, 0X08, 0x7f,
0X00, 0X41, 0x7f, 0X41, 0X00,  // I
0X20, 0X40, 0X41, 0x3f, 0X01,
0X7f, 0X08, 0X14, 0X22, 0X41,
0x7f, 0X40, 0X40, 0X40, 0X60,
0x7f, 0X02, 0X04, 0X02, 0x7f,
0x7f, 0X04, 0X08, 0X10, 0x7f,
0x3e, 0X41, 0X41, 0X41, 0x3e,
0x7f, 0X09, 0X09, 0X09, 0X06,
0x3e, 0X41, 0X51, 0X21, 0x5e,
0x7f, 0X09, 0X19, 0X29, 0X46,
0X46, 0X49, 0X49, 0X49, 0X31,  // S
0X01, 0X01, 0x7f, 0X01, 0X01,
0x3f, 0X40, 0X40, 0X40, 0x3f,
0x1f, 0X20, 0X40, 0X20, 0x1f,
0x3f, 0X40, 0X30, 0X40, 0x3f,
0X63, 0X14, 0X08, 0X14, 0X63,
0X07, 0X08, 070, 0X08, 0X07,
0X61, 0X51, 0X49, 0X45, 0X43 // Z
};
unsigned int LED;
int i;
 
void main()
{
   P2=0;
        P0=0;
for(;;)
 { 
     //P0=~LED_Alphabets[LED];
   P2=~LED_Alphabets[LED];
 
   for(i=0;i<2500;i++)
         {
            for(i=0;i<30000;i++);
                 
         }
   LED++;
         
   if(LED==25) 
   LED=0;
 }  
}


- - - Updated - - -

I trid this also... but it didnt work for me, yet let me know the connections you made. did u use any NOT gates?
 
Last edited by a moderator:
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top