This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

code

Hi

Iam facing displays flickering and data over write problem since last 20 days.

Iam using delay but I am not able to salve it

Here iam using 74LS373(4) latches.

Iam sending the data through PORT 2 and enable the latches using PORT 3


Iam using ADC804+89c51+74LS373(4 numbers) +7 seven segment displays (4 numbers)

Please check my code given below and give me a proper 'C' code for this problem.

Thank you

Regards

Naresh

This code i used in my project


sbit c1=P3^0;
sbit c2=P3^1;
sbit c3=P3^2;
Sbit C4=P4^3;


s1,s2,s3,s4=data;

while(1)
{

P2=s1;
c1=1; /* Latch enable*/
Delay(100);
c1=0; /* Latch disable*/

P2=s2;
c2=1;
Delay(100);
c2=0;

P2=s3;
c3=1;
Delay(100);
c3=0;

P2=s3;
c3=1;
Delay(100);
c3=0;


}


void Delay(unsigned int time)

{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}

  • first, who on earth can know what your delay is and next time it will be different. NEVER write a delay routine in ANYTHING BUT assembler.

    second, have you heard about comments? who on earth is supposed to figure out what
    sbit c2=P3^1;
    s1,s2,s3,s4=data;
    c2=1;
    does? It is an insult to people who may be willing to help you to post uncommented code.

    third, naah, I'll wait till you post commented code to help you.

    Erik

  • 1) Disable the latch (c1=0)
    2) Write your data on the port
    2a) you may need to delay but possibly not
    3) Take latch enable low to latch it(c1=1)

  • /* Program for display analog voltage On 7 segment display */

    #include<reg51.h>
    #include <stdio.h>
    void Delay(unsigned int);
    sbit R=P1^0; /* ADC control bits*/
    sbit W=P1^1;
    sbit I=P1^2;


    sbit c1=P3^0; /* Latch enable bit for 1 seven segment display*/
    sbit c2=P3^1; /* Latch enable bit for 2 seven segment display */
    sbit c3=P3^0; /* Latch enable bit for 3 seven segment display */
    sbit c4=P3^1; /* Latch enable bit for 4seven segment display */




    void main(void)
    {
    char convert[10] ={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; /* Display elements*/



    unsigned char value,value1;
    unsigned char a,b,c,s1,s2,s3,s4,a1,b1,d1;
    long int f,e;
    value1=0;
    b=0xc4;
    c=0x64;
    P0=0xFF; /* P0 is Input Port */
    I=0; /* ADC control elements initialization*/
    R=1;
    W=1;
    Value=0;

    While (1)
    {
    W=0;
    W=1; /* ADC convertion starts here*/
    While(I==1);
    R=0;
    Value=P0; /*Get the hex number corresponding analog input voltage */


    a=value; /* conversion of Hex number to voltage Ex:0XFF=5.00V */
    e=a*b;
    f=e/c;
    s1=f/10; /* Hex to decimal conversion * /
    s2=f%10;
    s3=s1/10;
    s4=s1%10;
    a1= convert[s3]; /* seven segment display convertion */
    d1= convert[s4];
    b1= convert[s2];

    if(value=value1)
    {

    P2=s1;
    c1=1; /* Latch enable*/
    Delay(100);
    c1=0; /* Latch disable*/

    P2=s2;
    c2=1; /* Latch enable*/
    Delay(100);
    c2=0; /* Latch disable*/

    P2=s3;
    c3=1; /* Latch enable*/
    Delay(100);
    c3=0; /* Latch disable*/

    P2=s3;
    c3=1; /* Latch enable*/
    Delay(100);
    c3=0; /* Latch disable*/

    }

    Value1=value;
    R=1;

    }
    /* Iam using 11.052MHZ Crystal */
    void Delay(unsigned int time)

    {
    unsigned int i,j;
    for(i=0;i<time;i++)
    for(j=0;j<1275;j++);
    }

  • I Try Again,

    Where you have:

    P2=s1;
    c1=1; /* Latch enable*/
    Delay(100);
    c1=0; /* Latch disable*/
    

    Repalce with:

    c1=0;
    P2=s1;
    c1=1;
    

    Same for other 3 ports.

    By the way, the line if (value=value1) does not do what you want it to.

  • By the way, the line

    if (value=value1)
    does not do what you want it to.

    We've all been there: confuse the Equation == with the Assignment = parameter...

  • Thanks for reply

    Weather I want use any Delay in between c1, P2, c1. How much Delay I want use.

    Here i used

    if (value==value1)

    Because the same repeated value is not enter in to the latch. It is all ready in the latch


    Regards

    Naresh

  • Weather I want use any Delay in between c1, P2, c1. How much Delay I want use.

    I don't know for certain, but try it without a delay. You might be suprised.

    Here i used if (value==value1)

    No, you used

    if (value=value1)

  • flicker (to most senitive eyes) occur whenever your loop takes more than 8mS to execute.

    Erik

  • flicker (to most senitive eyes) occur whenever your loop takes more than 8mS to execute.

    If I understand correctly, the way Naresh is trying to do it means it shouldn't flicker at all becase he is latching the data bytes seperately for each of the four 7 seg. displays.

  • a1= convert[s3]; /* seven segment display convertion */
    ....
    P2=s3;
    the above does not make any sense, why create 'a1' when 's3' is used?

    re flicker: it will of course 'flicker' when ONE a/d read is displayed (no averaging)

    Erik

  • Eric,

    True, it makes little sense, I'm still trying to drop hints about the

    if (value=value1)
    line. I guess they need
    if (value!=value1)
    but didn't want to spoon feed. Then again they have spent 20 days so far on it.

  • I can not disclose what I am "getting at". This is one of the cases where only indirect questions will give result. If the "indirect question" should give the desred result, you will see.

    Do not mistake the "indirect question" for being invalid, it is very valid, it seems that there is no legible display

    Erik

  • Hi

    In my program I used "if (value! = Value1)".

    That is my printing mistake.

    Yesterday I fallowed u r suggestion it is working well.

    To day I have use in the main program.

    Now presently I replaced 74LS373 with HEF4511BP (BCD to 7-segment

    Latch/decoder/driver).

    All its operations are in nano seconds (ns).

    My clock speed is 1micro second.

    Above things can affect my program.

    Regards

    Naresh

  • u r suggestion

    I see no suggestion that you use microresistors

    Erik

  • u r suggestion

    I see no suggestion that you use microresistors

    Erik