1 / 61

The Final Exam

The Final Exam. Next week, in your lab period. Computer Control of Hardware. Precision sensing of the environment (inputs) and activation of motors (outputs) http://www.youtube.com/watch?v=n_6p-1J551Y http://www.youtube.com/watch?v=_sUeGC-8dyk

Download Presentation

The Final Exam

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Final Exam • Next week, in your lab period

  2. Computer Control of Hardware Precision sensing of the environment (inputs) and activation of motors (outputs) http://www.youtube.com/watch?v=n_6p-1J551Y http://www.youtube.com/watch?v=_sUeGC-8dyk http://www.youtube.com/watch?feature=player_embedded&v=aqCmX5dMYHg

  3. The Computer Memory ModelA computer's architecture enables programs, data, and control

  4. computer memory 3B? Data, in computer format Address “points” to data Data, in human format

  5. ???

  6. Our 10-fingered system We use a numbering system based on 10 digits, 0 thru 9. Decimal. Dec = 10. e.g. 1624 is 1x103 + 6x102+ 2x101 + 4x100 = 1x1000 + 6x100 + 2x10+4x1 = 1000 + 600 + 20 + 4 = 1624

  7. Let’s try another 1,267,442 is 1x106 +2x105 +6x104 + 7x103 + 4x102 + 4x101 +2x100 = (1 x 1,000,000)+(2 x 100,000)+ (6 x 10,000)+ (7 x 1,000) + (4 x 100) + (4 x 10)+(2 x 1) = 1,267,442

  8. Decimal System • Base 10 • Number are written: 162410 • Uses digits 0 thru 9 (Digits are one less than the base)

  9. Represent the quantity 2710 in Base 10: 27 Base 8: how many each of 82+ 81 + 80 are needed? 0x82 + 3x81 + 3x80 = 0338 Base 4: how many each of 42+ 41 + 40 are needed? 1x42 + 2x41 + 3x40 = 1234 Base 2: how many 24 + 23 + 22 + 21 +20 how many 16s, 8s, 4s, 2s, 1s ? = 1x16 + 1x8 + 0x4 + 1x2 + 1x1 = 110112

  10. Pick any base… 7 for instance • Each digit is a placeholder for a power of 7: • 263417 is 2 6 3 4 1 74 73 72 71 70 2x2401 + 6x343 + 3x49 + 4x7 + 1x1 4802 + 2058 + 147 + 28 + 1 = 703610 • Why only digits 0-6? Because one more ( 7 ) is a power of 7, so in base 7 it would be 107 , so 6 is it

  11. digits = 1 less than the base Why can't there be a digit "8" in base 8? 8628 would be 8x82 + 6x81 + 2x80 so 8628 is really 10628 but this is 83

  12. Works for any number “base” • Base 8 (Octal) uses digits 0 – 7 • Base 4 uses digits 0 – 3 • Base 2 (Binary) uses digits 0 – 1

  13. Base 2 (Binary) 14652 - illegal 10110101 = 1x27 + 0x26 + 1x25 + 1x24 + 0x23 + 1x22 + 0x21 + 1x20 = 128 + 0 + 32 + 16 + 0 + 4 + 0 + 1 = 18110

  14. Bases greater than 10 Base 16… needs 16 digits, 0 thru 15? 0 1 2 3 4 5 6 7 8 9 then 10 11 12 …. ? But these are two digits each. Need single equivalents of 10 11 12 13 14 15 16 Any symbol will do A B C D E F !

  15. Base 16 - Hexadecimal • Harder, because it’s > 10 • A16 = 1010 B16 = 1110 C16 = 1210 D16 = 1310 E16 = 1410 F16 = 1510 1AE216 = 1 x 163 + 10 x 162 + 14 x 161 + 2 x 1 = 4096 + 2560 + 224 + 2 = 688210

  16. 0000 - 0 - 0 0001 - 1 - 1 0010 - 2 - 2 0011 - 3 - 3 0100 - 4 - 4 0101 - 5 - 5 0110 - 6 - 6 0111 - 7 - 7 1000 - 8 - 8 1001 - 9 - 9 1010 -10 - A 1011 -11 - B 1100 -12 - C 1101 -13 - D 1110 -14 - E 1111 -15 - F Thinking Binary Nibbles and Hex Digits blk-binary,blue-dec,green-hex

  17. Binary holds a special place • 0, 1 called Binary Digits, or “bits” • CAN BE REPRESENTED BY THE PRESENCE OR ABSENCE OF ELECTRICITY (and computers work via electrical circuits). • Eight binary digits: 0000 0000 (010) to 1111 1111 (25510 ) called a “byte”

  18. C++ Support for Binary / Hex From the C++ Reference Manual: Integer literals are written in three formats: decimal (base 10), hexadecimal (base 16), and octal (base 8). Decimal literals are written as ordinary numbers, hexadecimal literals always begin with 0X or 0x, and octal literals begin with 0. For example, the decimal number 10 is 0xA or 0XA in hexadecimal format, and 012 in octal format.

  19. meaning? 0x1234 means 123416, which means 466010 0xAEF4 means 4478810

  20. Why Hex? • Humans think like this: 1,247,658 easy • Computers think like this: 1110100101010111010111100111111010110 …. confusing

  21. Converting Binary to Hex 1010011110011110101100110100 step 1: break into “nibbles” 1010 0111 1001 1110 1011 0011 0100 step 2: convert each to Hex number 1010 0111 1001 1110 1011 0011 0100 A 7 9 E B 3 4

  22. Converting Hex to Binary 26D47FE16 2 6 D 4 7 F E 0010 0110 1101 0100 0111 1111 1110

  23. why? 1AF416 can be converted easily into binary 1 A F 4 0001 1010 1111 0100 So hex shows up in programming all the time, because binary is the computer’s interface to the world, but binary numbers are too confusing to humans. So hex is shorthand.

  24. the Byte • Eight bits • Can represent a number from 0 to 25510 0000 0000 to 1111 1111 • Reflect computer memory as a huge bank of 8-bit switches

  25. What it looks like “memory location 17 contains 0110 1110” location 8 values, restricted to 0’s and 1’s

  26. more like…. “memory location E1F3 CFE416 contains 0110 1110” Location 32 bits, unchangeable 8 values, restricted to 0’s and 1’s, changeable

  27. How large a number can be stored in a memory address? 1111 1111 1x27 + 1x26 + 1x25 + 1x24 + 1x23 + 1x22 + 1x21 + 1x20 • + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255 (which is 28 – 1)

  28. more bits, more data 8 bits: 0 to 28-1 0 to 256-1 0 to 255 16 bits: 0 to 216-1 0 to 65536-1 0 to 65535 32 bits: 0 to 232-1 0 to 4294967296 – 1 0 to 4294967295

  29. Computer Memory 0 1 1 1 0 0 1 0 Location 32 bits, Unchangeable (Read-Only) 8 values, restricted to 0’s and 1’s, changeable (R/W)

  30. Computer Memory • “1 megabyte” of memory means one million, 8-bit (binary digit) numbers • Each byte can hold a number from 0 to 255 • Called memory, because the computer uses each bit as a switch, that it sets to ON or OFF.

  31. How do computers control the world?

  32. Each joint is a motor that can be turned on and off with a switch

  33. 8 switches to control a whole robot

  34. A Computer “port” • Connects 1 byte of memory to outside world

  35. Bits translate into on/off • x = 255 means 1111 1111 means all motors or “ON” • x = 1 means 0000 0001 means the robot rotates at the waist • x = 16 means 0001 0000 means the robot grasps an object

  36. A printer “Port” • Computer connects an internal byte variable to the printer switches, and changes the values to tell the printer what to print

  37. Demo Program writes values into Memory location FA00 000116 0 0 0 0 1 1 0 1 Memory location FA00 000116 USB Port connects memory location FA00 000116 to bulbs

  38. Bit Position BC16 1 0 1 1 1 1 0 0 position: 7 6 5 4 3 2 1 0 MSB LSB most least significant significant bit bit

  39. Bits/Bytes can represent ANYTHING Numbers 0 0000 0000 1 0000 0001 2 0000 0010 3 0000 0011 4 0000 0100 5 0000 0101

  40. Use of Binary Encoding • On/off • Like a switch • Or a transistor • Or wire plugged in or not • High tones and low tones • Telephone and radio lines • These are the sounds that modems used to make when they connected http://www.youtube.com/watch?v=gsNaR6FRuO0

  41. Binary Encoding • Magnetic Disks (direction of magnetic field tells us if it’s a 0 or 1 • Hard drives • Optical storage (part of the disc does or does not reflect light) • CD, CD-ROM, DVD

  42. DVD, microscopic view

  43. ENCODING • Creating BINARY representations of information e.g. Color (three 8-bit numbers): Red component (0 - 255) + Green component (0 - 255) + Blue component (0 - 255 )

  44. For instance

  45. How many colors are possible? 255 * 255 * 255 = 16,581,375 But… how many colors are there? • There are an INFINITE amount of colors

  46. Encoding (continued) How do you represent analog values with digital numbers? ANALOG - continuous, infinite values between any two points DIGITAL - discrete values represented by 1s and 0s 6 6.034 5 4 2.746 3

  47. Loss of Information! Is this loss acceptable? Why? Because the difference is imperceptible to humans RESOLUTION - the difference between adjacent digital values, sometimes called FIDELITY

  48. Diff between 8 bit and 32 bit Full resolution: http://www.youtube.com/watch?v=1aKIpMl3Xh8 Not enough resolution: http://www.youtube.com/watch?v=vjrLCMO84eY Full resolution: http://www.youtube.com/watch?v=ikZiPo74B98 Not enough resolution: http://www.youtube.com/watch?v=b1WWpKEPdT4

More Related