# 8 bit to 3x7 segment display

#### WBahn

Joined Mar 31, 2012
26,398
Keep in mind that, in general, you have 12 output variables each with 8 input variables. Thus a table with 256 rows that you have to come up with the expressions for 12 variables.

Certainly it's doable. But likely to be very error prone.

I would hope that the problem constraints allow for a much more reasonable approach. But we need the TS to come clean and state the full and complete problem statement including what resources may and may not be used.

#### absf

Joined Dec 29, 2010
1,967
I think 10 output vars should be sufficient as the MSD of 255 is only 2 bits long.

I did one with EPROMs and I have to dig out the file so I can show the deadly spider.

Allen

#### WBahn

Joined Mar 31, 2012
26,398
I agree -- 10 is all that is needed.

Plus, there is invariably some low hanging fruit.

#### absf

Joined Dec 29, 2010
1,967
And here's the EPROM version of 8 bit Binary to BCD converter. The smallest ROM I can find in proteus is 2732. The smaller ones are TTL PROM and serial eeprom which I have no ideas how to program them.

I'll attach the design and ROM hex files later in case someone wants to try it out.

Allen

#### dl324

Joined Mar 30, 2015
13,574
This was an interesting problem.

I designed a 4 bit binary to BCD converter and implemented a 5 bit converter. I decided to do 4 bits instead of 5 like the 74185 to keep the kmaps simple.
Sorry about the weird aspect ratio. Still learning how to use the capture program.
EDIT: Just noticed that I have the labels for the Q3 and Q2 sequence generators at the bottom of the screen swapped...

This doesn't give away any more than the NatSemi or TI datasheets:

Last edited:

#### dl324

Joined Mar 30, 2015
13,574
And here's the EPROM version of 8 bit Binary to BCD converter.
Interesting. I might program some EPROMs to do the conversion. I have some M27C4002 that are 16 bits wide, so it would only require one EPROM for 4 digits and wiring would be simplified because the address lines are on one side and the data lines are on the other.

Using logic gates would take a lot of wiring and real estate...

#### crutschow

Joined Mar 14, 2008
28,227
I think the TS has left the building.

#### dl324

Joined Mar 30, 2015
13,574
Losing interest on this particular question seems to be common. This question has appeared on this and other forums a number of times and I've yet to see anyone complete the design. Most don't even try.

I never knew that the algorithm for the conversion had a name...

#### absf

Joined Dec 29, 2010
1,967
I think the TS has left the building.
Was that Elvis?

Just as what I have predicted.

Allen

Last edited:

#### absf

Joined Dec 29, 2010
1,967
----Continue from post #24

Here are the files..
1. The zip file is the design file in proteus 7.80
2. The hex file for lower data ROM
3. The hex file for upper data ROM

