1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Need the tail of 6 and 9

Discussion in 'Oshonsoft' started by manojsoorya, Aug 6, 2014.

  1. manojsoorya

    manojsoorya Member

    Joined:
    May 6, 2011
    Messages:
    35
    Likes:
    0
    Hi all

    I have a code for a digital Clock. I need the tail of 6 and 9. This is the code I have. But I dont know where to made the change to get the tail...
    Code (text):
    #include "p16f676.inc"

        __CONFIG _WDT_OFF & _XT_OSC & _CP_OFF & _MCLRE_OFF

    temp                EQU        0x20
    w_temp                EQU     0x21        ; variable used for context saving
    status_temp            EQU        0x22        ; variable used for context saving  

            ORG     0
            GOTO    Start

            ORG     0x004             ; interrupt vector location
            movwf   w_temp            ; save off current W register contents
            movf    STATUS,w          ; move status register into W register
            movwf    status_temp       ; save off contents of STATUS register

    ; isr code can go here or be located as a call subroutine elsewhere

            incf    ms,F
            movlw    .225
            xorwf    ms,w
            btfss    STATUS,Z
            goto    $+3
            clrf    ms
            incf    count,F
            bcf        INTCON,T0IF  

            movf    status_temp,w     ; retrieve copy of STATUS register
            movwf    STATUS            ; restore pre-isr STATUS register contents
            swapf   w_temp,f
            swapf   w_temp,w          ; restore pre-isr W register contents
            retfie                    ; return from interrupt

            cblock     0x23
            d1
            d2
            d3
            d4
            temp1
            digit1
            digit2
            digit3
            digit4
            digit5
            digit6
            tempA
            count
            secdigit1
            secdigit2
            c1
            c2
            c3
            ms
            second
            endc

    ;----------------------------------------------------------------------
    Initialize

            bcf        STATUS,RP0
            movlw    B'00000111'    ;to make RA0,RA1,RA2 ; test manoj B'00000111'
                                ;not comparator
            movwf    CMCON  
            clrf    PORTA
            bsf        STATUS,RP0
            movlw    B'00111000'
            movwf    TRISA  
            bcf        STATUS,RP0
            clrf    PORTC
            bsf        STATUS,RP0
            movlw    B'00000000'
            movwf    TRISC
           
            bcf        OPTION_REG,T0CS        ;configure the TMR0
            bcf        OPTION_REG,PSA
            bsf        OPTION_REG,0
            bsf        OPTION_REG,1
            bcf        OPTION_REG,2
            bsf        INTCON,T0IE
            bsf        INTCON,GIE
            bcf        STATUS,RP0            ;end      
            return
    ;-------------------------------------------------------------------
    increment_digits
            incf    secdigit1,f
            movlw    .10
            xorwf    secdigit1,w
            btfss    STATUS,Z
                return
            clrf    secdigit1
            incf    secdigit2,f
            movlw    .6
            xorwf    secdigit2,w
            btfss    STATUS,Z
                return
            clrf    secdigit2
    increment_min
            incf    digit1,f
            movlw    .10
            xorwf    digit1,w
            btfss    STATUS,Z
                return
            clrf    digit1
            incf    digit2,f
            movlw    .6
            xorwf    digit2,w
            btfss    STATUS,Z
                return
            clrf    digit2
    increment_hour
            incf    digit3,f
            movlw    .1
            xorwf    digit4,w
            btfsc    STATUS,Z
            goto    check_12hour
            movlw    .10
            xorwf    digit3,w
            btfss    STATUS,Z
                  return
            clrf    digit3
            incf    digit4,f
                  return
    check_12hour
            movlw    .3
            xorwf    digit3,w
            btfss    STATUS,Z
                return
            movlw    1h
            movwf    digit3
            clrf    digit4
            return
    ;---------------------------------------------------------------
    dec_digits
            movlw    0x00
            xorwf    digit1,w
            btfsc    STATUS,Z
            goto    $+3
            decf    digit1,f
            return

            movlw    0x00
            xorwf    digit2,w
            btfsc    STATUS,Z
            return
            decf    digit2,f
            movlw    0x09
            movwf    digit1
              return  
    ;------------------------------------------------------------          
    delay1ms
                movlw    3h
                movwf    d1              
                movlw    1h
                movwf    d2          
    loopd2        decfsz    d2,f
                goto    loopd2
                decfsz    d1,f
                goto    loopd2
                    return
    ;---------------------------------------------------------------
    Display_out

                movlw    B'00000100'
                andwf    PORTA,F
                movlw    B'00000000'
                iorwf    PORTA,F          
                bsf        PORTC,5            ;digit1
                bcf        PORTC,4            ;digit2
                movlw    B'11110000'
                andwf    PORTC,F
                movf    digit1,w
                iorwf    PORTC,f
                call    check_button
                call    delay1ms

                movlw    B'00000100'
                andwf    PORTA,F
                movlw    B'00000000'
                iorwf    PORTA,F  
                bcf        PORTC,5            ;digit1
                bsf        PORTC,4            ;digit2
                movlw    B'11110000'
                andwf    PORTC,F
                movf    digit2,w
                iorwf    PORTC,f
                call    check_button
                call    delay1ms

                movlw    B'00000100'
                andwf    PORTA,F
                movlw    B'00000010'
                iorwf    PORTA,F  
                bcf        PORTC,5            ;digit1
                bcf        PORTC,4            ;digit2
                movlw    B'11110000'
                andwf    PORTC,F
                movf    digit3,w
                iorwf    PORTC,f
                call    delay1ms

                movlw    B'00000100'
                andwf    PORTA,F
                movlw    B'00000001'
                iorwf    PORTA,F  
                bcf        PORTC,5            ;digit1
                bcf        PORTC,4            ;digit2
                movlw    B'11110000'
                andwf    PORTC,F
                movf    digit4,w
                iorwf    PORTC,f
                call    delay1ms
    display_RA2
                movf    tempA,w
                iorwf    PORTA,F
                call    delay1ms
                    return
    ;----------------------------------------------------------------------
    check_increment
            movlw    1h
            xorwf    count,w
            btfss    STATUS,Z
            return
            clrf    count
            call    increment_digits
            return
    ;----------------------------------------------------------------------
    second_check
            movlw    .112
            subwf    ms,w
            btfss    STATUS,C
            goto    $+3
            bcf        tempA,2
            return
            bsf        tempA,2
            return
    ;---------------------------------------------------------------
    check_button
                btfsc    PORTA,3
                return
                call    delay1ms
                btfsc    PORTA,3
                return
                call    delay1ms
                btfss    PORTC,4
                goto    check_min
                call    delay1ms
                btfss    PORTC,4
                goto    check_min
                call    delay1ms
                bcf        INTCON,GIE
                call    increment_hour
    loop_increment_hour
                btfss    PORTA,3
                goto    loop_increment_hour
                call    delay1ms
                btfss    PORTA,3
                goto    loop_increment_hour
                call    delay1ms
                clrf    count
                bsf        INTCON,GIE
                return
    check_min
                btfss    PORTC,5
                return
                call    delay1ms
                btfss    PORTC,5
                return
                call    delay1ms
                bcf        INTCON,GIE
                call    increment_min
    loop_increment_min
                btfss    PORTA,3
                goto    loop_increment_min
                call    delay1ms
                btfss    PORTA,3
                goto    loop_increment_min
                call    delay1ms
                clrf    count
                bsf        INTCON,GIE
                return
    ;---------------------------------------------------------------
    Start
                call     Initialize
                clrf    digit1
                clrf    digit2
                clrf    digit3
                clrf    digit4
                clrf    ms
                clrf    tempA
                clrf    count
                clrf    secdigit1
                clrf    secdigit2          
    main                      
                call    check_increment
                call    second_check
                call    Display_out
                goto    main
                END    
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,160
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE
    What's a tail???
     
  3. Mosaic

    Mosaic Well-Known Member

    Joined:
    Jun 3, 2010
    Messages:
    2,569
    Likes:
    128
    Location:
    Caribbean
    ONLINE
    Here are the Hex values for the seven segment alphanumeric shapes.
    retlw 0x3f ; code for 0, bit 7 is the dot. Common cathode. Invert values then clr bit 7 (dot) for common anode.
    retlw 0x06; 1
    retlw 0x5b; 2
    retlw 0x4f ;3
    retlw 0x66 ;4
    retlw 0x6d ;5
    retlw 0x7d ;6
    retlw 0x07 ;7
    retlw 0x7f ;8
    retlw 0x67 ;9
    retlw 0x77 ;A
    retlw 0x7c ;b
    retlw 0x39 ;C
    retlw 0x5e ;d
    retlw 0x79 ;E
    retlw 0x71 ;F
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. DerStrom8

    DerStrom8 Super Moderator Most Helpful Member

    Joined:
    Aug 9, 2010
    Messages:
    5,484
    Likes:
    503
    Location:
    Vermont (GMT-5:00)

    Tail:
    6-tail.png

    No Tail:
    6-notail.png
     
  6. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,160
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE
    OH!!! I didn't know that's what they were... I always use the tail otherwise the 6 becomes a b..

    With the code posted... It looks like the display out function is outputting a BCD value so the digits will be generated in hardware..... What chip drives the seven segment?
     
  7. manojsoorya

    manojsoorya Member

    Joined:
    May 6, 2011
    Messages:
    35
    Likes:
    0
    Hi all
    Thanks for helping me. I check the circuit again and again. Last I found its come from Hardware. The circuit use 74LS47 IC. The 74LS47 has no tail for 6 and 9. So can you please provide a circuit for BCD to seven segment converter with the tail?


    Thanks again

    Reguard manoj soorya
     
  8. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,160
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE
    How many digits??? 4 or 6..
     
  9. manojsoorya

    manojsoorya Member

    Joined:
    May 6, 2011
    Messages:
    35
    Likes:
    0
    4 digit sir
     
  10. DerStrom8

    DerStrom8 Super Moderator Most Helpful Member

    Joined:
    Aug 9, 2010
    Messages:
    5,484
    Likes:
    503
    Location:
    Vermont (GMT-5:00)
  11. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,160
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE
    Do you want the code changing so you can interface the displays directly????
     
  12. manojsoorya

    manojsoorya Member

    Joined:
    May 6, 2011
    Messages:
    35
    Likes:
    0
    Hi Sir

    Really I look for a cheap ( minimum component) 7 segment clock with Second blinking LED. I have the above code and the circuit. Its working good. but the number 6 and the 9 not seen good. Can you provide me a circuit with code for a digital clock with PIC IC like 16F676, 16F628A, 16F72, 16F73, 16F722, 16F84A, 16F876, 16F873, 16F886, 16F870, 16F876A, 18F2550, 16F913, 16F88 and some Atmega chips and Atmel Chip in my collection.

    Thanks for the valuable reply Sir......

    God bless you

    Reguard Manoj Soorya
     
  13. manojsoorya

    manojsoorya Member

    Joined:
    May 6, 2011
    Messages:
    35
    Likes:
    0
    Thank you DerStrom8 for your valuable suggession..I think its OK and I need the chip for testing.. I will inform here if its OK...

    Thanks again
     

Share This Page