This is only a preview of the November 2024 issue of Practical Electronics. You can view 0 of the 80 pages in the full issue. Articles in this series:
Articles in this series:
Articles in this series:
Articles in this series:
Items relevant to "Multi-Channel Volume Control, part one":
Articles in this series:
Articles in this series:
Articles in this series:
Articles in this series:
|
Max’s Cool Beans
By Max the Magnificent
Arduino Bootcamp – Part 23 (yet more on BCD!)
I
have received several emails
from readers saying how much
they’ve been enjoying our forays
into the realm of digital logic design.
They were talking about the 2:4 decoder we created out of AND and
NOT gates, along with our discussions
on ring and Johnson counters that
can be implemented using D-type
flipflops.
A cunning conundrum
On the software side of things, circa
the late 1970s, monthly magazines like
Byte often published programming
competitions. First, they picked a
simple microprocessor like an 8-bit
6502, 8080, or Z80. Next, they set
a task like counting all the 1s in an
8-bit word using the smallest number
of machine code instructions and/or
the least amount of memory for both
instructions and data.
Similarly, on the hardware side
of things, prior to the introduction
of logic synthesis technology in the
1980s, digital logic designers delighted
in setting and solving logic problems.
One of my favorites is shown in Fig.1.
We start with a black box (which means
we don’t know what’s inside) that has
three inputs (A, B, C) and three outputs
(NotA, NotB, NotC).
We want each output to reflect the
logical negation of its corresponding
input. That is, if A is 0 then NotA
should be 1 and vice versa. Similarly
for B and NotB, and for C and NotC.
Our mission is to decide on a set
of logic gates inside the box that
will implement this function. If we
could use any gates we wished, the
solution would be easy peasy lemon
squeezy: just three NOT gates would
be sufficient to do the job.
Unfortunately, for the purposes of
A
B
C
Black Box
NotA
NotB
NotC
Fig.1: A conundrum indeed.
Practical Electronics | November | 2024
this puzzle, we are constrained to
having only two NOT gates at our
disposal. On the bright side, we can
also use as many 2- and 3-input AND
and OR gates as we wish.
Even if you’ve seen this puzzle
before (I may have mentioned this
little brain-teaser years ago here in
PE), try to solve it yourself from first
principles. However impossible it may
seem, there is a real-world solution
(have I ever lied to you before?).
I will present the solution in next
month’s column.
Lest we forget
On the off-chance you are new to
this series (or mayhap your memory
isn’t what it used to be), we are in
the process of creating a clock using
four 7-segment light-emitting diode
(LED) displays, a real-time clock
(RTC) breakout board (BOB) and an
Arduino Uno microcontroller.
We are using this clock as a vehicle
to learn interesting stuff while investigating different techniques for
driving our displays.
The current state of play is that we
are employing a single binary-coded
decimal (BCD) to 7-segment decoder
in the form of a 7448 integrated circuit
(IC) to drive all four of our 7-segment
displays.
We’ve also implemented a homegrown 2-to-4 decoder using a 7408 IC
containing four 2-input AND gates and
a 7404 IC containing six NOT gates
(of which we are only using two).
We are using our decoder to multiplex the displays. That means we are
presenting different values to each
display, switching them on and off
so quickly that our eyes and brains
are tricked into thinking that all the
displays are lit all the time.
As usual, you can download a PDF
of our latest and greatest breadboard,
component, and wiring ensemble
(with a file name of CB-Nov24-brd-01.
pdf). As is typical, all the files mentioned in this column are available
from the November 2024 page of
the PE website: https://pemag.au/
link/ac15
Data sheet induced disorientation
A top view of our BCD decoder IC
is shown in Fig.2. The BCD inputs
( ABCD ) are driven by the Arduino,
while the decoded outputs (abcdefg)
are used to drive the 7-segment displays (via current-limiting resistors).
In our previous column (PE, October
2024), we showed the signal names
associated with pins 3, 4, and 5 as ?
(‘don’t know’) characters. We used a
10kΩ pull-up resistor to place them
in their inactive states, and we omitted them from our truth table and
discussions.
Well, now it’s time to pull aside
the curtains to reveal that the signals associated with pins 3, 4, and
5 are called LT , BI/RBO and RBI ,
respectively.
An overscore, overline, or overbar,
is a horizontal line immediately above
the text. Digital logic designers see
these overscores as indicating activelow signals (ie, they are ‘on’ when low
and ‘off’ when high), which is why we
used pull-up resistors to place these
pins in their inactive-high states.
That’s in contrast to the more intuitive ‘active-high’ scheme, where
‘on’ is represented by a high level,
and ‘off’ a low level.
To be honest, we aren’t going to
use these pins ourselves because we
have other poisson à frire (fish to fry).
Having said that, it’s still worthwhile
for us to take a moment to consider
what they do and how they work
their magic.
If we revisit the data sheet for the
7448 (https://pemag.au/link/abzk), we
find a cornucopia of confusing truth
From
Arduino
See
notes
From
Arduino
B
1
16
VCC
C
2
15
f
LT
3
14
g
BI / RBO
4
13
a
RBI
5
12
b
D
6
11
c
A
7
10
d
GND
8
9
e
To
Displays
Fig.2: A top view of the 7448 BCD decoder.
19
Wow! Look at that!
(they have weak
internal pull-up
LT RBI D C B A
a b c d e f g
resistors), we don’t
0
H
H L L L L
H
H H H H H H L
care what the RBI
1
H
X L L L H
H
L H H L L L L
signal is doing and
2
H
X L L H L
H
H H L H H L H
the outputs will be
decoded versions
3
H
X L L H H
H
H H H H L L H
of the BCD inputs.
4
H
X L H L L
H
L H H L L H H
Actually, that’s
5
H
X L H L H
H
H L H H L H H
not 100% true.
6
H
X L H H L
H
L L H H H H H
Observe the first
7
H
X L H H H
H
H H H L L L L
row (0 in the lefthand column). In
8
H
X H L L L
H
H H H H H H H
this one case, the
9
H
X H L L H
H
H H H L L H H
RBI signal must
10
H
X H L H L
H
L L L H H L H
be pulled high or
11
H
X H L H H
H
L L H H L L H
left floating (aka
12
H
X H H L L
H
L H L L L H H
unconnected).
In a moment, we
13
H
X H H L H
H
H L L H L H H
shall see why this
14
H
X H H H L
H
L L L H H H H
is the case.
15
H
X H H H H
H
L L L L L L L
Now let’s conBI
X
X X X X X
L
L L L L L L L
sider the last three
RBI
H
L L L L L
L
L L L L L L L
rows (the “FuncLT
L
X X X X X
H
H H H H H H H
tion” rows) in the
table, starting with
Fig.3: the complete 74LS48 BCD decoder truth table.
the BI row. This
tells us that if we
tables. The one we are interested in are using the BI/RBO signal as an
is Table T2, which I’ve replicated in input and we pull it down to its
Fig.3 for your delight.
active-low (0) state, we don’t care
Remember that this is an old data what any of the other inputs are doing
sheet that originated in the early because all the outputs driving the
1970s. The L (low) and H (high) values display will be set to 0.
correspond to what, in today’s truth
Since the 7448 is intended to
tables, we would show as 0s and 1s, drive common-cathode displays,
respectively. Also, the X characters this means all the segments on the
indicate ‘don’t care’ values. (In the
display will be off, resulting in a
discussions below, I’m going to use ‘blank’ character, which is why this
0s and 1s instead of Ls and Hs.)
incarnation of the signal is called
Wrapping our minds around this the “blanking input”.
truth table can make our brains
Next, let’s turn our attention to
wobble on their gimbals, so we shall the RBI row. In this case, we are
considering the BI/RBO signal in
take things step-by-step.
Let’s start with the fact that the its role as an output. This row tells
columns associated with the L T us that as long at the LT input is 1,
(“lamp test”) and RBI (“ripple blank- then when the RBI input is 0 and the
ABCD inputs are 0, this will cause the
ing input”) signals are shown on the
BI/RBO signal and all the outputs
inputs side of the table.
In contrast, the column associ- driving the display to be set to 0 (our
ated with the BI/RBO (“blanking ‘blank’ character).
input”/“ripple blanking output”)
In turn, this explains why the RBI
signal appears between the inputs signal had to be pulled high or left
and outputs in the table, because floating in the first row of the table.
it can act as either an input or an It’s only when this signal is 0 and the
output. It manages that trick using ABCD inputs are 0 that the outputs
will be set to 0; if RBI is 1 when the
something called ‘wired-AND’ logic,
but we don’t need to worry about ABCD inputs are 0, the outputs will
cause the display to present a “0”
that here.
The reason LT stands for “lamp test” character.
is that, in addition to LEDs, devices
The final row returns to assuming
of this ilk were originally used to that we are using the BI/RBO signal
control displays that employed small as an input that is being pulled high
or left floating. In this case, placing
incandescent bulbs (aka lamps).
For the first 16 rows of the table the LT signal in its active-low state
(indicated as 0 to 15 in the left-hand will cause all the outputs driving the
“Decimal or Function” column), as display to be set to 1, which means
long as the LT and BI/RBO signals are all the segments on the display will
pulled high or remain unconnected be switched on.
I don’t know about you, but fighting my way through the discussions
above made my head hurt. If you
want to know how I currently feel,
try explaining all this to someone
else.
So, why would the designers of
the 7448 go to all this trouble? Well,
let’s try to look at things from their
point of view.
The power, ground, four BCD
inputs, and seven decoded outputs
come to a total of 13 pins. If they
had used a 14-pin package, which
was very common at that time, this
would have left them with only one
free pin to play with.
They could have used this pin to
implement something like a LT (“lamp
test”) or BI (“blanking input”) function but not both. Instead, they opted
to use a 16-pin package, which was
also very common, and which left
them with three unused pins to play
with.
Part of the deliberations surrounding the creation of the 7448 would
have involved looking at the problems design engineers (the users of
these devices) were trying to solve
at that time.
In many cases, those engineers
wanted to create pieces of equipment
like frequency counters that boasted
a bunch of 7-segment displays. For
the purposes of these discussions, we
will assume those displays had only
five digits, but there could easily be
10 or more.
Now suppose we have a value like
42. On a 5-digit display, if we didn’t
blank the leading zeros, it would
be presented as 00042. In addition
to being aesthetically unpleasing,
this degrades the user’s ability to
quickly comprehend the value being
presented.
As a result, in many cases, we wish
to blank any leading zeros. As we’ve
seen with our own clock project,
this is relatively easy to do if we
are controlling our displays using a
microcontroller.
However, back in the early 1970s
when the 7448 was introduced, microcontrollers and microprocessors
were only just starting to appear on
the scene, and very few engineers
were using such components in their
designs.
Bearing all this in mind, consider
a generic 5-digit display using five
7448s BCD decoders. If all the RBI
inputs to the decoders are pulled
up to their inactive-high states, the
result will be no blanking of leading
zeros (Fig.4a).
By comparison, consider the case
20
Practical Electronics | November | 2024
Decimal
or
Function
Inputs
Outputs
BI / RBO
on the market but a very common
type is the CD4511. This part
number may be followed by a
series of suffixes, but it’s any+ve
+ve
+ve
+ve
+ve
one’s guess as to what they mean.
I asked my friend Joe, who
usually emulates a walking
encyclopedia when it comes to
this sort of thing, but Joe didn’t
7448
7448
7448
7448
7448
know, so he asked his friend
ChatGPT, which responded
RBI
RBI
RBI
RBI
RBI
as follows (I’ve edited this for
size):
(010) 00002
(010) 00002
(010) 00002
(410) 01002
(210) 00102
’B’ usually indicates a buffered version of the device, ‘N’
From processor or other electronics
usually denotes a standard DIP
(dual in-line package) part, ‘P’
(b) Automatic blanking of leading zeros
could indicate a plastic DIP, ‘C’
might be connected to a commercial temperature range, and
‘I’ might indicate an industrial
temperature range.
I must say that these “usually”,
“could”, and “might” qualifiers
RBI
RBI
RBI
RBI
RBI
make that information a little less
helpful than I would have liked.
7448
7448
7448
7448
7448
What the heck. I found a pack
RBO
RBO
RBO
RBO
of 20 CD4511BE devices on
Amazon for around £14 (https://
(010) 00002
(010) 00002
(010) 00002
(410) 01002
(210) 00102
pemag.au/link/ac11), which
seems like a good deal to me.
From processor or other electronics
I have no clue what the ‘E’
suffix might be trying to tell
Fig.4: This shows how to use the 7448 feature that provides automatic blanking of leading zeros.
us, but at least nothing has
Exploded… yet.
If we look at the data sheet
where the RBI input to the most- Meet the CD4511
(https://pemag.au/link/ac12), we disThere are a variety of BCD decoders cover something very interesting.
significant (left-most) BCD decoder is
pulled down to its active-low state,
after which the RBI inputs to any
downstream decoders are fed from
the RBO outputs from their upstream
counterparts (Fig.4b).
In this case, whenever a decoder
sees a 0 on its RBI input and 0000
on its ABCD inputs, it will set its RBO
output to 0 and disable the outputs
driving its 7-segment display.
However, any value other than
0000 on its ABCD inputs will ‘break
the chain’. That is, this decoder’s
RBO output will remain at 1, thereby
resulting in any downstream decoders seeing 1s on their RBI inputs and
displaying any values presented to
them, including zeros.
I don’t know about you, but I
think this is incredibly clever, especially when we consider that all
this functionality was realized using
less than 40 primitive logic gates, as
seen in the logic diagram provided
in the data sheet and presented here
as Fig.5.
Suffice it to say that I’m constantly
amazed by the ingenuity of the design
engineers of yesteryear who managed
to implement sophisticated functionFig.5: The logic gates used in the 74LS48 IC, from its data sheet.
ality using minimal resources.
(a) No blanking of leading zeros
Practical Electronics | November | 2024
21
From
Arduino
See
notes
From
Arduino
B
1
16
VCC
C
2
15
f
LT
3
14
g
BI
4
13
a
LE
5
12
b
D
6
11
c
A
7
10
d
GND
8
9
To
Displays
e
Fig.6: A top view of the CD4511 IC.
Consider the top view of this device,
shown in Fig.6.
Observe that, except for two of its
three control pins, this little rascal is
pin-compatible with the 7448 we’ve been
using. As we see, pin 3 still provides the
LT (“lamp test”) function to turn all the
segments on, and pin 4 also still offers the
BI (“blanking input”) function to turn all
the segments off, thereby allowing us to
show a blank character. However, pin 4
no longer implements the RBO (“ripple
blanking output”) function.
The most obvious difference is exhibited by pin 5. As opposed to performing the role of the 7448’s RBI (“ripple
blanking input”), this pin now acts as
the CD4511’s active-high LE (“latch
enable”) input.
What does this pin do? Well, let’s
ponder the CD4511’s truth table (Fig.7),
along with the segment identification,
numerical designations and resultant
displays (Fig.8), where all is revealed.
From the first row in the table, we
see that when the LT input is in its
active-low state, we don’t care what
values are on the other inputs; all the
outputs will be on. Similarly, from the
second row, we see that when the BI
input is in its active-low state, so long
as the LT input is in its inactive-high
state, we don’t care what values are
on the other inputs; all the outputs
will be off.
When both the LT and BI inputs are
in their inactive-high states, and the LE
input is set to 0, whatever BCD values
are presented to the ABCD inputs will
be decoded and the result presented on
the abcdefg outputs. The BCD codes
0000 through 1001 result in displayed
characters of ‘0’ through ‘9’, respectively.
Unlike the designers of the 7448,
the creators of the CD4511 took the
time and effort to decode the unused
Fig.8: Display
segment
identification and the
possible displays
from the CD4511, as
per the data sheet.
22
input values of 1010
through 1111 into
blank characters.
It’s the table’s last
row that calls for our
attention. Once the
LE input has transitioned from a 0 to a
1, whatever values
were present on the
outputs prior to this
transition are latched
(locked). After this,
any future changes
to the ABCD inputs
will have no effect.
The design of the
CD4511 is clever
on many levels, not
least that, since it was
developed after the
7448, its near pincompatibility with
the 7448 meant that
product developers
could transition between devices with
relative ease.
Multiplex no more
Inputs
Outputs
Display
LE
BI
LT
D
C
B
A
a
b
c
d
e
f
g
X
X
0
X
X
X
X
1
1
1
1
1
1
1
All On
X
0
1
X
X
X
X
0
0
0
0
0
0
0
Blank
0
1
1
0
0
0
0
1
1
1
1
1
1
0
0
0
1
1
0
0
0
1
0
1
1
0
0
0
0
1
0
1
1
0
0
1
0
1
1
0
1
1
0
1
2
0
1
1
0
0
1
1
1
1
1
1
0
0
1
3
0
1
1
0
1
0
0
0
1
1
0
0
1
1
4
0
1
1
0
1
0
1
1
0
1
1
0
1
1
5
0
1
1
0
1
1
0
0
0
1
1
1
1
1
6
0
1
1
0
1
1
1
1
1
1
0
0
0
0
7
0
1
1
1
0
0
0
1
1
1
1
1
1
1
8
0
1
1
1
0
0
1
1
1
1
0
0
1
1
9
0
1
1
1
0
1
0
0
0
0
0
0
0
0
Blank
0
1
1
1
0
1
1
0
0
0
0
0
0
0
Blank
0
1
1
1
1
0
0
0
0
0
0
0
0
0
Blank
0
1
1
1
1
0
1
0
0
0
0
0
0
0
Blank
0
1
1
1
1
1
0
0
0
0
0
0
0
0
Blank
0
1
1
1
1
1
1
0
0
0
0
0
0
0
Blank
1
1
1
X
X
X
X
*
*
*
*
*
*
*
*
*Same as the BCD code applied prior to the 0-to-1 transition on LE
Fig.7: The CD4511 truth table.
We could replicate our existing 7448based clock implementation using a
CD4511 with a single set of currentlimiting resistors. As before, we could
multiplex our four 7-segment displays
using a 2-to-4 decoder and four transistors.
However, the fact that the CD4511
provides latching functionality allows
us to opt for an alternative approach, as
illustrated in Fig.9.
In this case, each 7-segment display
is provided with its own set of currentlimiting resistors and its own CD4511
BCD decoder. The ABCD inputs to all
the CD4511s are connected in parallel.
The LE input to each CD4511 is controlled individually. Our default state
will be to have all the LE signals set
to 1, which means the CD4511s won’t
‘see’ or respond to any activity on the
ABCD inputs.
We are no longer multiplexing our
displays. All we need to do is place
a BCD value on the ABCD signals and
then apply a negative-going (1→0→1 ⍽)
pulse to the LE input associated with
whichever CD4511 we wish to load the
BCD value into.
Different approaches have their own
advantages and disadvantages. The ad-
vantages of the 7448-based multiplexing
technique using a 2-to-4 decoder is that
it requires one BCD decoder, one set of
current-limiting resistors, and (in the
case of four displays) only six of the
Arduino’s pins. The disadvantage is that
the more displays we add, the dimmer
they get because each display is active
for only part of the time.
The advantage of the CD4511-based
latching approach is that all the displays
are on all the time, which means we can
add more displays without any dimming.
The disadvantages are that we need a
separate BCD decoder with currentlimiting resistors for each display and,
in the case of four displays, we’re using
eight of the Arduino’s pins (although
there are ways to reduce that…).
As one final point of interest, observe that Fig.9 shows the LT and BI
inputs being pulled up to their inactive
states. Suppose that – in the fullness of
time – we desire the ability to vary the
brightness of our displays, perhaps to
implement a dimmed nighttime mode.
We could easily implement that function with our CD4511 devices by connecting all their BI inputs together
and driving them using one of the
Arduino’s pulse-width modulation
a
f
g
e
b
c
d
0
1
2
3
4
5
6
7
8
9
Blank
All On
Practical Electronics | November | 2024
3
3
D3
3
D2
3
Connection
D0
D1
No connection
Ground (0V)
5 10 9 1 2 4 6 7
5 10 9 1 2 4 6 7
5 10 9 1 2 4 6 7
5 10 9 1 2 4 6 7
dp g f e d c b a
dp g f e d c b a
dp g f e d c b a
dp g f e d c b a
Display segments
and pin numbers
Resistor Packs
g f e d c b a
g f e d c b a
g f e d c b a
CD4511
CD4511
CD4511
CD4511
LE * * D C B A
LE * * D C B A
LE * * D C B A
LE * * D C B A
g f e d c b a
BCD Decoders
Fig.9: Our new
circuit diagram using
four CD4511 8421
BCD decoders.
* LT and BI inputs pulled-up to inactive states
9 8 7 6
3 4 5 2
Arduino pin numbers
Upper Breadboard
(PWM)-equipped output pins (we introduced the concept of PWM in PE,
March 2023).
In this case, we could use the Arduino
pin directly; that is, we wouldn’t have
to employ any transistors (the use of
which we introduced in PE, January
2024) because the CD4511s handle the
current associated with driving their
displays.
If you have spares of everything, including breadboards, you may decide to
keep your existing clock as-is and start
a new version. Alternatively, if you’ve
splashed your cash only on an as-needed
basis, you will need to remove the components from your current breadboards
before proceeding.
The following instructions assume
we’re building everything from the
ground up.
We’re going to go through this with
our racing sneakers on because we’ve
already done everything discussed here
in one form or another. Let’s begin by
setting up two breadboards as shown in
Fig.10 (the full setup can be found in
the file named CB-nov24-brd-02.pdf).
I’ve decided to use current-limiting
resistors values of 1kΩ in the green
and blue power LED assemblies,
thereby limiting each LED’s current
Practical Electronics | November | 2024
Lower Breadboard
Preparing to rock and roll
GND
5V
Jumpers
16V 100µF Electrolytic Capacitor
From Arduino
Fig.10: Our new breadboard setup.
23
D2
D1
D0
Upper Breadboard
D3
From lower board
Fig.11: Adding the four 7-segment displays.
consumption to only 2mA.
Once you’ve wired everything up,
plug in the USB cable to power-up
your Arduino, then use your multimeter to verify that you are seeing
+5V (give or take) across all the power
and ground rail pairs.
The easiest way to do this is to
apply your multimeter’s probes to
the component leads soldered to
the header pins on the green and
blue LED/current-limiting resistor
assemblies.
Adding the 7-segment displays
Power everything down and add
four 7-segment displays on the lefthand side of the upper breadboard
as illustrated in Fig.11.
Make sure to add four wires connecting pin 3 on each display to the
nearest ground rail (the full setup
can be found in the file named CBnov24-brd-03.pdf).
Before you do anything else, power
it up and use your multimeter to reverify that you are seeing +5V (give
or take) across all the power and
ground rail pairs.
Observe the temporary current-
limiting resistor and flying lead. Remember that we’ve connected pin 3
of each display to the 0V rail. Also
remember that pins 3 and 8 are connected inside each display.
Use the end of the flying lead to
verify that the segments associated
with pins 1, 2, 4, 5, 6, 7, 9, and 10
of each display function as expected,
after which you can power it down
and remove the lead and resistor from
your setup.
As reflected in Fig.11, I used a 330Ω
resistor for this test. Anything between
150Ω and 680Ω would be OK.
The two competing criteria for
the resistor’s value are (a) to be low
enough to light the LED segments
sufficiently without burning out
the LED and (b) to be high enough
to adequately limit the current
should we accidentally probe pins
3 or 8, thereby shorting our 5V and
0V rails.
tors (we will consider the rationale
behind this value in a moment).
One option is to use 4 × 8 = 32 individual resistors, but that would be
a pain. Another possibility is to build
four 8-resistor BOBs (we discussed
how to build these in PE, July 2024).
A third option – the one I went
for – is to use four pre-built resistor
packs, each presented in a 16-pin
package containing eight isolated
270Ω resistors, as illustrated in Fig.12.
These components are offered by
various manufacturers, such as the
Bourns 4100R Series (https://pemag.
au/link/ac13). They are available
from most major component vendors, like Digikey (https://pemag.
au/link/ac14).
Add wires connecting pin 1 on each
resistor pack to the nearest ground
rail (the full setup can be found in
the file named CB-nov24-brd-04.pdf).
We are doing this because the other
side of these resistors (pin 16 on the
packs) are going to be connected to
the decimal point (“dp”) segments on
the displays. Since we aren’t using
these segments in this implementation, connecting these resistor pack
pins to ground will ensure those
segments remain off.
Once again, power everything up
and use your multimeter to re-verify
that you are seeing +5V (give or take)
across all the power and ground rail
pairs.
Cunning calculations
Fig.12: Adding the four resistor networks.
So, why did we decide to use
270Ω for our current-limiting resistors? From earlier columns we know
that the red LED segments in our
displays can support up to 20mA,
which we could achieve using 150Ω
resistors.
Your first guess might be that it’s
the current sourcing capability of the
CD4511s that’s the problem. However,
when we look at the CD4511 data
sheet, we see it proudly proclaiming:
“High current sourcing outputs (up
to 25mA)”.
The real reason is limitations in
our power source. I’m assuming that
you, like me, are using a USB cable to
power your Arduino Uno, which is,
in turn, powering your breadboards.
I’m also assuming you are using a
USB 2.0 port, which can deliver up
to 500mA at 5V, so this is the limiting factor.
I had a quick Google while no
one was looking to discover that an
Arduino Uno R3 has an average current consumption of 50mA.
As was previously noted, with
their 1kΩ current-limiting resistors, each of our four green and blue
24
Practical Electronics | November | 2024
RP2 270Ω
Our next task is to add the currentlimiting resistors to the right-hand
side of the upper breadboard. In this
case, we are going to use 270Ω resis-
RP1 270Ω
RP0 270Ω
Upper Breadboard
RP3 270Ω
Adding the current-limiting resistors
Practical Electronics | November | 2024
CD4511
CD4511
CD4511
CD4511
Lower Breadboard
power LED assemblies consumes
only 2mA, which equates to 8mA
in all. Our DS3231 real-time clock
(RTC) consumes a negligible amount
of current, but let’s assume 1mA to
be on the safe side.
“What about our four CD4511 devices?” I hear you cry. Well, the term
“quiescent” means “calm”, “inactive”
or “dormant”. In electronics, “quiescent current” refers to the amount
of current being consumed by an
IC when it is enabled but not doing
much.
If we return to our trusty data sheet,
we see that the quiescent current for a
CD4511 is 20µA at 25°C. This means
that, even if we were using five of
these devices, their total quiescent
current would be only 100µA or
0.1mA. Again, let’s say 1mA to be
on the safe side.
So, excluding our 7-segment displays, our total current consumption
is 60mA. Let’s also hold 90mA in
reserve to power other functions –
like a buzzer, perhaps – in the future,
which means we have 500mA – 60mA
– 90mA = 350mA remaining to power
our displays.
Since we aren’t using the “dp”
segments on our displays, our worstcase scenario would be for all four
displays to be presenting ‘8’ characters
(ie, “88 88”), each of which lights
seven segments, resulting in 4 × 7 =
28 segments lit.
If we felt like being clever (or if we
were desperate), we might note that,
in a 24-hour mode, our hours digits
will display values of “00” through
“23”. Alternatively, in a 12-hour
mode, they will display values of
“01” through “12”.
This means that the most-significant
hours digit only ever displays “0”,
“1”, or “2”, with 6, 2, and 5 segments
lit, respectively (referring to Fig.8).
Meanwhile, the least-significant hours
digit may be used to display “0”
through “9”, of which “8” lights all
seven segments.
Similarly, our minutes digits will
display values of “00” through “59”.
The worst case for the most-significant
minutes digit is “0”, which lights six
segments, while the worst case for
the least-significant minutes digit is
“8”, which lights all seven.
Putting all this together, we could
argue that, if we only ever used our
displays to implement a clock, our
worst-case scenario would occur at
eight minutes past eight (“08 08”),
which would light 6 + 7 + 6 + 7 =
26 segments.
On the other hand, it’s possible to
be too clever (“you’re so sharp you’ll
cut yourself”, as my dear old grannie
Fig.13: Adding the four BCD decoder chips.
used to say). Suppose we decided
to use our displays to present other
information. In this case, “88 88”,
lighting 28 segments could be a possibility, so let’s go with this.
Based on our self-imposed limit of
350mA, this means each segment has
350mA/28 = 12.5mA at its disposal.
Since the red segment LEDs have a
forward voltage drop of 2V, we can
calculate our ideal current-limiting
resistor values as (5V – 2V) ÷ 0.0125A
= 240Ω. The closest (and next highest)
value in the Bourns series is 270Ω,
so that’s what I used.
A pert little poser
a total allocation of 350mA to power
all four of our 7-segment displays?
We will contemplate the conclusion
to this conundrum in next month’s
column. For now, however, onwards
and upwards…
Adding the CD4511s
Ensure that everything is powered
down, then add the four CD4511
BCD decoders to the right-hand side
of the lower breadboard, as shown
in Fig.13.
As part of this, add wires connecting pin 8 on each CD4511 to
the nearest ground rail, along with
wires connecting pin 16 on each IC
to the nearest 5V rail. Also add a
0.1µF ceramic capacitor for each IC
as shown, along with a 10kΩ pull-up
resistor for each.
Once side of each of these resistors
should connect to 5V, while the other
side connects pins 3 and 4 (the LT
and BI inputs) of its respective IC.
The latest incarnation of the complete
setup can be found in the file named
Why should I do all the work? I have
a pert little poser for you to ponder.
Assume our displays are only ever
going to be used to implement a clock.
Also assume that this clock can support both 12- and 24-hour modes.
Now suppose that, in addition to
everything we’ve discussed above, we
decide to suppress any leading zeros
in the most-significant hours digit
(we introduced
this concept in
Online resources
PE, August 2024).
For the purposes of this series, I’m going to assume
In this case,
that you are already familiar with fundamental conwhat would be
cepts like voltage, current and resistance. If not, you
the maximum
might want to start by perusing and pondering a short
number of segseries of articles I penned on these very topics – see:
ments we might
https://pemag.au/link/ac16
see active at the
Similarly, I’ll assume you are no stranger to soldersame time?
less breadboards. Having said this, even if you’ve used
And, based on
these little scamps before, there are some aspects to
this, what would
them that can trap the unwary, so may I suggest you
be the ideal value
feast your orbs on a column I wrote just for you – see:
for our currenthttps://pemag.au/link/ac17
limiting resistors
Last, but not least, you will find a treasure trove of
to obtain the maxresources
at the Arduino.cc website, including examimum possible
ple programs and reference documentation.
segment current
value, assuming
Cool bean Max Maxfield (Hawaiian shirt, on the right) is emperor of
all he surveys at CliveMaxfield.com – the go-to site for the latest
and greatest in technological geekdom.
Comments or questions? Email Max at: max<at>CliveMaxfield.com
25
Display pin numbers
Display segments
Upper Breadboard
7 a
6 b
4 c
2 d
1 e
9 f
10 g
5 dp
D0
RP3 270Ω
RP2 270Ω
RP1 270Ω
RP0 270Ω
Probe
DO NOT Probe
Fig.14: Connecting the first 7-segment display.
Connecting the Arduino
Until now, we’ve been using only
the 0V (GND) and +5V pins from the
Arduino. Now it’s time to connect the
digital outputs driving our clock as
shown in Fig.15 (a full version of the
setup is available in the file named
CB-nov24-brd-07.pdf).
Observe the BCD and LE probe
points. As you may recall, we dis-
Power everything down, then connect pins 9 through 16
of resistor pack RP0 to
display D0 as shown in
Fig.14. Also add a temporary current-limiting
resistor and flying lead
as shown.
Power-up the Arduino, touch the end of
the flying lead to pins
CD4511
8, 7, 6, 5, 4, 3, and 2
of resistor pack RP0,
3
and observe segments
a , b , c , d , e , f and g
light up on display D0,
respectively.
The reason for the
current-limiting resistor is to prevent problems if you accidentally touch pin 1 on
BCD probe points
RP0, thereby shorting
the 0V and 5V rails.
D C B A
Once you’ve verified
3 2 1 0
the segments, you can
3 2 1 0
power everything down
and remove the lead
LE probe points
and resistor from your
26
CD4511
CD4511
2
1
CD4511
2
1
0
0
3
Lower Breadboard
Wiring up the first display
cussed the concept of logic probes
in a previous issue (PE, August
2024) If you haven’t already done
so, use a half-size breadboard to
create four such probes as illustrated
in Fig.16.
Connect probes 0, 1, 2, and 3 in
Fig.16 to the corresponding ABCD
BCD probe points shown in Fig.15.
Remember to connect the 0V and
5V wires connecting the logic probe
breadboard to the main clock breadboards.
setup (you can see a full drawing in
the file named CB-nov24-brd-06.pdf).
Fig.15: Connecting
the Arduino data
pins to the circuit.
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
TX-1
RX-0
CB-nov24-brd-05.pdf.
As usual, power everything up and
use your multimeter to re-verify that
you are seeing +5V (give or take)
across all the power and ground rail
pairs. Also, check that you are seeing
+5V between pins 8 and 16 on each
IC. As well, verify that you are seeing
+5V between pin 8 and both of pins
3 & 4 on each IC.
Arduino
DIGITAL IN/OUT (PWM ~)
Practical Electronics | November | 2024
From other breadboards
ValBcd
Inputs to BCD
D
C
B
A
0
1
2
3
4
5
6
Mode/
Cycle
LE Signals
D3 D2 D1 D0
Setup
0
1
2
3
Fig.18: The BCD LE signals.
8
9
3
2
1
0
RP0 270Ω
Fig.17: The expected BCD
data values as shown on the
logic probes when running
the test program. If you get
this sequence, everything is
working correctly so far!
Upper Breadboard
7
Stop! Before you power everything
up, double-check that you’ve connected 0V to 0V and 5V to 5V. You’d
be surprised how easy it is to slip up
here. In the best case, reversing the
supply polarity will mean it won’t
work, but it sometimes is possible to
do some damage this way. So it’s best
to make a habit of double-checking
this sort of thing before you proceed.
Do you remember the simple program we created in our previous
column (PE, October 2024)? I’m talking about the one than repeatedly
counts from 0 to 9, pausing for a
second between counts while it presents the current count value on the
Arduino’s BCD outputs.
Well, let’s take this program and
tweak it a little to accommodate things
like setting the CD4511’s LE input to
logic 1. You can find a copy of this
updated program in the file named
CB-nov24-code-01.txt.
When you power up your Arduino
and load and run this program, you
should see the BCD count sequence
being displayed on your logic probe
board as illustrated in Fig.17.
Now let’s use this program as a
starting point to create a new version that loops around applying a
negative-going (1→0→1 ⍽ ) pulse
to each of the CD4511’s LE inputs
in turn. A copy of this new code
is available in the file named CBnov24-code-02.txt.
Power everything down, remove
probes 0, 1, 2, and 3 in Fig.16 from
the BCD probe points shown in
Practical Electronics | November | 2024
Fig.15, then re-connect them to the
LE probe points shown in Fig.15.
When you power everything up and
load and run the new program, you
should be presented with the sequence illustrated in Fig.18 on your
logic probe board.
CD4511
Lower Breadboard
Fig.16: Making our four basic logic probes.
Finishing wiring up display 0
We are so close to finishing that I can
taste it. Power everything down and connect the right-most CD4511 to resistor
pack RP0 as illustrated in Fig.19. A full
version of the latest breadboard setup is
available to download in the file named
CB-nov24-brd-08.pdf.
Now, let’s create a new version of
our program that loops around generating a random number between 0
and 9, presenting this number to the
BCD inputs to our CD4511, pulsing the
LE input low to load this value into
the chip, and pausing for a second
before doing it all again.
We’ll also include a test to ensure
that the new random number isn’t the
same as the old one. A copy of this
new program is available in the file
named CB-nov24-code-03.txt.
When you look at this program,
you’ll see that, even though we currently have only one CD4511 decoder
and one 7-segment display fully
wired up, the program attempts to
load random values into all four
decoders.
The reason for this is so that we
don’t have to modify the program
when we get around to connecting
our remaining displays.
Fig.19: Connect the decoder to the resistors.
Power everything up, load and run
our new program and observe the
random values appearing on display
D0 (I could watch this running for
hours!).
Connecting displays 1, 2, and 3
It’s time to add the remaining wires.
Power everything down, then connect
resistor packs RP1, RP2, and RP3 to
displays D1, D2, and D3, respectively.
Next, connect the resistor packs to
their corresponding CD4511s.
It’s easy to get excited at this point
– I know I did – resulting in me forgetting to add the wires connecting
the ABCD inputs on the right-most
CD4511 to the ABCD inputs on the
remaining CD4511s.
I felt like a silly sausage when things
failed to work as planned. It took
me a while to realize what I’d done
wrong (or neglected to do right), but
I’m sure this won’t happen to you.
If, unlike me, you manage to get
the wiring right the first time, you
will end up with a configuration like
27
To Display D2
To Display D1
To Display D0
RP3 270Ω
RP2 270Ω
RP1 270Ω
RP0 270Ω
CD4511
CD4511
CD4511
CD4511
Fig.20: Connecting the remaining displays to our four CD4511 BCD decoders.
Vin
Components for Part 19
Prototyping boards
Kit of popular SN74LS00 chips
Components for Part 20
16V 100µF electrolytic capacitors
Ceramic capacitors (assorted values)
Components for Part 22
SN74LS48N BCD Decoders
16-pin resistor pack (8 × 390Ω)
Components for Part 24
4 × CD4511 BCD Decoders
16-pin resistor pack (8 × 390Ω)
28
https://bit.ly/3UMkcZ1
https://bit.ly/3wqgzyv
https://bit.ly/44LzpNa
https://bit.ly/4bEAUiv
https://bit.ly/3zT18jx
https://bit.ly/4d0ISDz
https://bit.ly/3yzWl6k
https://bit.ly/46HZ2PQ
SCL
BAT SQU
GND SDA
32K
RST
To decoders
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
TX-1
RX-0
This is it, the final step! Power
Arduino
Connecting the RTC
everything down and add the
DS3231 RTC BOB to the left-hand
side of the lower breadboard as illustrated in
Fig.21. A full drawing
of our final setup can be
found in the file named
CB-nov24-brd-10.pdf.
DS3231
Remember to add the
power and ground wires
as shown. Also, remember
Lower Breadboard
Lower Breadboard
From Arduino
that shown in Fig.20 (a full drawing can be found in the file named
CB-nov24-brd-09.pdf).
Remember that our current program is
still loaded in the Arduino. This means
that when we power everything up
again, we should see different random
values appearing on each of our displays.
to add the I2C communications bus wires between the RTC and the
Arduino as shown (SCL
= clock, SDA = data).
As we discussed
deep in the mists of
time, the two Arduino
pins we’re using are
connected in the board
to its A4 and A5 analog
inputs. That means we
can’t use the A4 and A5
pins for anything else
if we’re using them for
the I2C protocol.
All that remains
is to modify our old
7448-based clock program to reflect our new
CD4511-based implementation. I just did so.
You can download
and peruse my version
of this code at your leisure, in the file named
CB-nov24-code-04.txt.
All I can say is I’m
watching my clock perform its magic and I’m
squealing with delight
(well, I’m squealing
inside my head because
I don’t want to worry
my wife).
This should keep you
busy until next time
when… but no… let’s
not let any spoilers
ruin our excitement!
As always, I welcome
your insightful comments, penetrating
PE
questions and any suggestions.
Upper Breadboard
To Display D3
DIGITAL IN/OUT (PWM ~)
Fig.21: Adding the real-time clock (RTC).
Practical Electronics | November | 2024
The CD4511-based clock happily running.
This is a good demonstration of why PCBs
took over from point-to-point wiring in
commercially-produced electronics!
Teach-In 8 CD-ROM
Exploring the Arduino
EE
FR -ROM
CD
ELECTRONICS
TEACH-IN 8
FREE
CD-ROM
SOFTWARE
FOR
THE TEACH-IN
8
SERIES
FROM THE PUBLISHERS OF
This CD-ROM version of the exciting and popular Teach-In 8 series
has been designed for electronics enthusiasts who want to get to
grips with the inexpensive, immensely popular Arduino microcontroller,
as well as coding enthusiasts who want to explore hardware and
interfacing. Teach-In 8 provides a one-stop source of ideas and
practical information.
The Arduino offers a remarkably effective platform for developing a
huge variety of projects; from operating a set of Christmas tree lights
to remotely controlling a robotic vehicle wirelessly or via the Internet.
Teach-In 8 is based around a series of practical projects with plenty of
information for customisation. The projects can be combined together
in many different ways in order to build more complex systems that can
be used to solve a wide variety of home automation and environmental
monitoring problems. The series includes topics such as RF technology,
wireless networking and remote web access.
PLUS: PICs and the PICkit 3 – A beginners guide
The CD-ROM also includes a bonus – an extra 12-part series based around the popular
PIC microcontroller, explaining how to build PIC-based systems.
£8.99
INTRODUCING THE ARDUINO
• Hardware – learn about components and circuits
• Programming – powerful integrated development system
• Microcontrollers – understand control operations
• Communications – connect to PCs and other Arduinos
PLUS...
PIC n’MIX
PICs and the PICkit 3 - A beginners
guide. The why and how to build
PIC-based projects
Teach In 8 Cover.indd 1
04/04/2017 12:24
PRICE
£8.99
Includes P&P to UK if
ordered direct from us
SOFTWARE
The CD-ROM contains the software for both the Teach-In 8 and PICkit 3 series.
ORDER YOUR COPY TODAY!
JUST CALL 01202 880299 OR VISIT www.electronpublishing.com
Practical Electronics | November | 2024
29
![]() ![]() |