0% found this document useful (0 votes)
12 views76 pages

Week 1 _ Introduction

Uploaded by

tanveer1111110
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views76 pages

Week 1 _ Introduction

Uploaded by

tanveer1111110
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 76

MTS 311

Microcontroller & Embedded Systems

Enrollment Code for LMS:


Syn C: 295867104

Instructor: Dr. Anjum Naeem Malik


Email: [email protected]
Office: Ground Floor, DMTS/Block-III
Office Hours = Check Course Outline
Professional Ethics

• Punctuality
• Discipline
• Integrity

❖ Attendance and Quizzes


• Attendance will be marked either in the first or last five minutes of the class.
• Late comers will be marked absent straightaway without any tolerance.
• Quizzes will be taken without prior announcement.

3
Course Architecture

Subject MTS 311-Microcontroller & Embedded Systems

Credit hours Total = 4 out of which, Theory = 2 & Lab = 2

Contact hours 2 hrs Lec and 6 hrs Lab per week

Instructor Dr. Anjum Naeem Malik

Course Coordinators Mr. Muhammad Qasim

4
Pre-Requisites

Fundamentals of Programming Digital Logic Design

Microcontroller & Embedded Systems

5
Course Learning Outcomes (CLOs)
Level of
S. No. Outcomes PLO
Learning
To understand internal architecture of 8051
1 C2 1
microcontroller
To apply programming techniques for creating time
2 C3 1
delays using loops and timers
To be able to develop / design solution of daily life
3 problems using timers and interrupts of 8051 C2 3
microcontroller
To design and evaluate solutions using 8051/ AVR
4 C2 3
microcontroller for engineering problems
To reproduce practical skills of electronic circuits to
5 manufacture and fabricate PCBs using tools such as P1 5
Proteus
To assemble different circuit boards as given in the
6 project during lab and implement microcontroller- P2 5
based solutions
6
MTS-311 Course Contents: Theory & Lab
S/no. Topics Covered in the Theory Part
1 Introduction
8051Microcontroller
2
• Architecture and Hardware
Labs
3 • Assembly Language
> Proteus
4 • Assembly Language Contd.
5 • Timers and Counters
> Assembly language of 8051
6 • Serial Port
7 • Interrupt > C of 8051 & AVR
8 • Design and Interface Examples
> PIC/STM32
Arduino Microcontroller
9

PIC 18 F/STM32 Microcontroller > AVR


10
• Introduction, Architecture, I/O Pins
11 • Programming in C
12 • Timers / Counters
13 • Using Internal ADC of PIC
14 • Peripherals of PIC 18F Microcontrollers

7
Grading System
• The grade of this course will be the weighted average of the following
activities.

Theory Part: *contributes 50% to the total. Lab Part: *contributes 50% to the total.

1 Midterm Exam 30% Lab Midterm Exam 14%

2 Quizzes 10% Lab Tasks 12%

3 Assignments 10% Lab Reports 10%

4 Project 10% Lab Projects 44%

5 Final Exam 40% Lab Final Exam 20%

• Details regarding the project will be communicated later.

8
Benchmarking

 Similar Courses Taught at MIT & Stanford

 Benchmarked Curriculum

9
Benchmarking

 MIT > 6.S08 Interconnected Embedded Systems

 Stanford > EE281 - Embedded System Design Laboratory

10
Benchmarking
 Stanford > EE281 - Embedded System Design Laboratory

11
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
12
Acknowledgement
I am thankful to following for direct/ indirect contribution to this
course
 Dr Usman Rafique
 Univesity of Kentucky

 Prof. Joel Voldman


 MIT (6.S08 Interconnected Embedded Systems)

 Dr. Javaid Iqbal


 Principal SMME

 Dr. Mohsin Tiwana


 CE&ME

13
Introduction
To
Microcontroller & Embedded Systems
Embedded Systems
➢An embedded system is a single-purpose computer built into a
larger system for the purposes of controlling and monitoring the system
[1]. A general purpose computer (e.g. a personal computer) is
defined not to be an embedded system.

➢Embedded systems are computer-based systems which are


embedded inside another device (car, home, TV, etc.)

➢Interactions with embedded systems are different than with standard


computers

➢Interact with users via simple interface:


-Digital camera, TV, cellphone, …

➢Interact with another device, invisible to user:


- Disk drive, memory stick, anti-lock braking system, …
[1] Arnold, B. Embedded System Design. CMP Books, 2002
Cost Constraints

➢Embedded design methodology: Be Efficient!


• Vast majority of embedded products are in cost critical
markets

➢Very different from traditional software engineering


• Correct functionality is all that counts
• Performance, memory, power, not important

➢Embedded system designers should be control freaks


