Industrial Automation Using Microcontroller
Industrial Automation Using Microcontroller
Industrial Automation Using Microcontroller
Microcontroller
Transducer
Processing/ control Output/ Display
Set point
Appliances
Sensors/ Transducers
► Level
► Flow
► Pressure
► Temperature
► Humidity
Controllable applications
► Motors
► Solenoid valves
► Control valves
Display
► Input Parameters
► Set point
► Indication for Output (alarm)
Controller
► Takes Input
► Verifies the conditions
► Controls the equipment &
► Displays the output
Microcontrollers
The prime use of a microcontroller :
► A smaller computer
► On-chip RAM, ROM, I/O ports...
CPU
Bus Serial
4 I/O Ports
OSC Control Port
P0 P2 P1 P3 TxD RxD
Address/Data
Pin Description of the 8051
P1.0 1 40 Vcc
P1.1 2 39 P0.0(AD0
P1.2 3 38 P
) 0.1(AD1)
P1.3
P1.4
4
5
8051 37
36
P0.2(AD2
P
) 0.3(AD3)
P1.5 6 (8031) 35 P0.4(AD4)
P1.6 7 34 P0.5(AD5)
P1.7 8 33 P0.6(AD6)
RST 9 32 P0.7(AD7)
(RXD)P3.0 10 31 EA/VPP
(TXD)P3.1 11 30 ALE/PROG
(INT0)P3.2 12 29 PSEN
(INT1)P3.3 13 28 P2.7(A15)
(T0)P3.4 14 27 P2.6(A14
(T1)P3.5 15 26 )P2.5(A13
(WR)P3.6 16 25 P
) 2.4(A12
(RD)P3.7 17 24 )P2.3(A11
XTAL2 18 23 P ) 2.2(A10)
XTAL1 19 22 P2.1(A9)
GND 20 21 P2.0(A8)
Port 3 Alternate Functions
P3 Bit Function Pin
P3.0 RxD 10
P3.1 TxD 11
P3.2 INT0 12
P3.3 INT1 13
P3.4 T0 14
P3.5 T1 15
P3.6 WR 16
P3.7 RD 17
MICROCONTROLLER I/O pins
TB1
Read pin P0.x
8051 IC
Writing “1” to Output Pin P1.X
Setb p1.x
TB1
Read pin
8051 IC
Writing “0” to Output Pin P1.X
TB1
Read pin
8051 IC
Reading “High” at Input Pin
1 1 P1.X pin
Internal CPU bus D Q
P1.X
0 M1
Write to latch Clk Q
TB1
Read pin
3. Read pin=1 Read latch=0
Write to latch=1
8051 IC
Reading “Low” at Input Pin
0 0 P1.X pin
Internal CPU bus D Q
P1.X
1 M1
Write to latch Clk Q
TB1
Read pin
3. Read pin=1 Read latch=0
Write to latch=1
8051 IC
8051 Family
► Mask programmable
factory fitted Programs
► OTP one time programmable
User Programmable
► Reprogrammable
User Reprogrammable
Comparison of the 8051 Family Members
► ROM type
8031 no ROM ; requires external Rom
80xx mask ROM
87xx EPROM
89xx Flash EEPROM
► 89xx
8951
8952
8953
8955
898252
891051
892051
► Example (AT89C51,AT89LV51)
AT= ATMEL(Manufacture)
C = CMOS technology
LV= Low Power(3.0v)
Registers
R0
DPTR DPH DPL
R1
R2 PC PC
R3
R5
R6
R7
4k 8k
0000H 0000H 0000H
0FFFH
DS5000
-
1FFFH
8751
AT89C51
8752
AT89C52 7FFFH
7FH
General RAM
30H
2FH
Bit-Addressable RAM
20H
1FH Register Bank 3
18H
17H
Register Bank 2
10H
0FH Register Bank 1
08H
07H
Register Bank 0
00H
Development Cycle of microcontroller based project
How to interface Devices
► Inputs and Outputs
► Compatibility of I/Os
► Impedance matching
► Selecting right microcontroller
General diagram of Automation
Sensor
input/Analog Set point
D0~D7
Display
Analog to Digital
8051uc
converter
Actuator
Control
Signals
Why Microcontroller
Less complex
Cheaper
Example
Clk input
C
1
3
3pF
C
2
3
3pF
X
1 U
1
19 P
0.0/A
D0 39
X
TAL1
38
P
0.1/A
D1
37
CR
YSTA
L P
0.2/A
D2
18 P
0.3/A
D3 36
X
TAL2
35
R
1 P
0.4/A
D4
34
P
0.5/A
D5
C
3 10k P
0.6/A
D6 33
9 32 Q
1
R
ST P
0.7/A
D7
2N
2907
10u
F P2.0/A8 21
22
P2.1/A9
23
P
2.2/A10
29
P
SEN P
2.3/A11
24 Q
2
30 25 2N
2907
A
LE P
2.4/A12
31 E 26
A P
2.5/A13
27
P
2.6/A14
28
P
2.7/A15
1
P
1.0 P
3.0/R XD
10 Q
3
2 11 2N
2907
P
1.1 P3.1/TXD
3 12
P
1.2 P
3.2/INT0
4 13
P
1.3 P
3.3/INT1
5 14
P
1.4 P3.4/T0
6 P 15 Q
4
1.5 P3.5/T1
7 16
P
1.6 P3.6 /WR 2
N2907
8 17
P
1.7 P 3.7/RD
A
T89C
51
Controller
►Fixed
►Universal controllers
Universal controllers
► Inputin form of 0 ~5v
► 4 ~ 20mA
► 0 ~20mA
org 0
mov p0, #00
mov p1, #00
mov p2, #00
mov p3, #00
wait: jnb p1.0, wait1 ; wait for enter into parking
acall here ; if inside goto here subroutine
wait1: jnb p1.2, wait ; wait for leave parking
acall here1 ; if leave parking goto here1
here: setb p2.0 ; start motor1 for open d gate
limit1: jnb p3.0, limit1 ; start motor1 until it strikes to limit switch
clr p2.0 ; after defined time stop d motor
switch: 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 gate
limit2: 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 motor1
inc a ; start counter to count number of cars on seven segment display
mov p0, a ; display result on port 0 'use decoder'
ret ; return from subroutine
here1: setb p2.2 ; start motor2 for open d gate
limit3: jnb p3.2, limit3 ; start motor2 until it strikes to the other limit
clr p2.2 ; after defined time stop d motor
switch1: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 gate
limit4: jnb p3.3, limit4 ; start motor2 until it strikes to the other limit
clr p2.3 ; after closing the door now stop motor2
dec a ; count down
mov p0, a ; display result on port 0
sjmp wait ; restart
end