Module 2 YP

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Module 2

PART 1: Micro-processors and Micro-controllers

CONTENTS:
1.1. Introduction
1.2. Microprocessor systems
1.3. Basic elements of control system
1.4. Microcontrollers
1.5. Differences between Microprocessor and microcontroller

PART 2: Microprocessor Architecture

Microprocessor architecture terminology- CPU, memory and address, I/O and Peripheral

devices, ALU, Instruction and Program, Assembler, Data Registers, Program Counter, Flags

Fetch cycle, write cycle, state bus interrupts. Intel‟s 8085A Microprocessor Architecture of

Microprocessor

1
1.1 Introduction
Programmable Logic Devices (PLD) are programmable systems and are generally used in

manufacturing automation to perform different control functions, according to the programs

written in its memory, using low level languages of commands. There are following three

types of PLDs are being employed in mechatronics systems.

1 Microprocessor
It is a digital integrated circuit which carries out necessary digital functions to process the

information obtained from measurement system.

2 Microcomputer
It uses microprocessor as its central processing unit and contains all functions of a computer.

3 Programmable Logic Controller (PLC)


It is used to control the operations of electro-mechanical devices especially in tough and

hazardous industrial environments.

Fig 1: A typical programmable machine has basic three components

1. Processor
which processes the information collected from measurement system and takes logical

decisions based on the information. Then it sends this information to actuators or

output devices.

2. Memory
it stores the input data collected from sensors and the programs to process the

information and to take necessary decisions or actions. Program is a set of instructions

written for the processor to perform a task. A group of programs is called software.

3. Input/output devices
these are used to communicate with the outside world/operator.

1.2. Microprocessor systems

Fig 2: Schematic of configuration of a micro processor

It is a multi-purpose, programmable device that reads binary instructions from a storage

device called memory, processes the data according to the instructions, and then provides

results as output. In common practice it is also known as CPU (central processing unit). CPU

can be referred as complete computational engine on a single chip. First Microcontroller,

Intel 4004 was launched in 1971. It was able to process just 4 bits. It started a new era in

electronics engineering. Microprocessor chip was one of the important inventions of the 20th

century.

3
Table 1: the history of micro-processors.

Applications of microprocessors are classified primarily in two categories:

1. Reprogrammable Systems: Micro computers

2. Embedded Systems: photocopying machine, Digital camera

Microprocessor works or operates in binary digits i.e. 0 and 1, bits. These bits are nothing but

electrical voltages in the machine, generally 0 - low voltage level, and 1 - high voltage level.

A group of bits form a „word‟. In general, the word length is about 8 bits. This is called as a

„byte‟. A word with a length of 4 bits is called as a „Nibble‟.

Microprocessor processes the „commands in binary form‟ to accomplish a task. These are

called as „instructions‟. Instructions are generally entered through input devices and can be

stored in a storage device called memory.

Functions of microprocessor:
Various functions of microprocessor are as follows:

a. Microprocessor performs a variety of logical and mathematical operations using its ALU.

b. It controls data flow in a system and hence can transfer data from one location to

another based on the instructions given to it.


c. A microprocessor can take necessary decisions and jump to a new set of instructions based

on those decisions.

1.3. Basic elements of control system


The word control means “to regulate”, “manipulate” and “command”.

A control system may be defined as A group of devices/elements which maintains the

required output based on the predefined value by controlling the parameter responsible for

output.

Classification of control system:


1. Open loop control system (NO FEEDBACK control system).

2. Closed loop control system (WITH FEEDBACK control system).

1. Open loop control system (NO FEEDBACK control system):

A control system in which the output is dependent on the input, but input is independent of

output is called open loop control system. E.g.: ON/OFF of an electric lamp, traffic signal

2. Closed loop control system (WITH FEEDBACK control system):

5
A control system in which input is depend on the output. i.e., variation in the output

influences the input by some means of controlling on the input is called a closed loop system.

E.g.: Speed control of an automobile, Water level control of overhead tanks.

The basic elements of a closed loop control system are:

1. Comparison element.

2. Control unit.

3. Correction unit.

4. Process unit.

5. Feedback unit.

Functions of each elements of a closed loop system:


Comparison element: this unit compares the reference value with feedback value and

produces an error signal.

Error = reference value – feedback value

Control unit: Control unit analyses the error signal and decides what action is to be taken.

Correction unit: the modified signal from the control unit will be received by the correction

unit which produces a change in the process to correct or change the controlled condition.

Process unit: process unit is the unit which is being controlled.

Differences between open loop control system and closed loop control system
Microprocessor based controllers:
Introduction:
Recent development in the large scale integration (LSI), VLSI, SVLSI of semiconductor

