What is code b (7 segment display char set)? - Page 1
Forum section: electronics / projects

author: AsciiSimon
author_rank: Newbie
timestamp: February 25, 2013, 08:59:12 pm
content: Hi, I am working on a little 6502 based computer and it would be handy (well, at least fun) to be able to display the address/databus in HEX on 7 segment displays.Hunting about for a quick and easy way to do this I came across the Maxim ICM7212 (http://www.maximintegrated.com/datasheet/index.mvp/id/1675) decoder/driver chips. There are also others about.These will output in either hexadecimal (0123456789ABCDEF) or in Code B format (0123456789-EHLP ) depending on the variant.What the heck is code B? Rather, what is it actually used for? I can find mention of other ICs that decode and output it but I can't find any mention of what it's actually for. I suppose it might be useful to have the computer say HELP.....Simon

author: AndyC_772
author_rank: Super Contributor
timestamp: February 25, 2013, 09:04:26 pm
content: It looks like just another option to allow some different characters to be shown - maybe characters to indicate "error", "high", "low" and "program"?

author: Mr Smiley
author_rank: Frequent Contributor
timestamp: February 25, 2013, 09:15:29 pm
content: From the maxim MAX7219 data sheet, code B is described as BCD mode, where only 0-9 is decoded to the digit segments. You have to send the 8 bits, but only the lower 4 are looked at so it becomes a BCD to 7 segment decoderFrom page 7 of the datasheet;Decode-Mode RegisterThe decode-mode register sets BCD code B (0-9, E, H,L, P, and -) or no-decode operation for each digit. Eachbit in the register corresponds to one digit. A logic highselects code B decoding while logic low bypasses thedecoder. Examples of the decode mode control-regis-ter format are shown in Table 4.When the code B decode mode is used, the decoderlooks only at the lower nibble of the data in the digitregisters (D3–D0), disregarding bits D4–D6. D7, whichsets the decimal point (SEG DP), is independent of thedecoder and is positive logic (D7 = 1 turns the decimalpoint on). Table 5 lists the code B font.When no-decode is selected, data bits D7–D0 corre-spond to the segment lines of the MAX7219/MAX7221.Table 6 shows the one-to-one pairing of each data bitto the appropriate segment line.

author: AsciiSimon
author_rank: Newbie
timestamp: February 25, 2013, 09:21:45 pm
content: But what is that code actually used on is what I am getting at. It must have a purpose. What kind of machine uses it? Status panels for something perhaps?Simon

author: Jon Chandler
author_rank: Frequent Contributor
timestamp: February 25, 2013, 10:42:56 pm
content: The display can show HELP as an option.

author: Mr Smiley
author_rank: Frequent Contributor
timestamp: February 26, 2013, 03:29:09 am
content: Well, lets take 0xff, which is 255 decimal. To show 0xff as a decimal number you convert 0xff to three bcd bytes, first byte is 0x02, second is 0x05 third is 0x05. To display these onto say a serial or lcd display you convert to ascii by adding 0x30 to each byte so now you have 0x32, 0x35 and 0x35, send these and you display 255.Now, that's all fine, but you have to add 0x30 to each BCD value, takes a little longer and adds to your code allocation. If you want to display this onto a 7-segment display, you have to use a lookup table to convert the BCD value to the segments you want to light up. There are out there BCD to 7-segment driver chips.So it's quicker and easier just to send BCD to the display driver chip and let that do all the segment mapping.

author: Mr Smiley
author_rank: Frequent Contributor
timestamp: February 26, 2013, 03:37:39 am
content: It's also quicker and takes up less code space if you only want to count in the decimal system up to 9. Say 999, to do bcd counting and send that directly to the display chip, so no hex to bcd conversion.Real time clocks also only count in BCD, so easier path from RTC to CPU to Display.It's all down to speed and convenience.

author: AsciiSimon
author_rank: Newbie
timestamp: February 26, 2013, 06:38:34 am
content: No, no, I understand what BCD is and how the the coding works and how the IC works (but thanks for taking the time to explain). When outputting this "code B" the display will show '0123456789-EHLP ' for inputs 0-F. Normal hex would show '0123456789ABCDEF'.But what is it that needs to display that particular code B character set. There must be some machine or device that specifically needs to display those codes if they made a display driver IC for it. What is that machine? Where would this IC be used?I don't think I explained myself very well!Simon

author: cyr
author_rank: Frequent Contributor
timestamp: February 26, 2013, 11:55:56 am
content: Well, ' ' and '-' is needed for any application where you show positive and negative values with varying number of digits. E for error is quite common...I can easily imagine a requirements document listing 0-9, -, E and <blank> leaving the final three codes undefined and leading some bored chip designer to spell out HELP

author: Len
author_rank: Frequent Contributor
timestamp: February 26, 2013, 07:30:29 pm
content: I've seen "HI" and "LO" on 7-seg displays for out-of-range values, maybe that's what the H & L are for.

author: AsciiSimon
author_rank: Newbie
timestamp: February 28, 2013, 06:44:59 pm
content: I decided to ask the source and email Maxim tech support. They spent a few days hunting and came back with this which is the best answer found so far. It is an Intersil datasheet: |http://www.intersil.com/content/dam/Intersil/documents/fn31/fn3159.pdfOn page 5 it mentions "....Code B provides a negative sign (-), a blank (for leading zero blanking), certain useful alpha characters and all numeric formats."So it seems they are just some values selected to be useful. I think the H and L might be for High and Low as Len says. And the + and blank as cyr mentions.E for Error or Exponent maybe?P for, I don't know, displaying a Percentage? Probability?Would be interesting to find someone who actually used one in a real design!Simon

author: SeanB
author_rank: Super Contributor
timestamp: February 28, 2013, 07:20:38 pm
content: P - pulse.