Maker Pro
Maker Pro

8 Bit number to 3 seperate 7-segment LED displays

S

Sean Brown

Good afternoon,

I was wondering if anyone can give me some ideas on how to take an 8-
bit number and display it on 3 LED displays.

I would be extremely grateful if you could give me a push in the right
direction.

many thanks,

Sean
 
Good afternoon,

I was wondering if anyone can give me some ideas on how to take an 8-
bit number and display it on 3 LED displays.

I would be extremely grateful if you could give me a push in the right
direction.

many thanks,

Sean

I will push you in the direction of a microcontroller.
You'll have to be more specific though.
How fast is the number changing? Do you want the number displayed to
change as fast as the 8 bits change or is there a strobe signal?
I assume you want to convert 8 bits to decimal, hence the 3 displays?
It's not hard to do, but what's your background?
 
S

Spehro Pefhany

Good afternoon,

I was wondering if anyone can give me some ideas on how to take an 8-
bit number and display it on 3 LED displays.

I would be extremely grateful if you could give me a push in the right
direction.

many thanks,

Sean

Convert the number to an unsigned BCD number (with sign flag if
appropriate)

Look up each digit (from left to right is easiest) and find the
segment pattern for the digit. Unless you're at the rightmost digit,
use blank instead of '0' until you hit the first non-zero digit.
The results go into a 3-byte buffer. If the number is being updated
very frequently you may wish to slow down the updates to at most a few
per second.

Either scan the display (output one digit at a time, or Charlieplex it
etc.) or output static drive (eg. 3 shift registers). Deal with the
'-' sign (if present) either with another LED or a 4th digit or
whatever, up to you. If you scan the display you'll need to keep the
frequency high enough that flicker is acceptable. 1msec/digit is fine.
You can use an ISR or whatever to do the scanning..

Enough of a push?

Best regards,
Spehro Pefhany
 
J

Jan Panteltje

Good afternoon,

I was wondering if anyone can give me some ideas on how to take an 8-
bit number and display it on 3 LED displays.

I would be extremely grateful if you could give me a push in the right
direction.

many thanks,

Sean

Software?
binary -> bcd -> seven segment
Processor?, Language?
Hardware?
binary -> bcd -> seven segment

In case of hardware the old 74HCXXXX series has some bcd to seven segment decoders.
74HC4511?
You can use some presettable binary counter with BCD output perhaps to drive it.
 
S

Spehro Pefhany

Software?
binary -> bcd -> seven segment
Processor?, Language?
Hardware?
binary -> bcd -> seven segment

In case of hardware the old 74HCXXXX series has some bcd to seven segment decoders.
74HC4511?
You can use some presettable binary counter with BCD output perhaps to drive it.

Brute force hardware:

binary + 2-bit counter-> segment output (via flash or EPROM)
oscillator->counter-> decoder -> digit drive

You only need 8k bits of memory to do this.

To make it more general, use 4 digits and add the sign and another
input to select signed/unsigned, or 16k bits.

Probably direct segment drive of a CA display from the memory is okay.

A 64K x 8 EPROM is $3.24 in single quantity; of course you need to be
able to program it (and erase it if you make a mistake) or $1.42 in
10's if you want the kind that can't be erased.

Best regards,
Spehro Pefhany
 
P

Paul Burke

Sean said:
Good afternoon,

I was wondering if anyone can give me some ideas on how to take an 8-
bit number and display it on 3 LED displays.

I would be extremely grateful if you could give me a push in the right
direction.

I used to know several methods of doing this in TTL hardware, all long
forgotten thanks to microcontrollers. But the TI book on logic design in
TTL that I learned some of them from is still around... I saw a copy in
a local second hand bookshop the other day. 5 good UK pounds.
 
E

Eeyore

Sean said:
Good afternoon,

I was wondering if anyone can give me some ideas on how to take an 8-
bit number and display it on 3 LED displays.

I would be extremely grateful if you could give me a push in the right
direction.

By far the simplest (fewest parts) and least expensive way is to use a
microcontroller (such as a PIC or an 8051 derivative like the 89S51).

That will require writing software though.

Graham
 
S

Sean Brown

I will push you in the direction of a microcontroller.
You'll have to be more specific though.
How fast is the number changing? Do you want the number displayed to
change as fast as the 8 bits change or is there a strobe signal?
I assume you want to convert 8 bits to decimal, hence the 3 displays?
It's not hard to do, but what's your background?

Sorry,

The number will be coming from an EPROM and won't change once it's
been set. The 8 bits will be converted to decimal, so you're correct
in your assumption.

If it was only 0-9, then I comprehend sending the 4 LSB's to the
Display controller, but I'm confused on getting the same result with
the higher numbers.

Thanks for your response.

Sean
 
S

Spehro Pefhany

By far the simplest (fewest parts) and least expensive way is to use a
microcontroller (such as a PIC or an 8051 derivative like the 89S51).

That will require writing software though.

Graham

If you're more comfortable programming hardware, a small CPLD might be
similarly priced and they tend to have a lot of output drive current
and I/Os. You need a JTAG cable or whatever to program the thing.

