seven segment display

Thread Starter

electronicslover

Joined Mar 5, 2010
28
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!!!
 

retched

Joined Dec 5, 2009
5,207
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.
 

retched

Joined Dec 5, 2009
5,207
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.
 

Markd77

Joined Sep 7, 2009
2,806
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.
 

Thread Starter

electronicslover

Joined Mar 5, 2010
28
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... :(
 

Thread Starter

electronicslover

Joined Mar 5, 2010
28
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???
 

retched

Joined Dec 5, 2009
5,207
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.
 

Thread Starter

electronicslover

Joined Mar 5, 2010
28
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..
 

retched

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

Rich (BB code):
                                                     ; hardware declaration

 row1     equ p2.6
 row2     equ p2.5 
 row3     equ p2.4 
 row4     equ p2.3
 col1     equ p2.2
 col2     equ p2.1 
 col3     equ p2.1 

 segport  equ p0
 unitcom  equ p1.0
 tenscom  equ p1.1
 hundcom  equ p1.2
 thouscom equ p1.3 

 led        equ p1.4
 buzzer     equ p1.5 
  
                                                         ; ram declaration 

 keyno    equ 30h
 unit     equ 31h
 tens     equ 32h
 hund     equ 33h
 thous    equ 34h
 count    equ 35h 
        
                                                             ; bit declaration 

 flag bit #00h
 entryflag bit #01h
 passflag  bit #03h
 intflag   bit #02h 
                                                          
                                                          ; constant declaration
 
 stackval  equ 70h 

                                                          ; start of main program
 
 org 0000h
 ajmp poweron  
 
 org 0003h                                                 ; external interrupt 0
 acall int0isr
 reti 
 
 org 000bh                                                 ; t0
 reti  
 
 org 0013h                                                 ; external interrupt 1
 acall int1isr
 reti  
 
 org 001bh                                                 ; t1
 reti 
 
 org 0023h                                                 ; serial interrupt
 reti  

 org 002bh                                                 ; t2
 reti 
 
 org 0033h
 

 poweron: 
        Mov sp, # stackval
        mov p0, # 0ffh
        mov p1, # 0ffh
        mov p2, # 0ffh 
        mov p3, # 0ffh
        mov ie, # 00h
        mov ip, # 00h  
 
                                                              ; initialization or preparation
 
        mov keyno, # 0ffh
        mov dptr, #codetable
        mov unit,#00h 
        mov tens,#00h 
        mov hund,#00h 
        mov thous,#00h
        mov count,#00h
        clr passflag
        clr intflag
        clr entryflag
        clr flag
        setb led
        setb buzzer 
 
 mainloop:
        
    Back:
        Jb passflag, next 
        acall keycheck
        acall keyaction
        
    next: 
        Acall display 
        jnb intflag, back
        mov a, count
        mov b, #10h
        div ab
        mov unit, b  
        mov b, #10h
        div ab
        mov tens, b  
        mov b, #10h
        div ab
        mov hund, b 
        mov thous, #00h
        mov a, count
        acall display
        cjne a, #00h, ledon
        setb led
        setb buzzer
        sjmp mainloop 

   ledon:
        Clr led
        sjmp mainloop 
 
   int0isr:
        Push a
        push psw
        setb intflag         
        jb entryflag, label2        
        setb entryflag 
        inc count
        pop psw
        pop a
        reti 
 
   label2:
        Clr entryflag 
        pop psw
        pop a
        reti 
  
  
   int1isr:
        Push a
        push psw 
        setb intflag         
        jb entryflag, label3         
        setb entryflag
        mov a,count
        cjne a,#00h,decrement
        pop psw
        pop a
        reti 
 
   decrement: 
        Dec count
        pop psw 
        pop a
        reti 
   
   label3:
        Clr entryflag 
        pop psw 
        pop a 
        reti 
 
   keycheck:
        Setb col1
        setb col2
        setb col3
 
        clr col1
        jnb row1,key1
        jnb row2,key4
        jnb row3,key7
        setb col1
                
        clr col2
        jnb row1,key2
        jnb row2,key5
        jnb row3,key8
        jnb row4,keyb
        setb col2
        
        clr col3
        jnb row1,key3
        jnb row2,key6
        jnb row3,key9
        jnb row4,keyc
        setb col3
            
        mov keyno,#0ffh
        clr passflag
        clr entryflag
        clr flag
        ret
 
     
    key1: 
        Mov keyno,#01h
        ret
    
    key2: 
        Mov keyno,#02h
        ret
    
    key3: 
        Mov keyno,#03h
        ret    
   
    key4: 
        Mov keyno,#04h
        ret

    key5: 
        Mov keyno,#05h
        ret

    key6: 
        Mov keyno,#06h
        ret

    key7:
        Mov keyno,#07h
        ret

    key8: 
        Mov keyno,#08h
        ret

    key9: 
        Mov keyno,#09h
        ret

    keyb: 
        Mov keyno,#00h
        ret

    keyc: 
        Mov keyno,#0ch
        acall keypress
        ret

    keypress:
        Acall password
        ret

   keyaction:
        Mov a,keyno
        cjne a,#0ffh,label
        ret
 
   label: 
        Jb flag,label1
        setb flag
        mov thous,hund
        mov hund,tens
        mov tens,unit
        mov unit,keyno
        
label1: Ret
     
   password: 
        Jb flag,go
        setb flag
        mov a,unit
        cjne a,#01h,fail
        mov a,tens
        cjne a,#06h,fail
        mov a,hund
        cjne a,#00h,fail
        mov a,thous
        cjne a,#09h,fail
        acall pass
   go:  Ret
 
   fail:        
        Mov unit,#0dh
        mov tens,#01h
        mov hund,#0bh
        mov thous,#0ch
        clr buzzer
        acall sdelay
        acall sdelay
        acall sdelay
        setb buzzer
        ret 
 
   pass: 
        Mov unit,#05h
        mov tens,#05h
        mov hund,#0bh
        mov thous,#0ah

        mov ie,#85h
        setb it0
        setb it1
        setb passflag
        ret
 
   display:
         Mov a,unit
         movc a,@a+dptr
         mov segport,a

         clr unitcom
         acall sdelay
         setb unitcom
         mov a,tens
         movc a,@a+dptr
         mov segport,a

         clr tenscom
         acall sdelay
         setb tenscom
         mov a,hund
         movc a,@a+dptr
         mov segport,a

         clr hundcom
         acall sdelay
         setb hundcom
         mov a,thous
         movc a,@a+dptr
         mov segport,a

         clr thouscom
         acall sdelay
         setb thouscom

         ret

 
   sdelay: 
        Mov r5,#05h
 lp1:   Mov r6,#200h
 lp2:   Mov r7,#250h
 lp3:   Djnz r7,lp3
        djnz r6,lp2
        djnz r5,lp1
        ret 
 
   codetable:
        Db 0c0h; 0
        db 0f9h; 1
        db 0a4h; 2
        db 0b0h; 3
        db 99h ; 4
        db 92h ; 5
        db 82h ; 6
        db 0f8h ; 7
        db 80h ; 8
        db 90h ; 9
        db 8ch ; p
        db 88h ; a
        db 8ch ; f
        db 0c7h ; l
 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?
 

Thread Starter

electronicslover

Joined Mar 5, 2010
28
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.....
 

retched

Joined Dec 5, 2009
5,207
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.
 
Top