And the original source of the hex files.
Code:
; lower data ROM
ORG     0000
DB    00H,01H,02H,03H,04H,05H,06H,07H,08H,09H    ;000
DB    10H,11H,12H,13H,14H,15H,16H,17H,18H,19H    ;010
DB    20H,21H,22H,23H,24H,25H,26H,27H,28H,29H    ;020
DB    30H,31H,32H,33H,34H,35H,36H,37H,38H,39H    ;030
DB    40H,41H,42H,43H,44H,45H,46H,47H,48H,49H    ;040
DB    50H,51H,52H,53H,54H,55H,56H,57H,58H,59H    ;050
DB    60H,61H,62H,63H,64H,65H,66H,67H,68H,69H    ;060
DB    70H,71H,72H,73H,74H,75H,76H,77H,78H,79H    ;070
DB    80H,81H,82H,83H,84H,85H,86H,87H,88H,89H    ;080
DB    90H,91H,92H,93H,94H,95H,96H,97H,98H,99H    ;090
DB    00H,01H,02H,03H,04H,05H,06H,07H,08H,09H    ;100
DB    10H,11H,12H,13H,14H,15H,16H,17H,18H,19H    ;110
DB    20H,21H,22H,23H,24H,25H,26H,27H,28H,29H    ;120
DB    30H,31H,32H,33H,34H,35H,36H,37H,38H,39H    ;130
DB    40H,41H,42H,43H,44H,45H,46H,47H,48H,49H    ;140
DB    50H,51H,52H,53H,54H,55H,56H,57H,58H,59H    ;150
DB    60H,61H,62H,63H,64H,65H,66H,67H,68H,69H    ;160
DB    70H,71H,72H,73H,74H,75H,76H,77H,78H,79H    ;170
DB    80H,81H,82H,83H,84H,85H,86H,87H,88H,89H    ;180
DB    90H,91H,92H,93H,94H,95H,96H,97H,98H,99H    ;190
DB    00H,01H,02H,03H,04H,05H,06H,07H,08H,09H    ;200
DB    10H,11H,12H,13H,14H,15H,16H,17H,18H,19H    ;210
DB    20H,21H,22H,23H,24H,25H,26H,27H,28H,29H    ;220
DB    30H,31H,32H,33H,34H,35H,36H,37H,38H,39H    ;230
DB    40H,41H,42H,43H,44H,45H,46H,47H,48H,49H    ;240
DB    50H,51H,52H,53H,54H,55H                    ;250
END
Code:
;BIN TO BCD UPPER_ROM DATA
ORG    0000
DB    00,00,00,00,00,00,00,00,00,00    ;LINE 1-10
DB    00,00,00,00,00,00,00,00,00,00    ;LINE 1-10
DB    00,00,00,00,00,00,00,00,00,00    ;LINE 1-10
DB    00,00,00,00,00,00,00,00,00,00    ;LINE 1-10
DB    00,00,00,00,00,00,00,00,00,00    ;LINE 1-10
DB    00,00,00,00,00,00,00,00,00,00    ;LINE 1-10
DB    00,00,00,00,00,00,00,00,00,00    ;LINE 1-10
DB    00,00,00,00,00,00,00,00,00,00    ;LINE 1-10
DB    00,00,00,00,00,00,00,00,00,00    ;LINE 1-10
DB    00,00,00,00,00,00,00,00,00,00    ;LINE 1-10
DB    01,01,01,01,01,01,01,01,01,01    ;LINE 11-20
DB    01,01,01,01,01,01,01,01,01,01    ;LINE 11-20
DB    01,01,01,01,01,01,01,01,01,01    ;LINE 11-20
DB    01,01,01,01,01,01,01,01,01,01    ;LINE 11-20
DB    01,01,01,01,01,01,01,01,01,01    ;LINE 11-20
DB    01,01,01,01,01,01,01,01,01,01    ;LINE 11-20
DB    01,01,01,01,01,01,01,01,01,01    ;LINE 11-20
DB    01,01,01,01,01,01,01,01,01,01    ;LINE 11-20
DB    01,01,01,01,01,01,01,01,01,01    ;LINE 11-20
DB    01,01,01,01,01,01,01,01,01,01    ;LINE 11-20
DB    02,02,02,02,02,02,02,02,02,02    ;LINE 21-26
DB    02,02,02,02,02,02,02,02,02,02    ;LINE 21-26
DB    02,02,02,02,02,02,02,02,02,02    ;LINE 21-26
DB    02,02,02,02,02,02,02,02,02,02    ;LINE 21-26
DB    02,02,02,02,02,02,02,02,02,02    ;LINE 21-26
DB    02,02,02,02,02,02,02,02,02,02    ;LINE 21-26
END
I am not good in C or else I'd be able to generate the source code using a short C program.

Allen

#### Attachments

• 8.1 KB Views: 23
• 733 bytes Views: 19
• 754 bytes Views: 17

#### absf

Joined Dec 29, 2010
1,967
Interesting. I might program some EPROMs to do the conversion. I have some M27C4002 that are 16 bits wide, so it would only require one EPROM for 4 digits and wiring would be simplified because the address lines are on one side and the data lines are on the other.

Using logic gates would take a lot of wiring and real estate...
I too have some 16 data bit EPROM with quartz window. It was in 40 pin DIP by Intel from an outdated communication equipment designed by Motorola. I'll try to dig it out and take some picture of it.

Cannot remember the part numbers. But how are you going to program an EPROM with 16 bit data bus?

I have an EMP-xx programmer that was sitting inside the 8 bit ISA slot of my old PC. Not sure if it can program the intel eprom.

Allen

Last edited:

#### absf

Joined Dec 29, 2010
1,967
Losing interest on this particular question seems to be common. This question has appeared on this and other forums a number of times and I've yet to see anyone complete the design. Most don't even try.