• Need to have explicit control over timing, memory
• Why trust a compiler/interpreter/OS?

16 Slide created by:


Professor Ian G. Harris
Embedded System Structure

ADC microcontroller DAC


sensors actuators

ASIC FPGA

➢Sensors receive data from the world


• Analog (light sensor, microphone, etc.) and digital (buttons)
➢Actuators cause events in the world
• Analog (motors, speakers) and digital (lights)
➢Application-Specific Integrated Circuit (ASIC)- special-purpose hardware
➢Field Programmable Gate Array (FPGA) - reconfigurable hardware

17 Slide Courtesy of: Professor Ian G. Harris


Why Embedded Systems?

A real life case study

18
Embedded Systems in Cardiac Surgery
❖ What is the total length of blood vessels ?
❖ Make a guess at the total length, in
Kilometers, of all the blood vessels in an
adult human.

100,000 Kilometers
That’s more than twice the distance
around the Earth at the equator!

19
Embedded Systems in Cardiac Surgery
 The average adult heart beats 72 times a minute; 100,000
times a day; 3,600,000 times a year; and 2.5 billion times
during a lifetime
 Though weighing only 311 grams on average, a healthy heart
pumps 7600 litters of blood through 100,000 km of blood
vessels each day
 A kitchen faucet would need to be turned on all the way for at
least 45 years to equal the amount of blood pumped by the
heart in an average lifetime
 The volume of blood pumped by the heart can vary over a
wide range, from 5 to 30 liters per minute
 Every day, the heart creates enough energy to drive a truck 32
Km. In a lifetime, that is equivalent to driving to the moon and
back
 Because the heart has its own electrical impulse, it can
continue to beat even when separated from the body, as long
as it has an adequate supply of oxygen
 In 1929, German surgeon Werner Forssmann (1904-1979)
examined the inside of his own heart by threading a catheter
into his arm vein and pushing it 20 inches and into his heart,
inventing cardiac catheterization, a now common procedure

20
EM336: Instrumentation & Measurements

Development of Embedded Systems For Heart Surgery


22
Embedded Systems in Cardiac Surgery

 Various mythologies have


different concepts & theories
about heart

 No surgeon dared touch the


heart

 In 1881, a surgeon having


killed a patient on operating
table, while doing a cardiac
surgery, shot himself in the
head
23
Embedded Systems in Cardiac Surgery

Stephen Paget 1897


Classic textbook, Surgery Of The Chest

 “Surgery of the heart has probably


reached the limits set by nature to all
surgery…”

Christian Billroth 1897


founder of modern abdominal surgery

 “Any surgeon who wishes to preserve the


respect of his colleagues would never
attempt to suture the heart”
24
Embedded Systems in Cardiac Surgery

 Dr. Ludwig Rehn of Frankfurt,


Germany, repaired a stab
wound to the right ventricle
on September 7, 1896. This
became the first successful
heart surgery in history.

 Even Dr Ludwig got scared


and never performed the
surgery again.
How hard could the surgery be?
25
Embedded Systems in Cardiac Surgery

 Parallel world

Relativity Theory Television Invented World War II

 By 1940’s surgeons operated on every


organ of body except THE HEART

 War wounded with shrapnel in heart


were not touched and it was felt safer to
be left in heart. Safer?
26
Embedded Systems in Cardiac Surgery

 Questions
 How much blood do we have?
 What the minimum amount of blood required?

 How much blood does heart pump every minute?


 What’s the minimum flow rate?

 3 Sets of 14 operations
 Problem of pressurizing blood
 130 successful operations

Beginning of modern heart surgery


27
Embedded Systems in Cardiac Surgery
 Surgery on beating heart
 Too much risk

 Too much blood needed

 Could not perform complex surgeries due to rapid blood loss

 New method involved clamping


 Limitations of brain - gave 4 min window hold breath

28
Embedded Systems in Cardiac Surgery

 4-minute window was too short


 A new solution to stop or slow
this fatal stopwatch to increase
surgery time was needed

 1940s, Wilfred Bigelow, a


Canadian researcher, proposed
hypothermia/clinical death
 What is a safe minimum
temperature?
 How to maintain temperature?
 Took 10 years to perfect the
procedure
29
Embedded Systems in Cardiac Surgery

 Walton Lillehei
and Dr. F. John Lewis at the
University of Minnesota on
September 2, 1952
attempted first successful
open-heart surgery on a 5
year old girl.

 Temp of 28 degree C

 Took over two hours

 The heart rate became half

 Then they clamped the


vessels
30
Embedded Systems in Cardiac Surgery

 They calculated a time of 6 minutes

 A hole between two valves was


repaired

 Further experimentation increased


this time about 10 minutes

 Hyperthermia is still used today

 It was still not enough


