Top Banner
Microcontroller Based Design Muhammad Usman Rafique
40
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Micro Week 1

Microcontroller Based Design

Muhammad Usman Rafique

Page 2: Micro Week 1

Week 1 - Introduction

Air University, Spring 2015 2 M. Usman Rafique

Page 3: Micro Week 1

Course Introduction

Microcontroller Based Design – MT 253

4 Credit Hours Theory 2

Lab 2

Instructor M. Usman Rafique

Lab Control Instrumentation Lab, Mini Block

Lab Engineer: Ahmad Abdullah

Air University, Spring 2015 3 M. Usman Rafique

Page 4: Micro Week 1

Course Introduction

Course Website

sites.google.com/site/mtsengg/courses/micro

Microcontroller Based Design

Lecture Notes, Assignments and Grading will be uploaded on the course web

Air University, Spring 2015 4 M. Usman Rafique

Page 5: Micro Week 1

Course Outline

Air University, Spring 2015 5 M. Usman Rafique

Week Topic

1 Introduction

2 8051Microcontroller

Architecture and Hardware

3 Assembly Language

4 Assembly Language Contd.

5 Timers and Counters

6 Serial Port

7 Interrupt

8, 9 Design and Interface Examples

10 Midterm Exam

11 PIC 18 F Microcontroller

Introduction, Architecture, I/O Pins

12 Programming in C

13 Timers / Counters

14 Using Internal ADC of PIC

15, 16 Peripherals of PIC 18F Microcontrollers

17 Revision

Page 6: Micro Week 1

Module Percentage

Quizzes 5

Assignments 5

Midterm Exam 15

Projects 30

Final Exam 45

Grading Criteria

Air University, Spring 2015 6 M. Usman Rafique

Note: Assignments will be similar to the projects

Page 7: Micro Week 1

Books

8051 Microcontroller

I. Scott Mackenzie and R.C. Phan, “The 8051 Microcontroller”, Fourth Edition, Pearson Education 2007

Muhammad Ali Mazidi and J. G. Mazidi, “The 8051 Microcontroller and Embedded Systems”, Pearson Education 2006

PIC 18F Microcontroller

M. Ali Mazidi, R. D. Mickinlay and D. Causey, “PIC Microcontrollers and Embedded Systems”, Pearson Education 2008

Air University, Spring 2015 7 M. Usman Rafique

Page 8: Micro Week 1

Projects Projects

Projects will be individual Only PCBs are acceptable. Hardware sharing is NOT allowed Documentation is compulsory

Final project

Can be done in groups of up to 3 students

Assignments Individual

In case of copying Zero Points will be awarded to all parties involved

Air University, Spring 2015 8 M. Usman Rafique

Page 9: Micro Week 1

Projects

No. Description Deadline Percentage

8051

1 Generic Board Week 02 05

2 LEDs Week 04 05

3 Serial Communication Week 07 07

4 Interface Project Week 09 08

T1 Lab Test Week 11 15

PIC

1 Generic Board Week 12 05

2 Interface Project 2 Week 15 10

T2 Lab Test Week 16 15

Final Project [Submit Proposals] Week 17 30

9 Air University, Spring 2015 M. Usman Rafique

Page 10: Micro Week 1

Labs

2 Labs per week

Experiments as well as problem solving

Students are welcome to discuss queries

Air University, Spring 2015 10 M. Usman Rafique

Page 11: Micro Week 1

Prerequisites Number Systems

Binary Decimal Hexadecimal

Electronics Basic concepts

DLD Logic Gates Multiplexer, De-multiplexer Encoder, Decoder Basic Concepts

Computer Programming C Basic Concepts

Clear and practice these topics before this course

Air University, Spring 2015 11 M. Usman Rafique

Page 12: Micro Week 1

Introduction

What is a Computer?

Air University, Spring 2015 12 M. Usman Rafique

Page 13: Micro Week 1

Introduction

What is a Computer?

Computer

Device capable of

Performing computations

Making Logical Decisions

Works billions of times faster than human beings

Air University, Spring 2015 13 M. Usman Rafique

Page 14: Micro Week 1

Introduction

What is a Computer?

Programs Set of instructions that process data

