2nd chapter mechatronics

50
 By V . THULASIKANTH Assistant Professor Mechanical Engineering Department ME 0304   ELEMENTS OF MECHATRONICS SRM Nagar, Kattankulathur   603 203 1 UNIT  2 MICROPROCESSOR IN MECHATRONICS

Upload: premscrebd

Post on 05-Oct-2015

12 views

Category:

Documents


0 download

DESCRIPTION

BY VIMAL

TRANSCRIPT

  • By

    V. THULASIKANTHAssistant Professor

    Mechanical Engineering Department

    ME 0304 ELEMENTS OF MECHATRONICS

    SRM Nagar, Kattankulathur 603 203

    1

    UNIT 2 MICROPROCESSOR IN MECHATRONICS

  • 2Development of microprocessor systems, 8085 Architecture, Pindiagram, Input and Output peripheral circuits, communications Input, Output and Memory with timing diagrams, A/D and D/Aconvertors. Introduction to design and recent developments inmicroprocessors and controllers.

  • 3DEVELOPMENT OF MICROPROCESSORS

    Earlier we came through implementation of combinational and sequential logic operationsby interconnecting ICs containing gates and flip-flops.

    This is considered a hardware solution because it consists of a selection of specific ICs,which when hardwired on a circuit board, carry out predefined functions.

    To make a change in functionality, the hardware circuitry must be modified and mayrequire a redesign. This is a satisfactory approach for simple design tasks.

    However, in many mechatronic systems, the control tasks may involve complexrelationships among many inputs and outputs, making a strictly hardware solutionimpractical.

    A more satisfactory approach in complex digital design involves the use of amicroprocessor-based system to implement a software solution.

    Software is a procedural program consisting of a set of instructions to execute logic andarithmetic functions and to access input signals and control output signals.

    An advantage of a software solution is that, without making changes in hardware, theprogram can be easily modified to alter a mechatronic systems functionality.

  • 4Intel 8085

  • 5WHAT IS MICROPROCESSOR?

    A microprocessor is a single, very-large-scale-integration (VLSI) chip thatcontains many digital circuits that perform arithmetic, logic, communication, andcontrol functions.

    When a microprocessor is packaged on a printed circuit board with othercomponents, such as interface and memory chips, the resulting assembly isreferred to as a microcomputer or single-board computer.

    In 1971 Intel Corporation introduce 4004, a 4-bit microprocessor and its basiccircuit contains 2300 transistors.

    The Intel 8085 ("eighty-eighty-five") is an 8-bit microprocessor introduced byIntel in 1977.

    5" in the model number came from the fact that the 8085 requires only a +5-Volt(V) power supply.

  • 6The Intel 8085 required at least an external ROM and RAM and an 8 bit addresslatch (both latches combined in the Intel 8755 2Kx8 EPROM / 2x8 I/O, Intel 8155256-byte RAM and 22 I/O and 14 bit programmable Timer/Counter)

    At a first sight, the microprocessors are specified by: Number of bits it canhandle for data processing and speed of operation.

    Higher the bits microprocessor can handle for data processing more faster.

    The speed of the operation is estimated from the clock frequency of themicroprocessor.

    APPLICATIONS OF MICROPROCESSOR

    Actuator control system: Speed, velocity and acceleration control of electricmotor, fluid power actuators.

    Control system for home appliances: Microwave oven, washing machine,refrigerator, heating system, air conditioner, etc

  • 7Control system for computer peripherals.

    Automobile control system: Engine control, locking system, monitoring system, etc

    Traffic control systems: Road, air & ocean traffic, navigation, spindle machines, etc.

    Machine control systems: Robotics, AGV, CNC, etc

    Production lines: Assembly lines, Packaging, etc

    New and advanced versions of microprocessors are constantly being developed.

    Some of the leading companies are;

    IntelMotorolaToshibaFairchild

    PhillipsCyrixNational SemiconductorZilogTexas Instruments

  • 8WORKING OF MICROPROCESSOR

    The microprocessor, also called the central processing unit (CPU) ormicroprocessor unit (MPU), is where the primary computation and systemcontrol operations occur.

    It consists of semiconductor memories like EPROM, RAM, input/output devicean interfacing devices.

    The arithmetic logic unit (ALU) within the CPU executes mathematical functionson data structured as binary words.

  • 9

  • 10

  • 11

    A word is an ordered set of bits, usually 8, 16, 32, or 64 bits long. Theinstruction decoder interprets instructions fetched sequentially from memoryby the control unit and stored in the instruction register.

    Each instruction is a set of coded bits that commands the ALU to perform bitmanipulation, such as binary addition and logic functions, on words stored inthe CPU data registers.

    The ALU results are also stored in data registers and then transferred to memory by thecontrol unit.

    Buses: The buses are group of lines that carries data, address or controlsignals. With the help of buses, the devices communicate with one another.

    Data lines are used to communicate words to and from data registers in the varioussystem components such as memory, CPU, and input/output (I/O) peripherals.

    Address lines are used to select devices on the bus or specific data locations withinmemory.

    Control lines transmit read and write signals, the system clock signal, and othercontrol signals such as system interrupts, which are described in subsequentsections.

  • 12

    A key to a CPUs operation is the storage and retrieval of data from a memorydevice. Different types of memory include read-only memory (ROM),randomaccess memory (RAM), and erasable-programmable ROM (EPROM).

    ROM is used for permanent storage of data that the CPU can read, but the CPUcannot write data to ROM.ROM does not require a power supply to retain its data and therefore is callednonvolatile memory.

    RAM can be read from or written to at any time, provided power ismaintained. The data in RAM is considered volatile because it is lost whenpower is removed.

    There are two main types of RAM: static RAM (SRAM), which retains its data in flip-flopsas long as the memory is powered, and dynamic RAM (DRAM), which consists ofcapacitor storage of data that must be refreshed (rewritten) periodically because ofcharge leakage.

    Data stored in an EPROM can be erased with ultraviolet light applied through atransparent quartz window on top of the EPROM IC. Then new data can bestored on the EPROM

  • 13

    . Another type of EPROM is electrically erasable (EEPROM). Data in EEPROM canbe erased electrically and rewritten through its data lines without the need forultraviolet light.

    Because data in RAM are volatile, ROM, EPROM, EEPROM, and peripheral massmemory storage devices such as magnetic, optical, and solid-state drives aresometimes needed to provide permanent data storage.

    Communication to and from the microprocessor occurs through I/O devicesconnected to the bus.

    External computer peripheral I/O devices include keyboards, printers, displays,and network devices.

    For mechatronic applications, analog-todigital (A/D), digital-to-analog (D/A),and digital I/O (D/D) devices provide interfaces to switches, sensors, andactuators.

    The instructions that can be executed by the CPU are defined by a binary codecalled machine code.

  • 14

    Microprocessors can be programmed using assembly language.

    Programs can also be written in a higher level language such as BASIC or C,provided that a compiler is available that can generate machine code for thespecific microprocessor being used.

  • 15

    8085 Microprocessor It is a 8 bit microprocessor.

    It has 16-bit address bus and hence can address up to 216 = 65536 bytes (64KB)

    memory locations through A0-A15 .

    The first 8 lines of address bus and 8 lines of data bus are multiplexed AD0 AD7

    Data bus is a group of 8 lines D0 D7 .

    It supports external interrupt request.

    A 16 bit program counter (PC)

    A 16 bit stack pointer (SP)

    Six 8-bit general purpose register arranged in pairs: BC, DE, HL.

    It requires a signal +5V power supply and operates at 3.2 MHZ single phase

    clock.

    It is enclosed with 40 pins DIP (Dual in line package).

  • 16

    Architecture of Intel 8085

  • 17

    Six general-purpose registers B, C, D, E, H, L with capacity to store 8 bit dataare employed.

    They are combined as BC, DE, HL to perform 16 bit operations.

    In addition to Register array, two 16 bit registers viz. stack register andprogram counter are provided.

    Program counter is employed to sequence execution of instructions.

    This register always points to the memory address from which next byte is tobe fetched.

    Stack Pointer points to memory location in R/W memory. It is also called as astack'

    AccumulatorThe accumulator is an 8-bit register (can store 8 bit data) that is a part ofarithmetic/logic unit (ALU). In general after performing logical or arithmeticaloperations, result is stored in accumulator. Accumulator is also identified asRegister A.

  • 18

    Flags

    ALU of 8085 have five flip flops whose states (set/reset) are determined by theresult data of various other registers and accumulator. They are called as Zero,Carry, Sign, Parity and auxiliary carry.

    Instruction Register/DecoderBefore execution of instruction, it is sent to Instruction Register. Instructionregister stores current instruction of any program. Decoder takes the instructionfrom memory, decodes it and then passes it to next stage.

    Memory Address RegisterMemory Address Register or generally abbreviated as MAR holds address ofnext instruction to be executed.

  • 19

    The pins on the chip can be grouped into 6 groups:

    1. Address Bus.2. Data Bus.3. Control and Status

    Signals.4. Power supply and

    frequency.5. Externally Initiated

    Signals.6. Serial I/O ports.

  • The Address and Data Bus Systems

    The address bus has 8 signal lines A8 A15 which are unidirectional.

    The other 8 address bits are multiplexed (time shared) with the 8 data bits.

    So, the bits AD0 AD7 are bi-directional and serve as A0 A7 and D0 D7 at the same time.

    During the execution of the instruction, these lines carry the address bits during the early part, then during the late parts of the execution, they carry the 8 data bits.

    In order to separate the address from the data, we can use a latch to save the value before the function of the bits changes.

  • The Control and Status Signals

    There are 4 main control and status signals. These are: ALE: Address Latch Enable. This signal is a pulse that

    become 1 when the AD0 AD7 lines have an addresson them. It becomes 0 after that. This signal can beused to enable a latch to save the address bits fromthe AD lines.

    RD: Read. Active low. WR: Write. Active low. IO/M: This signal specifies whether the operation is a

    memory operation (IO/M=0) or an I/O operation(IO/M=1).

    S1 and S0 : Status signals to specify the kind ofoperation being performed. Usually not used in smallsystems.

  • Frequency Control Signals

    There are 3 important pins in the frequency control group.

    X0 and X1 are the inputs from the crystal or clock generating circuit. The frequency is internally divided by 2. So, to run the microprocessor at 3 MHz, a clock

    running at 6 MHz should be connected to the X0 and X1 pins.

    CLK (OUT): An output clock pin to drive the clock of the rest of the system.

  • Control and Status Signals.

  • RESET signal

    Following are the two kind of RESET signals:

    RESET IN: an active low input signal, Program Counter (PC) will be set to 0 and thus MPU will reset.

    RESET OUT: an output reset signal to indicate that the p was reset (i.e. RESET IN=0). It also used to reset external devices.

  • 25

    Direct Memory Access (DMA)

    DMA is an IO technique where external IO device

    requests the use of the MPU buses.

    Allows external IO devices to gain high speed access to the

    memory.

    Example of IO devices that use DMA: disk memory system.

    HOLD and HLDA are used for DMA.

    If HOLD=1, 8085 will place it address, data and control

    pins at their high-impedance.

    A DMA acknowledgement is signaled by HLDA=1.

  • 26

    Interrupt signals

    An interrupt is a hardware-initiated subroutine CALL.

    When interrupt pin is activated, an ISR will be called, interrupting the program that is currently executing.

  • 27

    Timing diagram of 8085

    Timing diagram is the display of initiation of read/write and transferof data operations under the control of 3-status signals IO / M , S1,

    and S0.

    As the heartbeat is required for the survival of the human being, theCLK is required for the proper operation of different sections of the

    microprocessors.

    All actions in the microprocessor is controlled by either leading ortrailing edge of the clock.

    The execution of instruction always requires read and writesoperations to transfer data to or from the P and memory or I/Odevices.

    Each read/ write operation constitutes one machine cycle (MC1)

  • 28

    Each machine cycle consists of many clock periods/ cycles, called T-states.

    The heartbeat of the microprocessor is the clock period.

    Each and every operation inside the microprocessor is under thecontrol of the clock cycle.

    The clock signal determines the time taken by the microprocessor toexecute any instruction.

    The clock cycle shown in Fig. has two edges (leading and trailing orlagging).

    State is defined as the time interval between 2-trailing or leadingedges of the clock.

    Machine cycle is the time required to transfer data to or from memoryor I/O devices.

  • 29

  • 30

    PROCESSOR CYCLE

    The function of the microprocessor is divided into fetch andexecute cycle of any instruction of a program.

    In the normal process of operation, the microprocessor fetches(receives or reads) and executes one instruction at a time in the

    sequence until it executes the halt (HLT) instruction.

    Thus, an instruction cycle is defined as the time required to fetchand execute an instruction.

    For executing any program, basically 2-steps are followedsequentially with the help of clocks, (1) Fetch and (2) Execute.

    The time taken by the P in performing the fetch and executeoperations are called fetch and execute cycle.

  • 31

    Each read or writes operation constitutes a machine cycle.

    The instructions of 8085 require 15 machine cycles containing 36states (clocks).

    The 1st machine cycle of any instruction is always an OpCode fetchcycle in which the processor decides the nature of instruction.

    It is of at least 4-states. It may go up to 6-states.

  • 32

    The processor during (M1 cycle) puts the program countercontents on the address bus and reads the opcode of the

    instruction through read process.

    The T1, T2, and T3 clock cycles are used for the basic memoryread operation and the T4 clock and beyond are used for its

    interpretation of the opcode.

    Based on these interpretations, the P comes to know the type ofadditional information/data needed for the execution of the

    instruction and accordingly proceeds further for 1 or 2-machine

    cycle of memory read and writes.

    The Op. code fetch cycle is of fixed duration (normally 4-states),whereas the instruction cycle is of variable duration depending on

    the length of the instruction.

  • 33

    A2D and D2A ConvertersDigital signals

    Out put from the most sensors tends to be in analog form, if we use microprocessor as a

    part of measurement or control system.

    Analog output from the sensor has to be converted into digital form before we get it as a

    input to microprocessor.

    Same way most of the actuators need analog input and so digital input from the

    microprocessor should be converted to analog form before sending to actuators.

    SENSOR PAnalog ADC Digital Digital DAC Analog

    ACTUATOR

  • Analog Signals

    Analog signals directly measurable quantities in terms of some other quantity

    Examples:

    Thermometer mercury height rises as temperature rises

    Car Speedometer Needle moves farther right as you accelerate

    Stereo Volume increases as you turn the knob.

    Digital Signals

    Digital Signals have only two states. For digital computers, we refer to binary states, 0 and 1. 1 can be on, 0 can be off.

    Examples:

    Light switch can be either on or off

    Door to a room is either open or closed

  • 35

    A digital signal is superior to an analog signal because

    it is more robust to noise and can easily be recovered,

    corrected and amplified. For this reason, the tendency

    today is to change an analog signal to digital data.

  • Examples of A/D Applications

    Microphones - take your voice varying pressure waves in the air and convert them into varying electrical signals

    Strain Gages - determines the amount of strain (change in dimensions) when a stress is applied

    Thermocouple temperature measuring device converts thermal energy to electric energy

    Voltmeters

    Digital Multimeters

  • 37

    In practice, an ADC is usually in form of an integrated circuit (IC).

    ADC0808 and ADC0809 are two typical examples of 8-bit ADC with 8-

    channel multiplexer using successive approximation method for its

    conversion.

    ADC0809

    National Semiconductor

  • Just what does an

    A/D converter DO?

    Converts analog signals into binary words

  • 4.39 Pulse Code Modulation (PCM) Delta Modulation (DM)

  • Analog signal is sampled every TS sec.

    Ts is referred to as the sampling interval.

  • Analog Digital Conversion 2-Step Process:

    Quantizing - breaking down analog value is a

    set of finite states

    Encoding - assigning a digital word or

    number to each state and matching it to the

    input signal

  • Step 1: Quantizing

    Example:

    You have 0-10V

    signals. Separate them

    into a set of discrete

    states with 1.25V

    increments. (How did

    we get 1.25V? See

    next slide)

    Output

    States

    Discrete Voltage

    Ranges (V)

    0 0.00-1.25

    1 1.25-2.50

    2 2.50-3.75

    3 3.75-5.00

    4 5.00-6.25

    5 6.25-7.50

    6 7.50-8.75

    7 8.75-10.0

  • Quantizing

    The number of possible states that the converter can output is:

    N=2n

    where n is the number of bits in the AD converter

    Example: For a 3 bit A/D converter, N=23=8.

    Analog quantization size:

    Q=(Vmax-Vmin)/N = (10V 0V)/8 = 1.25V

  • Encoding

    Here we assign the

    digital value (binary

    number) to each

    state for the

    computer to read.

    Output

    States

    Output Binary Equivalent

    0 000

    1 001

    2 010

    3 011

    4 100

    5 101

    6 110

    7 111

  • Accuracy of A/D Conversion

    There are two ways to best improve accuracy of A/D conversion:

    increasing the resolution which improves the accuracy in measuring the amplitude of the analog signal.

    increasing the sampling rate which increases the maximum frequency that can be measured.

  • Resolution

    Resolution (number of discrete values the converter can

    produce) = Analog Quantization size (Q)

    (Q) = Vrange / 2^n, where Vrange is the range of analog

    voltages which can be represented

    limited by signal-to-noise ratio (should be around 6dB)

    In our previous example: Q = 1.25V, this is a high

    resolution. A lower resolution would be if we used a 2-bit

    converter, then the resolution would be 10/2^2 = 2.50V.

  • 47

    A/D Converter TypesNumerous methods are used for converting analog signals to digital

    form. Five most commonly used methods are listed below:

    Staircase ramp Successive approximation Dual slope Voltage to frequency Parallel (or flash)

  • Reg

    iste

    r

    Voltage

    Switch

    Resistive

    Summing

    NetworkAmplifier

    Input Binary

    Number

    Analog Voltage

    Output

    48

    DACs are electronic circuits that convert digital, (usually binary) signals

    (for example, 1000100) to analog electrical quantities (usually voltage)

    directly related to the digitally encoded input number.

    D/A Converter

    DACs are used in many other applications, such as voice synthesizers,

    automatic test system, and process control actuator. In addition, they

    allow computers to communicate with the real (analog) world.

  • 49

    Register: Use to store the digital input (let it remain a

    constant value) during the conversion period.

    Voltage: Similar to an ON/OFF switch. It is closed when

    the input is 1. It is opened when the input is 0.

    Resistive Summing Network: Summation of the

    voltages according to different weighting.

    Amplifier: Amplification of the analog according to a pre-

    determined output voltage range. For example, an

    operation amplifier

  • 50