devises and the resulting availability of inexpensive microprocessor, memory chips and

analog to digital converters (ADC) have made it possible to use computer as integral part of

control system without much increase in cost. Some of the application areas of

microprocessor and microcontroller based control system include; Automatic washing

machine, automatic cameras, ATM, Computers, Automatic engine management systems,

Disc drivers in system, Industrial automations, etc.

Block diagram of a microprocessor based control system:

Fig 3: Microprocessor based control system

Using data acquisition system (DAS) which converts the analog signals, from various sensors

to digital signals that can be processed by a microprocessor.

A keyboard in the system allow the user to enter set point values which are stored in the

memory and the feedback of the current values of the process variable are into the memory,

Relays, solenoids values, DAC and other actuators are used to control the process variables

using the program.

7
Block diagram of a microprocessor based processor control system of an Automatic
camera:

Fig 4: Automatic Camera


Working:
Camera is used to photograph an object; the switch is pressed which activates the system.

The range sensor sense the distance of the object to be photographed and this data is input to

microprocessor. The microprocessor in turn sends on output to motor to drive to position the

lens for focusing. The position of the lens is input to microprocessor. Next the light sensor

sends the signal of light intensity on the object to microprocessor. Based on this, signals are

sent to control the duration of time the shutter have to be kept open. All these action and

reaction take place within a fraction of second.

Once the film has exposed, the information is input to the microprocessor which gives

output for driving the motor for advancing the film to drive and the camera is ready for the

next exposure.

Block diagram of a microprocessor based processor control system of Automatic


washing machine:
Fig 5: Automatic Washing Machine
Working:
This is a sequential control system wherein control is exercised based on event, or parameter

etc., i.e., control action will be executed one after another event. The events to be carried out

in a domestic washing machine are soaking, washing, rinsing and drying.

Each of these operations involves a number of steps. Soaking involves selection of correct

quantity of detergent and water based on the type and amount of cloth. This requires opening

of the valve to fill the machine drum to required level and closing the valve once the required

level of water has reached and rotating the drum in either direction for a pre-set amount of

time during the soaking operation.

This is followed by washing which is a time parameter event. Then the rinsing event which

measures the pH value using a chemical sensor of water in the drum and compares it with

supply of water.

This event continues till the pH value of the water in the cloth and the supply water are

equal. Finally drying operation till the minimum percentage of moisture is retained in the

cloth. All these events were earlier controlled with the help of mechanical system involving a

set of cam operated switches.

In modern washing machine mechanical system is replaced by digital devices. i.e., a

microcontroller and the sequence of instruction; program embedded in the microcontrollers.

The amount of detergent, amount of water, pH value is all sensed by the sensor and these

sensed qualities are input to the microcontroller.

9
Based on the input and the software embedded, the corresponding output of the

microcontroller to carry out the different sequence of operations.

Block diagram of Engine management system using microprocessor:

Fig 6: Engine Management System


Engine management system is used for managing the ignition and air/fuel requirement of an

IC engine. In the case of four stroke multi cylinder petrol engine, each cylinder has a piston

performing all the four stroke (suction, compression, working or expansion and exhaust

strokes) and the piston rod of each Piston connected to common crankshaft, and their power

strokes at different times resulting power for rotation of the crankshaft.

The power and speed of an engine are functions of ignition timing and air/fuel mixture.

Hence, by controlling the ignition timing and air/fuel mixture it is possible to control the

speed and power of the engine in modern cars the ignition timing, opening and closing of

valves at appropriate time, quality of air/fuel mixture are controlled by microprocessor with

the help of sensors. For ignition timing the crankshaft drives a distributor which makes

electrical contacts for each spark plug and turns a timing wheel. The timing wheel generates

pulses which are input the microprocessor.


1.4 Microcontroller
Microcontroller is a microprocessor based system. It is a data processing system that employs

a microprocessor as its central unit. Based on the input it takes decisions. These decisions are

further used to control a system or to actuate an action or operation.

Fig 4: Schematic of microcontroller.


It is a microprocessor-based system. It implements the functions of a computer and a

controller on a single chip. Generally, microcontroller is programmed for one specific

application and it is dedicated to a specific control function.

Microcontrollers find applications in automobiles, aircraft, medical electronics and home

appliances. They are small in size and can be embedded in an electromechanical system

without taking up much space. Thus we can have a system with its functions completely

designed into a chip. However, microcontrollers have very little user programmable memory.

Various types of microcontroller chip available in market are: Motorola

68HC11, Zilog Z8 and Intel MCS51 and 96 series.

1.5. Differences between Microprocessor and microcontroller


The differences are listed below and are considered as a major distinguishing parameters

