seven segment output problem

Discussion in 'Embedded Systems and Microcontrollers' started by bobparihar, Nov 19, 2014.

  1. bobparihar

    Thread Starter Member

    Jul 31, 2014
    93
    0
    I did seven segment interfacing o simulation and on developing kit of 8051 and i was successful( when i did connect the seven segment only to the MCU in Proteus )
    but now when i did implement it on my own general purpose PCB board with the circuit that is required for the hardware then i am getting error in output..

    with the same circuit proteus also giving error on output

    the circuit i am following is in the attached images

    my code is as follows

    Code:

    #include<reg51.h>
    sbit a=P1^0;
    int ar[]= {0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10}; // common anode segment
    unsigned int i,j;
    void main()
    {


    for(i=0;i<10;i++)
    {
    a=1; //to the common pin of segment
    P2=ar; //
    for(j=0;j<50000;j++); // just for some delay

    }
    }
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,342
    1,024
    A couple of thoughts:

    P2=ar; assigns the address of the array (with a compiler warning probably) to the port. You want to index the array like P2=ar[1];
    I would use a PNP with active low on the base to drive the anode. The port pin may not be able to source the current required to drive the display at a high enough voltage to satisfy Vbe+ Vled + Vol to turn on the transistor.

    Good luck.
     
    ErnieM likes this.
  3. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,387
    497
    And the error is?
     
  4. bobparihar

    Thread Starter Member

    Jul 31, 2014
    93
    0
    sir, i am using a common anode seven segment display

    and iam already using ar instead of ar in my code.. it just misplaced by editor here

    can i use a PNP transistor for a common anode configuration?
    if so...then how the common pin of seven segment will get positive voltage(high)?

    actually my real purpose is to multiplex two seven segment and then use it for display.. but first i want to test that does my circuit is correct for one seven segment.. that is why i am trying.. once i succeed then i will do multiplexing
     
    Last edited: Nov 20, 2014
  5. bobparihar

    Thread Starter Member

    Jul 31, 2014
    93
    0
    seven segment does not shows any output only a single seven segment glows all time
     
  6. JohnInTX

    Moderator

    Jun 26, 2012
    2,342
    1,024
    Like this:
    Change the NPN to a PNP transistor.
    Interchange the collector and emiter i.e. connect the emitter to +5 and the collector to the common anode of the display.
    Add a resistor between base and emmitter (68K-200K - not critical) to ensure that the transistor turns off.
    Be sure the 10K base resistor will sink enough base current to turn it on fully.
    Drive the digit select (a1) LOW to turn on the transistor, drive it HIGH to turn the transistor off.

    To turn on a digit pattern, write the complement of the desired pattern to the segments (0 = segment ON) and write a 0 to P1.0
    Something like this - changes in CAPS:
    Code (Text):
    1. #include<reg51.h>
    2. sbit a=P1^0;
    3. unsigned char ar[]= {0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10}; // common anode segment CHANGED TO UNSIGNED CHAR
    4. unsigned char i; CHANGED TO UNSIGNED CHAR
    5. unsigned int j;
    6.  
    7. void main(){
    8. while(1){
    9.    for(i=0;i<10;i++){
    10.        a=1; //to the common pin of segment TURN DISPLAY OFF WHILE CHANGING SEGMENTS
    11.        P2=ar[i]; // FETCH PATTERN USING INDEX i
    12.        a = 0; //TURN DISPLAY ON
    13.        for(j=0;j<50000;j++); // just for some delay
    14.    }//for i
    15. }//while
    16. }//main
    EDIT: presumably you have the rest of the uC hooked up properly - EA/ pulled up, etc. You can verify that the processor is running by inspecting ALE. Unless explicitly disabled in the code, it will be pulsing if the processor is running.
     
    Last edited: Nov 20, 2014
    bobparihar likes this.
  7. bobparihar

    Thread Starter Member

    Jul 31, 2014
    93
    0

    thanks a ton for help, sir..
    the circuit i am following is shown in attached picture
    u can check it and if there is something wrong please inform me..
    i did connect 31 pin(EA) to 40 pin(VCC) by wire

    how can i verify that the processor is running by inspecting ALE??
     
    Last edited: Nov 21, 2014
  8. JohnInTX

    Moderator

    Jun 26, 2012
    2,342
    1,024
    If you have an oscilloscope or logic probe its easy. If you have a digital multimeter you can sometimes see by measuring the voltage on the pin. If ALE is running, the reading will jump around a bit. You can also check the oscillator this way.

    The segment pattern you show looks like an inverted '0' but that does not correspond to the value indicated on the output port?
    The circuit looks OK but its hard to tell from the picture if the correct pins are used on the display.

    Did you update the code as suggested?
     
Loading...