CS-424/580A Microcontrollers & Robotics CS-424/580A • Professor Richard R. Eckert – EB-N6, 777-4365 Microcontrollers and – Office hours: W 10-11:30 A.M., R 1-2:30 P.M. – Email: [email protected] Robotics – Web Page: www.cs.binghamton.edu/~reckert/ • Link to CS-424/580A – Class listserv • [email protected] • Active after first week of classes • TA: Chao Huang – Email: [email protected] – Office hours: TBA • Robotics Course Content – LEGO Mindstorms RCX • Microcontrollers – Programming with NQC – Architectures, instruction sets, and programming • Motor/sensor control • Microchip Technology’s PIC microcontrollers • Sound – PIC18F452 • Multitasking – Memory interface • Timers – Control of alphanumeric LCD displays • IR communication, data logging – Digital and analog I/O ports – Behavior architectures – A/D, D/A conversion, sensors – Robot navigation – Motor control, PWM – Robot vision control – Timers – Programming with Lejos Java – Interrupts – BIObot, interface with Microsoft .NET – Serial I/O – Robot communications • USARTs – Robot competition Lab The Microcontroller • Most important part of course • Common component in modern electronic systems • Every Friday, 1:10-4:10 P.M., LNG-210 • Computer on a single chip – We will meet this Friday • Students work in teams of three – Microprocessor-based device (the “core”) – Completely self contained with memory and I/O on • One report per team for lab experiments chip • 1st half of course: Microcontroller experiments • Primary role: – QuikFlash & QuikProto boards – Provide inexpensive, programmable logic control and • PIC 18F452 microcontroller interfacing to external devices • 2nd half, robot experiments • Monitor external input, receive input from sensors – LEGO Mindstorms RCX • Regulate and turn devices on or off – BIObot • Very commonly used in robots • Usually embedded in the systems they control 1 Use of Microcontrollers • Greatly outnumber conventional CPUs used in PCs Microprocessor • Used in a wide variety of electronic systems: • Programmable device that integrates many – Automobile systems useful functions into a single IC package – PC keyboards and printers – Electronic measurement instruments • The CPU of a computer on a chip – Mobile phones • Some functions: – TV, radio, CD/DVD players, tape recording equipment – Execute a stored set of instructions to carry out – Hearing aids user-defined tasks – Security alarm systems – Microwave ovens – Access external memory and I/O chips to – Remote controllers read/write data from/to memory and I/O – Food dispensers devices – Many, many more Organization of a Microprocessor- Microprocessor-based Computer System Details based Microcomputer System Input/Output Memory • Digital I/O Ports • In order of increasing “writeability” and • Serial vs. Parallel volatility • Asynchronous vs. Synchronous – ROM • Programmable Parallel Ports (e.g., Intel 8255 PPI) – PROM – Direction, handshaking conventions, etc. – EPROM • Serial Interface (e.g., Intel 8251 USART) – EEPROM • Analog I/O – Flash – A/D, D/A Converters (e.g., 804, 1408) • Timers (e.g., Intel 8254 PIT) – Static RAM • Programmed vs. Interrupt-driven I/O – Dynamic RAM – Interrupt Controllers (e.g. Intel 8259 PIC) 2 Basic Microcontroller • Integrates most of the components of a microcomputer system onto a single chip • Just need to add power and clocking • Following components usually included: – CPU Core – I/O – Memory • PROM, EPROM, or Flash for programs and nonvolatile data • RAM for volatile data More Complete Microcontroller • CPU, I/O, Memory – Timer module • perform tasks for specified time periods, output pulses of determined length, measure time intervals – Digital I/O – Serial I/O (USART) – Analog I/O (D/A, A/D) • e.g. to receive data from sensors and control motors and other analog devices – Interrupt controller – External memory interfaces to expand memory – Built-in monitor/debugger program – Support for external peripherals • e.g., I/O and bus extenders – Often lots of other support devices Differences between Microprocessors • Hardware and Instruction Set Support: and Microcontrollers – mC: Built-in I/O operations, event timing, interrupt priority schemes • Design: – mP: Requires external support (programmable – mC: Designed to control I/O devices controller chips) for these activities – mP: Designed to process large amounts of data fast in large computer systems • Bus Widths: • Instruction Sets: – mP: Very wide – mP: processing intensive ? • Large memory address spaces ? wide Address Bus • Powerful, complex instructions w/ many addressing modes – e.g., 4 Gigabyte memory ? 32 bit wide A.B. • Large instruction size • Lots of data transferred very fast ? wide Data Bus – mC: Instructions to control I/O ? – (32, 64, 128 bits common) • Small instruction sets, set/clear bits, Boolean operations – mC: Relatively narrow • Compact instructions • Memory size: kilobytes ? 8/16 bit Address Bus – Control program must fit in small on-chip PROM • Data Bus typically 4, 8, 16 bits wide 3 • Clock Rates Microcontroller Software – mP: Very fast for fast processing of large amounts of data • Programming • Typically > 1 GigaHertz – Usually in core CPU’s native assembly language – mC: Relatively slow to control slow I/O devices – Sometimes HLL support available • Typically 10 KHz -10 MHz • C, Basic • Cost – Assemblers/Linkers often provided by mfg. – mP: High – C Compilers: • Typically > $100.00 • Sometimes free – tend to be buggy – mC: Low • Better ones are expensive • 4 Bit: < $1.00 • 8 Bit: $1.00 to $10.00 – Programming environments are often not user • 16 Bit: $10.00 to $20.00 friendly • Even less in bulk quantities • Microchip’s MPLAB is an exception Microcontroller Pgm. Downloading Monitor Program • Program Development usually done on a PC • On-chip program that communicates with PC • SW tools must produce a file that can be software downloaded to the mC’s PROM or Flash memory • Typically uses a serial port to talk to PC terminal – Several standard formats emulation program • Intel Hex format most common • Capabilities vary • EEPROM burner often needed – Used to download programs, but often includes a – Expensive quartz glass window debugger • UV EPROM eraser required • Examine/change registers, memory • If mC has Flash memory, it’s much easier • Single step, set break points – Can be reprogrammed with resident monitor program • We’ll be using the TeraTerm Pro Terminal – Often on-chip USART to communicate w/ the PC program on a PC to communicate with the QuikBug monitor burned into the PIC18F452 – Expedites the Program/Test/Erase/Reprogram cycle mC on our QuikFlash microcontroller boards Microcontroller Architectures Princeton Architecture • Princeton (Von Neumann) Architecture – All memory space on same bus – Instructions and data treated in same way • Possible bottleneck between instruction fetches and data fetches • Can be overcome with prefetching (pipelining) and/or by using instruction/data caches – Simple processor design • Only one memory interface • More reliable since fewer things can fail • RAM used for both data ans instructions ? greater flexibility in SW/OS design – Intel 80x86 (Pentium) mP, Motorola 68HC11 mC are examples 4 Harvard Architecture • Harvard Architecture – Code and data memory storage areas are on different busses – Potentially more efficient – Instructions execute in fewer cycles • Instructions and data can be fetched simultaneously • Greater instruction parallelism – More complex processor design – Example: Microchip’s PIC microcontrollers CISC vs. RISC • CISC – Complex Instruction Set Computer • RISC – Reduced Instruction Set Computer CISC RISC • Many instructions in the instruction set • Few instructions in the instruction set – Can be very powerful and serve very special purposes – Simple instructions • Many addressing modes – Short and fast • Can do complex operations with one instruction – Often instructions are “orthogonal” – But many are used very infrequently • All access registers in same way • Many are very long (many bytes) and require • Few addressing modes many clock cycles • Example: PIC and many other microcontrollers • Example: Intel 80X86 • Some mPs and mCs offer both CISC and RISC • Control Unit (Instruction Decoder) must be very features complex, occupying much of chip area • Simpler (smaller) control unit – Less space for registers – More space for more registers – More access to memory required – Less access to memory – Slower – Faster 5 Internal Organization of a Computer with Hardwired Control Unit Computer’s Control Unit • Hardwired – Control signals required to execute instructions generated by logic gates in a “control matrix” • Faster, but less flexible • Microprogrammed – A processor within the processor causes “control words” to be fetched from a control ROM • Bits are control signals • Greater flexibility in instruction set design • Easier to design (SW vs. HW) • But slower A Hardwired Computer Control Unit Microprogrammed Computer Control Unit Some Examples of Intel 8051 Family • Introduced in late 1970s Microcontrollers • At the heart of biggest variety of micros on earth • Intel 8051 • CISC with Harvard Architecture • Microchip’s PICmicro • Some Pros: – We’ll use the PIC18F452 in first half of course – Powerful bit manipulation instructions – Part of RAM & many registers bit-addressable • Motorola 68HC11 – Multiply/divide instructions • Hitachi H8 – At least two 16-bit timers – UART capable of 500 kb/s at 16 MHz – Microcontroller in the LEGO MindStorms RIS – Lots of internal RAM RCX used in the
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages7 Page
-
File Size-