8-bit binary into 7 segments

Discussion in 'The Projects Forum' started by lenn24, Jan 31, 2009.

  1. lenn24

    Thread Starter New Member

    Jan 23, 2009
    6
    0
    Our group have a project in Computer Architecture that we have to add an instruction in SAP-1, we decided to do the comparator that compares two 8-bit binary numbers. The output must be displayed using seven segments.
    eg.
    condition output (8 LED)
    if a less than b 11110000
    if a is equal to b 11111111
    if a is greater than b 00001111

    Our problem is we don't know how to convert it into (3) 7-segment display. Can someone please teach us how to convert 8-bit binary into 7 segments display? Your help would be greatly appreciated.
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    You have to convert to a decimal value for each condition. Then you will need three 7 segment displays to indicate the values. You might find it simpler to use a dedicated IC for driving the displays. Something like a CD4547 might do.
     
  3. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    You can use three of these ICs to drive three seven segment displays as to be able to see an 8-bit number.

    If the number is 10001100 split it into:

    010 001 100

    The rightmost three bits will drive the rightmost display, the middle three bits the middle display and the left three bits the left display. There is one extra bit on the leftmost bits as to make a group of three bits. Also, you need to add another 0 bit because the display driver has 4 inputs to show some other figures too. Thus the 8 bit value will be

    0010 0001 0100
     
  4. lenn24

    Thread Starter New Member

    Jan 23, 2009
    6
    0
    thank u very much for your help..now, we have ideas how to make our project well..
    God bless..
     
  5. Skeebopstop

    Active Member

    Jan 9, 2009
    358
    3
    doesn't sound to me like he needs 3 digits to display, rather just to display the binary combination provided out of the little logic statement.

    That being said, a single character 7 segment display generally has 7 segments and a dot (i.e. 8 bits).

    So output a > b you drive 8 pins into the 7 segment display as your binary 11110000. Just have other driven orientations for other conditions and make sure your logic never drives two conditions at once through enable/disable lines of any buffer ICs.
     
  6. lenn24

    Thread Starter New Member

    Jan 23, 2009
    6
    0
    hi..i said the idea of mik3 to our professor..but unfortunately she didn't accepted it..the reason?same as alberto's reason..she needs the exact conversion of 8-bit binary to decimal and display it in 3 seven segments..
    pls..can someone help me to analyze it..is there an IC that can help us?

    what is the IC given by beenthere?i am not familiar of that..i tried to look its datasheet but i am not familiar of the terms..

    thnx..
     
  7. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    I thought it better and my answer was stupid!!!!
    Forget it guys:p
     
  8. Skeebopstop

    Active Member

    Jan 9, 2009
    358
    3
    I have a little custom made display on a design I am currently working with that latches in 5 7 segs with dots over an 8 bit bus. Snazzy little dinger. 4% of the lil betches were faulty in production.

    I agree with Alberto. If you're to be doing binary to BCD conversions you'll be best to be doing bit shifting and controlling 3 output ports of 8 bits to write out your 7 segs.

    unsigned char[] myConversion = {
    0110010b , \ // '1'
    1001111b , \ // '2'
    1010000b , \ // '3'
    ...
    1000011b \ // '9'
    } ;

    void main(void) {
    unsigned char myBinary ;
    unsigned char myBinaryTemp ;

    while(1) {
    myBinary = PORTA ;
    myBinaryTemp = (myBinary/100) ;

    PORTB = dec_to_bcd(myBinaryTemp) ;

    myBinaryTemp = (myBinary/10)%10 ;

    PORTC = dec_to_bcd(myBinaryTemp) ;

    myBinaryTemp = (myBinary)%10 ;

    PORTD = dec_to_bcd(myBinaryTemp) ;
    }
    }

    unsigned char dec_to_bcd(unsigned char myDec) {
    switch (myDec) {
    case 1 :
    return myConversions[myDec] ;
    case 2 :
    return myConversions[myDec] ;
    case 3 :
    ...
    case 9 :
    return myConversions[myDec] ;
    }
    }

    O please lordy don't let the formatting go on this one!
     
  9. Skeebopstop

    Active Member

    Jan 9, 2009
    358
    3
    Damn! It eats up my attempts at spaces or tabs to delineate code. bugger.

    O and btw, the 'binary' values I spit out for '1', '2' etc.. were randomly chosen. They would have to represent the appropriate LEDs in the 7 seg.
     
  10. gelopig

    New Member

    Feb 4, 2009
    4
    0
    Actually, their problem is how to show the 8bit binary to decimal((2^8)-1), which means they have to show an output 255(max) using (3)7segment in decimal value. 000-099, 100-199, 200-255.
     
  11. Skeebopstop

    Active Member

    Jan 9, 2009
    358
    3
    Aye, my code does that... Reads in 8 bit binary on one port and outputs 3 characters on remaining ports (hoping you have a pic with 4 ports!), i.e. 127 shows "1", "2", "7"
     
  12. gelopig

    New Member

    Feb 4, 2009
    4
    0
    i think what they need is a circuit design that will show 8bit binary to decimal. for example: 4bit binary that will show a decimal value using (2)7segment. 1 7segment can show a 0-9 value but a 4 bit binary have to show 0-15. In order for us to show 0-15 we have to use (2)decoder for each 7segment but we have to use a full adder to have an output from 10-15. 00-09 and 10-15 in 7segment. in binary 0000-1001 and 1011-1111. but a decoder for 7segment can only handle 0000-1001 so we have to use full adder to have an input for the second decoder(the tens digit) from 0000-0001.

    darn! its really hard to explain! haha! my nose is already bleeding! i think i just have to make a picture of it.
     
  13. gelopig

    New Member

    Feb 4, 2009
    4
    0
    [​IMG]


    the 2nd input must have a value of 0110(6) to have a value of 1 0000, but we have to add that six when the 1st input has the value of 1010-1111(10-15). we already solve it. but our problem is how to convert a 8bit binary to decimal?
    0000 0000-1001 0000-1001 000-099(7segment)
    0001 0000-1001 0000-1001 100-199(7segment)- most probably our problem will be in this part
    0010 0000-0101 0000-0101 200-255(7segment)- and this one too haha
     
  14. gelopig

    New Member

    Feb 4, 2009
    4
    0
    BTW... we cant use microcontroller in SAP1.

    we have to focus on combinational gates like full adder, half adder, decoder,etc.
    and we have to include their IC. thats why were having a problem solving a 8bit binary to decimal conversion OUTPUT.
     
Loading...