Best regards,
Spehro Pefhany
 
J

Jan Panteltje

If you're more comfortable programming hardware, a small CPLD might be
similarly priced and they tend to have a lot of output drive current
and I/Os. You need a JTAG cable or whatever to program the thing.

Best regards,
Spehro Pefhany


That reminds me, I did it in Verilog for my frequency counter, in FPGA
http://panteltje.com/panteltje/fpga/frequency_counter-0.2.1.bz2 ,
and used the routine from www.opencores.org.
It has MANY more digits :)

//---------------------------------------------------------------------------
// Binary to BCD converter, serial implementation, 1 clock per input bit.
//
//
// Description: See description below (which suffices for IP core
// specification document.)
//
// Copyright (C) 2002 John Clayton and OPENCORES.ORG (this Verilog version)
//
// This source file may be used and distributed without restriction provided
// that this copyright statement is not removed from the file and that any
// derivative work contains the original copyright notice and the associated
// disclaimer.
//
// This source file is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This source is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
// License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this source.
// If not, download it from http://www.opencores.org/lgpl.shtml
//
//-----------------------------------------------------------------------------
//
// Author: John Clayton
// Date : Nov. 19, 2003
// Update: Nov. 19, 2003 Copied this file from "led_display_driver.v" and
// modified it.
// Update: Nov. 24, 2003 Fixed bcd_asl function, tested module. It works!
// Update: Nov. 25, 2003 Changed bit_counter and related logic so that long
// start pulses produce correct results at the end of
// the pulse.
//
//-----------------------------------------------------------------------------
// Description:
//
// This module takes a binary input, and converts it into BCD output, with each
// binary coded decimal digit of course occupying 4-bits.
// The user can specify the number of input bits separately from the number of
// output digits. Be sure that you have specified enough output digits to
// represent the largest number you expect on the binary input, or else the
// most significant digits of the result will be cut off.
//
//-----------------------------------------------------------------------------


module binary_to_bcd (
clk_i,
ce_i,
rst_i,
start_i,
dat_binary_i,
dat_bcd_o,
done_o
);
parameter BITS_IN_PP = 32; // # of bits of binary input
parameter BCD_DIGITS_OUT_PP = 10; // # of digits of BCD output
parameter BIT_COUNT_WIDTH_PP = 5; // Width of bit counter

// I/O declarations
input clk_i; // clock signal
input ce_i; // clock enable input
input rst_i; // synchronous reset
input start_i; // initiates a conversion
input [BITS_IN_PP-1:0] dat_binary_i; // input bus
output [4*BCD_DIGITS_OUT_PP-1:0] dat_bcd_o; // output bus
output done_o; // indicates conversion is done

reg [4*BCD_DIGITS_OUT_PP-1:0] dat_bcd_o;

// Internal signal declarations

reg [BITS_IN_PP-1:0] bin_reg;
reg [4*BCD_DIGITS_OUT_PP-1:0] bcd_reg;
wire [BITS_IN_PP-1:0] bin_next;
reg [4*BCD_DIGITS_OUT_PP-1:0] bcd_next;
reg busy_bit;
reg [BIT_COUNT_WIDTH_PP-1:0] bit_count;
wire bit_count_done;

//--------------------------------------------------------------------------
// Functions & Tasks
//--------------------------------------------------------------------------

