The following presentation is a part of the level 4 module -- Digital Logic and Signal Principles. This resources is a part of the 2009/2010 Engineering (foundation degree, BEng and HN) courses from University of Wales Newport (course codes H101, H691, H620, HH37 and 001H). This resource is a part of the core modules for the full time 1st year undergraduate programme.
The BEng & Foundation Degrees and HNC/D in Engineering are designed to meet the needs of employers by placing the emphasis on the theoretical, practical and vocational aspects of engineering within the workplace and beyond. Engineering is becoming more high profile, and therefore more in demand as a skill set, in today’s high-tech world. This course has been designed to provide you with knowledge, skills and practical experience encountered in everyday engineering environments.
3. Binary Coded Decimal BCD Numbers Each decimal digit to be represented in BCD is converted into its 4 digit binary equivalent. The final number will consist of four times the number of original decimal digits. As the decimal digits relating to 1010, 1011, 1100, 1101, 1110, 1111 do not exist these are invalid. Decimal Binary BCD 0 0000 0000 0000 0000 1 0000 0001 0000 0001 2 0000 0010 0000 0010 3 0000 0011 0000 0011 4 0000 0100 0000 0100 5 0000 0101 0000 0101 6 0000 0110 0000 0110 7 0000 0111 0000 0111 8 0000 1000 0000 1000 9 0000 1001 0000 1001 10 0000 1010 0001 0000 11 0000 1011 0001 0001 12 0000 1100 0001 0010 13 0000 1101 0001 0011 14 0000 1110 0001 0100 15 0000 1111 0001 0101 16 0001 0000 0001 0110 17 0001 0001 0001 0111 18 0001 0010 0001 1000 19 0001 0011 0001 1001 20 0001 0100 0010 0000
4. Converting between Decimal and BCD From Decimal to BCD: To convert decimal to binary replace each decimal digit by its binary equivalent and then concatenate the result. For example, 2769 0010 0111 0110 1001 = 0010011101101001 Number Codes
5. From BCD to Decimal: Group the bits from the left into fours – if leading zeroes have been removed so that the total number of digits are a multiple of four. Convert each group into its decimal equivalent. Example 110101011010010001 00 11 0101 0110 1001 0001 3 5 6 9 1
6. BCD Addition BCD numbers can be added as long as certain rules are followed – these are. if the addition produces a carry or if it creates an invalid BCD number then correct the digit by adding six where the error occurred. . For example, 24 + 13 = 37 15 + 9 = 24 19 + 28 = 47 Number Codes
7. BCD Subtraction BCD numbers can be subtracted as long as certain rules are followed – these are. if the subtraction produces a borrow or if it creates an invalid BCD number then correct the digit by subtracting six where the error occurred. For example, 37 - 12 = 25 65 – 19 = 46 41 – 18 = 23 Number Codes
8. Other Codes ASCII Representation of Digits (American Standard Code for Information Interchange) ASCII is a code that allows not only decimal digits to be represented in binary format but also other non numerical characters. In its simplest form it has seven binary digits allowing the identification of 128 different characters. For the representation of the numbers from 0 to 9 we simply convert each digit to four bit binary and then add 011 to the left hand side. 5 0101 0110101 decimal binary ASCII Number Codes
9. EBCDIC Representation of Digits (Extended Binary Coded Decimal Interchange Code) This is an eight bit code which is used to represent decimal numbers. The decimal number is converted to its four bit binary equivalent and then four ones are added to the left. 5 0101 11110101 decimal binary EBCDIC Number Codes
10. Excess-3 (XS3) Excess three is the same as BCD but before the conversion takes place three is added to the decimal number. This means the following combinations do not exist as valid XS3 numbers. 0000 0001 0010 1101 1110 and 1111 This representation simplifies the addition process. Rule: if the addition stage generates a carry add 3, if it does not subtract 3 Number Codes
11. For example, 24 + 13 = 37 15 + 9 = 24 19 + 28 = 47 Subtraction Rule: if the subtraction stage requires a borrow subtract 3, if it does not add 3 For example, 37 - 12 = 25 65 – 19 = 46 41 – 18 = 23 Number Codes
12. 4221 This coding technique is used to produce a balanced number of 0s and 1s in a random sequence of decimal conversions Rather than the multipliers scaling by a factor of 2 as we move to the left, the multipliers are 4, 2, 2, 1 not 8, 4, 2, 1 This is sometimes written 4221 BCD. Number Codes
14. Gray Code If the decimal numbers to be encoded are increasing or decreasing linearly e.g. 3 – 4 – 5 – 6 – 7 or 23 – 22 – 21 – 20 – 19 etc then it is possible for the conversion process to cause ambiguities as the digits change. This can be prevented if Gray Codes are employed. Begin with all zeros and change the least significant bit. Change the next bit and reflect previous lower significant bits. Carry on with this process. Number Codes
15. Shaft Encoder This converts rotary movement into a digital number. It takes the following form: Number Codes Encoder Disk Light Sources Light Detectors Rotating Shaft
16. The encoder disk has areas that are opaque and areas that are transparent. As the disk turns light is passed to the detectors or blocked. The disk has the following form: complete this for binary code Binary Disk 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
17. As the disk rotates anticlockwise we will reach a point where the output is 0 1 1 1 which is the output for position 7. Further rotation will move us to segment 8 where the output is 1 0 0 0 . Note that each of the four bits change their state during this transition. Problems arise due to the fact that the light sources and detectors can never be “perfectly” aligned and therefore one of the bits will change before the others. Bit 0 first we have a reading of 0 1 1 0 position 6 Bit 1 first we have a reading of 0 1 0 1 position 5 Bit 2 first we have a reading of 0 0 1 1 position 3 Bit 3 first we have a reading of 1 1 1 1 position 15 Number Codes
18. We can see that with this code we can have erroneous outputs, which could be very serious. For this reason we use Grey Code Generation of Gray is as follows: 0 0 0 0 0 0 0 0 1 1 0 0 1 1 3 0 0 1 0 2 0 1 1 0 6 0 1 1 1 7 0 1 0 1 5 0 1 0 0 4 1 1 0 0 12 1 1 0 1 13 1 1 1 1 15 1 1 1 0 14 1 0 1 0 10 1 0 1 1 11 1 0 0 1 9 1 0 0 0 8 Note Only one bit changes as we move from one segment to the next – hence no possible erroneous outputs. Complete the Gray disk on the next page. How can we convert from Gray to Binary? Number Codes