1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

31
1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,201

Transcript of 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

Page 1: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

1© Unitec New Zealand

Embedded Hardware ETEC

6416

Date: - 10 Aug,2011

Page 2: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

2© Unitec New Zealand

Outline

• Embedded system overview

• Microcomputer overview

• Microcontroller overview

• Developing an application and its requirement

Page 3: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

3© Unitec New Zealand

Embedded System

• An embedded system is simply a computer embedded in an engineering product. This computer undertakes the control of all the tasks within the engineering product.

• Examples

Home Office Automotive

Washing machine Photocopier Door Mechanism

Microwave Printer Climate control

Toys, games Scanner Brakes, Engine Control

Fridge Car Entertainment

Page 4: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

4© Unitec New Zealand

An Example

Designing embedded systems with PIC microcontrollers principles and applications / Tim Wilmshurst.

Page 5: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

5© Unitec New Zealand

Elements of a computer

Central Processing

Unit

Input/Output

Program Memory

Data Memory

Page 6: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

6© Unitec New Zealand

Instruction Sets

• CISC : - Complex Instruction Set Computer refers to computers designed with a full set of computer instructions that were intended to provide needed capabilities in the most efficient way.

• RISC: - Reduce Instruction Set Computer is that by reducing the full set to only the most frequently used instructions, the computer would get more work done in a shorter amount of time for most applications. CPU architecture is kept simple as compared to CISC.

Page 7: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

7© Unitec New Zealand

Memory Types

• Volatile: - The memory that only work as long as it is powered on. E.g. , RAM. It is also called Data Memory

• Non-volatile : - The memory that retains its stored value, even when power is removed. E.g. , ROM. Also called Program memory.

Page 8: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

8© Unitec New Zealand

Organizing Memory

• Von Neumann Architecture : - It has one data and one memory bus, and the same address and data buses serve both program and data memory.

• Harvard Structure : - Every memory area gets its own address and data bus.

• Pic is an example of Harvard structure.

Page 9: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

9© Unitec New Zealand

Von Neumann Architecture

Designing embedded systems with PIC microcontrollers principles and applications / Tim Wilmshurst.

Page 10: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

10© Unitec New Zealand

Harvard Structure

Designing embedded systems with PIC microcontrollers principles and applications / Tim Wilmshurst.

Page 11: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

11© Unitec New Zealand

• Microprocessor???

• Microcontroller???

Page 12: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

12© Unitec New Zealand

Microcontroller families

Designing embedded systems with PIC microcontrollers principles and applications / Tim Wilmshurst.

Page 13: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

13© Unitec New Zealand

Generic requirements for Micro’s

• Input/ output :- Microcontrollers emphasis is on their I/O resources, i.e. , ability to handle interrupts, analog signals, number of I/O lines.

• Optimization of space: - Footprint is small and large pins means large footprint. Therefore one pin should perform different functions.

Page 14: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

14© Unitec New Zealand

Generic requirements

• Application specific microcontroller: - Vendors have developed families of devices with same instruction set but different hardware aspects, such as memory size, i/o, A/D, timers, interrupts, oscillators.

• Protection against failure: - Program should execute correctly and if a failure occurs then Micro controller should be capable enough to immediately correct it. Watch dog timer (WDT) is used for this purpose.

Page 15: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

15© Unitec New Zealand

Generic requirements

• Low Power consumption: - Microcontrollers are normally battery operated. Therefore low power consumption must be ensured for long operation.

• Protection of program against copies: -

Page 16: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

16© Unitec New Zealand

Block Diagram of Microcontroller

Timers

Analog I/O

Interrupt Control

RAM Memory

Parallel I/O

ROM memory

Watch Dog

CPU

Serial I/O

Oscillator

Add

ress

, D

ata

and

Con

trol

Bus

Page 17: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

17© Unitec New Zealand

Components of microcontroller

• Oscillator to generate the signal necessary to synchronize all internal operations.

• CPU is the brain of the microcontroller. CPU fetches the program instructions from their locations in memory one by one, interprets or decode and finally execute them. It also contains the ALU.

Page 18: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

18© Unitec New Zealand

CPU Registers

• CPU has general and specific purpose registers. Specific purpose registers are

• Instruction Register (IR)

• Accumulator “working register for pic (W)”

• Status Register (STATUS)

• Program Counter (PC)

• Data Address Register (DAR) “File Select Register(FSR)”

• Stack Pointer (SP)

Page 19: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

19© Unitec New Zealand

Types of Memories

• RAM (Random Access Memory)

• ROM (Read Only Memory)

• Erasable Programmable Read Only Memory (EPROM)

• Electrical EPROM (EEPROM)

• OTP (one-time programmable)

Page 20: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

20© Unitec New Zealand

I/O resources

• I/O resources consists of serial and parallel ports, timers and interruption managers.

• Some microcontroller also contain analog input/ output lines associated with Analog to Digital (A/D) or D/A convertors.

• Watchdog are also considered apart of the I/O resources.

Page 21: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

21© Unitec New Zealand

Watch Dog Timer

• Watch Dog timer keep an eye on proper function of microcontroller. It get reset after a certain time. Therefore, programmer needs to continuously reset it for proper function of microcontroller.

Page 22: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

22© Unitec New Zealand

Watch Dog Timer

N- Pulse Counter

Oscillator

Clear from Program

To Internal reset circuitry of microcontroller

Page 23: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

23© Unitec New Zealand

LOW Consumption

• Power consumption depends on three factors– Technology used– Frequency of Oscillator– Value of voltage supply.

Idle and power down mode are two status which are used for conserving the power.

Page 24: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

24© Unitec New Zealand

Developing a program

• Select a Microcontroller model

• Write a Program

• Assemble or build or compile

• Simulate

• Blow it in Microcontroller

Page 25: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

25© Unitec New Zealand

Choosing your Microcontroller

• What is the application?

• Draw a circuit diagram or layout of your application.

• Then decide the input and output pin.

• What is the speed requirement?

• How many timers do you need?

• Do you need interrupt?

Page 26: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

26© Unitec New Zealand

Example

• To design a device to count the number of times a push button is pressed and display the value on a single seven segment display. When the value reaches nine it should resets.

Suppose, we have PIC 16F54 and PIC 16F57 available with 12 and 20 I/O pins, respectively.

Page 27: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

27© Unitec New Zealand

Problem

• Design a system to test 16 push buttons and display the number of the button pressed (e.g., button number 11) on 16 output LEDs corresponding to specific input push button.

– How many outputs pins required by 16 LEDS?– How many input pins required by 16 push buttons?– Which microcontroller is required?

Page 28: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

28© Unitec New Zealand

Flow chart

• A flow chart show the fundamental steps that microcontroller must perform, showing a clear program structure.

Page 29: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

29© Unitec New Zealand

Example of flow chart

• The flow chart for a simple program to simply keep a LED turned on.

Start of program: Setup

Turn LED ON

Loop back to beginning

Page 30: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

30© Unitec New Zealand

Example of flow chart

• The flow chart for a program to turn an LED on, when a button is being pressed.

Start of program: Setup

Turn LED ON

Loop back to beginning

Is button pressed

Turn LED OFF

Page 31: 1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.

31© Unitec New Zealand

Problem

• Draw the flow chart to represent the program required to make an LED flash on and off every second (i.e. , on for a second , then off for a second) and a buzzer to sound for one second every five seconds.