introducing microcontrollers system...

36
Introducing Microcontrollers System Design Eng. Ahmed S. Afifi Eng. Ahmed S. Afifi 1

Upload: vanlien

Post on 01-Feb-2018

237 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Introducing Microcontrollers System Design

Eng. Ahmed S. AfifiEng. Ahmed S. Afifi

1

Page 2: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

• Mini-ComputerCPU (Brain)

1. Arithmetic Logic Unit (ALU)2. Control Unit3. Register

Program/ Data Memory Peripherals (Input/Output) Buses (data, address and control)

What is a Microcontroller?

2

Page 3: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Computer Essentials

3

Page 4: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Von Neumann and Harvard Computers

4

Page 5: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Microcontrollers

5

Page 6: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

- Microprocessors

Microprocessors vs. Microcontrollers

General Purpose

Microprocessor

RAM ROM TimerSerialCOMPort

IO Port

Data BUS

Address BUS

Control BUS

CPU RAM ROM

I/OTimerSerialPort

- Microcontrollers

6

Page 7: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Embedded SystemGeneral Block Diagram

Microcontroller(uC)

sensor

sensor

sensor

Sensor conditioning

Output interfaces

actuator

indicator

7

Page 8: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Types of microcontrollers

8

Page 9: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Microcontroller Packaging and Appearance

From left to right: PIC 12F508, PIC 16F84A, PIC 16C72, Motorola 68HC05B16, PIC 16F877, Motorola 68000

9

Page 10: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

What are PIC’s?What are PIC’s? Programmable Intelligent Computer Developed by Microchip Technology in 1975 Microcontrollers NOT Microprocessors Microprocessor system with number of

components (EEPROM, RAM, I/O Support)

http://o.mneina.googlepages.com/what_is_microcontroller.htm

10

Page 11: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

ApplicationsApplications Automotive systems Airplanes Toys Medical Devices Furniture

Why Important?

11

Page 12: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Why Important?

Microchip – Human Interface Lab(http://www.microchip.com/stellent/)

Appliances Human interface:

• Touch Screen Display, Button Control, Audio handling

Home systems:• Heating & Cooling, Security

Cell phones

GSM Phone hacked(http://hackedgadgets.com)

12

Page 13: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Examples: Refrigerator

13

Page 14: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Examples: Car Door

14

Page 15: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Examples: Robot Autonomous Guided Vehicle

15

Page 16: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

PIC Family Stack Size Instruction Word Size

No of Instructions

Interrupt Vectors

12CX/12FX 2 12- or 14-bit 33 None

16C5X/16F5X 2 12-bit 33 None

16CX/16FX 8 14-bit 35 1

17CX 16 16-bit 58 4

18CX/18FX 32 16-bit 75 2

PIC Families

‘C’ implies CMOS technology; Complementary Metal Oxide Semiconductor

‘F’ insert indicates incorporation of Flash memory technology

Example: 16C84 was the first of its kind. It was later reissued as the 16F84, incorporating Flash memory technology. It was then reissued as 16F84A.

16

Page 17: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

PIC Families Divided into families

8-bit: 8F, 16F, 18F 16-bit: 24F, ds33F 32-bit: 32F

Minor differences Power Consumption Speed Package size Memory Capacity

17

Page 18: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

PIC Families

8-bit: Max Speed 20 MIPS (mill. instr / sec) Generally 4 cycle processor Memory Range <1kB to 128kB instruction up to 32 kB data

16-bit: Max speed 40 MIPS 2 Cycle Processor Memory Range <1kB to 256kB instruction up to 32kB data

32-bit: Max speed 80 MIPS 5 stage pipeline, out of order Memory Range 32kB to 512kB instruction up to 32kB data

18

Page 19: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

vhttp://www.microchip.com/stellent/images/mchpsiteimages/en537986.jpg

19

Page 20: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

PIC16Fxxx

• Microcontroller PIC 16F84A– Architecture, Instructions, Applications

• Microcontroller PIC 16F877– Architecture, Applications with, Keypad, LCD, Stepper motors, Analog to

digital conversions, Timers, PWM, Serial communications, graphical LCD

20

Page 21: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Programming Languages

ASM• Low level• Full Control

C, BASIC, Forth, LOGO….• Easy to use• Slow

21

Page 22: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

1. Proteus.2. MPLAB, MPASM3. MicroC.4. QL-2006 programmerPic

simulator.

Software Requirements

22

Page 23: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Hardware Requirements1. Pc.2. QL-2006 Programmer..3. Other components as:

pic16F84A..pic16f877a..breadboard.. resistors….capacitors…LCD… sensor…Oscillator ..power supply

23

Page 24: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Oscillator

24

Page 25: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

25

Page 26: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

• PIC can be bread-boarded, with the following important connections:– Power– Ground– Reset signal– Crystal (oscillator)

Necessary Connections

26

Page 27: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

PIC16F84A

27

The PIC16F84A belongs to the mid-range family.

18-pin Enhanced FLASH/EEPROM 8-Bit Microcontroller.

Harvard architecture.

Only 35 single word instructions to learn.

Operating speed 20 MHz clock input /200 ns instruction cycle.

25 mA sink/source max. Per pin.

10,000 erase/write cycles Enhanced FLASH Program memory typical.

10,000,000 typical erase/write cycles EEPROM Data memory typical.

Page 28: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

15 Special Function Hardware registers. Direct, indirect and relative addressing modes Four interrupt sources:

1- External RB0/INT pin2- TMR0 timer overflow 3- PORTB<7:4> interrupt-on-change4- Data EEPROM write complete

The program memory contains 1K words. 14-bit wide instruction words. 8-bit wide data bytes. The data memory (RAM) contains 68 bytes Data EEPROM is 64 bytes.

PIC16F84A

28

Page 29: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

A84F16PIC

29

Page 30: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Program Memory

30

Page 31: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

Data Memory

31

Page 32: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

(Buffer)First Application

32

Page 33: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

(Buffer)First Application

33

Page 34: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

ان شاء هللا لما نخلص الكورس DI\O تخرج قیم على المیكرو) دیجیتال او انالوج (ھتعرف تقرا قیم بالمیكرو

تعرف تربط المیكروكنترولر بالكمبیوتر وتبادل البیانات ما بینھمLCD تعرف تربط المیكروكنترول بالنعرف نتعامل مع االشارات االنالوج

Dc motorتعرف تتحكم بال

34

Page 35: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

35

Page 36: Introducing Microcontrollers System Designsite.iugaza.edu.ps/ahafifi/files/Introduction-in-Microcontrollers.pdf · Microprocessors vs. Microcontrollers General Purpose Micro ... PIC

THANK YOU

36