8051, 7 segment, 74595 and LEDs

Thread Starter

engwas

Joined Jan 9, 2009
18
HI All
I trying to build a digital time and date clock using 89S52 micro-controller and DS1307 with 7 segments and LED's, I use 74595 to multiplexing the 7 segments and LED the problem is i have a blink on display as i use Proteus simulation and the LED that indicate the PM blinking all the time, my code is take 3.6ms to read the information from the DS1307 and goto loop to display the info i use 14 (7 segments) to show the time and date LED to indicate the PM the loop repeat 183 times to complete 1 seconds then read the info again and display
in loop every 7 segment take 0.42ms to display digit and go of for 5.88ms and repeat display every 6.3ms and the LED take a 0.42ms i use 74595 daisy-chain to multiplexing,
i need to know how i calculate the POV correctly and how to display LED with 7 segment (the time) for each
what is wrong with my code

Code:
sbit test=P1^6;
sbit Latch = P3^5;
sbit Data = P3^6;
sbit Clock = P3^7;
sbit seconds = P2^2;
sbit SetKey = P3^2;
sbit UpKey = P3^3;
sbit DownKey = P3^4;
sbit OE =P2^0;
unsigned char i;
unsigned char pSetArray[]={0,13,4,Tuesday,4,10,14,1}; //sec,min,hour,day,date,month,year,PMorAM
unsigned char *pInfoArray=&pSetArray;
void select_display(int digit,select1,select2)
{unsigned char i,value;
Latch=0;
value=Seven_Segment_Selector[select2];
for(i=0;i<8;++i)
{Data=value&0x01;
Clock=0;
Clock=1;
value>>=1;}
value=Seven_Segment_Selector[select1];
for(i=0;i<8;++i)
{Data=value&0x01;
Clock=0;
Clock=1;
value>>=1;}
value=Seven_Segment_Digit[digit];
for(i=0;i<8;++i)
{Data=value&0x01;
Clock=0;
Clock=1;
value>>=1;}
Latch=1;
delay(1);
}     

void main()
    {    IT0 = 1;  
    EX0 = 1;  
          
    InitI2C();    // Initialize i2c pins                                           

    // Set initial time
    Set_DS1307_RTC_Info(pInfoArray);
    seconds=1;
    while(1)
    {OE=1;test=1;seconds=~seconds;
    EA = 1;
    pInfoArray=Get_DS1307_RTC_Info();
    test=0;OE=0;
    for(i=0;i<183;++i){
    select_display( pInfoArray[0]/10,0,8 );//Seconds higher nibble
    select_display( pInfoArray[0]%10,1,8 );//Seconds lower nibble
    select_display( pInfoArray[1]/10,2,8 );//min MSB
    select_display( pInfoArray[1]%10,3,8 );//min LSB
    if(pInfoArray[2]/10==0);else select_display( pInfoArray[2]/10,4,8 );
    select_display( pInfoArray[2]%10,5,8 );
    if(pInfoArray[4]/10==0);else select_display( pInfoArray[4]/10,6,8 );
    select_display( pInfoArray[4]%10,7,8 );
    if(pInfoArray[5]/10==0);else select_display( pInfoArray[5]/10,8,0 );
    select_display( pInfoArray[5]%10,8,1);
    select_display( pInfoArray[6]/10,8,2 );
    select_display( pInfoArray[6]%10,8,3 );
    select_display( 2,8,4 );
    select_display( 0,8,5 );
    if(pInfoArray[7]==1)select_display(0,8,6 );   
    }   
    }
Kindly need help
 

Papabravo

Joined Feb 24, 2006
21,228
You can't possibly expect us to infer the details of your design from a verbal description! For all I can determine your code is perfect and it is the hardware that is borked. How about posting a schematic diagram.

The time you leave each digit on seems a bit short to me. Each digit should be on for 20-30 milliseconds to take advantage of the persistence effect.
 
Last edited:

Thread Starter

engwas

Joined Jan 9, 2009
18
Dear Papabravo
Many thanks
How can i do this with 74595 multiplexing, Kindly help
the schematic diagram as

Clock.jpg
 
Last edited:

Papabravo

Joined Feb 24, 2006
21,228
Your mistake is now obvious to me. You cannot use an HC device to supply power to a seven segment display. If you read the datasheet you will see that an HC output can supply only a limited amount of current. This is typically 6 mA, which is far to small. If each segment requires 10-20 mA, displaying a '8' will take 80-160 mA. Traditionally a common anode display would be powered from a transistor switch that could source the required current. Using a decoder for the select lines is way more efficient and guarantees that only one will be on at a time which is what you want for a multiplexing scheme.

Making implied connections via net names (OE) almost tripped me up. Try to use something more explicit. When OE is disabled all the lines to the displays are floating is this what you intend?
 

Thread Starter

engwas

Joined Jan 9, 2009
18
thanks for reply
i see many circuits use HC to multiplexing i plan to use current sink or seek after i finish the code and everything go ok
i see circuit using 5 (74595) to drive 24 (7 segment ca) with 8 transistor via 4 wire connection with 8051 i see the top view of circuit not the all connection. so if i use transistor the led will not blink i mean the pm led
i use oe someone said the solution on it i try some code not work
i think the solution on POV time but i have no idea this what i wrote in code and hardware and hope to get answer from you
thanks

Dears
Any help

Dears
I attached my work, kindly see the PM LED it blinking and it should not (light on when PM time) and i notice a simple blink on 7 segment kindly any help

I put a 32 led and drive then with new code (same method with 74595 multiplexing daisy chain) the led not light ON it blink (it should ON all the led), I attached the code and circuit hope anyone give me what go wrong?
 

Attachments

Last edited by a moderator:

MrCarlos

Joined Jan 2, 2010
400
Hello engwas

I did a run of your design in Proteus ISIS.

It looks good, and yes, the PM LED flashes.
I think it's the speed of the PC.

But, if you have armed you with your design real components and has the same problem, I suggest you use another port on the AT89C52 to turn on or off the LED PM.
Of course, you'd have to modify the code of your program.

By the way: What compiler you use to get the HEX file ??
 

MrCarlos

Joined Jan 2, 2010
400
Hello engwas

Well, I do not know that compiler.
But the issue here is flashing LED PM.

We can say that all electronic circuits simulators make the same effect.
Something that should not blink, blinks.
Why the 7-segment displays do not flicker?. . . Probably the SoftWare (Proteus ISIS) has a higher priority for those 7-segment displays while for LED’s has lower priority.
Surely you did an experiment with simple 7-segment displays, and noticed some flickering.

The only reason I can find is this: the different components that make up a circuit have different priority to act or not to act in a particular circuit.

So: if you have armed the circuit with real components and the problem persists you will have to change the PM LED to a port of AT89C52 to turn it off or turn it on as needed.
 

absf

Joined Dec 29, 2010
1,968
I totally agree with MrCarlos. A simulator is a simulator. It will never replace real hardware.......unless you can afford a supercomputer running a version of proteus written for supercomputers.


Allen
 
Last edited:

dannyf

Joined Sep 13, 2015
2,197
You run the display routines in the main loop, together with the i2c routine which is very slow.

A better approach is to run the display routines in a timer isr and then the slow i2c routine in the main.
 
Top