I never knew that the algorithm for the conversion had a name...
May be it was my fault.

I should have used more encouraging tones in post #20 like:

"I am very sure you are able to design an 8 bit version of what I have just done...."

"Now do you think you can do an 8 bit version of this?"

Allen

#### dl324

Joined Mar 30, 2015
13,574
t how are you going to program an EPROM with 16 bit data bus?
I have some hobbyist EPROM/FLASH programmers that are called Willem programmers. A number of adapters are available; one will program 16 bit wide EPROMs. They require a parallel interface and the software works best with Windows versions prior to XP. I have an old laptop running WinME for running the programmers.

Most Willem designs are open source and schematics are readily available. The software was once open sourced until the active maintainer decided to make it proprietary and made hardware changes so it would only work with his designs.

Early designs had some power deficiencies that I worked with Willem to address. He fixed the worst of them in his 4.1 version; which is what I use. He was working with someone to make a USB interface programmer, but passed away before it was finalized.

The person who made the latest hardware and software private is in your neck of the woods. His website is sivava.com. I tried to work with him to fix the power problems in his design and improve the software, but he stopped communicating with the Willem Community.

Some of the Willem programmers don't work. As I recall, that's what brought me to AAC. A post asking questions about one of the variants that was barely suitable for reading devices came up in a search and I joined to try to help him.

#### Brian Griffin

Joined May 17, 2013
64
May be it was my fault.

I should have used more encouraging tones in post #20 like:

"I am very sure you are able to design an 8 bit version of what I have just done...."

"Now do you think you can do an 8 bit version of this?"

Allen
I do not think the question "Now do you think you can do an 8 bit version of this?" is condescending. Many interactive tutorials and some hobby electronic magazines often ask the reader that way.

#### dl324

Joined Mar 30, 2015
13,574
May be it was my fault.
The OP may come back. If he doesn't it won't be because of your post. Sometimes they have more important things to do.

People who abandon their homework threads usually do so when they find out they're expected to do most of the work.

#### WBahn

Joined Mar 31, 2012
26,398
The OP may come back. If he doesn't it won't be because of your post. Sometimes they have more important things to do.

People who abandon their homework threads usually do so when they find out they're expected to do most of the work.
I'm pretty sure that is often the case. It is also probably frequently the case that once they get enough help to complete their assignment they simply move on and don't bother to post anything further.

#### dl324

Joined Mar 30, 2015
13,574
I am not good in C or else I'd be able to generate the source code using a short C program.
No frills code to generate the table for 4 digits:
Code:
main() {
char *cptr, tmp[5];
int i, fd;
unsigned int bcdn;

fd = open("bcd.dat", O_RDWR|O_CREAT);
for (i = 0; i < 10000; i++) {
sprintf(tmp, "%4.4d", i);
for (bcdn = 0, cptr = tmp; *cptr;) {
bcdn = (bcdn << 4) + *cptr++ - '0';
}
write(fd, &bcdn, 2);
}
close(fd);
exit(0);
}
I programmed an MC27C4002, but have only checked programming of the second word to make sure byte order was correct.

#### absf

Joined Dec 29, 2010
1,967
No frills code to generate the table for 4 digits:
Code:
main() {
char *cptr, tmp[5];
int i, fd;
unsigned int bcdn;

fd = open("bcd.dat", O_RDWR|O_CREAT);
for (i = 0; i < 10000; i++) {
sprintf(tmp, "%4.4d", i);
for (bcdn = 0, cptr = tmp; *cptr;) {
bcdn = (bcdn << 4) + *cptr++ - '0';
}
write(fd, &bcdn, 2);
}
close(fd);
exit(0);
}
I programmed an MC27C4002, but have only checked programming of the second word to make sure byte order was correct.
Thanks so much. I'll try it out after I come back from my holidays.

Allen

#### dl324

Joined Mar 30, 2015
13,574
Thanks so much. I'll try it out after I come back from my holidays.
You'll need to include some header files.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
The programmer you use might expect the bytes in the opposite order. The program I use can swap bytes. If you need bytes swapped and the program you use doesn't support swapping, you can use the Unix dd command (conv=swab).

If you want to program in two byte wide EPROMs, you could modify the code example. Or write a program to separate the file into odd/even bytes, which is what I did because it might be useful for some other application.