between the Microprocessor and microcontroller

11
Table 2: Microprocessor and microcontroller comparison

PART 2: Microprocessor Architecture

Microprocessor Architecture

A microprocessor is the central processing unit (CPU) of a computer. It is where processing

of program instructions and data occurs. A basic computer consists of a microprocessor,

external memory, and input and output devices.

The central processing unit (CPU) built on a single chip forms the heart of a computer. The

CPU controls all the devices connected to it.


Fig 1: central processing unit (CPU)

Arithmetical Logical Unit (ALU):


As name indicates it has two parts: Arithmetical unit which is responsible for Mathematical

operations like addition, subtraction, multiplication and division, Logical unit which is

dedicated to take logical decisions like greater than, less than, equal to, not equal to etc.

(Basically AND/OR/NOT Operations)

Memory:
There are two different types of memory segments being used by the CPU. First is the ROM

which stands for Read Only Memory while other is R/W which stands for Read and Write

Memory or Random Access Memory (RAM).

ROM: From this memory unit, CPU can only read the stored data. No writing operations can

be done in this part of memory. Thus it is used to store the programs that need no alteration or

changes like Monitor Program or Keyboard driver etc.

There are four types of ROM‟s. they are masked ROM, programmable ROM, Erasable

programmable ROM and electrically erasable programmable ROM

ROM: It is a memory device in which the data is stored permanently. ROM‟s are

programmed with the required contents. No data can then be written into this memory chip in

the computer
13
PROM: Here the ROM can be programmed

EPROM: Here the programmed chip can be altered. The data is erased by shining UV light

through a quartz window on the top of the device

EEPROM: It is similar to EPROM; however, the erasing is done the application of high

voltage instead of UV light. Each of the memory locations are identified with the help of a

binary number known as address.

RAM: As name indicates it is opposite to ROM and used for both reading and writing

operations. In general User‟s program and instruction are stored in this segment of memory

unit.

I/O Devices:
Input Devices: Input devices are used to enter input data to microprocessor from Keyboard or

from ADC which receives data from sensors/signal conditioning systems.

Output Devices: These devices display the results/conclusions coming out from ALUs either

in soft copy (Monitor) or in Hard Copy (Printer).

Internal Architecture of 8085 Microprocessor


Register Array
8085 Microprocessor consists of six registers, one accumulator and a flag register. The

typical architecture is shown in figure 6. There are six general-purpose registers B, C, D, E,

H, and L, each having capacity to store 8-bit data. They are combined as BC, DE, HL to

perform 16 bit operations. In addition to this Register array, two 16 bit registers viz. stack

register and program counter are provided. As discussed in the earlier lecture, the

„program counter‟ is employed to sequence the execution of instructions. It always points to

the memory address from which the next byte is to be fetched. Stack Pointer points to the

memory location in R/W (Read and/or write) memory. It is also termed as a „stack‟.
Fig 2: Architecture of 8085 microprocessor

Accumulator
The accumulator is 8-bit register (can store 8-bit data). It is a part of arithmetic/logic unit

(ALU). In general, after performing logical or arithmetical operations, result is stored in

accumulator. Accumulator is also identified as Register A.

Program Counter (PC)


The program counter contains the memory address of the next program instruction to be

executed. A program counter is a register in a computer processor that contains the address

(location) of the instruction being executed at the current time. As each instruction gets

fetched, the program counter increases its stored value by 1. ... Within a computer, an

address is a specific location in memory or storage.

Registers

15
Microprocessors have temporary data holding places called registers. These memory areas

maintain data, such as computer instructions, storage addresses, characters and other data.

Some computer instructions may require the use of certain registers as part of a command.

Each register has a specific function, such as instruction register, program counter,

accumulator and memory address register. For example, a program register holds the address

of instructions taken from random access memory.

Assembler
An assembler is a program that converts assembly language into machine code. It takes the

basic commands and operations from assembly code and converts them into binary code that

can be recognized by a specific type of processor.

Assemblers are similar to compilers in that they produce executable code. However,

assemblers are more simplistic since they only convert low-level code (assembly language) to

machine code. Since each assembly language is designed for a specific processor, assembling

a program is performed using a simple one-to-one mapping from assembly code to machine

code. Compilers, on the other hand, must convert generic high-level source code into machine

code for a specific processor.

Flags
ALU of 8085 have five flip flops whose states (set/reset) are determined by the result data of

other registers and accumulator. They are called as Zero, Carry, Sign, Parity and Auxiliary-

Carry flags.

A) Zero Flag (Z): When an arithmetic operation results in zero, the flip-flop called the Zero

flag - which is set to one.

B) Carry flag (CY): After an addition of two numbers, if the sum in the accumulator is