function [4*BCD_DIGITS_OUT_PP-1:0] bcd_asl;
input [4*BCD_DIGITS_OUT_PP-1:0] din;
input newbit;
integer k;
reg cin;
reg [3:0] digit;
reg [3:0] digit_less;
begin
cin = newbit;
for (k=0; k<BCD_DIGITS_OUT_PP; k=k+1)
begin
digit[3] = din[4*k+3];
digit[2] = din[4*k+2];
digit[1] = din[4*k+1];
digit[0] = din[4*k];
digit_less = digit - 5;
if (digit > 4'b0100)
begin
bcd_asl[4*k+3] = digit_less[2];
bcd_asl[4*k+2] = digit_less[1];
bcd_asl[4*k+1] = digit_less[0];
bcd_asl[4*k+0] = cin;
cin = 1'b1;
end
else
begin
bcd_asl[4*k+3] = digit[2];
bcd_asl[4*k+2] = digit[1];
bcd_asl[4*k+1] = digit[0];
bcd_asl[4*k+0] = cin;
cin = 1'b0;
end

end // end of for loop
end
endfunction

//--------------------------------------------------------------------------
// Module code
//--------------------------------------------------------------------------

// Perform proper shifting, binary ASL and BCD ASL
assign bin_next = {bin_reg,1'b0};
always @(bcd_reg or bin_reg)
begin
bcd_next <= bcd_asl(bcd_reg,bin_reg[BITS_IN_PP-1]);
end

// Busy bit, input and output registers
always @(posedge clk_i)
begin
if (rst_i)
begin
busy_bit <= 0; // Synchronous reset
dat_bcd_o <= 0;
end
else if (start_i && ~busy_bit)
begin
busy_bit <= 1;
bin_reg <= dat_binary_i;
bcd_reg <= 0;
end
else if (busy_bit && ce_i && bit_count_done && ~start_i)
begin
busy_bit <= 0;
dat_bcd_o <= bcd_next;
end
else if (busy_bit && ce_i && ~bit_count_done)
begin
bcd_reg <= bcd_next;
bin_reg <= bin_next;
end
end
assign done_o = ~busy_bit;

// Bit counter
always @(posedge clk_i)
begin
if (~busy_bit) bit_count <= 0;
else if (ce_i && ~bit_count_done) bit_count <= bit_count + 1;
end
assign bit_count_done = (bit_count == (BITS_IN_PP-1));

endmodule
 
E

Eeyore

Spehro said:
If you're more comfortable programming hardware, a small CPLD might be
similarly priced and they tend to have a lot of output drive current
and I/Os. You need a JTAG cable or whatever to program the thing.

How cheap do suitable CPLDs go these days ?

Graham
 
Sorry,

The number will be coming from an EPROM and won't change once it's
been set. The 8 bits will be converted to decimal, so you're correct
in your assumption.

If it was only 0-9, then I comprehend sending the 4 LSB's to the
Display controller, but I'm confused on getting the same result with
the higher numbers.

Thanks for your response.

Sean

Well there's obviously a lot more to the problem than you first let
on!
What's this "display controller"?
 
S

Sean Brown

Well there's obviously a lot more to the problem than you first let
on!
What's this "display controller"?

I apologise for not being very clear.

By display controller, I mean the decoder which takes the BCD input: 0
- 9 and controls the 7-segment displays for each display.

Maybe if I just ask: How do i convert an 8 bit number into the 3 digit
BCD equivalent. I would like to keep it through hardware if possible,
but am open to other ideas.

Many thanks,

Sean
 
R

Rich Grise

Maybe if I just ask: How do i convert an 8 bit number into the 3 digit
BCD equivalent. I would like to keep it through hardware if possible,
but am open to other ideas.

The bog-simplest in theory is just a 21-bit ROM, or a bank of 8-bit ROMS
such that the truth table is:

00000000 <0> <0> <0>
00000001 <0> <0> <1>
....
00001001 <0> <0> <9>
00001010 <0> <1> <0>
00001011 <0> <1> <1>
....
00010011 <0> <1> <9>
00010100 <0> <2> <0>

And so on - I'm sure you get the idea.

Good Luck!
Rich
 
S

Sean Brown

The bog-simplest in theory is just a 21-bit ROM, or a bank of 8-bit ROMS
such that the truth table is:

00000000 <0> <0> <0>
00000001 <0> <0> <1>
...
00001001 <0> <0> <9>
00001010 <0> <1> <0>
00001011 <0> <1> <1>
...
00010011 <0> <1> <9>
00010100 <0> <2> <0>

And so on - I'm sure you get the idea.

Good Luck!
Rich

Silly me...

That would be the most simple. I got my head too far into the clouds
to see what was in front of me.

Thanks very much.
 
J

John Fields

I apologise for not being very clear.

By display controller, I mean the decoder which takes the BCD input: 0
- 9 and controls the 7-segment displays for each display.

Maybe if I just ask: How do i convert an 8 bit number into the 3 digit
BCD equivalent. I would like to keep it through hardware if possible,
but am open to other ideas.

---
An old brute-force way to do it is to simultaneously load the binary
number into an 8 bit down-counter and clear three BCD counters, then
use the same clock to count the binary number down to zero while
up-counting the BCD counters. Stop counting when the binary counter
gets to zero, and the BCD counters will have accumulated the BCD
equivalent of the original binary number.
 
R

Richard Henry

I apologise for not being very clear.

By display controller, I mean the decoder which takes the BCD input: 0
- 9 and controls the 7-segment displays for each display.

Maybe if I just ask: How do i convert an 8 bit number into the 3 digit
BCD equivalent. I would like to keep it through hardware if possible,
but am open to other ideas.

Many thanks,

Sean- Hide quoted text -

- Show quoted text -

Here's one way:

http://web.mit.edu/6.s28/www/datasheets/DM74LS47.pdf
 
R

Rich Grise

On Tue, 08 Jan 2008 09:40:04 -0800, Sean Brown wrote: [binary to 7-segment]
The bog-simplest in theory is just a 21-bit ROM, or a bank of 8-bit ROMS
such that the truth table is:
...
And so on - I'm sure you get the idea.

Good Luck!
Rich

Silly me...

That would be the most simple. I got my head too far into the clouds
to see what was in front of me.

Thanks very much.

You're more than welcome - it's nice when my answers actually work! :)

Cheers!
Rich
 
D

DJ Delorie

Rich Grise said:
The bog-simplest in theory is just a 21-bit ROM, or a bank of 8-bit ROMS
such that the truth table is:

Can you still buy plain old ROMs any more? I checked digikey but the
smallest EPROM they had was 1kx8 for $13, or some 2kx8 eeprom for $4.

They did have a 44 pin CPLD for $1 though.
 
Top