free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Rickey's World :: Discussion Forums :: Discuss and Learn :: 8051 Discussion Forum
 
<< Previous thread | Next thread >>
8051 microcontroller and 4 7segment display....pls help
Go to page       >>  
Moderators: Ajay Bhargav, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph, ExperimenterUK, DavesGarage
Author Post
dgkadesewa
Thu Jul 02 2009, 03:56AM
 User Offline
Registered Member #19400
Joined: Tue Jun 16 2009, 09:38AM

Posts: 28
Thanked 1 time in 1 posts
hey every1....i'm programming a STK microcontroller which is an 8051 microcontroller in c language. the program makes the 7segmant count down from 9999 to 0 on a 4 7segment display. i want the 4 7segment to start blinking when it gets to 50 and blink till it gets to 0 i.e blink every second..and oh i forgot to add the delay is for 1 second.
i'v programmed the microcontroller and it counts down without a problem...bt d problem comes in the blinking part....d blinking is nt in uniform n i think its cos each digit is controlled separately at a different time....its blinkin could synchronize for 20secs and then go out of phase for d next 10 secs , go back in phase for d nxt 5 secs n ends out of phase......nxt time, it alternates i.e go out of phase for the 20 secs...go back in phase n d rest....sorrry i cnt give ma code now..bt i promise to do so..soon....
i desperately need an ansa..its drivin me nuts...PLSSSSS HELP....and oh!...am using d keil uvision compiler and proteus 7 professional simulator.....tnx in advance



in Christ and with Christ for ever...
Back to top

dgkadesewa
Thu Jul 02 2009, 08:51AM
 User Offline
Registered Member #19400
Joined: Tue Jun 16 2009, 09:38AM

Posts: 28
Thanked 1 time in 1 posts
c'mon guysss....i tot we had geniuses on dis forum...quit viewin n nt repling...instead, view n reply.........plsss

in Christ and with Christ for ever...
Back to top

ExperimenterUK
Thu Jul 02 2009, 10:28AM
 User Offline
Registered Member #9602
Joined: Tue Aug 05 2008, 04:15PM

Posts: 1254
Thanked 199 times in 198 posts
If you could post your project.. code and proteus simulation it would help.
Back to top

ali.mir10v
Thu Jul 02 2009, 09:01PM
 User Offline
Registered Member #13351
Joined: Mon Dec 22 2008, 04:31AM

Posts: 137
Thanked 6 times in 6 posts
Decrement the value of unit place and also decrment a counter whihch will test for a count upto 950 as follows ( four user define counter cnt1 = ff, cnt2 = ff, cnt3 = ff ,cnt4 = 87h). As 950 occurs set a user define bit which will say the controller that already 950 count are completed now start dec with blinking
And you can now do the blinking with decrementing the unit place digit , setting all 7 segment OFF calling delay and setting all four 7 segment as per order,
Hai na simple...Reply me if this work or not.Plz PM me.

no zodiac sign but believe in the hardwork:-)
Back to top

dgkadesewa
Fri Jul 03 2009, 06:57AM
 User Offline
Registered Member #19400
Joined: Tue Jun 16 2009, 09:38AM

Posts: 28
Thanked 1 time in 1 posts
ok.. dis is my source code..it counts down from 999 to 0 and starts blinking when it gets to 995...

CODE:
#include<reg51.h> //
void delay(){
int b;
for(b=0;b<23;b++){
TMOD=0x01;
TH0=0x00;
TL0=0x00;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}}

