lec__uc

43
Industrial automation Industrial automation Using Microcontroller Using Microcontroller By: Engr. M. By: Engr. M. Rizwan Anjum Rizwan Anjum Department of Electronic Engineering Department of Electronic Engineering UCET, IUB. UCET, IUB.

Upload: biswajit-sarkar

Post on 02-Dec-2015

214 views

Category:

Documents


0 download

DESCRIPTION

Microcontroller

TRANSCRIPT

Industrial automation Industrial automation Using MicrocontrollerUsing Microcontroller

By: Engr. M.By: Engr. M.Rizwan AnjumRizwan AnjumDepartment of Electronic EngineeringDepartment of Electronic Engineering

UCET, IUB. UCET, IUB.

ContentsContents► IntroductionIntroduction►Parameters consideration for Parameters consideration for

AutomationAutomation►Selecting microcontrollerSelecting microcontroller► Internal architecture of MicrocontrollerInternal architecture of Microcontroller►ApplicationsApplications

IntroductionIntroduction

AutomationAutomation►The control of an industrial process (e.g manufacturing, The control of an industrial process (e.g manufacturing,

production etc) by automatic rather that manual means is often production etc) by automatic rather that manual means is often called automationcalled automation

►Automation can be defined as a technology that uses Automation can be defined as a technology that uses programmed commands to operate a given processprogrammed commands to operate a given process

Basic building block diagram of Basic building block diagram of AutomationAutomation

Transducer

Processing/ controlProcessing/ control Output/ Display

Appliances

Set point

Sensors/ TransducersSensors/ Transducers

►LevelLevel►FlowFlow►PressurePressure►TemperatureTemperature►HumidityHumidity

Controllable applicationsControllable applications

►MotorsMotors►Solenoid valvesSolenoid valves►Control valvesControl valves

DisplayDisplay

► Input ParametersInput Parameters►Set pointSet point► Indication for Output (alarm)Indication for Output (alarm)

ControllerController

►Takes InputTakes Input►Verifies the conditionsVerifies the conditions►Controls the equipment & Controls the equipment & ►Displays the outputDisplays the output

Microcontrollers

The prime use of a microcontroller :The prime use of a microcontroller :

► To control the operation of a machine using a To control the operation of a machine using a fixed program that is stored in ROM and that fixed program that is stored in ROM and that does not change over the lifetime of the system does not change over the lifetime of the system

Typical Microcontrollers

►The most common microcontrollers are The most common microcontrollers are 8-bit.8-bit.

►4-bit are used in high volume very low 4-bit are used in high volume very low cost applicationscost applications

►16 & 32 bit are used in high-end 16 & 32 bit are used in high-end applicationsapplications. . 

►Typical clock frequencies are 12 - 24 Typical clock frequencies are 12 - 24 MHzMHz

Different manufacturers of Different manufacturers of microcontrollermicrocontroller

► IntelIntel► AtmelAtmel► PhilipsPhilips► Dallas SemiconductorsDallas Semiconductors► MicrochipMicrochip► MotorolaMotorola

Criteria for Selecting Criteria for Selecting microcontrollermicrocontroller► meeting the computing needs of the

task efficiently and cost effectively speed, the amount of ROM and RAM, the

number of I/O ports and timers, size, packaging, power consumption

easy to upgrade cost per unit

► availability of software development tools assemblers, debuggers, C compilers,

emulator, simulator, technical support► wide availability and reliable sources

of the microcontrollers.

Different aspects of a microcontroller

► Hardware: Interface to the real world

► Software: order how to deal with inputs

Test case: Test case: 80518051

► A smaller computer► On-chip RAM, ROM, I/O ports...

RAM ROM

I/O Port

TimerSerial COM Port

CPU

A single chip

History of 8051History of 8051

►1981, Intel MCS-511981, Intel MCS-51►The 8051 became popular after Intel The 8051 became popular after Intel

allowed other manufacturers to make allowed other manufacturers to make and market an flavor of the 8051.and market an flavor of the 8051. different speed, amount of on-chip ROMdifferent speed, amount of on-chip ROM code-compatible with the original 8051code-compatible with the original 8051 form a 8051 familyform a 8051 family

Block DiagramBlock Diagram

Counter Inputs

CPU

On-chip RAM

On-chip ROM for program code

4 I/O Ports

Timer 0

Serial PortOSC

Interrupt Control

External interrupts

Timer 1

Timer/Counter

Bus Control

TxD RxDP0 P2 P1 P3

Address/Data

Pin Description of the 8051Pin Description of the 8051

1234567891011121314151617181920

4039383736353433323130292827262524232221

P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7RST

(RXD)P3.0(TXD)P3.1

(T0)P3.4(T1)P3.5

XTAL2XTAL1

