112 Note I
112 Note I
It’s the job of the analog electronics engineer to deal with many of these thermal, magnetic, optical, acoustical,
biological, chemical, or electrical “signals” by designing the appropriate analog sensors and control circuitry.
Digital electronics, on the other hand, is completely different. In the digital realm (i.e., digital electronic circuits), there
are only two “states” that are important: ON or OFF. For example, when you flip the light switch on in your bathroom,
you know there are only two possible positions the light switch can be in (i.e. ON or OFF). It’s of no real concern to you
that there could be 110, 113, 120, or 125 volts (i.e., fluctuating analog “signal”) running through the electrical wiring
connected to the light switch.
Thus, digital electronics are based on a “switching logic” (ON or OFF). On the other hand, analog electronics are more
concerned with a fluctuating (constantly changing) electrical quantity like voltage and/or current.
Number Systems
When we type some letters or words, the computer translates them in numbers as computers can understand only
numbers. A computer can understand positional number system where there are only a few symbols called digits and
these symbols represent different values depending on the position they occupy in the number.
A value of each digit in a number can be determined using
The digit
The position of the digit in the number
The base of the number system (where base is defined as the total number of digits available in the number
system).
1. Decimal Number System
The number system that we use in our day-to-day life is the decimal number system. Decimal number system has base
10 as it uses 10 digits from 0 to 9. In decimal number system, the successive positions to the left of the decimal point
represent units, tens, hundreds, thousands and so on.
Each position represents a specific power of the base (10). For example, the decimal number 1234 consists of the digit
4 in the units position, 3 in the tens position, 2 in the hundreds position, and 1 in the thousands position, and its value
can be written as
(1x1000)+ (2x100)+ (3x10)+ (4x1)
(1x103)+ (2x102)+ (3x101)+ (4x100)
1000 + 200 + 30 + 4
1234
1
Characteristics of binary number system are as follows:
Uses two digits, 0 and 1.
Also called base 2 number system
Each position in a binary number represents a power of the base 2. Example 20
Last position in a binary number represents a x power of the base 2. Example 2 x where x represents the last or
leftmost position.
Example
Binary Number: 101012
Step 2 19FDE16 ((1 x 164) + (9 x 163) + (15 x 162) + (13 x 161) + (14 x 160))10
Number Conversion
There are many methods or techniques which can be used to convert numbers from one base to another. We'll
demonstrate here the following:
3
Step Operation Result Remainder
Step 1 29 / 2 14 1
Step 2 14 / 2 7 0
Step 3 7/2 3 1
Step 4 3/2 1 1
Step 5 1/2 0 1
As mentioned in Steps 2 and 4, the remainders have to be arranged in the reverse order so that the first remainder
becomes the least significant digit (LSD) and the last remainder becomes the most significant digit (MSD).
4
Step 1 258 ((2 x 81) + (5 x 80))10
Step 1 21 / 2 10 1
Step 2 10 / 2 5 0
Step 3 5/2 2 1
Step 4 2/2 1 0
Step 5 1/2 0 1
Step 1 - Divide the binary digits into groups of three (starting from the right).
Step 2 - Convert each group of three binary digits to one octal digit.
Example
Binary Number : 101012
Calculating Octal Equivalent:
Step Binary Number Octal Number
Step 2 101012 28 58
5
Example
Octal Number : 258
Calculating Binary Equivalent:
Step Octal Number Binary Number
Zone: 1 1 The 11 in the first two digits of the zone indicates an upper-case letter or a number.
The last two digits of the zone represent the group or range:
code range
00 A-I
01 J-R
10 S-Z
11 numbers
digit: __ __ __ __
23 22 21 20
8 4 2 1
Using the binary powers of 2, we can determine a value for each bit within the digit portion of the code. For example,
since A is the first character in its group (A - I), we would use the digit portion of the code to indicate a 1. Since B is the
second character in the group A - I, we would use the digit portion of the code to indicate a binary equivalent of a 2.
Since C is the third character in the group A - I, we would use the digit portion of the code to indicate the binary
equivalent of a 3.
Examples:
1. If we want to represent the letter F, we will first determine the digit portion of the code. We first determine that
it is the 6th letter within the range (range A - I). Now we have to figure out how to express 6 in binary. We find
that by turning on (putting a 1) over the positional value of 4 (22) and turning on (putting a 1) over the positional
value of 2 (21) we have the equivalent of 6 (4 + 2 = 6). We do not need the 8 (23) or the 1 (20) so we put a 0 in
these positions.
0 1 1 0
23 22 21 20
8 4 2 1
2. Note: 4 and 2 turned on and 4 + 2 = 6
Looking at the zone portion, we know that F is upper case so we put a 11 in the first two characters of the zone.
7
We also know that it is in the range A - I and we know that the range A - I calls for entering 00 in the last two
characters of the zone. This gives us a zone of: 1 1 0 0
Combining the zone portion of 1 1 0 0 and the digit portion of 0 1 1 0 we find that the EBCDIC code for the letter
F is 1 1 0 0 0 1 1 0.
The zone is: 1 1 for upper case followed by 0 1 for the range J - R.
The digit is: since M is the 4th letter in the range, the position with the value of 4 is turned on by placing a 1
there and the other positions are turned off by using 0.
0 1 0 0
23 22 21 20
8 4 2 1
4. The EBCDIC code for the character M is: 1 1 0 1 0 1 0 0
The zone is: 1 1 for upper case letter or number followed by 1 1 for the numbers range.
The digit is: since 9 is the 9th number in the range, we need to find a way to represent a 9. Turning on the 8 and
the 1 will accomplish this, so a 1 is placed in these two positions. This means the positions with a value of 4 and
2 are not used, so a 0 is placed in these positions.
1 0 0 1
23 22 21 20
8 4 2 1
6. The EBCDIC code for the number 9 is: 1 1 1 1 1 0 0 1
7. The letter S: There are only 8 characters in the range S - Z, so S is considered the second character in the range
while Z is the 9th (in other words, there is no first character in the range S - Z).
The zone is: 1 1 for upper case followed by 1 0 for the range S - Z.
The digit is: Since S is considered the second letter in the range, we need to represent the number 2 by turning
on (putting a 1) in the position with a value of 2 and 0 in all other positions.
0 0 1 0
23 22 21 20
8 4 2 1
8. The EBCDIC code for the letter S is: 1 1 1 0 0 0 1 0
8
Binary Hexadecimal
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
Examples:
1. F = 11000110 1100 0110 in EBCDIC
hexadecimal translation of
C 6
EBCDIC
M=
2. 1101 0100 in EBCDIC
11010100
hexadecimal translation of
D 4
EBCDIC
3. 9 = 11111001 1111 1001 in EBCDIC
hexadecimal translation of
F 9
EBCDIC
4. S = 11100010 1110 0010 in EBCDIC
hexadecimal translation of
E 2
EBCDIC
Looking at all of the upper-case letters and the numbers or digits from 0 to 9, it can be seen that there is a pattern. For
example, any character in the range A - I has a zone of 1100 which can be represented by hexadecimal C. This means
that if we are looking at a dump, etc., we know that any hexadecimal translation of EBCDIC that has a C is in the range A
- I.
9
128 64 32 16 8 4 2 1 Positional value from appropriate power of 2
EBCDIC equivalents:
Character EBCDIC Equivalent Character EBCDIC Equivalent
A 193 N 213
B 194 O 214
C 195 P 215
D 196 Q 216
E 197 R 217
F 198 S 226
G 199 T 227
H 200 U 228
I 201 V 229
J 209 W 230
K 210 X 231
L 211 Y 232
M 212 Z 233
10
The number 9 uses a 1 in the bit with a positional value of 8 and a 1 in the bit with a positional value of 1 with a 0 in the
bits with positional values of 4 and 2. Therefore you have 8 + 1 turned on for a value of 9.
1 0 0 1
23 22 21 20
8 4 2 1
The bits 1 0 in the left most bits of the standard 7-bit code indicate an upper-case letter with the last 5 bits specifying the
exact letter. Since there are 26 upper case letters in the alphabet, 5 bits are needed to tell which one is being
represented.
__ __ __ __ __ face value
positional value in powers
24 23 22 21 20
of 2
16 8 4 2 1 positional value in decimal
Using these five positions, numbers from 1 to 26 can be represented standing for the letters A Ð Z.
The letter A only turns on the positional value of 1 since it is the first letter in the alphabet.
__ __ __ __ 1 face value
positional value in powers
24 23 22 21 20
of 2
16 8 4 2 1 positional value in decimal
Combining the 10 indicating an upper-case letter and the 00001 indicating the first letter, the letter A in 7 bit ASCII is
1000001.
The letter L turns on the positional value of 8 and the positional value of 4 to add up to 12 since it is the 12th letter in the
alphabet.
0 1 1 0 0 face value
positional value in powers of
24 23 22 21 20
2
16 8 4 2 1 positional value in decimal
Combining the 10 indicating an upper-case letter and the 01100 indicating the 12th letter, the letter L in 7 bit ASCII is
1001100.
The letter Z turns on the positional value of 16 and the positional value of 8 and the positional value of 2 to add up to 26
since it is the 26th letter of the alphabet.
1 1 0 1 0 face value
positional value in powers of
24 23 22 21 20
2
16 8 4 2 1 positional value in decimal
Combining the 10 indicating an upper case letter and the 11010 indicating the 26th letter, the letter Z in 7 bit ASCII is
1011010.
11
ASCII Equivalent represented in decimal translation of binary code:
When working with ASCII, again it is difficult to deal with the 7 or 8 bit string of binary digits. Therefore, frequently the
code is represented by the decimal equivalent of the binary code for ease of use.
__ __ __ __ __ __ __ face value
positional value in
26 25 24 23 22 21 20
powers of 2
positional value in
64 32 16 8 4 2 1
decimal
To do this the binary code is represented as shown above. If the position is turned on with a 1, the decimal equivalent is
added to the total.
Examples:
The letter L has an equivalent value of 76 as shown:
1 0 0 1 1 0 0 face value
positional value in
26 25 24 23 22 21 20
powers of 2
positional value in
64 32 16 8 4 2 1
decimal
The chart of ASCII equivalents for the upper-case letters is shown below:
Characte ASCII ASCII
Character
r Equivalent Equivalent
A 65 N 78
B 66 O 79
C 67 P 80
D 68 Q 81
E 69 R 82
F 70 S 83
G 71 T 84
H 72 U 85
12
I 73 V 86
J 74 W 87
K 75 X 88
L 76 Y 89
M 77 Z 90
Gray code is not weighted that means it does not depend on positional value of digit. This cyclic variable code that
means every transition from one value to the next value involves only one-bit change.
Gray code also known as reflected binary code, because the first (n/2) values compare with those of the last (n/2)
values, but in reverse order.
n-bit Gray code can be generated recursively using reflect and prefix method which is explained as following below.
Therefore, Gray code 0 and 1 are for Binary number 0 and 1 respectively. Gray codes: 00. 01, 11, and 10 are for Binary
numbers: 00, 01, 10, and 11 respectively. Similarly you can construct Gray code for 3 bit binary numbers:
13
For n = 1 bit For n = 2 bit For n = 3 bit
Binary Gray Binary Gray Binary Gray
0 0 00 00 000 000
1 1 01 01 001 001
10 11 010 011
11 10 011 010
100 110
101 111
110 101
111 100
Iterative method of generating G(n+1) from Gn are given below. This is simpler method to contract Gray code of n-bit
Binary numbers. Each bit is inverted if the next higher bit of the input value is set to one. The nth Gray code is obtained
by computing n⊕(floor(n/2)).
The hamming distance of two neighbours Gray codes is always 1 and also first Gray code and last Gray code also has
Hamming distance is always 1, so it is also called Cyclic codes.
You can construct Gray codes using other methods but they may not be performed in parallel like given above method.
For example, 3 bit Gray codes can be contracted using K-map which is given as following below:
14