Guide computer through orderly sets of actions specified by “Programmer”

Computer System Consists of various hardware devices

Keyboard

Screen

Disks

Memory

Processing Units

Air University, Spring 2015 14 M. Usman Rafique

Page 15: Micro Week 1

Introduction

Computer

Inputs

Outputs

Central Processing Unit

RAM

ROM

ALU

Air University, Spring 2015 15 M. Usman Rafique

Page 16: Micro Week 1

Introduction

Every computer consists of

1. Input Unit

Receiving section of computer

Gets data from input devices e.g. Keyboard, Mouse etc

2. Output Unit

Puts information on various output devices

Monitors

Printouts

Speakers

Air University, Spring 2015 16 M. Usman Rafique

Page 17: Micro Week 1

Introduction

Every computer consists of

3. Central Processing Unit (CPU)

Administrative section of computer

Supervises other sections

4. Arithmetic Logic Unit (ALU)

Performs calculations (addition, subtraction, multiplication and division)

Can make decisions and comparisons

Air University, Spring 2015 17 M. Usman Rafique

Page 18: Micro Week 1

Introduction

Every computer consists of 5. Memory Unit

Rapid access, Fast

Temporarily retains information; lost when powered off

Also called Memory, Primary Memory or Random Access Memory (RAM)

6. Secondary Storage Units Long-term high capacity storage

Stores programs Or data not currently being used

Hard drives, Disks, CDs etc

Slower than primary memory

Air University, Spring 2015 18 M. Usman Rafique

Page 19: Micro Week 1

Introduction

Computer Architecture

Von Neumann Vs Harvard

Instruction = Program / Code

Data = Information being used

RISC Vs CISC

Instruction Set = Set of Instructions (low level) that CPU can process

Air University, Spring 2015 19 M. Usman Rafique

Page 20: Micro Week 1

Von Neumann Vs Harvard

Von Neumann Architecture

A single memory has

DATA: the information being used

Instructions: Program to be executed

A single Bus connects CPU with the memory

At a time, either Instruction can be read OR data can be read or written

2 cycles complete an

instruction

1st : Read instruction

2nd : Read/Write Data

Image courtesy Dr. Javaid Air University, Spring 2015 20 M. Usman Rafique

Page 21: Micro Week 1

Von Neumann Vs Harvard

Harvard Architecture

Separate Memories for

DATA: the information being used

Instructions: Program to be executed

Separate Buses connects CPU with the memory

When an instruction is being executed, data for next instruction is fetched,

known as Pipelining.

Image courtesy Dr. Javaid Air University, Spring 2015 21 M. Usman Rafique

Page 22: Micro Week 1

Von Neumann Vs Harvard

Von Neumann Harvard

Same memory keeps Data and Instructions

A single bus connects CPU with memory

At a time, either reading an instruction OR reading / writing data

Separate memories for data and instructions

Two buses between memory and CPU

Reading / Writing memory

and reading an Instruction can be done simultaneously

Air University, Spring 2015 22 M. Usman Rafique

Page 23: Micro Week 1

RISC Vs CISC CISC Complex Instruction Set Computer

Instruction Set is set of all Instructions (low level Commands)

that CPU can execute

Primary goal of CISC Architecture is to complete task in as few lines of assembly as possible

Processor that understands and performs series of actions for each assembly command

Instructions may be variable in length

Air University, Spring 2015 23 M. Usman Rafique

Page 24: Micro Week 1

RISC Vs CISC

RISC

Reduced Instruction Set Computer

Compact Uniform instructions

Reduces chip complexity by using simpler instructions

Few types of instructions to operate at high speed

Requires more RAM

Has become more popular due to decreasing RAM cost

Air University, Spring 2015 24 M. Usman Rafique

Page 25: Micro Week 1

RISC Vs CISC

CISC RISC

Large Instruction set

Less lines of code

Variable length of instructions

Complex architecture

Small and Compact Instruction set

More lines of Code

Uniform length of instructions

Simple architecture

Air University, Spring 2015 25 M. Usman Rafique

Page 26: Micro Week 1

Programming Languages

Programming Language: A set of rules, symbols and special words used to construct a computer program

High Level Language

A computer language that is more intuitive to the humans. Closer to plain English