GND

(INT0)P3.2(INT1)P3.3

(RD)P3.7(WR)P3.6

VccP0.0(AD0)P0.1(AD1)P0.2(AD2)P0.3(AD3)P0.4(AD4)P0.5(AD5)P0.6(AD6)P0.7(AD7)EA/VPPALE/PROGPSENP2.7(A15)P2.6(A14)P2.5(A13)P2.4(A12)P2.3(A11)P2.2(A10)P2.1(A9)P2.0(A8)

8051(8031)

Port 3 Alternate FunctionsPort 3 Alternate Functions

1717RDRDP3.7P3.7

1616WRWRP3.6P3.6

1515T1T1P3.5P3.5

1414T0T0P3.4P3.4

1313INT1INT1P3.3P3.3

1212INT0INT0P3.2P3.2

1111TxDTxDP3.1P3.1

1010RxDRxDP3.0P3.0

PinPinFunctionFunctionP3 BitP3 Bit

MICROCONTROLLER I/O pins

I/O pins are very useful for the following :I/O pins are very useful for the following :► reading Inputs/ reading keypadsreading Inputs/ reading keypads► Displaying output Displaying output ► controlling Motors (PWM) etc.controlling Motors (PWM) etc.

A Pin of Port 1 A Pin of Port 1

8051 IC

D Q

Clk Q

Vcc

Load(L1)

Read latch

Read pin

Write to latch

Internal CPU bus

M1

P1.X pinP1.X

TB1

TB2

P0.x

Writing “1” to Output Pin P1.XWriting “1” to Output Pin P1.X

D Q

Clk Q

Vcc

Load(L1)

Read latch

Read pin

Write to latch

Internal CPU bus

M1

P1.X pinP1.X

8051 IC

2. output pin is Vcc1. write a 1 to the pin

1

0 output 1

TB1

TB2

Setb p1.x

Writing “0” to Output Pin P1.XWriting “0” to Output Pin P1.X

D Q

Clk Q

Vcc

Load(L1)

Read latch

Read pin

Write to latch

Internal CPU bus

M1

P1.X pinP1.X

8051 IC

2. output pin is ground1. write a 0 to the pin

0

1 output 0

TB1

TB2

Reading “High” at Input PinReading “High” at Input Pin

D Q

Clk Q

Vcc

Load(L1)

Read latch

Read pin

Write to latch

Internal CPU bus

M1

P1.X pin

P1.X

8051 IC

2. MOV A,P1

external pin=High

1

0

3. Read pin=1 Read latch=0 Write to latch=1

1

TB1

TB2

Reading “Low” at Input PinReading “Low” at Input Pin

D Q

Clk Q

Vcc

Load(L1)

Read latch

Read pin

Write to latch

Internal CPU bus

M1

P1.X pin

P1.X

8051 IC

2. MOV A,P1

external pin=Low

1

0

3. Read pin=1 Read latch=0 Write to latch=1

0

TB1

TB2

8051 Family8051 Family

►Mask programmableMask programmable factory fitted Programsfactory fitted Programs

►OTP one time programmableOTP one time programmable User ProgrammableUser Programmable

►ReprogrammableReprogrammable User ReprogrammableUser Reprogrammable

Comparison of the 8051 Family MembersComparison of the 8051 Family Members► ROM typeROM type

8031 no ROM ; requires external Rom8031 no ROM ; requires external Rom 80xx mask ROM 80xx mask ROM 87xx EPROM87xx EPROM 89xx Flash EEPROM89xx Flash EEPROM

► 89xx89xx 89518951 89528952 89538953 89558955 898252898252 891051891051 892051892051

► Example (AT89C51,AT89LV51)Example (AT89C51,AT89LV51) AT= ATMEL(Manufacture)AT= ATMEL(Manufacture) C = CMOS technologyC = CMOS technology LV= Low Power(3.0v)LV= Low Power(3.0v)

Registers

A

B

R0

R1

R3

R4

R2

R5

R7

R6

DPH DPL

PC

DPTR

PC

Some 8051 16-bit Register

Some 8-bitt Registers of the 8051

Memory mapping in 8051Memory mapping in 8051

► ROM memory map in 8051 family

0000H

0FFFH

0000H

1FFFH

0000H

7FFFH

8751AT89C51 8752

AT89C52

4k

DS5000- 32

8k 32k

from Atmel Corporationfrom Dallas Semiconductor

0000H

0FFFH

0000H

1FFFH

0000H

7FFFH

8751AT89C51 8752

AT89C52

0000H

0FFFH

0000H

1FFFH

0000H

7FFFH

8751AT89C51 8752

AT89C52

4k

DS5000- 32

8k 32k

from Atmel Corporationfrom Dallas Semiconductor