void delay2(){

TMOD=0x01;
TH0=0xF7;
TL0=0xF0;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
void delay21(){

TMOD=0x01;
TH0=0xF8;
TL0=0x00;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
void delay22(){

TMOD=0x01;
TH0=0xF8;
TL0=0xF0;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
void delay23(){

TMOD=0x01;
TH0=0xF9;
TL0=0xF0;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

void delay4(){

TMOD=0x01;
TH0=0xF9;
TL0=0xF0;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

void delay5(){

TMOD=0x01;
TH0=0xFA;
TL0=0xF0;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

void delay6(){

TMOD=0x01;
TH0=0xFF;
TL0=0xF0;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

void delay3(){

TMOD=0x01;
TH0=0xF7;
TL0=0xC0;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

int decode (int digit)
        {
        int acode;
        switch(digit)
                {
                case 0: acode = 0x40; break;
                case 1: acode = 0x79; break;
                case 2: acode = 0x24; break;
                case 3: acode = 0x30; break;
                case 4: acode = 0x19; break;
                case 5: acode = 0x12; break;
                case 6: acode = 0x02; break;
                case 7: acode = 0x78; break;
                case 8: acode = 0x00; break;
                case 9: acode = 0x10; break;
                case 24:acode = 0xff; break;
                }
        return acode;
        }
int thousands, hundreds, tens, units;
int  thingy(int count)
        {
        if(count<1000 && count>99){
        thousands = 24;
        hundreds = count%1000/100;
        tens = count%1000%100/10 ;
        units = count%1000%100%10;}

        else if(count<100 && count>9)
        {
        thousands=24;
        hundreds=24;
        tens = count%1000%100/10 ;
        units = count%1000%100%10;}
        else if(count<10)
        {
        thousands=24;
        hundreds=24;
        tens=24;
        units = count%1000%100%10;
        }
        else{
        thousands = count/1000;
        hundreds = count%1000/100;
        tens = count%1000%100/10 ;
        units = count%1000%100%10;}
        return thousands,hundreds,tens,units;
        }
void main()
{
        int countnum,time;
while(1){
{  
                for (countnum=999; countnum >= 0; countnum-- )
                        {
                       
                                if(countnum<=995)
                                        {
                                                thingy(countnum);
                                                P2=1;
                                                P3=decode(thousands);
                                                delay3();
                                                P3 = 0xff;
                                                delay2();
 

                                                P2=2;
                                            P3=decode(hundreds);
                                                delay4();
                                                P3 = 0xff;
                                                delay21();
 
 
                                                P2=4;
                                                P3=decode(tens);
                                                delay5();
                                                P3 = 0xff;
                                                delay22();
 
 
                                                P2=8;
                                                P3=decode(units);
                                                delay5();
                                                P3 = 0xff;
                                                delay();
 
                                        }          
                                       
                                        else{
                        thingy(countnum);
                       
                                for(time=0;time<82;time++)
                        {

                        P2 = 0x01;
                        P3 = decode(thousands);
                        delay2()        ;
                        P3 = 0xff;
                        delay2();
 
                        P2 = 0x02;
                        P3 = decode(hundreds);
                        delay2();
                        P3 = 0xff;
                        delay2();
 
                        P2 = 0x04;
                        P3 = decode(tens);
                        delay2();
                        P3 = 0xff;
                        delay2();
 
                        P2 = 0x08;
                        P3 = decode(units);
                        delay2();
                        P3 = 0xff;
                        delay2();

                        }}}}
 }
   }
 


pls help....
am having troubles uploadin d simulation..bt will do dat as soon as i can......1 more fin how can i attach a file in dis forum..

[ Edited Sat Jul 18 2009, 08:58AM ]

in Christ and with Christ for ever...
Back to top

tweety bird
Fri Jul 03 2009, 11:08AM
 User Offline
Registered Member #7329
Joined: Sat Apr 19 2008, 08:49PM

Posts: 70
Thanked 8 times in 7 posts
u gotta be kiddin me... :mad
such a big code for such a small problem...!!
follow ari.mir10v suggestions..
n try make da code small.. !!! u using so many delay routines, just use 1 ...
Back to top

dgkadesewa
Sat Jul 04 2009, 03:30AM
 User Offline
Registered Member #19400
Joined: Tue Jun 16 2009, 09:38AM

Posts: 28
Thanked 1 time in 1 posts
au wld i do dat?.....n i strted out wiv one delay bt i still had d same problems so i decided to av varyind routines and all...bt all i nid right now is the way forwad...help..
au wld i get to ari.mir10v suggestions....gogled it n didnt find anyfing.....

in Christ and with Christ for ever...
Back to top

Ajay Bhargav
Mon Jul 06 2009, 02:28AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 7542
Thanked 1330 times in 1254 posts
to attach a file, zip the file and use the "POST REPLY" button on the top right or bottom right corner of forum.

or use the preview buttom of quick reply form.

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top

dgkadesewa
Mon Jul 06 2009, 04:11AM
 User Offline
Registered Member #19400
Joined: Tue Jun 16 2009, 09:38AM

Posts: 28
Thanked 1 time in 1 posts
uhm..ajay..au abt an answer to my question concerning the 4 7segment display...thank you..

in Christ and with Christ for ever...
Back to top

afilash
Fri Jul 17 2009, 02:58PM

 User Offline
Registered Member #20315
Joined: Tue Jul 14 2009, 07:52AM

Posts: 21
Thanked 2 times in 2 posts
adesewa,
here is the pseudo code, if you haven't got the answer yet :-)

// this will blink the display 10 times if count is less than 50

initialize_timerx for say 50ms
let var_b = 9999
let var_a = 20
blink = 0


here:
go to sleep -- idle mode
is var_b == 0( put blink as 0 ; var_b as 9999)
loop here


timerx_interrupt:
{
is var_b < 50 ?( compliment blink)

is blink == 0( display var_b else switch off display )

dec var_a

is var_a == 0? ( dec var_b and put var_a = 20 again )

}

[ Edited Fri Jul 17 2009, 03:00PM ]
Back to top

Go to page       >>   

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems