basic logic 2.1 basic numbering systems technician series ©paul godin updated dec 2014 prgodin @...
TRANSCRIPT
Basic Logic 2.1
Basic Numbering Systems
Technician Series
©Paul GodinUpdated Dec 2014
prgodin @ gmail.com
Basic Logic 2.2
Numbering Systems
Binary numbers represent a value, and it is important to express these into values that we understand.
Binary numbers need to be converted to decimal and hexadecimal values to make them easier to describe and understand.
Basic Logic 2.3
Converting Binary to Decimal
Each position represents a “weight”
25+24+21= 32+16+2 = 50 in decimal
1100102
20
21222324
25
Each position has a weight that is a factor of 2. Add all positions that have a binary “1” (ignore “0”)
Basic Logic 2.4
Short-Cuts
◊ You may be able to calculate some values in your head if you remember the weight of each position:
_ _ _ _ _ _ _ _ _ _
20
1
27
128
22
423
824
1625
3226
64
21
228
256
29
512
Basic Logic 2.5
Short-Cuts Examples
Value remembered
0010 = 2
1000 = 8
10000 = 16
Value determined through remembered value.
0011 is one more than 0010 0011 = 2 +1 = 3
1011 is three more than 1000 1011 = 8 +3 = 11
01111 is one less than 10000 01111 = 16 - 1 = 15
0011
1011
1111
Number
Basic Logic 2.6
Exercise 1
0101 = _________
1001 = _________
10101 = ________
110 = ___________
11011 = _________
1011011 = ________
Convert the following Binary numbers to Decimal:
Basic Logic 2.7
Converting Decimal to BinaryPowers of 2 Method
Powers of 2: The decimal value is successively reduced by the largest power of 2 that will fit.
57 – 32 = 25 32 is position #6
_ _ _ _ _ _
25 – 16 = 9 16 is position #5
9 – 8 = 1 8 is position #4
1 – 1 = 0 1 is position #1
Example: Convert 57 to binary
Blank positions become 0
1 1 1 10 0
Animated
Basic Logic 2.8
Converting Decimal to BinaryDivision by 2 Method
Division by 2: The decimal value is successively divided by 2 and the remainder is recorded.
57 ÷ 2 = 28, remainder 1
_ _ _ _ _ _
28 ÷ 2 = 14, remainder 0
Example: Convert 57 to binary
1 1 1 10 0Animated
14 ÷ 2 = 7, remainder 07 ÷ 2 = 3, remainder 13 ÷ 2 = 1, remainder 1
1 ÷ 2 = 0, remainder 1
Basic Logic 2.9
Exercise 2
12 = _________
17 = _________
124 = ________
8 = ___________
33 = _________
155 = ________
Convert the following Decimal numbers to Binary:
Basic Logic 2.10
Converting Hexadecimal to Decimal
Each position represents a “weight”
11x163 + 0 + 3x161 + 2x160 =
B03216
160
161162
163
Each position has a weight that is a factor of 16. Multiply the value (converted to decimal) by its weight.
(11 x 4096) + (3x16) + (2x1) =
45,056 + 48 + 2 = 45,106
Basic Logic 2.11
Converting Decimal to HexadecimalDivision by 16 Method
Division by 16: The decimal value is successively divided by 16 and the remainder is recorded.
45,106 ÷ 16 = 2819, remainder 2
_ _ _ _
2819 ÷ 16 = 176, remainder 3
Example: Convert 45,10610 to Hexadecimal
B 20 3Animated
176 ÷ 16 = 11, remainder 011 ÷ 16 = 0, remainder 11
Basic Logic 2.12
Exercise 3
1210 = _________16
1710 = _________16
12410 = ________16
1816 = ___________10
3B16 = _________10
ABC16 = ________10
Convert the following numbers:
Basic Logic 2.13
Converting Hexadecimal to Binary
The Hexadecimal numbering system is used because of the ease converting between it and a 4-bit binary value. Each digit is converted to Decimal then converted to Binary.
Example: Convert B032h to Binary
B03216
_ _ _ _ _ _ _ _
1110 010 310 210
01 10_ _ _ _0 10 000 001_ _ _ _0 112
Basic Logic 2.14
Converting Binary to Hexadecimal
To convert from Binary to Hexadecimal, convert each grouping of 4 bits to Decimal, then to a Hexadecimal digit.
Example: Convert 1011 0000 0011 0010 to Hexadecimal
B03216
1110 010 310 210
01 100 10 000 0010 112
Basic Logic 2.15
Counting in Binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Basic Logic 2.16
Binary Counting
When counting up, 1 is added to the current state to determine the next state.
In Binary, when adding “1” to a “1”, the result is “10” (zero and carry the one).
Example:
1011
111
100
Basic Logic 2.17
Adding in Binary
◊ Example:
1101+0101
1101+0101
0
11101
+010110
11101
+0101010
11
1101+010110010
11
Basic Logic 2.18
Adding in Binary
101+011
1 + 1 = 10
0
1 Carry 1
1 + 1 = 100
1
Carry 11 + 1 = 10
0
1
1
Carry 1
Animated
Basic Logic 2.19
Binary Codes
◊ Binary numbers are used to represent values such as alphanumeric characters.
◊ One encoding system is ASCII, a standard that defines the representation of an alphanumeric character using binary.
◊ Example: The letter A in Binary is 100 0001
Note ASCII code is 7 bit but there are several 8 bit codes available.
Basic Logic 2.20
Exercise
Determine what the following says (7-bit ASCII):
010010010010000001010111011010010110111000100001
Google for it.
Basic Logic 2.21
Grey Code
When counting in Binary there are instances where two or more bits change at the same time. Examples: 001 to 010, 011 to 100.
In mechanical systems, such as those using an encoding wheel, it is desirable to have just one bit change at a time to allow for more uniform transitions with rotation.
In Digital Electronic communications, these multi-bit changes may interfere with one another.
Encoder Disk(Wikipedia - PD)
Basic Logic 2.22
Grey Code
000001011010110111101100
00011110
0000000100110010011001110101010011001101111111101010101110011000
2-b
it G
rey C
od
e
4-b
it G
rey C
od
e
3-b
it G
rey C
od
e
Basic Logic 2.23
END
©Paul R. Godinprgodin°@ gmail.com