RAM memory space allocation in the 8051

7FH

30H

2FH

20H

1FH

17H

10H

0FH

07H

08H

18H

00HRegister Bank 0

Register Bank 1

Register Bank 2

Register Bank 3

Bit-Addressable RAM

General RAM

Development Cycle of microcontroller based project

How to interface DevicesHow to interface Devices

► Inputs and OutputsInputs and Outputs►Compatibility of I/OsCompatibility of I/Os► Impedance matchingImpedance matching►Selecting right microcontrollerSelecting right microcontroller

General diagram of General diagram of AutomationAutomation

Analog to Digital

converter8051uc

Display

Actuator

D0~D7

Sensor input/Analog

Control Signals

Set point

DecoderDecoderDecoderDecoder

Counter Counter Counter Counter

UnitsTenshundreds

Thousands

Clk input

Why MicrocontrollerLess complexCheaper

Example

X1

CRYSTAL

C2

33pF

C1

33pF

XTAL218

XTAL119

ALE30

EA31

PSEN29

RST9

P0.0/AD0 39

P0.1/AD138

P0.2/AD237

P0.3/AD3 36

P0.4/AD435

P0.5/AD534

P0.6/AD6 33

P0.7/AD732

P1.01

P1.12

P1.23

P1.34

P1.45

P1.56

P1.67

P1.78

P3.0/RXD10

P3.1/TXD11

P3.2/INT012

P3.3/INT113

P3.4/T014

P3.7/RD17

P3.6/WR16

P3.5/T115

P2.7/A1528

P2.0/A8 21

P2.1/A922

P2.2/A1023

P2.3/A1124

P2.4/A1225

P2.5/A1326

P2.6/A1427

U1

AT89C51

C3

10uF

R1

10kQ12N2907

Q22N2907

Q32N2907

Q42N2907

ControllerController

Universal controllersUniversal controllers► Input in form of 0 ~5vInput in form of 0 ~5v► 4 ~ 20mA4 ~ 20mA► 0 ~20mA0 ~20mA

Conversion using TransmitterConversion using TransmitterExp. Exp. Temperature transmitter, pressure transmitter. etcTemperature transmitter, pressure transmitter. etc

►Fixed►Universal controllers

Applications of Applications of microcontrollermicrocontroller

► Personal information products: Cell phone, Personal information products: Cell phone, pager, watch, pocket recorder, calculatorpager, watch, pocket recorder, calculator

► Laptop components: mouse, keyboard, Laptop components: mouse, keyboard, modem, fax card, sound card, battery modem, fax card, sound card, battery chargercharger

► Home appliances: door lock, alarm clock, Home appliances: door lock, alarm clock, thermostat, air conditioner, TV remote, thermostat, air conditioner, TV remote, VCR, small refrigerator, exercise VCR, small refrigerator, exercise equipment, washer/dryer, microwave ovenequipment, washer/dryer, microwave oven

► Industrial equipment: Industrial equipment: Temperature/pressure controllers, Temperature/pressure controllers, Counters, timers, RPM Controllers Counters, timers, RPM Controllers

► Toys: video games, cars, dolls, etc. Toys: video games, cars, dolls, etc.

Microcontroller Applications

Microcontroller Application Area

Sample projectsSample projects

Car parking gate control

org 0mov p0, #00mov p1, #00mov p2, #00mov p3, #00

wait: jnb p1.0, wait1 ; wait for enter into parkingacall here ; if inside goto here subroutine

wait1: jnb p1.2, wait ; wait for leave parkingacall here1 ; if leave parking goto here1

here: setb p2.0 ; start motor1 for open d gatelimit1: jnb p3.0, limit1 ; start motor1 until it strikes to limit switch

clr p2.0 ; after defined time stop d motorswitch: jnb p1.1, switch ; wait for input when the car cross the entering door

setb p2.1 ; when gate crossed start motor1 in revese direction to close d gatelimit2: jnb p3.1, limit2 ; start motor1 in reverse direction until it strikes to the other limit

clr p2.1 ; after closing the door now stop motor1inc a ; start counter to count number of cars on seven segment displaymov p0, a ; display result on port 0 'use decoder'ret ; return from subroutine

here1: setb p2.2 ; start motor2 for open d gatelimit3: jnb p3.2, limit3 ; start motor2 until it strikes to the other limit

clr p2.2 ; after defined time stop d motorswitch1:jnb p1.3, switch1 ;wait for input when the car cross the exit door

setb p2.3 ; when gate crossed start motor2 in revese direction to close d gatelimit4: jnb p3.3, limit4 ; start motor2 until it strikes to the other limit

clr p2.3 ; after closing the door now stop motor2dec a ; count downmov p0, a ; display result on port 0sjmp wait ; restartend

Car parking gate control program