7 segment problem

Discussion in 'Embedded Systems and Microcontrollers' started by muttu.sarve, Apr 10, 2012.

  1. muttu.sarve

    Thread Starter New Member

    Aug 5, 2011
    4
    0
    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:

    Code ( (Unknown Language)):
    1.  
    2. #include<16f877.h>
    3. unsigned int cnt, brk;
    4. char led [3];
    5. unsigned int rem;
    6. void converter (unsigned int z);
    7. void scanled (void);
    8. void main()
    9. {
    10.  OPTION_REG=0x80;
    11.  PORTA=0;
    12.  TRISA=255;
    13.  PORTD=0;
    14.  TRISD=0;
    15.  while(1)
    16.  {
    17.   cnt=ADC_Read(2);
    18.   cnt=cnt*5;
    19.   converter (cnt);
    20.   scanled ();
    21.   }
    22. }
    23. void converter(unsigned int z)
    24.      {
    25.       led[0]=z/1000;
    26.       rem=z%1000;
    27.       led[1]=rem/100;
    28.       rem=rem%100;
    29.       led[2]=rem/10;
    30.       led[3]=rem%10;
    31.       }
    32. void scanled (void)
    33.      {
    34.      unsigned char i;
    35.      for (i=0;i<4;i++)
    36.          {
    37.          portd=i;portd=led[i];delay_ms(10);
    38.          }
    39.      }
    40.  
    41. [/i]
     
    Last edited by a moderator: Apr 10, 2012
  2. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    could it be your portd assignment? should it be something like this instead?

    Code ( (Unknown Language)):
    1.  
    2.     portd = led[i] + (i<<4); delay_ms(10);
    3. [/i]
     
Loading...