31
Embedded Systems in Cardiac Surgery

 Walton Lillehei came up


with a bizarre yet
ingenious solution

 Connect Femoral Artery


and Vein
 Do blood groups match?
 How to maintain blood
circulation pressure

32
Embedded Systems in Cardiac Surgery

 The first operation 1953.

 Haward’s heart was keeping 10 year


old Micheal alive

 Over 40 successful surgeries followed

 Banned after one volunteer suffered


severe brain damage

 Going past 10 minutes seemed an


impossible challenge

 In search for a solution, researchers


used animals – 15 children died.
These were desperate times

33
Embedded Systems in Cardiac Surgery
 Surface area of lungs is that of a tennis court.
 How to cram a tennis court into an operating theatre

 John Gibbon spent 18 years to create a machine that could


keep a cat alive for 100 minutes.

 Invented a machine that allowed the heart and lungs to


stop working allowing surgery to be performed whilst the
machine took over.
 Lots of things could go wrong
 Clotting in radiator
 Meshing of blood in pumps

 The first operation using it was in 1953.


 First patient died because of wrong diagnosis
 In second surgery, a clot blocked the exit tube of the machine.
Patient survived.
 Next two patients died
 Gibbon never returned to surgery
 Died of heart attack on tennis court
34
35
Embedded Systems in Cardiac Surgery

First Generation of Heart Pumps

36
Embedded Systems in Cardiac Surgery
Second Generation of Heart Pumps

37
Embedded Systems in Cardiac Surgery
Third Generation of Heart Pumps

38
Embedded Systems in Cardiac Surgery

39
Embedded Systems in Cardiac Surgery

40
Embedded Systems in Cardiac Surgery

• Istanbul Heart (iheart) was implanted in a goat.


• The iheart was able to maintain the required blood
flowrate and pressure.
• The goat survived for 3hours and died.
• Possible reasons of death: hemolysis, clotting, etc.

41
Embedded Systems in Cardiac Surgery

Synergy of Biomedical - Mechatronics Engineering


42
Embedded Systems in Cardiac Surgery
 Synergy of Biomedical - Mechatronics Engineering

Instrumentation CAD Design & Manufacturing

Thermo and
Fluid Dynamics
Electronics

Design of Machines
Microcontrollers
Introduction
What is a Computer?

 Computer
 Device capable of
 Performing computations
 Making Logical Decisions

 Works billions of times faster than human beings

44
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

45
Introduction
Computer
• Keyboard
• Mouse
RAM
• Touchscreen

Inputs

Central Processing
Unit
Outputs

• Monitors
• Printouts
• Speakers
ROM

46
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

47
Introduction

Every computer consists of


3. Control Unit/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

48
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

49
Introduction
Computer Architectures / Design Philosphies
 Hardware Architectures
 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

50
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
 Suitable for PCs & laptops.

51
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.
 Suitable for micro-
controllers & embedded
systems

52
Von Neumann Vs Harvard

Von Neumann Harvard

 Same memory keeps Data  Separate memories for data


and instructions
and Instructions

 A single bus connects CPU  Two buses between memory


with memory and CPU

 At a time, either reading  Reading / Writing memory


an instruction OR reading and reading an Instruction
can be done simultaneously
/ writing data
53
RISC Vs CISC
RISC
Reduced Instruction Set Computer/Computing

 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


54
RISC Vs CISC
CISC
Complex Instruction Set Computer/Computing

 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

55
CISC Vs RISC

R4

56
RISC Vs CISC

CISC RISC
 Large Instruction set  Small and Compact
Instruction set

 Less lines of code  More lines of Code

 Variable length of  Uniform length of


instructions instructions

 Complex architecture  Simple architecture

57
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
58
Programming Languages
High Level Languages

concept

59
From Machine Code Going Deeper

60
Going Deeper

61
Even Deeper (RAM)

Built bit-by-bit Remember flip-flops?

62
Even Deeper (RAM)

63
Even Deeper (RAM)

32,768 x 32 = 1,048,576 bits


= 1 Mb

128 x 64
bits
8 x 1 Mb = 1MB

128 x 64 x 4 = 32,768 bits


RAM module from 1980’s ☺
64
Even Deeper

65
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

66
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
67
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

68
Programming Languages
Assembly is a Low-Level Language
FORTRAN
 High Level Pascal
COBOL
BASIC

C++
 Middle Level C

 Low Level Assembly

69
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

71
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

72
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

73
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

74
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

75
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

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

 Group of address lines is called Address Bus

 Address bus is Uni-directional


 It only specifies the address of the target location

77
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

78
Next Lecture

 What is a microprocessor?

 What is a microcontroller?

 What are the differences between both?

 Which one is better?

79

You might also like