Chapter 3
Chapter 3
Chapter 3
and Microcontrollers
Ali Parsayan
[email protected]
1
Chapter 3
Microcontrollers
2
Outline
• Introduction
• Memories
• Microcontroller Features
• Applications of Microcontrollers
3
Embedded Systems
8
Microcontrollers
9
Microcontrollers
10
Microcontrollers
11
Microcontrollers Families
• Intel Family:
o Intel 8061.
o Intel i960.
o Intel MCS-48.
o MCS-51.
o Intel MCS-96.
o Intel MCS-296.
o Intel Quark. CPU RAM ROM
o ……………..
I/O Serial
Timer COM
Port
Port
12
Microcontrollers Families
13
Microcontrollers Families
• PIC Family – “Peripheral Interface Controller”
• Made by Microchip Technology
• Most popular by industry developers and hobbyists
– PIC10 and PIC12.
– PIC16.
– PIC17.
– PIC18.
– PIC24 and dsPIC.
– PIC32M MIPS-based line.
– PIC32MX.
– PIC32MZ.
– …………… 14
Microcontrollers Families
STM32F4DISCOVERY
➢ STM32F407VGT6 microcontroller
➢ 32-bit Arm®(a) Cortex®-M4
➢ with FPU core,
➢ 1-Mbyte Flash memory,
➢ 192-Kbyte RAM memory.
o …………………
15
Microcontrollers Different Features
16
Microcontroller:
Supply Voltage
• Most microcontrollers operate with the
standard logic voltage of +5V.
• Some microcontrollers can operate at as
low as +2.7V and some will tolerate + 6V
without any problems
17
Microcontroller:
Power-on Reset
• Some microcontrollers (e.g. PIC) have built-in
power-on reset circuits which keep the
microcontroller in reset state until all the internal
circuitry has been properly initialized.
• This feature is very useful as it starts the
microcontroller from a known state on power-up.
• An external reset can also be provided where the
microcontroller can be reset when an external
button is pressed.
18
Microcontroller:
Reset Input
• A reset input is used to reset a microcontroller
externally.
• Resetting puts the microcontroller into a known
state such that the program execution starts from
a known address (usually address 0) of the
program memory.
• An external reset action is usually achieved by
connecting a push-button switch to the reset
input such that the microcontroller can be reset
when the switch is pressed.
19
Microcontroller:
Reset Input
20
Microcontroller:
Central Processor Unit – CPU
• As its name indicates, this is a unit which monitors and
controls all processes inside the microcontroller.
• It consists of several smaller units, of which the most
important are:
21
Microcontroller:
Central Processor Unit – CPU
o Buses:
➢ Physically, the buses consists of 8, 16 or more wires.
➢ There are two types of buses: address and data bus.
➢ The first one consists of as many lines as necessary
for memory addressing.
➢ It is used to transmit address from CPU to memory.
➢ The later one is as wide as data, in our case it is 8 bits
or wires wide.
➢ It is used to connect all circuits inside the
microcontroller.
22
Microcontroller:
Memories
23
Microcontroller:
Memories - RAM
• Most microcontrollers have some amount of
internal RAM.
• 256 bytes is a common amount, although some
microcontrollers have more, some less.
• For example, Intel 8051 microcontroller has 128
bytes of RAM.
• In general, it is not possible to extend the RAM
memory of microcontrollers easily.
• The user should select a different microcontroller
if the RAM memory provided is not enough.
24
Microcontroller:
Memories - ROM
• Today’s microcontrollers commonly use 16-bit
addressing, which means that they are able to address
up to 64 Kb memory, i.e. 65535 locations.
• There are several types of ROM:
o Masked ROM. Microcontrollers containing this ROM are
reserved for the great manufacturers. Program is loaded into
the chip by the manufacturer. In case of large scale
manufacture, the price is very low. Forget it...
o OTP ROM (One Time Programmable ROM). If the
microcontroller contains this memory, you can download a
program into the chip, but the process of program
downloading is “one-way ticket”, meaning that it can be done
only once.
25
Microcontroller:
Memories - ROM
o PROM is programmable Read Only Memory.
This is a type of ROM that can be
programmed in the field, often by the end user,
using a device called a PROM programmer.
o Once a PROM has been programmed, its
contents cannot be changed.
o PROMs are usually used in low production
applications where only a small batch (e.g.
several similar samples) of such memories are
required.
26
Microcontroller:
Memories - ROM
o EPROM is Erasable Programmable Read Only
Memory. This is similar to ROM, but the EPROM
can be programmed using a suitable programming
device.
27
Microcontroller:
Memories - ROM
o EPROM memories have a small clear glass window on top of
the chip where the data can be erased under strong
ultraviolet light. Once the memory is programmed, the
window can be covered with dark tape to prevent accidental
erasure of the data (e.g. under direct sunlight).
o An EPROM memory must be erased before it can be re-
programmed. Many development versions of
microcontrollers are manufactured with EPROM memories
where the user programs can be stored.
o These memories are erased and re-programmed until the user
is satisfied with the program.
o Some versions of EPROMs, known as OTP (One Time
Programmable), can be programmed using a suitable
programmer device , but once programmed the se memories
can not be erased. 28
Microcontroller:
Memories - ROM
o EEPROM is Electrically Erasable Programmable Read Only
Memory, which is a non-volatile memory.
o These memories can be erased and also be re-programmed
using suitable programming devices.
o EEPROMs are used to save configuration information,
maximum and minimum values of a variable, identification
data, passwords and so on.
o Some microcontrollers have built-in EEPROM memories. e.g.
PIC18F452 contains a 256-byte EEPROM memory where
each byte can be programmed and erased directly by the
applications software .
o EEPROM memories are usually very slow.
o The cost of an EEPROM chip is much higher than that of an
EPROM chip.
29
Microcontroller:
Memories - ROM
o Flash EEPROM. This is another version of
EEPROM type memory.
o This memory has become popular in microcontroller
applications and is used to store the user program.
o Flash EEPROM is non-volatile and is usually very
fast. The data can be erased and then re-
programmed using a suitable programming device.
o Some microcontrollers have only 1K flash EEPROM
while some others have 32K or more.
o Intel 8051 microcontroller has 4K bytes and
PIC18F452 microcontroller has 32K bytes of flash
memory.
30
Microcontroller:
Memories - ROM
• EEPROM type data memory is also very common in
many microcontroller architectures.
• The advantage of an EEPROM memory is that the
programmer can store non-volatile data in such a
memory, and can also change this data whenever
required.
• For example, in a temperature monitoring application
the maximum and the minimum temperature readings
can be stored in an EEPROM memory.
• Another typical application of these memories in
microcontroller systems is to store configuration data or
passwords.
31
Microcontroller:
Clock Pulse
• All microcontrollers require a clock to operate.
• The clock is usually provided by connecting external
timing devices to the microcontroller.
• Most microcontrollers will generate clock signals when a
crystal and two small capacitors are connected to their
oscillator inputs.
• Some will operate with resonators or external resistor-
capacitor pair.
• Some microcontrollers have built-in timing circuits and
they do not require any external timing components.
• For applications where the timing is very critical it is
recommended to use an external crystal for timing.
32
Microcontroller:
Clock Pulse
• An instruction is executed by fetching it from the
memory and then decoding it.
• This usually takes several clock cycles and is known as
the instruction cycle.
• In most of the microcontrollers an instruction cycle
takes four clock periods.
o Thus, the microcontroller is actually operated at a clock rate
which is a quarter of the actual oscillator frequency.
• In general, most microcontrollers can operate with clock
frequencies up to 8MHz.
• Higher end microcontrollers can operate at up to
100MHz, and some 32-bit microcontrollers can operate
at up to 200MHz or at higher frequencies. 33
Microcontroller:
Oscillator
• The microcontroller oscillator uses quartz crystal or ceramic
resonator for frequency stabilization.
• Furthermore, it can also operate without elements for
frequency stabilization (like RC oscillator).
• The pulses coming from the oscillator enable harmonic and
synchronous operation of all circuits of the microcontroller.
• It is important to say that instructions are not executed at
the rate imposed by the oscillator itself, but several times
slower.
o It happens because each instruction is executed in several
steps.
• In some microcontrollers, the same number of cycles is
needed to execute any instruction, while in others, the
execution time is not the same for all instructions. 34
Microcontroller:
Oscillator
35
Microcontroller:
Timers
• Timers are important parts of any microcontroller
system.
• A timer is basically a counter which is driven either from
an external clock pulse or from the internal oscillator of
the microcontroller.
• A timer can be 8-bits, 16-bits , or 32-bits wide. \
• Data can be loaded into a timer under program control
and the timer can be stopped or started by program
control.
• Most timers can be configured to generate an interrupt
when they reach a certain count (usually when they
overflow).
36
Microcontroller:
Timers
37
Microcontroller:
Timers
• In practice, everything works as follows:
o Pulses coming from quartz oscillator are once per each
machine cycle directly or via prescaler brought to the circuit
which increments number in the timer register.
o If one instruction (one machine cycle) lasts for four quartz
oscillator periods then, by embedding quartz with the
frequency of 4MHz, this number will be changed a million
times per second (each microsecond).
• It is easy to measure short time intervals (up to 256
microseconds) in a way described above because it is the
largest number that one register can contain.
• This obvious disadvantage may be easily overcome in
several ways by using slower oscillator, registers with
more bits, prescaler or interrupts. 38
Microcontroller:
Timers
39
Microcontroller:
Timers
• A prescaler is an electronic device used to reduce a
frequency by a pre-determined factor.
• Meaning that in order to generate one pulse on its
output, it is necessary to bring 1, 2 , 4 or more pulses to
its input.
• One such circuit is built in the microcontroller and its
division rate can be changed from within the program.
• It is used when it is necessary to measure longer periods
of time.
• One prescaler is usually shared by timer and watch-dog
timer, which means that it cannot be used by both of
them simultaneously.
40
Microcontroller:
Timers
41
Microcontroller:
Timers
• If the timer register consists of 8 bits, the largest
number that can be written to it is 255 (for 16-bit
registers it is the number 65.535).
• If this number is exceeded, the timer will be
automatically reset and counting will start from
zero.
• This condition is called overflow.
• If enabled from within the program, such
overflow can cause interrupt, which gives
completely new possibilities.
42
Microcontroller:
Timers
43
Microcontroller:
Watchdog Timer
• Most microcontrollers have at least one watchdog
module. The watchdog is basically a timer which is
refreshed by the user program and a reset occurs if the
program fails to refresh the watchdog.
• The watchdog timer is used to detect a system problem,
such as for example the program being in an endless
loop.
• A watchdog is a safety feature that prevents runaway
software and stops the microcontroller from executing
meaningless and unwanted code.
• Watchdog facilities are commonly used in real-time
systems where it may be required to regularly check the
successful termination of one or more activities. 44
Microcontroller:
Watchdog Timer
45
Microcontroller:
Watchdog Timer
46
Microcontroller:
Interrupts
• Interrupts are very important concepts in
microcontrollers.
• An interrupt causes the microcontroller to
respond to external and internal (e.g. a timer)
events very quickly.
• When an interrupt occurs, the microcontroller
leaves its normal flow of program execution and
jumps to a special part of the user program,
known as the Interrupt Service Routine (ISR).
47
Microcontroller:
Interrupts
48
Microcontroller:
Interrupts
• The program code inside the ISR is executed and upon return
from the ISR the program resumes its normal flow of execution.
• The ISR generally starts from a fixed address of the program
memory.
• This address is also known as the interrupt vector address.
• Some microcontrollers with multi-interrupt features have just one
interrupt vector address, while some others have unique interrupt
vector addresses, one for each interrupt source.
• Interrupts can be nested such that a new interrupt can suspend
the execution of another interrupt.
• Another important feature of a microcontroller with multi-
interrupt capability is that different interrupt sources can be
given different levels of priority.
49
Microcontroller:
Brown-out Detector
• Brown-out detectors are also common in many
microcontrollers.
• They reset a microcontroller if the supply voltage
falls below a nominal value.
• Brown-out detectors are safety features and they
can be employed to prevent unpredictable
operation at low voltages, especially to protect the
contents of EEPROM type memories when the
supply voltage falls.
50
Microcontroller:
Analogue-to-Digital Converter (A/D)
• An analogue-to-digital converter (A/D) is used to convert an
analogue signal such as voltage to a digital form so that it can be
read and processed by a microcontroller.
• Some microcontrollers have built-in A/D converters.
• It is also possible to connect an external A/D converter to any type
of microcontroller.
• A/D converters are usually 8 to 10 bits, having 256 to 1024
quantization levels.
• A/D converters usually generate interrupts when a conversion is
complete so that the user program can read the converted data as
soon as it is available.
• A/D converters are very useful in control and monitoring
applications since most sensors produce analogue output voltages.
51
Microcontroller:
Analogue-to-Digital Converter (A/D)
52
Microcontroller:
Serial Communication
• Some microcontrollers have built-in hardware called USART
(Universal Synchronous-Asynchronous Receiver-Transmitter)
to implement a serial communication interface.
• The communication parameters such as the baud rate and
the data format can usually be selected by the user program.
• If any serial input-output hardware is not provided, it is easy
to develop software to implement serial data communication
using any I/O pin of a microcontroller.
o Such software usually makes use of the microcontroller
timer or delay routines.
• Serial communication enables a microcontroller to be
connected to another microcontroller or to a PC using a
serial type interface.
53
Microcontroller:
Serial Communication
54
Microcontroller:
UART (RS232)
• UART (also called RS232 communication) is Universal
Asynchronous Receiver/Transmitter.
• This connection is asynchronous, which means that a
special line for clock signal transmission is not used.
• Since only one communication line is used, both receiver
and transmitter operate at the same predefined rate in
order to maintain necessary synchronization.
• This is a very simple way of transferring data since it
basically represents conversion of 8-bit data from
parallel to serial format.
55
Microcontroller:
UART (RS232)
56
Microcontroller:
UART (RS232)
57
Microcontroller:
𝑰𝟐 𝑪
• Some microcontrollers incorporate 𝑰𝟐 𝑪 (Integrated Inter Connect)
or SPI (Serial Peripheral Interface) hardware bus interfaces.
• These enable a microcontroller to interface to other compatible
devices easily.
• 𝑰𝟐 𝑪 is a system used when the distance between the
microcontrollers is short and specialized integrated circuits of a
new generation (receiver and transmitter are usually on the same
printed circuit board).
• Connection is established via two conductors, one is used for data
transfer whereas another is used for synchronization (clock
signal).
• The two 𝑰𝟐 𝑪 signals are called ‘serial data’ (SDA) and ‘serial clock’
(SCL).
58
Microcontroller:
𝑰𝟐 𝑪
59
Microcontroller:
𝑰𝟐 𝑪
• Any number of slaves and masters can be connected onto these 2
signal lines and communicate between each other using a protocol:
oFirst, the master will issue a START condition.
➢ This acts as an ‘Attention’ signal to all of the connected devices.
oAll slaves on the bus will listen to the bus for incoming data.
oThen the master sends the ADDRESS (7-bits slave address) of the device it wants
to access, along with an indication whether the access is a Read or Write
operation.
o data is divided into 8-bit bytes. a few control bits for controlling the
communication start, end, direction and for an acknowledgment mechanism.
oHaving received the address, all slaves will compare it with their own address.
➢ If it doesn’t match, they simply wait until the bus is released by the stop
condition.
➢ If the address matches, however, the slave will produce a response called the
ACKNOWLEDGE signal.
o Once the master receives the acknowledge, it can start transmitting or receiving
DATA.
oWhen all is done, the master will issue the STOP condition. 60
Microcontroller:
𝑰𝟐 𝑪
61
Microcontroller:
𝑰𝟐 𝑪
62
Microcontroller:
SPI
• SPI (Serial Peripheral Interface Bus) is a single-master communication
protocol.
o This means that one central device initiates all the communications with the
slaves.
• It is full duplex connection, which means that data are sent and received
simultaneously.
• SPI is a protocol on 4 signal lines:
o A clock signal named SCLK, sent from the bus master to all slaves; all the SPI
signals are synchronous to this clock signal;
o A slave select signal for each slave, SSn, used to select the slave the master
communicates with;
o A data line from the master to the slaves, named MOSI (Master Out-Slave In)
o A data line from the slaves to the master, named MISO (Master In-Slave Out).
• When the SPI master wishes to send data to a slave and/or request information
from it, it selects slave by pulling the corresponding SS line low and it activates
the clock signal at a clock frequency usable by the master and the slave.
63
Microcontroller:
SPI
64
Microcontroller:
SPI
65
Microcontroller:
SPI
66
Microcontroller:
LCD Drivers
• LCD drivers enable a microcontroller to be
connected to an external LCD display directly.
• These drivers are not common since most of the
functions provided by them can be implemented
easily in software.
• For example, PIC18F6490 microcontroller has
built-in LCD driver module where an LCD can
be connected directly.
67
Microcontroller:
Analogue Comparator
• Analogue comparators are used where it is
required to compare two analogue voltages.
• These circuits are implemented in some different
family microcontrollers as high-end PIC family
microcontrollers.
• For example, PIC18F series of microcontrollers
have built-in analog comparator modules.
68
Microcontroller:
Real-Time Clock
• Real-time clock enables a microcontroller to
have absolute date and time information
continuously.
• Built-in real-time clocks are not common in
most microcontrollers since they can easily
be implemented by either using a dedicated
real-time clock chip, or by writing a
program.
69
Microcontroller:
Sleep Mode
• Some microcontrollers offer built-in sleep
modes where executing this instruction puts
the microcontroller into a mode where the
internal oscillator is stopped and the power
consumption is reduced to an extremely low
level.
• The main reason of using the sleep mode is
to conserve the battery power when the
microcontroller is not doing anything useful.
70
Microcontroller:
Low Power Operation
• Low power operation is especially
important in portable applications where
the microcontroller-based equipment is
operated from batteries.
• Some microcontrollers can operate with less
than 2mA at 5V supply, and around 15 μA
at 3V supply.
71
Microcontroller:
Current Sink/Source Capability
• This is important if the microcontroller is to
be connected to an external device which
may draw large current for its operation.
• For example, PIC microcontrollers can
source and sink 25mA of current from each
output port pin.
• The current capability of a microcontroller
input-output pin can be increased by
connecting external transistor switching
circuits or relays to the output port pins.
72
Microcontroller:
USB Interface
• USB is currently a very popular computer
interface specification used to connect
various peripheral devices to computers
and microcontrollers.
• Some high-end microcontrollers provide
built-in USB modules.
• For example, PIC18F2x50 has built-in USB
interface capabilities.
73
Microcontroller:
Ethernet Interface
• Some high-end microcontrollers provide
TCP/IP-based Ethernet (Intranet or
Internet) data communication capabilities.
• Such microcontrollers can easily be used in
network-based applications.
74
Microcontroller:
ZigBee Interface
• ZigBee is an interface similar to Bluetooth
and is used in low-cost wireless home
automation applications.
• Some high-end microcontrollers provide
ZigBee interface capabilities making the
design of such wireless systems very easy
specially for IoT applications.
75
Applications of Microcontrollers
76
Applications of Microcontrollers
Embedded System
• What is an embedded system?
o If we take any engineering product that needs
control, and if a computer is incorporated
within that product to undertake the control,
then we have an embedded system.
o An embedded system can be defined as a
system whose principal function is not
computational, but which is controlled by a
computer embedded within it.
77
Applications of Microcontrollers
Embedded System
• These days embedded systems are everywhere, appearing in the
home, office, factory, car or hospital.
• The next table lists some example products that are likely to be
embedded systems, all chosen for their familiarity.
• While many of these examples seem very different from each
other, they all draw on the same principles as far as their
characteristics as embedded systems are concerned.
• The vast majority of users will not recognize that what they are
using is controlled by one or more embedded computers.
• Indeed, if they ever saw the controlling computer they would
barely recognize it as such.
• Most people, after all, recognize computers by their screen,
keyboard, disc drives and so on.
• These embedded computers would have none of those.
78
Applications of Microcontrollers
Embedded System
• Some familiar examples of embedded systems
79
Applications of Microcontrollers:
domestic refrigerator
• A simple domestic refrigerator is shown in the next figure.
• It needs to maintain a moderately stable, low internal
temperature.
• It does this by sensing its internal temperature and comparing it
with the temperature required.
• It lowers the temperature by switching on a compressor.
• The temperature measurement requires one or more sensors, and
then whatever signal conditioning and data acquisition circuitry
that is needed.
• Some sort of data processing is required to compare the signal
representing the measured temperature to that representing the
required temperature and deduce an output.
80
Applications of Microcontrollers:
domestic refrigerator
81
Applications of Microcontrollers:
domestic refrigerator
• Controlling the compressor requires some form of electronic
interface, which accepts a low-level input control signal and then
converts this to the electrical drive necessary to switch the
compressor power.
• This process of control can be done by a conventional electronic
circuit or it can be done by a small embedded computer.
• If used, the embedded computer could be designed simply to
replicate the minimalist control process described above.
• Once a little computer is in place, however, there is tremendous
opportunity for ‘added value’.
• With the signal in digital form and processing power now readily
available, it is an easy step to add features like intelligent displays,
more advanced control features, a better user control mechanism
and so on.
82
Applications of Microcontrollers:
domestic refrigerator
• Taking the idea of added value one step further, once an
embedded computer is in place it is possible to network
it to other computers, embedded or otherwise.
o This opens up wide new horizons, allowing a small system to become
a subset of a much larger system and to share information with that
system.
o This is now happening with domestic products, like the refrigerator,
as well as much more complex items.
o The diagram of the next figure, while specific to a fridge, actually
represents very well the overall concept of an embedded system.
o There is an embedded computer, engaged in reading internal
variables, and outputting signals to control the performance of the
system.
o It may have human interaction (but in general terms does not have
to) and it may have networked interaction. 83
Applications of Microcontrollers:
domestic Oven
• Microcontroller based simple oven temperature control system
84
Applications of Microcontrollers:
domestic Oven
• User-friendly temperature control system with a keypad and LCD
85
Applications of Microcontrollers:
A car door mechanism
• A very different example of an embedded system
is the car door, as shown in the next figure.
• Once again there are some sensors, some human
interaction and a set of actuators that must
respond to the requirements of the system.
• One set of sensors relates to the door lock and
another to the window.
• There are two actuators, the window motor and
the lock actuator.
86
Applications of Microcontrollers:
A car door mechanism
87
Applications of Microcontrollers:
A car door mechanism
• It might appear that a car door could be designed as a self-
contained embedded system, in a similar way to the fridge.
• Initially, one might even question whether it is worthy of any form
of computer control whatsoever, as the functions seem so simple.
• Once again, by creating it as an embedded system, we see the
opportunity to enhance functionality.
• Now we have the door status and actuators under electronic
control, they can be integrated with the rest of the car.
• Central locking can be introduced, or an alarm sounded if the
door is not locked when the driver tries to pull away.
• There is therefore considerable advantage in having a network
which links the humble actions of the door control to other
functions of the car.
88
Applications of Microcontrollers:
The electronic ‘ping- pong’ game
• This little game, shown in the next figure, is a game for
two players, who each have a push-button ‘paddle’.
• Either player can start the game by pressing his/her
paddle.
• The ball, represented by the row of eight LEDs (light-
emitting diodes), then flies through the air to the
opposing player, who must press his paddle only when
the ball is at the end LED and at no other time.
• The ball continues in play until either player violates this
rule. Once this happens, the non-violating player scores
and the associated LED is briefly lit up. When the ball is
out of play, an ‘out-of-play’ LED is lit.
89
Applications of Microcontrollers:
The electronic ‘ping- pong’ game
90
Applications of Microcontrollers:
The electronic ‘ping- pong’ game
• All the above action is controlled by a tiny embedded computer, a
microcontroller, made by a company called Microchip.
• It takes the form of an 18-pin integrated circuit (IC), and has
none of the visible features that one would normally associate with
a computer.
• Nevertheless, electronic technology is now so advanced that inside
that little IC there are a Central Processing Unit (CPU), a
complex array of memories, and a set of timing and interface
circuits.
• One of the memories contains a stored program, which it executes
to run the game.
• It is able to read in as inputs the positions of the switches (the
player paddles) and calculate the required LED positions.
• It then has the output capability to actually power the LEDs to
which it is connected. 91
Applications of Microcontrollers:
The Derbot Autonomous Guided Vehicle
• Another project used later in this book is the
Derbot (Derby Robot) Autonomous Guided
Vehicle (AGV), pictured in the next figure.
• Looking at the photograph, we can see from the
front that it bristles with sensors and actuators.
• Two micro switch bump detectors sense if the
Derbot hits an obstacle.
• An ultrasound detector, mounted on a servo
actuator, is there with the aim of ensuring that
the Derbot never has an unexpected collision!
92
Applications of Microcontrollers:
The Derbot Autonomous Guided Vehicle
93
Applications of Microcontrollers:
The Derbot Autonomous Guided Vehicle
• Two light sensors on either side of the servo are used for
light tracking applications; a third, not seen in the photo,
is mounted at the rear.
• A further navigational option is a compass, so that
direction can be determined from the earth’s magnetic
field.
• Locomotion is provided by two geared DC motors, while
a sensor on each (again not seen in this picture) counts
wheel revolutions to calculate actual distance moved.
• Steering is achieved by driving the wheels at different
speeds.
• A piezo-electric sounder is included for the AGV to alert
its human user. 94
Applications of Microcontrollers:
The Derbot Autonomous Guided Vehicle
• The block diagram is shown in the Figure.
• The Derbot operates as an embedded system,
reading in values from its diverse sensors and
computing outputs to its actuators.
• It is controlled by another Microchip
microcontroller, hidden from view in the picture
by the battery pack.
• This microcontroller is seemingly more powerful
than the one in the ping-pong game, as it needs to
interface with far more inputs and drive its
outputs in a more complex way. 95
Applications of Microcontrollers:
The Derbot Autonomous Guided Vehicle
96
Applications of Microcontrollers:
The Derbot Autonomous Guided Vehicle
• The CPU of each microcontroller (for all
examples shown above) is the same.
• They are differentiated primarily by their
interface capabilities.
• Basically, a microcontroller (or a microprocessor)
executes a user program that is loaded in its
program memory.
• Under the control of this program, data are
received from external devices (inputs),
manipulated, and then sent to external devices
(outputs). 97
Applications of Microcontroller:
Fluid level control system
• In a microcontroller-based fluid level control system the
aim is to control the level of the fluid at a given point.
• Here, the fluid level is read by the microcomputer via a
level sensor device.
• The program running inside the microcontroller then
actuates the pump and the valve and attempts to control
the fluid level at the required value.
• If the fluid level is low, the microcomputer operates the
pump to draw more fluid from the reservoir.
• In practice, the pump is controlled continuously in order
to keep the fluid at the required level.
98
Applications of Microcontroller:
Fluid level control system
• The next figure shows the block diagram of our simple
fluid level control system.
• The system shown in the next figure is a very simplified
fluid level control system.
• In a more sophisticated system we may have a keypad to
set the required fluid level, and an LCD to display the
current fluid level in the tank.
• The second figure shows the block diagram of this more
sophisticated fluid level control system.
• We can make our design even more sophisticated (see
the last figure) by adding an audible alarm to inform us
if the fluid level is outside the required point.
99
Applications of Microcontroller:
Fluid level control system
• Micro controller-Based Fluid Level Control System.
100
Applications of Microcontroller:
Fluid level control system
• Fluid Level Control System with a Keypad and LCD
101
Applications of Microcontroller:
Fluid level control system
• More Sophisticated Fluid Level Controller.
102
• Also, the actual level at any time can be sent to a PC every second
for archiving and further processing.
• For example, a graph of the daily fluid level changes can be
plotted on the PC.
• Wireless interface (e.g. Bluetooth or RF) or internet connectivity
can be added to the system so that the fluid level can be monitored
or controlled remotely.
• Also, the actual level at any time can be sent to a PC every second
for archiving and further processing.
• For example, a graph of the daily fluid level changes can be
plotted on the PC.
• Wireless interface (e.g. Bluetooth or RF) or internet connectivity
can be added to the system so that the fluid level can be monitored
or controlled remotely.
103
Applications of Microcontroller:
Fluid level control system
• Using Bluetooth for Remote Monitoring and Control.
104
Applications of Microcontrollers:
Speed control of a direct current (DC) motor
• Another example of a microcontroller-based
system is the speed control of a direct current
(DC) motor.
• The next figure shows the block diagram of such
a system.
• Here, a speed sensor device reads current speed
of the motor and this is compared with the
desired speed (which is assumed to be analog).
• The error signal between the desired and the
actual speed is converted into digital and fed to a
microcontroller.
105
Applications of Microcontrollers:
Speed control of a direct current (DC) motor
• A control algorithm running on the microcontroller generates
control signals that are converted into analog form and are fed to
a power amplifier.
• The output of the power amplifier drives the motor to achieve the
desired speed.
• Depending upon the nature of the signals the block diagram given
in the next figure can take different shapes.
• For example, if the output of the speed sensor is digital (e.g.
optical encoder) and the set speed is also digital, then there is no
need to use the A/D converter at the input of the microcontroller.
• Also, the D/A converter can be eliminated if the power amplifier
can be driven by digital signals.
• A microcontroller is a very powerful tool that allows a designer to
create sophisticated I/O data manipulation under program
control. 106
Applications of Microcontrollers:
Speed control of a direct current (DC) motor
• DC Motor Control System
107
Manufacturers of
Microcontrollers and Microprocessors
• Actel. FPGA with 8051 and ARM7 cores.
• Advanced Micro Devices (AMD). Microprocessors compatible
with xx86.
• Altera. FPGA with Nios II core.
• Analog Devices. Architectures for digital signal processing based
on 8052, ARM7, and other processors.
• Applied Micro Circuits Corp. (AMCC). Architectures based on
the PowerPC microprocessor.
• ARC International. Architectures based on ARC 600, ARC 700,
etc., microprocessors.
• ARM. Architectures based on ARM7, ARM9, ARM10, etc.,
microprocessor cores.
• Atmel. Architectures based on Marc 4, AVR, 8051, ARM7, ARM9,
ARM11, PowerPC, and SPARC. 108
Manufacturers of
Microcontrollers and Microprocessors
• Broadcom. Processors for communications and data networks
with MIPS architecture.
• Cambridge Consultants. Architectures based on XAP1, XAP2,
and XAP3 core processors.
• Cavium Networks. Architectures based on MIPS.
• Cirrus Logic. Architectures based on ARM.
• Cradle Technologies. Digital signal processors: CT3400 and
CT3600.
• Cyan Technology. Microcontroller eCOG1k.
• Cybernetic Micro Systems. ASICs with microcontroller P-51.
• Cypress Microsystems. Devices with PSoC (Programmable
System-on-Chip) architecture.
• Dallas Semiconductor. 8051-compatible microcontrollers.
• EM Microelectronics. Very low consumption EM6812. 109
Manufacturers of
Microcontrollers and Microprocessors
• Freescale Semiconductor (from Motorola). Microcontrollers
68HC05, 68HC08, 68HC11, 68HC12, and 68HC16. DSPs.
Processors ColdFire and PowerQuicc with PowerPC core.
• Fujitsu Microelectronics America. Microcontrollers FR80,
MB9140x, and F2MC-8FX.
• Goal Semiconductor. Architectures based on 8051.
• Holtek Semiconductor. Microcontroller HT8.
• Hyperstone. Digital Signal Processors E1-32XSR/XSRU,
HyNet32S, etc.
• Infineon Technologies (formerly Siemens). Microcontrollers C500,
C800, C166, TriCore, etc.
• Infrant Technologies. Microcontrollers for data networks.
• Integrated Device Technology (IDT). Data Communications
processors based on MIPS architecture. 110
Manufacturers of
Microcontrollers and Microprocessors
• Intel. Microcontrollers from families MCS51, MCS151, MCS251,
MCS96, MCS296, etc. Microprocessors xx86, IXP4xx, etc.
• Microchip Technology. Microcontrollers PIC (PICmicro) and
digital signal controllers dsPIC.
• MIPS Technologies. Processors MIPS (Microprocessor without
Interlocked Pipeline Stages).
• National Semiconductor. Microcontrollers COP8 and CR16, and
microprocessors NS32000.
• NEC Electronics America. Microcontrollers 78K0, V850, and
others.
• NetSilicon. Processors based on ARM7 and ARM9 cores.
• NXP Semiconductors (formerly Philips Semiconductors).
Microcontrollers with 8051, ARM7, and ARM9 cores.
• Oki Semiconductor. Microcontrollers with ARM core. 111
Manufacturers of
Microcontrollers and Microprocessors
• PMC-Sierra. MIPS-based processors.
• Rabbit Semiconductor. Processors Rabbit 2000 and 3000.
• Renesas Technology (formerly Hitachi). Microcontrollers R8, H8, and others.
• Sharp Microelectronics. Microcontrollers BlueStreak with ARM7 and ARM9
core.
• Silicon Laboratories. Microcontrollers with 8051 core.
• Silicon Storage Technology. Microcontrollers with 8051 core.
• STMicroelectronics. Microcontrollers with 8051 and ARM7 cores.
• Texas Instruments (TI). Digital signal processors TMS370 and
TMS470. Microcontrollers MSP430.
• Toshiba America Electronic Components. Microcontrollers CISC and RISC.
• Ubicom. Microcontrollers SX, IP2000, and IP3000.
• Xemics. Microcontrollers with CoolRISC core.
• Xilinx. FPGA with PowerPC cores.
• ZiLOG. 8-bit microcontrollers with Z8 and Z80 architectures.112
Question?
113