This is only a preview of the November 1987 issue of Silicon Chip. You can view 42 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Articles in this series:
Items relevant to "1GHz Digital Frequency Meter":
Articles in this series:
Items relevant to "Your House Wiring Could Kill You":
Articles in this series:
Articles in this series:
|
')
DIGITAL
FUNDAMEN'I'ALS.
•
.
I
This is the first in a series of short courses
that will quickly teach you the basics of
digital electronics. We 'II begin by
considering binary and· hexadecimal
numbers.
.. j
•
.JI
I
LESSON 1: BINARY DATA
By Louis E. Frenzel, Jr.
.1
r
,
...
....
I
Digital logic circuits use on-off, pulse-type signals to
process and communicate information. Such circuits
are now found in virtually all types of electronic
equipment. This series of self-instructional lessons introduces the subject of digital electronics. It will show
you how digital circuits operate.
What you can expect to learn in this article is this:
the difference between analog and digital methods;
why digital methods are used; binary data representation; converting between binary and decimal numbers;
understanding hexadecimal, BCD and ASCII data;
how to represent binary information with electronic
signals and components; and exactly what is serial
and parallel data.
analog and digital. The terms analog and digital r efer
to the types of signals and circuits used in electronic
processes.
An analog signal is one that varies smoothly and
continuously. Fig.1 shows several kinds of analog
signals. A constant positive DC voltage level of 6 volts
is illustrated in Fig.lA. An alternating current (AC)
signal known as a sinewave in shown in Fig.lB. It has
CONSTANT OC
VOLTAGE
+6V----'/"--r----
VOLTAGE
VALUE
Electronic applications
The three basic applications for electronics are
communications, computation and control.
In communications, we transmit information from
one place to another by wires or radio techniques.
In computation, we process data. Numerical, text
and o,ther types of information are manipulated with
mathematical or logic techniques to create new information. Computers, of course, are our data
processors.
Control refers to automating industrial and other
processes. That means using electronics methods to
operate equipment remotely and/or automatically.
All three areas of electronics are well known and
you can probably name numerous examples of each.
Analog and digital
There are two basic methods used in implementing
electronic communications , computation, and control
processes. And there are two basic methods of
representing information. Those two methods are
O V ' - - - - - ' - -- ----TIME
(b)
(a)
RANDOM ANALOG SIGNAL
(c)
Fig. 1 - Three sample analog voltages: A, constant
DC voltage typical of that produced by a voltage
regulator circuit; B, sinewave signal typical of an
unmodulated AM broadcast station or signal
generator; and C, random analog signal that may be
the plot of temperature, light intensity during a
cloudy day, or just about any type of non-periodic event.
NOVEMBER1987
83
tional weights as units, tens, hundreds, thousands, etc.
a peak value ± 3 volts and a peak-to-peak value of 6
Each position is a successively larger power of 10: 10
volts.
A randomly varying analog signal is shown in
to the O power = 10° = 1; 10 to the 1st power = 10 1
Fig.lC. Although the latter may appear to be random,
= 10; 10 to the 2nd power = 10 2 = 100; 10 to the 3rd
power = 10' = 1000; etc. The simple illustration
it could be a track of temperature during a 24-hour
below shows how any decimal number is structured
period, a section of a voice signal, or the rise and fall
and evaluated.
of a local tide.
The other type of electronics signal is a
digital one. Instead of a smooth, continuous
Thousand
Hundreds
Tens
Units
variation, a digital signal is made up of clearly
1
9
8
5
1 X 1000 = 1000 9 X 100 = 900 8 X 10 = 80 5 X 1 = 5
defined discrete voltage or current levels with
abrupt changes between them. The most
1,000
900
80
5
= 1985
+
+
+
common type of digital signal is the two-level or
binary-pulse type signal shown in Fig.2. In
In digital circuits, we use binary numbers rather
Fig.ZA, the signal switches between the O and + 5V
levels. In Fig.2B, the two switched states are - 12 and
than decimal numbers. In the binary number system
+ 12 volts.
only two digits, 0 and 1, are used. For example, the
While digital signals can have more than two
binary number 1010011 represents the decimal
discrete levels, typically they do not. The term digital
number 83. The digits O and 1 are called binary digits
is virtually synonymous with the term binary which
or bits. Like the decimal number system, the binary
implies two levels.
system uses a positional or weighted method. Instead
of weights of some power of 10, the position weights in
Representing information
the binary number as some power of 2. Thus we have
Digital and analog signals typically represent infor2 to the O power = 2° = 1; 2 to the 1st power = 21 =
mation to be communicated or processed. For exam2; 2 to the 2nd power = Z2 = 4; 2 to the 3rd power =
ple, the analog voice signal generated by a microphone
Z3 = 8; etc. Note that each successively higher weight
might be modulated and transmitted by radio. Or the
is twice that of the preceding weight.
binary input from a keyboard may be processed by a
The structure of a typical binary number is shown
digital computer to enter your savings deposit. Those
below.
signals, representing information (data), are then processed to accomplish some useful end result. Analog
Weight
64
16
4
2
1
32
8
1
Number
1
1
0
1
signals are processed by analog (linear) circuits.
0
0
LSB
MSB
Binary data is processed by digital logic circuits.
At one time, virtually all electronic signals and pro64 + 0 + 16 + 0 + 0 + 2 + 1 = 83
cesses were analog. However, with the development of
the digital computer, digital methods became more
Notice that the binary number is usually made up of
popular and widely used. Then, semiconductor
a number of bits; in this case, eight. Each bit may be
technology gave us digital integrated circuits and the
binary O or binary 1. The weight of each position is inmicroprocessor, both of which have revoltionised elecdicated. Note particularly the least significant bit
tronics technology. Today, digital methods are prefer(LSB) with the lowest position weight and the most
red because of their ease of implementation, low cost,
significant bit (MSB) with the highest position weight.
reliability and overall effectiveness. While digital
The question is: how do you determine what decimal
techniques will never replace analog techniques comquantity is represented by a given binary number?
pletely, the use of digital techniques has grown continuously over the years and today virtually dominates
Converting a binary number to
in most electronics applications.
Decimal verses binary numbers
The information or data to be communicated, processed, or used for control purposes is usually
numerical in nature. For that reason, the main
language of digital
techniques involves
Weight 32
16
numbers that can also
Number 1
1
represent letters of the
1 X 32 = 32
X 16 = 16
alpha bet and even
32
t16
+
special control
features.
You are familiar with the decimal number system
where we use the digits O through 9 in various combinations to represent any quantity. The decimal
number system is based upon a method of giving
numerical weights to each position or digit in the
number. Recall that we usually refer to those posi84
SILICON CHIP
its decimal value
Evaluating a binary number means determining its
decimal value. The process is similar to that used in
evaluating any other decimal number. The illustration
below shows what we mean.
8
1
X 8 = 8
0
8
+
X
4
2
1
0
4 =0
1
2 =2
0
1=0
0
X
+·
2
0
+
X
0
--
58
To determine the decimal value of a given binary
number, all you do is multiply each bit by its position
weight, then sum all those values. Looking closely at
the process above, you can see that those bit positions
with a zero in them actually have no effect on the outcome. For that reason, they can be ignored. You can
OV
OFF
ON
OFF
-12V
--
W
00
0000
0001
0010
0011
4
5
0100
0101
0110
0111
6
7
Fig.2 - Two commonly used digital signals used in
electronic circuits. The left one (A) is from a singleended output such as from a 4000 chip series; and B,
the output from a balanced op amp that uses ± 12V DC
rails.
quickly evaluate the binary number by simply adding
up the weights of those positions that contain a binary
1 bit. The secret is in remembering the weight of each
position, and that's easy.
Converting a decimal number to its binary
equivalent
Another procedure that you will find handy is that
for converting a decimal number into its binary
equivalent. The process is essentially that of dividing
the original number by two, then dividing the resulting
quotient by two continuously until a quotient of zero is
obtained. The remainders resulting from each of those
divisions form the binary number.
Division
Remainder
84 .,_
42-'21 -'10 _,_
0 LSB
0
1
0
1
0
5 .,_ 2 = 2
2 _,_ 2 = 1
1 .,_ 2 = 0
Binary
0
1
2
3
Therefore, 84
= 1010100
1 MSB
Maximum decimal value
A binary number, or binary word as it is sometimes
called, usually consists of a fixed number of bits when
used within one confined system. With that number of
bits you can represent a certain maximum value. The
same is true of decimal numbers. With a given number
of digits, some maximum value can be represented.
For example, with four digits, the maximum decimal
value is 9999. With a 4-bit binary number. the maximum value is 1111. The question is: what's the maximum decimal value for a given number of binary bits?
This value can be computed using the simple formula
shown below:
Hexadecimal
Binary
0
1
2
0000
0001
0010
0011
0100
0101
0110
0111
6
7
1
1100
1101
1110
1111
To represent larger and larger decimal values,
binary numbers with more bits must be used. And, as
the binary numbers get larger, they become increasingly difficult to work with. For example, it takes 20
bits to respresent one million (1,0448,576 to be exact).
It's tough enough to remember a long decimal number,
but just imagine the problem of remembering a very
long binary number.
That task is made easier by the use of a special
shorthand known as hexadecimal notation which uses
hexadecimal numbers. Hex means six and, of course,
decimal means ten; therefore hexadecimal means sixteen. Hexadecimal refers to a special notation as well
as a number system using a total of 16 digits. Those
digits are the decimal numbers 1 through 9, and the
letters A through F. Each digit corresponds to its
equivalent 4-bit binary code as shown in Fig.4. The
idea is to use the hex digit corresponding to each 4-bit
where M is the maximum decimal value and n is the
number of bits. To illustrate the use of the formula,
let's determine the maximum decimal value you can
represent with 4 bits. This is done as shown below:
-
12
13
14
15
Hexadecimal notation
4
5
24
10
11
1000
1001
1010
1011
word with their decimal equivalents. There are sixteen values, 0 through to a maximum of 15. Remember
that 0 (zero) is a number and it is one of 16 values that
can be represented by a 4-bit binary number.
Eight bits is a very common binary word size. With 8
bits, you can represent decimal values up to 28 - 1 =
255 . 8-bit words or numbers are so widely used that
they have been given a special name. An 8-bit number
or word is called a byte. You will also hear the term
nibble to refer to 4-bit words.
3
=
Binary
Fig.3 - The decimal/binary equivalents are listed here
for the first 16 numbers. Keep in mind that 0 (zero) is a
number.
M = 2" - 1
M
Decimal
8
9
ON
~TIME
2 = 42
2 = 21
2 = 10
2 = 5
Decimal
=
(2x2x2x2) - 1
=
16 - 1
=
15
Fig.3 shows all possible combinations of a 4-bit
Hexadecimal.
8
9
A
B
C
D
E
F
Binary
1000
1001
1010
1011
1100
1101
1110
1111
Fig.4 - The hexadecimal/binary equivalents are listed
here for the first 16 numbers. Compare this illustration
to that of Fig.3. When you use the hexadecimal number
system for a short while, you will begin to appreciate
the convenience of the system.
NOVEMBER 1987
85
segment of a long binary number. The result is a
shorter hexadecimal number that is far easier to
remember and apply.
To convert a binary number into a hexadecimal
number, all you do is divide the long binary number into 4-bit segments starting with the LSB on the far
right. Then, you replace each of those 4-bit segments
with the corresponding hex digit from Fig.4. The result
is illustrated below.
B
1
~
0
~
0
MSB
B t1
1
UP (1)
DOWN (D)
1
LSB
+5V
MSB
0 (DV)
0 (DY)
1 (+5V)
LSB
1011 /0001 /0111 /0010/1101
B
1
7
2
D
Changing a hexadecimal number back into its
binary equivalent is also easy. You simply reverse the
above process; ie, you replace each hexadecimal digit
with its binary equivalent and string all of the
resulting bits together as shown below.
6
F
9
0
5
0110/1111 /1001 /0000/0101
Binary coded decimal (BCD)
Besides the standard binary notation for representing a decimal number, some special variations are
also widely used. The most common is binary coded
decimal (BCD). The BCD system is essentially a hybrid
of both the binary and decimal systems. It uses binary
digits, but a separate 4-bit group is used to represent
each decimal digit individually. The BCD code is the
same as the first ten digits (0 to 9) of the hexadecimal
code in Fig.4.
To represent a given binary coded decimal value,
you simply use the 4-bit group representing each digit.
An example is given below using the decimal number
4891:
4
8
9
1
0100 1000 1001 0001
A space is left between each 4-bit group to denote
separate digits.
BCD is a widely used method as it greatly simplifies
the conversion process between binary and decimal. It
is also an aid in improving communications between
man and machine. Where a human operator must interface with a piece of communications equipment,
BCD is normally employed. Keyboards generally produce BCD outputs. BCD information from a piece of
electronic equipment is normally used to drive the
7-segment decimal displays that are so popular.
ASCII
A special form of BCD is widely used in computers.
Known as the American Standard Code of Information Interchange (ASCII, pronounced ass-key), it normally uses 7-bits to represent not only the decimal
digits Oto 9, but also letters of the alphabet (both upper and lower case), punctuation marks, and special
symbols. Some examples of ASCII designations are
shown below.
8
L
J
?
Bell
86
011
100
110
011
000
1000 (Last 4-bits same as BCD)
1100
1010
1111
0 111 (This code rings a bell or sounds a tone.)
SILICON CHIP
1 (+5V)
•
1 (+5V)
•
.,.
Fig.5 - A simple manual switching circuit can be
constructed and used to demonstrate binary data for
decimal numbers O to 31.
The ASCII code is widely used in computers. It is the
main code used in communicating information between computers and peripheral devices. For example,
virtually all printers produce hard copy output from
ASCII input supplied by the computer. ASCII coded
data is also what is normally transmitted and received
by a modem in digital communications.
Representing binary numbers
with hardware
The reason for using the binary number system in
digital equipment is that it is easier to implement
binary electronic circuits than it is decimal circuits.
Decimal circuits would have to represent at least 10
states. With binary, only two states are required. As a
result, any electronic component that can assume two
states can be used for binary representation. The
result is smaller, simpler, cheaper and faster circuits.
The most obvious component to represent a bit is a
switch. A switch can be off or on and, therefore, can
represent O and 1.
Fig.5 shows how a group of slide switches is used to
produce binary data. The number being displayed on
those switches is 10011 , whose decimal equivalent is
19. The illustration also shows what the schematic
diagram may look like. When the slide switch is down,
it is closed. The voltage at the output, therefore, is 0
volts or ground potential. That typically represents a
binary O (sometimes referred to as a logic low). When
the switch is up, it is open. As a result, the output is
+ 5 volts as seen through the resistor. This represents
a binary 1 (or a logic high).
Another obvious choice for a component to repre'
I
,
ON: 1 - Q -
,
OFF:O
''
0
-a- o -a- o -a.·:- o
I
I
0
=
42
Fig.6 - A six-unit light emitting diode (LED) display can
be used to display binary data for decimal numbers
from O to 63. The most significant bit is at the display
left side.
FOUR BITS OF
PARALLEL DATA
0
'""'
SOURCE
OF DATA
I I
I I
I I
0
DESTINATION
OF DATA
ov-
1
....,
1.
+sv-
1
Fig. 7 - 4-bits of parallel data from a circuit like that in
Fig.5 can be transmitted over four lines at the same
time. The destination could be another chip on the same
circuit board, a remote printer, or some other devices.
sent binary data is a simple light. Both incandescent
lamps and light emitting diodes (LEDs) are used to
display binary information. An off (unlit) display
represents a binary 0, while an on (lit) display
respresents a binary 1. Fig.6 shows how a typical
binary LED display might look.
The key component in any electronic circuit is the
transistor which is used in digital circuits as a switch.
A transistor can be on (conducting), or off (nonconducting). Those are natural conditions
representing binary 0 and binary 1 states.
Parallel and serial data
Binary data in digital circuits is generated, processed, displayed, or communicated. There are two ways
in which those things are done: parallel and serial.
Parallel binary data is where all bits of a word are
generated, processed, transmitted or displayed
simultaneously. The data generated by the switches in
Fig.5 and that displayed in Fig.6 are both examples of
parallel binary data. All bits of the word occur at the
same time and can be transmitted from one place to
another as shown in Fig. 7.
t
-
START
BIT
If.-ONE
PERIOD
---l-TIME
STOP
Fig. 8 - An 8-bit serial binary word displayed against
time.
The other form of binary data is serial. Serial
binary data is transmitted or processed one bit at a
time. The bits occur sequentially and, therefore, each
is handled separately in order. A serial data word is
shown in Fig.8. The binary 0's and 1's are represented
by voltage levels. Note that each bit occurs for a fixed
length of time. If each bit lasts one millisecond, then it
will take a total of 8 milliseconds to transmit and process one byte.
As you can see, the main disadvantage of serial
data is the long time required to transmit or process it.
On the other hand, serial data is far less expensive to
deal with. Only one set of processing circuits is required to transmit it from one place to another.
Despite its low-speed disadvantage, serial data is
widely used. It is perfectly suitable for many digital
applications.
In Lesson 2 next month, we'll take a look at the five
basic digital logic elements and learn how to use their
truth tables.
Reproduced from Hands-On Electronics by arrangement.
Gernsback Publications, USA.
©
SHORT QUIZ ON DIGIT AL FUNDAMENTALS
1 . The three primary eletronics applications are
_ _ _ _ _ ,and _ __ __
2 . a. Smooth ,
continuous
signals
are
called
5 . An eight-bit number is called a _ _ _ _ _ __
6 . Write the BCD equivalent of
2805 . - - - - - - - - --
the number
----
b. Digital signals usually have _ _ (how many?)
levels.
7 . The special code used to transmit letters as well
as numbers is called _ _ _ __ _ _ _ _ __
3 . Refer to the LED binary display above . What
decimal number is represented? _ _ __ _ __
8 . The maximum decimal value you can represent
with 12 bits is _ _ _ _ _ _ _ _ _ _ _ __
0
MSB
-QLSB
4. a. If binary O = O volt and binary 1 = +6 volt,
write the binary output voltage levels equivalent to
the decimal number 207 . MSB ____ ,____ ,
_ __ ,___ ,___ ,_ _ _ ,_ _ _ ,_ __ ,LSB.
b. The above decimal number expressed as a
hexadecimal number is _ _ _ _ _ _ _ _ __
9. Which method of processing and transmission of
binary data is slower?
_ __ ____ parallel _ _ _ __ __serial.
repas
960t
= •-
·e
960t
= • - .. c:
:geot ·e
.o .o 0000 000 ~
11:::>S'v' . L
0 ~00 ·g
a1Aq ·g
::I:) ·q
:••• wo •• =
8S7 ' 9+ '9+ '9+ '9+
·o ·o •9+ •9+ ssv-i ·e
(I-ewpap) 69 • = (AJBU!Q) .oo .o •O •
·v
·s
·c:
OMI ·q :BoIBUB ·e
iOJjUO::l 'UO!IBlndwo::i 'SUO!JB::l!Unwwo::i . •
NOVEMBER 1987
87
|