+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2012
    Posts
    3

    Default programming problem in 7segment display

    programming problem in 7segment display

    hi every one..
    i'm facing some problem in my projects. i worked it on proteus and i have attached some snaps shot of my project. i'm reading analog i/p from RA2 and display it on 4 7-segments devices. i used 74ls78 bcd to 7 segment decoder and 74ls138 decoder. i've copied my source code too with this. the fig1 shows the intial setup and fig2 shows the during execution of the project. i think the problem with the code it self.. when i simulate in proteus only one device is active and its always shows zero (0) irrespective of analog input. i want to display the result on 7 segment so please go through the code and let me know if is there any changes have to make in this.
    code:

    #include<16f877.h>
    unsigned int cnt, brk;
    char led [3];
    unsigned int rem;
    void converter (unsigned int z);
    void scanled (void);
    void main()
    {
    OPTION_REG=0x80;
    PORTA=0;
    TRISA=255;
    PORTD=0;
    TRISD=0;
    while(1)
    {
    cnt=ADC_Read(2);
    cnt=cnt*5;
    converter (cnt);
    scanled ();
    }
    }
    void converter(unsigned int z)
    {
    led[0]=z/1000;
    rem=z%1000;
    led[1]=rem/100;
    rem=rem%100;
    led[2]=rem/10;
    led[3]=rem%10;
    }
    void scanled (void)
    {
    unsigned char i;
    for (i=0;i<4;i++)
    {
    portd=i;portd=led[i];delay_ms(10);
    }
    }
    Attached Images Attached Images   

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    1,798

    Default Re: programming problem in 7segment display

    That looks like C, this is a PIC Basic forum.

    Robert

  3. #3
    Join Date
    Apr 2012
    Posts
    3

    Default Re: programming problem in 7segment display

    yes its a pic16f877 only and the code is in embedded c.. then where should i post it..

  4. #4
    Join Date
    Apr 2012
    Posts
    3

    Default programming problem in 7segment display

    hi every one..
    i'm facing some problem in my projects. i worked it on proteus and i have attached some snaps shot of my project. i'm reading analog i/p from RA2 and display it on 4 7-segments devices. i used 74ls78 bcd to 7 segment decoder and 74ls138 decoder. i've copied my source code too with this. the fig1 shows the intial setup and fig2 shows the during execution of the project.fig3 shows the message what i'm getting when i simulate it in protues.. when i simulate in proteus only one device is active and its always shows zero (0) irrespective of analog input. i want to display the result on 7 segment so please go through the code and let me know if is there any changes have to make in this.
    code:

    #include<16f877.h>
    unsigned int cnt, brk;
    char led [3];
    unsigned int rem;
    void converter (unsigned int z);
    void scanled (void);
    void main()
    {
    OPTION_REG=0x80;
    PORTA=0;
    TRISA=255;
    PORTD=0;
    TRISD=0;
    while(1)
    {
    cnt=ADC_Read(2);
    cnt=cnt*5;
    converter (cnt);
    scanled ();
    }
    }
    void converter(unsigned int z)
    {
    led[0]=z/1000;
    rem=z%1000;
    led[1]=rem/100;
    rem=rem%100;
    led[2]=rem/10;
    led[3]=rem%10;
    }
    void scanled (void)
    {
    unsigned char i;
    for (i=0;i<4;i++)
    {
    portd=i;portd=led[i];delay_ms(10);
    }
    }
    Attached Images Attached Images    

  5. #5
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,527

    Default Re: programming problem in 7segment display

    Quote Originally Posted by muttusarve View Post
    yes its a pic16f877 only and the code is in embedded c.. then where should i post it..
    How about a C compiler forum, like http://www.microchip.com/forums/

    But we could tell you why it won't work on our basic compiler


    Hi, we are pleased to see that you are using our forum.

    We'd like you to become a member of our community. Membership is FREE, please REGISTER and view our forums without these annoying reminders!

    Once registered you may post on the forums, download from the file areas and use the WIKI without interruption.




    http://www.scalerobotics.com

  6. #6
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    229

    Default Re: programming problem in 7segment display

    When it comes to 7-segment displays there are 2 types, "common anode" and "common cathode" both require a different way of driving them. One suggestion is dump the 74ls78 bcd to 7 segment decoder and 74ls138 decoder and go to a MAX7219 and an LTC-4727JR. The MAX7219 communicates with 3 wires. The LTC-4727JR is a very flexable display.

    Best, Ed

Members who have read this thread : 5

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts