seven segment display

Discussion in 'The Projects Forum' started by electronicslover, Apr 23, 2010.

  1. electronicslover

    Thread Starter New Member

    Mar 5, 2010
    28
    1
    I am working on a project based on embedded systems "password controlled room light controller and visitor counter". it's not working as yet n i am reqd to submit it before 30th april..after trying many things..i am finally taking help from this forum.

    i have used 4 seven segments (CA) in which i have interconnected all the respective pins of seven segments(a to dp) to each other except both the common pins.
    also i have finally connected these pins to P0 of at89s52 through a 10k pull up resistor array and eight 330 ohms resistor..one each.

    i have left one common pin unconnected and the other common pin..i have interfaced with microcontroller using pnp transistor and 1k resistor each .
    i jst wanted to ask whether this way of interfacing 7segments with at89s52 is correct or not??
    plzz do reply...itz a humble request!!!
     
  2. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    Do you have a schematic you can show us? It is hard to imagine what your saying. And we could draw what your saying, but It may not be what you have.

    If you are not using anything for multiplexing the rest of the 7segs, you are just showing the same on all four.

    From what your saying, it doesn't sound right. Post a schematic to be sure.
     
  3. electronicslover

    Thread Starter New Member

    Mar 5, 2010
    28
    1
    is this clear enough???
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Maybe 1K is too high a value to let the transistor saturate.
     
  5. electronicslover

    Thread Starter New Member

    Mar 5, 2010
    28
    1
    which value shd i choose then??
    n wt abt the rest of the circuit??? is it correct??
     
  6. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    Yes, it can work. You have to have the pins go high for the segments you want lit, then hit the cathode of the digit you want it on. and do that very fast.

    So, yes, it can work.. watch the transistors resistor value.
     
    electronicslover likes this.
  7. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    300 ohms should be better - max current from IO pin would then be 5/300=0.016 = 16mA which should be safe. Hopefully that should be enough to saturate the transistors.
     
    electronicslover likes this.
  8. electronicslover

    Thread Starter New Member

    Mar 5, 2010
    28
    1
    thank you so much...i have 330 ohms resistor....i will try with that
     
  9. electronicslover

    Thread Starter New Member

    Mar 5, 2010
    28
    1
    sorry for troubling again...but the circuit is still not working...wt else can i do??
    the circuit works if i provide the 5 volts manually but it doesn't work with uc... :(
     
  10. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    Are you SURE the pin on the uC is at 5v(high)? And is it steady or pulsing?
     
  11. electronicslover

    Thread Starter New Member

    Mar 5, 2010
    28
    1
    for transsitor to be in saturation, the pin should be at low and for the 7 seg to display something...the corresponding pin on the uc should be low again..this thing i have ensured through coding...should i attach the code of display portion here???
     
  12. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    Sure, attach your code.. But If you attach 5v to the circuit and it works, you have 5v there. A low pin will not be 5v.

    Are you SURE if you are using PNP or NPN transistors?

    And when attaching code, be sure to use the CODE tags. In 'Go Advanced' editor, the # button in the top menu will give you the CODE tags.
     
  13. electronicslover

    Thread Starter New Member

    Mar 5, 2010
    28
    1
    well...on DSO...the output came out to be pulsing dc..not steady one...varying between 4.2 to 5.7 volts...
     
  14. electronicslover

    Thread Starter New Member

    Mar 5, 2010
    28
    1
    i have checked the sensor portion and it's workinng fine...so am attaching the rest of the circuit and the entire code...
     
  15. electronicslover

    Thread Starter New Member

    Mar 5, 2010
    28
    1
    i think there is some sort of misunderstanding here....providing 5 volt to the circuit...by this i meant providing supply to the 7 seg portion along with transsitors without using the microcontroller..
     
  16. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    Ok here is your code so others don't have to download it:

    Code ( (Unknown Language)):
    1.                                                      ; hardware declaration
    2.  
    3.  row1     equ p2.6
    4.  row2     equ p2.5
    5.  row3     equ p2.4
    6.  row4     equ p2.3
    7.  col1     equ p2.2
    8.  col2     equ p2.1
    9.  col3     equ p2.1
    10.  
    11.  segport  equ p0
    12.  unitcom  equ p1.0
    13.  tenscom  equ p1.1
    14.  hundcom  equ p1.2
    15.  thouscom equ p1.3
    16.  
    17.  led        equ p1.4
    18.  buzzer     equ p1.5
    19.  
    20.                                                          ; ram declaration
    21.  
    22.  keyno    equ 30h
    23.  unit     equ 31h
    24.  tens     equ 32h
    25.  hund     equ 33h
    26.  thous    equ 34h
    27.  count    equ 35h
    28.        
    29.                                                              ; bit declaration
    30.  
    31.  flag bit #00h
    32.  entryflag bit #01h
    33.  passflag  bit #03h
    34.  intflag   bit #02h
    35.                                                          
    36.                                                           ; constant declaration
    37.  
    38.  stackval  equ 70h
    39.  
    40.                                                           ; start of main program
    41.  
    42.  org 0000h
    43.  ajmp poweron  
    44.  
    45.  org 0003h                                                 ; external interrupt 0
    46.  acall int0isr
    47.  reti
    48.  
    49.  org 000bh                                                 ; t0
    50.  reti  
    51.  
    52.  org 0013h                                                 ; external interrupt 1
    53.  acall int1isr
    54.  reti  
    55.  
    56.  org 001bh                                                 ; t1
    57.  reti
    58.  
    59.  org 0023h                                                 ; serial interrupt
    60.  reti  
    61.  
    62.  org 002bh                                                 ; t2
    63.  reti
    64.  
    65.  org 0033h
    66.  
    67.  
    68.  poweron:
    69.         Mov sp, # stackval
    70.         mov p0, # 0ffh
    71.         mov p1, # 0ffh
    72.         mov p2, # 0ffh
    73.         mov p3, # 0ffh
    74.         mov ie, # 00h
    75.         mov ip, # 00h  
    76.  
    77.                                                               ; initialization or preparation
    78.  
    79.         mov keyno, # 0ffh
    80.         mov dptr, #codetable
    81.         mov unit,#00h
    82.         mov tens,#00h
    83.         mov hund,#00h
    84.         mov thous,#00h
    85.         mov count,#00h
    86.         clr passflag
    87.         clr intflag
    88.         clr entryflag
    89.         clr flag
    90.         setb led
    91.         setb buzzer
    92.  
    93.  mainloop:
    94.        
    95.     Back:
    96.         Jb passflag, next
    97.         acall keycheck
    98.         acall keyaction
    99.        
    100.     next:
    101.         Acall display
    102.         jnb intflag, back
    103.         mov a, count
    104.         mov b, #10h
    105.         div ab
    106.         mov unit, b  
    107.         mov b, #10h
    108.         div ab
    109.         mov tens, b  
    110.         mov b, #10h
    111.         div ab
    112.         mov hund, b
    113.         mov thous, #00h
    114.         mov a, count
    115.         acall display
    116.         cjne a, #00h, ledon
    117.         setb led
    118.         setb buzzer
    119.         sjmp mainloop
    120.  
    121.    ledon:
    122.         Clr led
    123.         sjmp mainloop
    124.  
    125.    int0isr:
    126.         Push a
    127.         push psw
    128.         setb intflag        
    129.         jb entryflag, label2        
    130.         setb entryflag
    131.         inc count
    132.         pop psw
    133.         pop a
    134.         reti
    135.  
    136.    label2:
    137.         Clr entryflag
    138.         pop psw
    139.         pop a
    140.         reti
    141.  
    142.  
    143.    int1isr:
    144.         Push a
    145.         push psw
    146.         setb intflag        
    147.         jb entryflag, label3        
    148.         setb entryflag
    149.         mov a,count
    150.         cjne a,#00h,decrement
    151.         pop psw
    152.         pop a
    153.         reti
    154.  
    155.    decrement:
    156.         Dec count
    157.         pop psw
    158.         pop a
    159.         reti
    160.    
    161.    label3:
    162.         Clr entryflag
    163.         pop psw
    164.         pop a
    165.         reti
    166.  
    167.    keycheck:
    168.         Setb col1
    169.         setb col2
    170.         setb col3
    171.  
    172.         clr col1
    173.         jnb row1,key1
    174.         jnb row2,key4
    175.         jnb row3,key7
    176.         setb col1
    177.                
    178.         clr col2
    179.         jnb row1,key2
    180.         jnb row2,key5
    181.         jnb row3,key8
    182.         jnb row4,keyb
    183.         setb col2
    184.        
    185.         clr col3
    186.         jnb row1,key3
    187.         jnb row2,key6
    188.         jnb row3,key9
    189.         jnb row4,keyc
    190.         setb col3
    191.            
    192.         mov keyno,#0ffh
    193.         clr passflag
    194.         clr entryflag
    195.         clr flag
    196.         ret
    197.  
    198.      
    199.     key1:
    200.         Mov keyno,#01h
    201.         ret
    202.    
    203.     key2:
    204.         Mov keyno,#02h
    205.         ret
    206.    
    207.     key3:
    208.         Mov keyno,#03h
    209.         ret    
    210.    
    211.     key4:
    212.         Mov keyno,#04h
    213.         ret
    214.  
    215.     key5:
    216.         Mov keyno,#05h
    217.         ret
    218.  
    219.     key6:
    220.         Mov keyno,#06h
    221.         ret
    222.  
    223.     key7:
    224.         Mov keyno,#07h
    225.         ret
    226.  
    227.     key8:
    228.         Mov keyno,#08h
    229.         ret
    230.  
    231.     key9:
    232.         Mov keyno,#09h
    233.         ret
    234.  
    235.     keyb:
    236.         Mov keyno,#00h
    237.         ret
    238.  
    239.     keyc:
    240.         Mov keyno,#0ch
    241.         acall keypress
    242.         ret
    243.  
    244.     keypress:
    245.         Acall password
    246.         ret
    247.  
    248.    keyaction:
    249.         Mov a,keyno
    250.         cjne a,#0ffh,label
    251.         ret
    252.  
    253.    label:
    254.         Jb flag,label1
    255.         setb flag
    256.         mov thous,hund
    257.         mov hund,tens
    258.         mov tens,unit
    259.         mov unit,keyno
    260.        
    261. label1: Ret
    262.      
    263.    password:
    264.         Jb flag,go
    265.         setb flag
    266.         mov a,unit
    267.         cjne a,#01h,fail
    268.         mov a,tens
    269.         cjne a,#06h,fail
    270.         mov a,hund
    271.         cjne a,#00h,fail
    272.         mov a,thous
    273.         cjne a,#09h,fail
    274.         acall pass
    275.    go:  Ret
    276.  
    277.    fail:        
    278.         Mov unit,#0dh
    279.         mov tens,#01h
    280.         mov hund,#0bh
    281.         mov thous,#0ch
    282.         clr buzzer
    283.         acall sdelay
    284.         acall sdelay
    285.         acall sdelay
    286.         setb buzzer
    287.         ret
    288.  
    289.    pass:
    290.         Mov unit,#05h
    291.         mov tens,#05h
    292.         mov hund,#0bh
    293.         mov thous,#0ah
    294.  
    295.         mov ie,#85h
    296.         setb it0
    297.         setb it1
    298.         setb passflag
    299.         ret
    300.  
    301.    display:
    302.          Mov a,unit
    303.          movc a,@a+dptr
    304.          mov segport,a
    305.  
    306.          clr unitcom
    307.          acall sdelay
    308.          setb unitcom
    309.          mov a,tens
    310.          movc a,@a+dptr
    311.          mov segport,a
    312.  
    313.          clr tenscom
    314.          acall sdelay
    315.          setb tenscom
    316.          mov a,hund
    317.          movc a,@a+dptr
    318.          mov segport,a
    319.  
    320.          clr hundcom
    321.          acall sdelay
    322.          setb hundcom
    323.          mov a,thous
    324.          movc a,@a+dptr
    325.          mov segport,a
    326.  
    327.          clr thouscom
    328.          acall sdelay
    329.          setb thouscom
    330.  
    331.          ret
    332.  
    333.  
    334.    sdelay:
    335.         Mov r5,#05h
    336.  lp1:   Mov r6,#200h
    337.  lp2:   Mov r7,#250h
    338.  lp3:   Djnz r7,lp3
    339.         djnz r6,lp2
    340.         djnz r5,lp1
    341.         ret
    342.  
    343.    codetable:
    344.         Db 0c0h; 0
    345.         db 0f9h; 1
    346.         db 0a4h; 2
    347.         db 0b0h; 3
    348.         db 99h ; 4
    349.         db 92h ; 5
    350.         db 82h ; 6
    351.         db 0f8h ; 7
    352.         db 80h ; 8
    353.         db 90h ; 9
    354.         db 8ch ; p
    355.         db 88h ; a
    356.         db 8ch ; f
    357.         db 0c7h ; l
    358.  end
    As for the pulsing, that should be fine, if its fast enough.

    If you apply 5v in place of the uC pin, Still using the resistor to the transistor, it lights?
     
  17. electronicslover

    Thread Starter New Member

    Mar 5, 2010
    28
    1
    yes it does..that's what am trying to say..that my circuit is not working with the microcontroller but without uc it does... is there any problem with the code
    i expect the circuit to be correct because i tested each portion of circuit manually without the uc also..and it worked fine.....
     
  18. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    Are you still using the 1k resistor, or did you switch to the 330?

    Also, what transistors are you using?

    There may not be enough current available through the uC.

    And yes, the code seems correct.
     
  19. electronicslover

    Thread Starter New Member

    Mar 5, 2010
    28
    1
    well...not 5 volts but zero to the pin of uc... as is expected i guess for a CA 7 seg to light
     
  20. electronicslover

    Thread Starter New Member

    Mar 5, 2010
    28
    1
    well..the transsitor is getting saturated by using 1 k also..so m still using the same
     
Loading...