Low Level (Assembly Language)

In which a mnemonic is used to represent each machine language instruction

Machine Language

The binary representation of instructions a computer can perform

Air University, Spring 2015 26 M. Usman Rafique

Page 27: Micro Week 1

Programming Languages

High Level Languages

Single statements accomplish substantial tasks

Translated to machine language

Compilers convert to machine language

Conversion takes much time

Instructions comprehensible to humans

Looks mostly like general English

Contains common mathematical notations

Air University, Spring 2015 27 M. Usman Rafique

Page 28: Micro Week 1

Programming Languages

Low Level (Assembly Language)

English-like abbreviations Represent basic operations of computer

Translated to machine language Assemblers convert to machine language

High speed conversion

Easier for human interpretation as compared to Machine language Still tedious and difficult

Many instructions for simple tasks

These problems led to High Level languages

Air University, Spring 2015 28 M. Usman Rafique

Page 29: Micro Week 1

Programming Languages

Machine Language

Only language understood directly by computer

Defined by computer’s hardware design

Machine-dependent

Difficult to understand for human readers

Ultimately reduced binary code i.e. 0s and 1s

Slow, tedious and error prone

Led to assembly language

Air University, Spring 2015 29 M. Usman Rafique

Page 30: Micro Week 1

Programming Languages

Assembly is a Low Level Language

High Level

Middle Level

Low Level

FORTRAN Pascal COBOL BASIC

C++ C

Assembly

Air University, Spring 2015 30 M. Usman Rafique

Page 31: Micro Week 1

Programmer’s Model of Computer

It does not matter whether the machine is microprocessor / microcontroller based or a larger machine

Programmers see the computer as having 3 characteristics

Address Space

Registers

Instruction Set

Air University, Spring 2015 31 M. Usman Rafique

Page 32: Micro Week 1

Address Space

Address Space is set of storage locations, each of which has an Address

The size of Address Space is defined by number of bits the computer uses to form an address

A machine that uses 8 bits for address can access at most 28 = 256 locations

Air University, Spring 2015 32 M. Usman Rafique

Page 33: Micro Week 1

Registers

Registers serve many important functions, including temporary storage of data

The register set of a computer is fundamental to its operation

Registers may be:

General Purpose

Special Function

Air University, Spring 2015 33 M. Usman Rafique

Page 34: Micro Week 1

Instruction Set

Set of commands that computer can obey

Machine codes are generated from instruction set

Very simple commands

Instruction set specifies set of operations e.g. ADD, SUBTRACT, JUMP and Addressing Modes etc

Air University, Spring 2015 34 M. Usman Rafique

Page 35: Micro Week 1

Buses

Bus – Collection of wires through which data is transmitted from one part of computer to another

Buses can be thought of as highways of computer on which data travels

Types of Buses

1. Data Bus

2. Address Bus

3. Control Bus

Air University, Spring 2015 35 M. Usman Rafique

Page 36: Micro Week 1

Data Bus

Data is shared among various components inside a computer using wires known as Data Lines

Group of data lines is called Data Bus

Each data line carries a bit i.e. it can be Off or On

Data bus is Bi-Directional

Air University, Spring 2015 36 M. Usman Rafique

Page 37: Micro Week 1

Address Bus

Addresses are accessed in a computer using wires known as Address Lines

Group of address lines is call Address Bus

Address bus is Uni-directional

It only specifies the address of the target location

Air University, Spring 2015 37 M. Usman Rafique

Page 38: Micro Week 1

Control Bus

These lines control the operation of a computer

For example, CPU uses these lines to specify whether a read or write is required

This is done by different Control Lines

Air University, Spring 2015 38 M. Usman Rafique

Page 39: Micro Week 1

Next Lecture

What is a microprocessor?

What is a microcontroller?

What are the differences between both?

Which one is better?

Air University, Spring 2015 39 M. Usman Rafique

Page 40: Micro Week 1

Acknowledgement

Material used with permission of

Dr. Javaid Iqbal

Head of Department, Mechatronics Engineering

College of EME, NUST

I am extremely thankful to Dr. Javaid who has been a great teacher and still helps and supports me

Air University, Spring 2015 40 M. Usman Rafique