larger than eight bits, then the flip-flop uses to indicate a carry called the Carry flag – which

is set to one.

C) S-Sign (S): It is set to 1, if bit D7 of the result = 1; otherwise reset. D7 is the first digit of a

binary number.
A) P-Parity (P): If the result has an even number of 1s, the flag is set to 1; for an odd number

of 1s the flag is reset.

B) AC-Auxiliary Carry (AC): In an arithmetic operation, when a carry is generated

by digit D3 and passed to digit D4, the AC flag is set. Generally, this flag is used internally

for Binary Coded Decimals (BCD).

Instruction Register/Decoder
Before execution of an instruction, it is sent to the Instruction Register. Instruction register

stores current instruction of any program. Decoder takes the instruction from memory,

decodes it and then passes it to the next stage.

Memory Address Register


Memory Address Register (MAR) holds the address of next instruction to be executed.

Control Generator
In microprocessor, the Control Generator generates a signal that executes the operations in

accordance to the decoded instructions. In fact it creates a signal (information) which have

details about connections between different blocks of the microprocessor so that data reaches

to the respective place.

Register Selector
Register selector is basically a logical controller which directs switching between different

registers of microprocessor.

17
General Purpose Registers
Microprocessor has few extra registers which can be used to store additional data during a

program.

Programming in 8085
As mentioned in above section, a simple and very effective substitution to binary codes could

be use of standard English words to complete any task. For example, addition of two numbers

can be represented by ADD. Such codes are referred as mnemonic codes and that language is

called assembly language. Most of the early processers including

8085, are programmed using mnemonics. However, assembly language codes should be

converted into binary one so that microprocessor can identify the instructions given to it. This

operation is done by Assembler. In assembly language, instructions are composed of two

segments which are as follows:

C. Operation (Op) Code: It depends on which operation is to be performed. For example, for

OR operation, we have Op Code “OR”.

D. Operands: Operand is the object on which the required operation is to be done. Generally,

operations are done on data stored in registers.

Classification of Instructions:
A) Data Transfer
B) Arithmetic
C) Logical
D) Program Control

Data Transfer
1. Load: It reads content from specified memory location and copies it to specified register

location in CPU.

2. Store: It copies content of a specified register into specified memory location.

Arithmetic:
Add: It adds contents of a specified memory location to the data in some register. B

Decrement: It subtracts 1 from contents of specified location.

Compare: It tells whether contents of a register are greater than, less than or same as content

of specified memory location.

Logical:
AND: Instruction carries out Logical AND operation with the contents of specified memory

location and data in some register. Numbers are ANDed bit by bit.

OR: Instruction carries out Logical OR operation with the contents of specified memory

location and data in some register. Numbers are ORed bit by bit.

Logical Shift: Logical shift instruction involves moving a pattern of bits in the register one

place to left or right by moving a zero in the end of number.

Program Control:
Jump: This instruction changes the sequence in which program steps are carried out.

Normally program counter causes the program to be carried out sequentially in strict

numerical sequence. However, JUMP causes program counter to some other specified

location in the program.

Branch: This is a conditional instruction which might „branch‟ if „zero‟ results or „branch‟ if

„plus‟ results of an operation. Branch also followed if right conditions occur in the decision

making process.

Halt: This instruction stops all further microprocessor activity.

Fetch cycle
it is called Fetch -decode-execute cycle or sometime it‟s called fetch cycle. In Fetch

cycle, CPU fetch some data or instruction from main memory then store it into its internal

memory called Register, this stage is called Fetch cycle

19
QUESTION BANK:

1. List out any four differences between Microcontroller and Microprocessor. (Dec
2018/Jan 2019), (June /July 2018), (Dec 2014/Jan 2015), (Dec 2013/Jan 2014).

2. Discuss the Basic Elements of Microprocessor based control system. (Dec 2018/Jan
2019), (Dec 2017 /Jan 2018)

3. What is a Register? Sketch and explain Program Counter. (Dec 2018/Jan 2019)

4. Explain with the block diagram of a Microcontroller. (Dec 2018/Jan 2019), (June
/July 2016), (Dec 2013/Jan 2014)

5. Explain in detail with the block diagram the architecture of intel 8085 A
microprocessor (June /July 2018), (June /July 2015), (Dec 2014/Jan 2015), (Dec
2013/Jan 2014)

6. What is a Microprocessor? Explain briefly the three segments of a microprocessor.


(Dec 2013/Jan 2014)

7. Explain briefly the evolution of microprocessor. (Dec 2013/Jan 2014)

8. Explain the memory devices of a microprocessor. (Dec 2018/Jan 2019)

You might also like