Professional Documents
Culture Documents
?
?
What constitutes a controller will vary from
application to application.
It may be no more than an amplifier or a switch.
It may be a complex system that may include
computers and other types of processors such as
data acquisition and signal processors.
Most of the time, it is a microprocessors.
We shall therefore focus the discussion here on
microprocessors.
?
?
Focus on microprocessors as general purpose,
flexible and reconfigurable controllers and the
ways sensors and actuator relate to these.
Microprocessors are often called microcontrollers
What is a microprocessor? What is the different
between a microprocessor and a computer or a
microcomputer and how a distinguishing set of
features is arrived at are all difficult and subjective
issues. What is a microprocessor to one is a full
fledged computer to another
?
A microprocessor is a stand alone, self contained
single chip microcomputer.
It must have as a minimum:
± a central processing unit (CPU)
± nonvolatile and program memory
± input and output capabilities.
A structure that has these can be programmed in
some convenient programming language
can interact with the outside world through the
input/output ports.
?
Other important requirements:
must be relatively simple
reasonably small
necessarily limited in most of its features memory,
processing power and speed, addressing range and, of
course in number of I/O devices it can interact with.
The designer must have access to all features of the
microprocessor bus, memory, registers, all I/O ports,
c
, Microprocessors are components with
flexible features that the engineer can configure
and program to perform task or a series of tasks.
?
Two limits on the tasks microprocessors can
perform:
The limitations of the microprocessor itself
The imagination (or capabilities) of the
designer.
?
?
We will narrow down to 8 bit microprocessors
± these are the most common in sensor/actuator systems
± they are simple and representative of all microprocessor
16 and 32 bit microprocessors exist
There are a number of architectures being used.
We will emphasize the Harvard architecture
because of its simplicity, flexibility and
popularity.
?
There are about two dozen manufacturers of
microprocessors
All based on a few architectures.
We shall only briefly describe here one
architecture the Harvard architecture
used in many microprocessors
Simple and efficient
The choice in smaller microprocessor
Example: Microchip and Atmel microprocessors
?
Main features:
Separate busses for program memory and operand
memory.
Pipelined architecture
Allows fetching data while another operation
executes.
Each cycle consists of fetching the (n+1)th
instruction while executing the nth
Integer arithmetic
Limited instruction set
?
Bus widths vary depending on manufacturer and
on the microprocessor size.
Example: = , bus architecture for a
PIC18F452 from Microchip.
The instruction is 16bit
Program address is 15bit wide.
Data is 8bits and
Operand address is 12 bits.
These vary from device to device.
[ ?
?
Example, the smallest microprocessors
available (PIC10FXX) are 6 pin devices
Summarized in .
The architecture for this device is shown in
= .
Here the program address bus is only 9 bits
while the instruction buss is 12 bits.
Ä
?
Ä
?
?
Example: one of the largest, is the
PIC18FXX20
Has an address bus 21 bits wide.
The processor and its variants are shown in
Its architecture in = .
?
Architecture supports:
Direct addressing for the first 8 bits of address
space
Indirect addressing (variable pointer addressing)
for all memory space.
Includes a CPU with associated status bits and a
set of special functions registers.
I/O ports, other peripherals (such as comparators,
A/D converters, PWM modules, etc.)
Timers, status indications and much more,
?
All modules available to the user.
User writable registers are also provided.
Microprocessors have been designed to respond to
specific needs: common to find modifications that
respond to these needs
Example: various processors from the same family
may have a different instruction sets
± PIC10FXX has 33 instructions
± PIC18FXX20 has 77 instructions
± ATmega128 (from Atmel) has 133 instructions.
?
Memory varies from 256 bytes to over 256
kbytes
Number of peripherals, ports, etc vary from
as few as 4 to over 100
Physical size: from 6 pin to 100 pins
Various chip configurations (DIP, surface
mount, dies etc.)
ð
8 bit microprocessors have word length of 8 bits.
Integer data from 0 to 255 may be represented
directly.
To address memory, usually a longer word is
needed.
Most microprocessor have a 12 bit (4k) 14 (16k)
or 16 bit (64k) memory address but longer address
words are also used.
ÿ
Most microprocessor operate at clock
speeds between 1 and 40 MHz.
Since often the clock is internally divided,
the instruction cycle is slower than that
Typical values are up to about 10 MHz
cycle clock or 0.1 ws per instruction
c
Microprocessors have a small instruction set
sometimes no more than 2-3 dozen simple
instructions.
Varies from a minimum of about 30 to a
maximum of about 150 instructions.
These are selected to cover the common
requirements of programming a device
Allows one to perform almost any task that can be
physically performed within the basic limitations
of the device.
c
Instructions include:
± logical instructions (AND, OR, XOR, etc.)
± move and branching instructions (allow one to move
data from and to registers and conditional and
unconditional branching)
± bit instructions (operations on single bits in an operand)
± arithmetic instructions such as add and subtract,
± subroutine calls
± other instructions that have to do with the performance
of the microprocessor such as reset, sleep and others.
Some are bit oriented, some are byte (register)
oriented, some are literal and control operations
c
Input and output is defined by the availability of
pins on the package.
Usually limited to less than about 100 pins (6, 8,
14, 18, 20, 28, 32, 40, 44, 64 and 100 pins are
common).
Two pins are used to power to the device
For example, an 18 pin device can have no more
than 14 I/O pins.
Of these, some may be used for other purposes
such as oscillators or communication
c
All microprocessor will have a number of pins
available as I/O.
Example, a 6 pin microprocessor may have as
many as 4 I/O, a 64 pin processor can have in
excess of 48 I/O pins.
I/O pins are grouped into ports, each addressable
as an 8 bit word (each group has up to 8 I/O pins).
Different ports may have different properties and
may be able to perform different functions.
c
I/O pins are tri-state enabling an I/O pin to serve
as input, output or to be disconnected.
Most I/O are digital but some may be configured
as analog as well.
I/O pins can supply or sink considerable current
usually in the range of 20-25 mA.
This is not sufficient to drive many actuators but it
can drive low power devices directly or indirectly
through switches and amplifiers.
icroprocessor must have a timing mechanism
that defines the instruction cycle.
This is done by an oscillator
Oscillators may be internal or external.
Usually and RC oscillator is used for internal
oscillation
A crystal is the most common way of setting the
frequency externally (this requires either dedicated
pins or the use of two I/O pins).
The oscillator frequency is usually divided
internally to define the basic cycle time.
Microprocessors have internal timers
± under the control of the user
± used for various functions requiring counting/timing
± At least one counter is available
± larger microprocessors can have 4 or more timers
± some are 8 bit timers and some 16 bit timers.
± a watchdog timer is available for the purpose of
resetting the processor should it be stuck in an
inoperative mode.
Registers
Used for
Execution of commands
Control over the functions of the microprocessor,
Addressing
Flagging
Status indication
Modern microprocessors, contain three
types of memory:
program memory, in which the program is
loaded,
data memory (RAM),
EEPROM memory
Note: EEPROM not available on some very
small microprocessors.
Program memory is usually the largest
From less than 256 bytes to over 256kBytes.
In most cases, flash memory which means that is
rewritable at will and is nonvolatile (program is
retained until rewritten or erased).
Data memory (RAM) is usually quite small and
may be a small fraction of the program memory
Does not retain data upon removal of power.
EEPROM is nonvolatile rewritable memory used
mostly to write data during execution
Ä
Most microprocessor operate from 1.8V to 6V.
Some have a more limited range (2.7-5.5V).
Based on CMOS technology: This means that:
± power consumption is very modest.
± power consumption is frequency dependent.
The higher the frequency the higher the power
consumed
Ä
Power is also dependent on
What the processor does
Which modules are functioning at any given time.
The user has considerable control over power
consumption through:
± Choice of frequency
± Mode of operation
± Special functions such as interrupt wakeup and sleep.
v
Microprocessor must have certain modules (CPU,
memory and I/O)
They can have many more modules
Add functionality and flexibility
Many microprocessors include
± comparators (for digitization purposes),
± A/D converters,
± Capture and Compare (CCP) modules,
± PWM generators
± Communication interfaces.
v
One or two comparators are provided on many
microprocessors.
Depending on the microprocessors 8 or 10 bit A/D
converters are provided, usually in multiple
channels (4 to 16).
PWM channels (up to 8) are common on some
processors.
Serial interfaces such as UART, SPI, two wire
interface (I2C), synchronous serial and USB ports
are available
v
Many microprocessors provide multiple
interfaces, all under the userÚs control.
Other functions such as analog amplifiers and
even transceivers are sometimes incorporated
within the chip.
The I/O used for these functions are either digital
I/O (for communication for example) or analog
I/O (for A/D for example)
Ä
A microprocessor is only useful if it can be
programmed.
Programming languages and compilers have been
designed specifically for microprocessors.
The basic method of programming
microprocessors is through the Assembly
programming language
Can be, and very often is done through use of
higher level languages with C leading.
Ä
These are specific compilers, adapted for a class
of microprocessors.
They are based on a standard C compiled (such as
ANSI C) and modified to produce executables that
can be loaded onto the microprocessor.
Most microprocessors can be programmed in
circuit allowing changes to be made, or the
processors to be programmed or reprogrammed
after the circuit has been built.
Ä
Instruction sets for microprocessors are small and
based on the assembly language nomenclature.
Microprocessors have been designed for integer
operations.
Programming for control, especially sequential
control is simple and logical.
Floating point operations and, are either not
practical or difficult and tedious.
They also tend to require considerable time and
should only be attempted if absolutely necessary.
Ä
There are both integer and floating point
libraries freely available.
Floating point operations are only practical
on the larger microprocessors because they
require much memory.
Äc= (low level, 6 pin),
Äc= (midrange, 18 pin),
Äc= (high level, 64 or 80 pin),
ð (high level, 64 pin).
A comparison of these typical processors
will reveal most of the properties and
capabilities of microprocessors.
c c
±
± Ä
± c
c
Ú
v
Ä
ÿ
c
Ú
v
c
v
c
c
=
a ?
?
? ? ? ?
?
?
?
?
?
? ?
?
?
?
?
?? ?
? ?
?
?
v? ?
?
?
Ä !
?
?
[?"# $
$ !
??
!
?
?
?
%
?
?
? ?
%
!
?
?
0
"
/#wÄ?
,1
w,-
??
2
* 1? ?.
( ?
? ?
?
? ",/#
?
? 2/#
(
? ?
? !?
? "
'??
Ú
???
0 wÄ
*$
?
0
?
3 ?
Ä,
0 ?
?
?
?? ?
v
Ä?
?
!
3
?
?
?,
(?
?
? ?
?
v
0
? " 4
$?
5
,!
4
1000Ω
12V
microprocessor
thermistor
500Ω at 20°C
v
(4
$-&.61$
(4
$-&1.617,1$
(4
$-&5.65,81$
$?! 7,1$
,81$
,81$? $ ?
?
v
?
7,1$ ? ?
??
$
8$, ?!?
,91$
,1$
?
:
:, ?!?
!?
,8$ 1,$
v* ?
?
???
v ??? ? ?
[?* ?
??
!?
?
C
S
R
v* ?
[?
?
[
?
v"$4 ,7$4,
v ?
'
? !*?
$ !? ,9 ?
400Ω 400Ω
12V
optical coupler
sensor driver
LED photodiode
?
?
% ?!? !?
? ?
? " !!? ?
(
?
2 ?
v
? "
, 8$
( ?
!
?- '
.
Ä ?
?
v
"
Vdd Vdd
Vdd Vdd
230Ω
load
load
$&11, $
(
/ Ä )
Ä .=
(2)
Ä3
? ?
?
?
?
"8
? ?
?
?
? ?
?#
- !? !
? .
?
(?
?
, ?"
?
v
?
2 ?
0
! 0?
?
? ?
? 2
?
?
? ? & !
? ! ?
? ? ??
?0
*
? !
!
?!?