Sei sulla pagina 1di 40

Microcontroller Based Design

Muhammad Usman Rafique

Muhammad Usman Rafique

Week 1 - Introduction

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

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

Course Outline

Week

Topic

1

Introduction

 

8051Microcontroller

2

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

 

PIC 18 F Microcontroller

11

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

Grading Criteria

Module

Percentage

Quizzes

5

Assignments

5

Midterm Exam

15

Projects

30

Final Exam

45

Note: Assignments will be similar to the projects

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

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

Projects

 

No.

Description

Deadline

Percentage

   

1

Generic Board

Week 02

05

2

LEDs

Week 04

05

8051

3

Serial Communication

Week 07

07

4

Interface Project

Week 09

08

T1

Lab Test

Week 11

15

 

1

Generic Board

Week 12

05

PIC

2

Interface Project 2

Week 15

10

T2

Lab Test

Week 16

15

Final Project

 

[Submit Proposals]

Week 17

30

Labs

2 Labs per week

Experiments as well as problem solving

Students are welcome to discuss queries

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

Introduction

What is a Computer?

Introduction

What is a Computer?

Computer

Device capable of

Performing computations

Making Logical Decisions

Works billions of times faster than human beings

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

Introduction

Computer

RAM

Introduction Computer RAM Central Processing Unit ROM Inputs ALU Outputs 15 M. Usman Rafique Air University,

Central Processing

Unit

Introduction Computer RAM Central Processing Unit ROM Inputs ALU Outputs 15 M. Usman Rafique Air University,

ROM

Inputs

Computer RAM Central Processing Unit ROM Inputs ALU Outputs 15 M. Usman Rafique Air University, Spring

ALU

Computer RAM Central Processing Unit ROM Inputs ALU Outputs 15 M. Usman Rafique Air University, Spring
Computer RAM Central Processing Unit ROM Inputs ALU Outputs 15 M. Usman Rafique Air University, Spring

Outputs

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

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

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

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

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

1 st : Read instruction

2 nd : Read/Write Data

s t : Read instruction  2 n d : Read/Write Data 20 I m a
s t : Read instruction  2 n d : Read/Write Data 20 I m a

20 Image courtesy Dr. Javaid

M. Usman Rafique

Air University, Spring 2015

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.

data for next instruction is fetched, known as Pipelining. 21 I m a g e c
data for next instruction is fetched, known as Pipelining. 21 I m a g e c

21 Image courtesy Dr. Javaid

M. Usman Rafique

Air University, Spring 2015

Von Neumann Vs Harvard

Von Neumann

Same memory keeps Data

and Instructions

A single bus connects CPU

with memory

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

Harvard

Separate memories for data

and instructions

Two buses between memory

and CPU

Reading / Writing memory

and reading an Instruction can be done simultaneously

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

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

RISC Vs CISC

CISC

Large Instruction set

Less lines of code

Variable length of instructions

Complex architecture

RISC

Small and Compact Instruction set

More lines of Code

Uniform length of instructions

Simple architecture

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

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

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

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

Programming Languages

Assembly is a Low Level Language

High Level

Middle Level

Low Level

FORTRAN

Pascal

COBOL

BASIC

FORTRAN Pascal COBOL BASIC C++ C Assembly

C++

C

FORTRAN Pascal COBOL BASIC C++ C Assembly

Assembly

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

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

2 8 = 256 locations

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

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

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

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

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

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

Next Lecture

What is a microprocessor?

What is a microcontroller?

What are the differences between both?

Which one is better?

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