chapter 10 microcontrollers
TRANSCRIPT
-
8/11/2019 Chapter 10 Microcontrollers
1/51
Computing Machinery
Chapter 10: Microcontrollers
-
8/11/2019 Chapter 10 Microcontrollers
2/51
Microprocessors vs. Microcontrollers
The primary difference between a microprocessor and a microcontroller is that the
microcontroller includes more supporting functions such as on-board memory and I/O
than the microprocessor.
Until recently, microcontroller units (MCU's) were considered less powerful than
microprocessors, however, continued development has lead to MCU's that meet or
exceed the throughput (number of equivalent instructions per second) of high-end
microprocessors.
The power of some modern
microcontrollers is equal to high-
end CPU's but more specific in
their designs and applications than
general-purpose microprocessors.
Microcontrollers offer many
application specific features such
as I2C and CAN bus
communications and video
controllers.
Microcontroller
-
8/11/2019 Chapter 10 Microcontrollers
3/51
Embedded Systems
An embedded systemis a device or module designed for a specific purpose and based on
some computational (software modifiable) element. One of the key features of an
embedded system is real-time operation.
http://www.ece.cmu.edu/~koopman/iccd96/iccd96.html
-
8/11/2019 Chapter 10 Microcontrollers
4/51
The Harvard Architecture separates the data and instructions into separate memory
units each with their own bus. Besides speeding up the data transfer rate, separating
the data from the instructions permits us to implement different bus widths and wordsizes for program and data memory space.
Harvard Architecture
-
8/11/2019 Chapter 10 Microcontrollers
5/51
Digital Signal Processors
Digital Signal Processors (DSP's) are types of microcontrollers that are more specialized
for a particular application. DSP represent around 20% of the total MCU market.
DSP's are particularly well suited to real-time operations in which a data stream, video,
audio, etc. is modified in someway as it is passed along to another device or
component.
Most DSP's are based on the Harvard Architecture. DSP's commonly include analog-to-
digital (A/D) conversion for their inputs and digital-to-analog (D/A) conversion of theiroutputs.
-
8/11/2019 Chapter 10 Microcontrollers
6/51
Pulse Width Modulation
Pulse Width Modulation (PWM)- Many MCU are designed to generate variable width
squarewave signals as shown below. A pulse width modulated (PWM) signal is a
squarewave with a varying ratio of high and low logic levels, called the duty cycle.
The PWM signal is defined by two parameters, the frequency and the duty cycle.
A 10% duty cycle signal is at a logical high 10% of the time and low 90% of the
time. The average rate at which the signal oscillates between logic levels is given
by the frequency in cycles per second (Hertz).
-
8/11/2019 Chapter 10 Microcontrollers
7/51
Digital to Analog Conversion
A PWM signal can be filtered using passive electronic components (e.g. an RC
[resistor-capacitor] network) to generate a smoothed average voltage level. A
controlled voltage level or power level can be delivered using PWM signals.
-
8/11/2019 Chapter 10 Microcontrollers
8/51
Serial I/O Interface (UART)
The Universal Asnychronous Receiver/Transmitter (UART) is a popular form of serial
communication between digital devices.
A number of bits are presented to the UART in parallel and are then serialized,transmitted to another UART where they are converted back into a binary vector.
The UART specification does not include details of the communication details.
In fact, there are several interface standards in common use (e.g. RS232, RS422 and
RS485). For embedded systems the RS232 standard is the most popular.
-
8/11/2019 Chapter 10 Microcontrollers
9/51
The Serial Peripheral Interface (SPI)
This is a communications protocol used on most MCU's as an inexpensive
alternative to multiple pin parallel communications. SPI is used for many
applications in MCU including memory data block transfers. The SPI interface
include a clock line, a data-in, a data-out and a chip enable line, named as,
SCLK - serial clock
MISO - master input, slave output
MOSI - master output, slave input
CS - chip select (optional, usually inverted polarity)
-
8/11/2019 Chapter 10 Microcontrollers
10/51
Basic-X35 Schematic
AT25256
-
8/11/2019 Chapter 10 Microcontrollers
11/51
The Inter-Integrated Circuit (I2C) computer bus is used to interface many different
types of peripherals to MCU's or other embedded systems when a high data throughput
is not required.
The I2C uses bidirectional data and clock lines with open-collector logic. The standard
data rate for the I2C is 100 kilobits/second. It also support a low-speed 10 Kbits/s or
lower.
The I2C protocol is ideal for sending control signals to remote devices, collecting A/D
signals from sensors and accessing slow-speed non-volatile RAM.
One of the most valuable features is that periperals can be connected and removed from
the I2C bus while powered up. This is possible because of the open-collector logic in
which a bus line is either set to ground or no-connection.
In open-collector circuits, a logical high is achieved by placing pull-up resistor on each
open-collector line.
I2C Communications
-
8/11/2019 Chapter 10 Microcontrollers
12/51
Controller Area Nework (CAN) Bus
This is a multicast shared serial
bus standard. The CAN bus wasdesigned to operate in high noise
conditions, which makes it a
preferred communications standard
for applications involving
electrical motors and internal
combustion engines.
The CAN protocol uses error-
correcting codes to automatically
detect and recover bit errors in data
words. The the full data transfer
rate of 1Mbit/s the total length ofthe CAN network is limited to less
than 50 meters.
-
8/11/2019 Chapter 10 Microcontrollers
13/51
Analog-to-Digital (ADC)
Many of the devices and sensors interfaced to a MCU produce varying voltage levels
(analogsignals) rather than binary vectors (digitalsignals). For this reason most modern
MCU's include built-in analog-to-digital (A/D)conversion circuits. These circuits accept
a voltage level on an input line and generate an internal binary encoded value that
corresponds to the magnitude of the voltage.
-
8/11/2019 Chapter 10 Microcontrollers
14/51
Aliasing
When we choose a sampling rate, we are setting a limit on the maximum frequency (or
time rate of change) of the signal that we will be able to measure.
Shown below are two signals of different frequencies. The lower frequency signal is
being sampled at a rate of 12 samples per cycle of the signal. If we replace this signal
with one with a frequency that is 11 times higher we will be sampling this signal a little
more that once per cycle. As shown the sampled voltage levels will match those of the
lower frequency signal. This effect is called aliasing.
To prevent aliasing we need to sample at a rate at least twice as high (in samples per
second) at the highest frequency signal we want to measure (in cycles/second).
-
8/11/2019 Chapter 10 Microcontrollers
15/51
Digital to Analog (D/A)
This is the process of converting a digital (binary encoded) value into an analog voltage
level. This operation is much less common on an MCU, but can be implemented using a
varying duty-cycle signal and some passive electronics for filtering (see Pulse Width
Modulation above). A much better aproach is to use a linear amplifier as a summing
circuit, as shown in Figure 10-6. This is an example of a digital to analog (D/A) circuit
called anR2R ladder network.
http://www.play-hookey.com/analog/d2a_converter.html
-
8/11/2019 Chapter 10 Microcontrollers
16/51
A prescaler is a circuit that divides an incoming clock signal by a predetermined
amount. An N level prescaler is sometimes called a divide-by-N counter.
Prescalar
-
8/11/2019 Chapter 10 Microcontrollers
17/51
AVR A/D
The AVR MCU includes 8 A/D input circuits. These cicuits can operate in two different
modes, either single conversion and free run.
When in single conversion mode, each conversion must be prompted by the runningprogramming.
In free-run mode the A/D conversion is started and will run continuously with updated
values being placed in the ADC data register.
-
8/11/2019 Chapter 10 Microcontrollers
18/51
BasicX Microcontrollers
The BasicX system is the MCU and the software development environment for a PC-
compatible desktop computer running the Microsoft Windows operating system.
BASIC programs are written and compiled on the PC and downloaded onto theBasicX MCU through a serial interface to an EEPROM or a parallel USB interface
(which needs some additional circuitry).
As with the AVR and PIC18, the BasicX is in-circuit/FLASH programmable. The
BX-24 and BX-35 IC's are depicted in Figure 10-22. The BX-35 is also available as a
surface mount IC.
BasicX-35 BasicX-24
-
8/11/2019 Chapter 10 Microcontrollers
19/51
The BasicX MCU's offer the following features:
25 I/O Lines BX-35 (16 I/O Lines BX-24)
- (17 TTL I/O BX-35) (8 TTL I/O BX-24)
- 8 Channel Analog-to-Digital Converters (10-bit) or TTL
32 KB EEPROM (external for BX-35) for program and data storage
On-chip RAM 400 bytes
Program execution speed 60 microseconds per 16 bit integer add/subtract
Serial I/O speed 2400 baud to 460.8 Kbaud on Com1
300 baud to 19 200 baud on any I/O pin (Com3)
Operating voltage range - 4.0 VDC to 6.0 VDC
I/O internal pull-up resistors 120 k maximumFloating point math
On-chip multitasking
On-chip clock/calendar
Built-in SPI interface
Parallel or serial FLASH Programmable
-
8/11/2019 Chapter 10 Microcontrollers
20/51
-
8/11/2019 Chapter 10 Microcontrollers
21/51
-
8/11/2019 Chapter 10 Microcontrollers
22/51
-
8/11/2019 Chapter 10 Microcontrollers
23/51
-
8/11/2019 Chapter 10 Microcontrollers
24/51
-
8/11/2019 Chapter 10 Microcontrollers
25/51
-
8/11/2019 Chapter 10 Microcontrollers
26/51
-
8/11/2019 Chapter 10 Microcontrollers
27/51
-
8/11/2019 Chapter 10 Microcontrollers
28/51
-
8/11/2019 Chapter 10 Microcontrollers
29/51
-
8/11/2019 Chapter 10 Microcontrollers
30/51
-
8/11/2019 Chapter 10 Microcontrollers
31/51
-
8/11/2019 Chapter 10 Microcontrollers
32/51
-
8/11/2019 Chapter 10 Microcontrollers
33/51
-
8/11/2019 Chapter 10 Microcontrollers
34/51
-
8/11/2019 Chapter 10 Microcontrollers
35/51
-
8/11/2019 Chapter 10 Microcontrollers
36/51
-
8/11/2019 Chapter 10 Microcontrollers
37/51
-
8/11/2019 Chapter 10 Microcontrollers
38/51
-
8/11/2019 Chapter 10 Microcontrollers
39/51
-
8/11/2019 Chapter 10 Microcontrollers
40/51
-
8/11/2019 Chapter 10 Microcontrollers
41/51
-
8/11/2019 Chapter 10 Microcontrollers
42/51
-
8/11/2019 Chapter 10 Microcontrollers
43/51
-
8/11/2019 Chapter 10 Microcontrollers
44/51
-
8/11/2019 Chapter 10 Microcontrollers
45/51
-
8/11/2019 Chapter 10 Microcontrollers
46/51
-
8/11/2019 Chapter 10 Microcontrollers
47/51
-
8/11/2019 Chapter 10 Microcontrollers
48/51
-
8/11/2019 Chapter 10 Microcontrollers
49/51
-
8/11/2019 Chapter 10 Microcontrollers
50/51
-
8/11/2019 Chapter 10 Microcontrollers
51/51