Docsity

topic 2 - microcontrollers, Slides of Introduction to Robotics

Partial preview of the text

Download topic 2 - microcontrollers and more Slides Introduction to Robotics in PDF only on Docsity!

Introduction to robotics

4. Microcontrolers

Aistis Raudys ir Vytautas Valaitis

Processors

โ— Execute programs

โ— (^) Serial execution of instructions โ— (^) Simple, Universal

โ— Instruction execution engine: fetch/execute cycle

โ— (^) flow of control determined by modifications to program counter โ— (^) instruction classes: โ— (^) data: move, arithmetic and logical operations โ— (^) control: branch, loop, subroutine call โ— (^) interface: load, store from external memory

โ— Traditional architecture goal: Performance

โ— (^) Caches โ— (^) Branch prediction โ— (^) Multiple/OOO issue

Embedded Processor (Microcontroller)

โ— Processor optimized for low cost

โ— (^) No cache โ— (^) Small memory โ— No disks โ— (^) 4 bit/8 bit/16 bit โ— (^) No FP โ— (^) No complicated datapath โ— (^) Multicycle instruction interpretation โ— Simple/no operating system โ— (^) Programs are static

โ— Low performance

โ— (^) 1 MIPS is enough if 1 ms is the time scale

โ— Integrate on a single chip

General-purpose processor

โ— Programmed by user

โ— New applications are developed routinely

โ— General-purpose

โ— (^) must handle a wide ranging variety of applications

โ— Interacts with environment through memory

โ— (^) all devices communicate through memory โ— (^) DMA operations between disk and I/O devices โ— (^) dual-ported memory (as for display screen) โ— (^) oblivious to passage of time (takes all the time it needs)

CP U Memo ry Display (with dual-port video RAM) Dis k I/O (serial line, keyboard, mouse) Netwo rk Interfa ce standard interfaces system bus all the parts around the processor are usually required

Typical general-purpose architecture

Microcontr oller RO M I/O Inter face RA M custo m logic medium- speed interaction s high-speed interaction s low-speed interaction s standard interface any of the parts around the microcontroller are optional

Typical task-specific architecture

Connecting to inputs/outputs

โ— Map external wire to a bit of a variable (memory or register)

โ— (^) if (a & 1)... โ— (^) X = 2;

Example Problem: Accelerometer Interface

โ— Accelerometer output has one wire!

โ— (^) Acceleration coded as the duty cycle โ— (^) pulse-width/cycle-length

- (^) 20% = - - (^) 80% = + โ— (^) cycle time = 10ms

โ— Write a C program that measures the acceleration

โ— (^) Input is low-order bit of variable X โ— (^) Assign result to variable Z โ— (^) Make up whatever you need

RD WR WAIT ADDR DATA Micro- processor EN IN OUT DATA WR decode r ADDR to environment

Memory-mapped outputs

โ— Map external wire to a bit in the address space

of the processor

โ— Connect output of memory-mapped register

to environment

โ— (^) map register into address space โ— (^) decoder need to select register for writing (holds value indefinitely) โ— (^) input enable (EN) so that many registers can use the same data bus

On-chip support for communication

โ— Processor may not be fast enough

โ— Offload standard protocols

โ— Built-in device drivers

โ— (^) for common communication protocols โ— (^) serial-line protocols most common as they require few pins

โ— e.g. R S-232 serial interface

โ— (^) special registers in memory space for interaction

โ— Increases level of integration

โ— (^) pull external devices on-chip โ— (^) must be standard โ— (^) eliminate need for shared memory or system bus

Timers

โ— Separate and parallel counting unit(s)

โ— (^) co-processor to microprocessor โ— (^) does not require microprocessor intervention โ— in simple case, like a real-time clock โ— (^) set timer/read timer โ— (^) interrupt generated when expired

โ— More interesting timer units

โ— (^) self reloading timers for regular interrupts โ— (^) pre-scaling for measuring larger times โ— (^) started by external events

Input/output events

โ— Input capture

โ— (^) record precise time when input event occurred โ— (^) to be used in later handling of event

โ— Output compare

โ— (^) set output to happen at a point in the future โ— (^) reactive outputs โ€“ set output to happen a pre-defined time after some input โ— (^) processor can go on to do other things in the meantime

Why this choice?

โ— Used on the XESS board we are using

โ— Atmel part with 20K on-chip flash memory

โ— (^) dispense with external memory for instructions

โ— (^) very common microcontroller with simple instruction set โ— (^) lots of features โ— (^) lots of alternatives โ— (^) lots of support and resources โ— (^) good tools available: we will use the Keil software โ— (^) Assembler โ— (^) C compiler โ— (^) Debugger โ— (^) we will use the C compiler mostly โ— (^) requires a good understanding of the 8051 architecture

The Arduino Development Board

Making-robots-with-arduino.pdf