Continue to Site

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.

  • 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.
Resource icon

Binary to 7 segment decoder 2013-04-26

Status
Not open for further replies.
jakeselectronics submitted a new article:

Binary to 7 Segment Decoder - This circuit displays the Hexadecimal equivalent of a 4 bit Binary Number. The number is displayed

There are many Binary to 7 Segment decoders out there, such as the CD4511, DM74LS47, SN7447 and the DM9368. All of which have attractive features, but none have all of them in one package. Another downside is many only display 0 - 9 with few displaying all Hexadecimal digits (0 - F). With many of these chips obsolete and hard to find, my Binary to 7 Segment Decoder is a versatile substiute.

How It Works

I am using a PIC16F628A to read the Binary Number and Display the Hexadecimal...

Read more about this article...
 
I really like the work you did on this, Jake, though I'm not sure the 'latch' feature would be fast enough for many applications where you would use a DM9368 which can operate with a latch pulse as short as 30-nanoseconds.

I analyzed and re-wrote the main loop to help me understand the logic. I realize this is a very old project, but if you get a chance I wonder if you could take a peek to see if I understand the algorithm correctly for handling the 'blanking' or 'leading zero suppression'? Also, I'm not sure the "latch" function is correct. After looking at the DM9368 datasheet, it seems you should only sample the 4-bit binary input and update the display while the 'latch' input is low, and perhaps wait in a short loop while the 'latch' input is high.

Cheerful regards, Mike

Code:
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;  main loop                                                      ~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

loop
        movlw   8               ; value used for lamp test        |00
        btfsc   PORTA,5         ; lamp test? yes, skip, else      |00
        movf    PORTA,W         ; get input                       |00
        andlw   b'00001111'     ; lower nibble only               |00
        movwf   temp            ; save temporarily                |00
        call    bcd7seg         ; W = digit segment pattern       |00
        movf    temp,F          ; if input = 0, set Z = 1         |00
        bnz     display         ; branch to display '1'..'F'      |00
;
;  handle '0' value (leading zero suppression)
;
        btfss   PORTA,6         ; blank in? no, skip, else        |00
        movlw   b'00000000'     ; W = blank segment pattern       |00
        btfss   PORTA,6         ; blank in? no, skip, else        |00
        bcf     PORTA,7         ; blank out 'on'                  |00
display
        btfss   PORTB,0         ; CC type (1)? yes, skip, else    |00
        xorlw   0xFF            ; CA type (0) (invert pattern)    |00
        movwf   PORTB           ; display '0'..'F' pattern        |00
latch
        btfss   PORTA,4         ; latch high? yes, skip, else     |00
        bsf     PORTA,7         ; blank out 'off'                 |00
        btfss   PORTA,4         ; latch high? yes, skip, else     |00
        goto    latch           ; branch (wait for active low)    |00
        goto    loop            ; branch (loop)                   |00

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        end
 
Last edited:
Hey, I would like to congratulate you on this post. I have brought all of the bits, and the only problem I had was a faulty power supply :s (not that, that was your fault). Your description is very comprehensive and the you tubepost illustrates your project description even further. Well done, top job!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top