Chapter 10 Microcontrollezrs

download Chapter 10 Microcontrollezrs

of 51

Transcript of Chapter 10 Microcontrollezrs

  • 8/10/2019 Chapter 10 Microcontrollezrs

    1/51

    Computing Machinery

    Chapter 10: Microcontrollers

  • 8/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    10/51

    Basic-X35 Schematic

    AT25256

  • 8/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    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/10/2019 Chapter 10 Microcontrollezrs

    20/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    21/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    22/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    23/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    24/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    25/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    26/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    27/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    28/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    29/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    30/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    31/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    32/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    33/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    34/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    35/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    36/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    37/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    38/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    39/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    40/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    41/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    42/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    43/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    44/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    45/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    46/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    47/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    48/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    49/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    50/51

  • 8/10/2019 Chapter 10 Microcontrollezrs

    51/51