Professional Documents
Culture Documents
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
Electrical Circuits
A simple Electric Circuit is a closed connection of Power Supplies ,
Switches/Sensors and Wires. An Electric Circuit consist of voltage loops and current
nodes
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
Sensors/ Switches
Switches
A switch is a mechanical device that either opens or closes sets of contacts inside
th body
the
b d off the
th switch.
it h
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
Proximity Switches
The proximity switch can be either magnetic, inductive or capacitive. Magnetic
switches are usually adjustable, in that they can be moved along the length of
cylinder body to any desired position.
A magnetic strip attached to the piston gives a magnetic field which is sensed by the
reed switch when it is in its proximity.
Courtesy of Parker
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
Optical Sensor
The optical switch, as its name implies, uses light to establish the position of objects
that are required to be sensed. The beam type has a sender, light sources and a
receiver. The light source shines a light beam into the receiver. When the light beam
i broken
is
b k by
b an object
bj t the
th state
t t off the
th electrical
l t i l output
t t from
f
he
h receiver
i
changers.
h
Courtesy of Festo
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
Relays
The relay is widely used in electrical circuits. Applications range from classical
panel built control systems to modern interfaces between the microprocessor and
their power circuits or any applications where reliable galvanic separation is
required between different circuits.
Relay coil
Relay contact
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
Timer, Counter
These two device are widely used in Electrical Circuits.
Timer contains of coil and contacts. When the timer coil is activated, the timer
mechanism starts working, and as soon as the time reaches the desired pre-set time,
the timer contacts switch over.
The counter also acts as the timer.
Timer contact
Counter contact
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
Symbols
General normally open toggle switch
Alternative
Pushbutton
Limit switch NO
Temperature sensor
Limit switch NC
Pressure switch
Time delay
Indicator lamp
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
PLC
Sensors
Actuators
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
Why PLC?
Increased Reliability
Increased Flexibility
C
Communication
i ti Feature
F t
Better real-time Performance
Lower Cost
Electric Noise
Operating System
Computing Power
Input/output Connections and Wiring
Software
Shock
D st
Dust
Cost
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
10
PLC Hardware
Power Supply
Digital
Input
Module
Digital
Output
Module
Memory
Program Data
Analog
Input
Module
Analog
Output
Module
Ethernet
Interface
Profibus
Programming
Device
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
11
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
12
PLC Size
Nano PLCs
Micro
Mi
PLC
PLCs
connected
d up to 32 I/O
/O ddevices
i
Small PLCs
Medium PLCs
Large PLCs
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
13
CPU Module
The most important PLC-hardware is the central processing
unit (CPU), which corresponds to a computer in structure.
The processes take place in the central control unit. The data,
processedd andd storedd in
i the
h CPU are in
i the
h form
f
off binary
bi
signals. The CPU can usually manage many timers and
counters.
Memory
Communication
C
i ti Port
P t
Serial/parallel, 486 IEEE,..
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
14
I/O Module
The input/output modules are connected to sensors/actuators to obtain the binary
information from the system and implement the requested logics.
Wiring diagram
for Input
Module with 16
inputs
+
DC
To PLC
To PLC
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
15
I/O Module
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
16
Wiring diagram
for output
Module with 16
outputs
Out 1
Out Com
PLC
Out 1
Out 1
Out Com
Out Com
Out 1
Out Com
PLC
PLC
Transistor Sinking
Output (NPN)
Transistor Sourcing
Output (PNP)
PLC
Triac Output
Unit (AC)
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
17
I/O Module
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
18
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
19
Wiring
Wi
i diagram
di
for
f
Analogue Output Module
with 8 outputs
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
20
Interface Module
This module is used to communicate with other PLCs or control systems through
Serial/Parallel, Ethernet, Profibus FMS,VME, etc. A number of standard protocols are
implemented and allow data transfer with a wide variety of stations.
Courtesy of Siemens
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
21
PLC Programming
g
g
PLC program languages are categorized into three classes:
1.
2.
3.
User program
Data table
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
22
Program Files
System
S
fil
files
Reserved
Main ladder/STL/FUC pprogram
g
Data Files
Output
O
t t
Input
Status
Bit
Timer
Counter
Integer
Reserved
Net ork Comm
Network
Communication
nication
User-defined
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
23
Input/Output Imaging
M
0
I
N
P
U
T
1 IInputt
0 Image
0
MEMORY
Output
O
t t 1
Image
0
1
Data bus
C.P.U.
A.L.U.
O
U
T
P
U
T
K.B.,
Port,
H/D,
Etc.
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
24
Operating Cycle
Initialization
Set Output
Output
Set
Self-Test
PLC
SCAN
CYCLE
Solve Logic
Solve
Logic
Read Input
Input
Read
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
25
1
Service
S
i
Comm
etc.
Input
Scan
Output
Scan
Program
Scan
3
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
26
Response time
1
IN
RUN
Scan 1
Pulse Stretch
OUT
IN
RUN
OUT
IN
Scan 2
RUN
OUT
Scan 3
Interrupt Function
Scan
IN
RUN
OUT
IN
Scan
IN
RUN
OUT
Pulse Stretch
Interrupt
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
27
PLC addresses
The following letters are used for the modules (For Siemenss PLCs):
I= Input
C= Counter
C
O= Output
F= Flag
T= Timer
RO=Analogue
RO
Analogue Output
ZXX.YY
bit address or desired I/O
number on module
Type of Module
O1
O2
0
1
2
Power
supply
3
4
5
6
7
I0.6
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
28
NO Output
NC Output
Function Block
FUN (name)
Parameter 1
Parameter 2 (opt)
.
.
Parameter N (opt)
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
29
Rung
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
30
Example
Sink
Rung
Output 1
Output_1
Output 2
Output_2
Conditions In
Results Out
Source
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
31
X
0
0
1
1
Z
X
Y
0
1
0
1
Truth Table
Z
0
0
0
1
Z=XY
OR
X
0
0
1
1
0
1
0
1
0
1
1
1
Truth Table
Z=X+Y
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
32
NOT
X
Y
X
Truth Table
Y=X
XOR
Z
X
Z
Y
X
0
0
1
1
Y
0
1
0
1
Z
0
1
1
0
Truth Table
Z=X Y
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
33
Z (X Y)
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
34
SW_D
Output_E
SW_D
END (01)
SW_B
SW_N
Output_A
SW_A2
SW_AN
END (01)
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
35
Common Errors
SW_1
Output_1
END (01)
SW_1
Output_1
SW_N
Output_1
Output_NoGood
TIM
000
#0020
END ((01))
Problem:
Causing
g Logical
g
Error !!!
END (01)
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
36
Important Functions
(OMRON)
SET
Set
Button
Output
Reset
Button
Reset
Button
RESET
Output
Output
INC function
Start Count
INC
Start
Count
DMxxxx
DMxxxx
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
37
TIM
xxx
Start
Time
Set Value
Present
V l
Value
TIMxxx
TIMxxx
Output
Output
xxx
Set Value
Start
Count
Reset
Count
Present
Value
CNTxxx
Output
Output
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
38
CNTR Function
Count UP
Count
Up
CNTR
Count Down
Count
Down
xxx
Reset
Count
Count Down
Set Value
Present
Value
CNTxxx
Output
Output
DIFU Function
Input
p _SW
DIFU
Input_SW
OneShotOut
O Sh tO t
OneShotOut
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
39
DIFD Function
Input_SW
Input_SW
DIFD
OneShotOut
OneShotOut
MOV Function
Input_SW
MOV
Input_SW
Source
Destination
Source
Destination
2918
0000
2918
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
40
Status Monitoring
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
41
RUN
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
42
Example
Q: A lamp (H1) is to remain switched on as long as push button S1 and either one
or both of the push buttons S2 and S3 are actuated.
I0
S1
S2
S3
H1
0
0
0
1
0
1
1
0
1
0
1
0
0
0
0
0
1
1
1
0
1
1
1
0
1
Truth table
0
1
1
1
S1
S2
O0
0
1
0
1
H1
S3
-Circuit diagram
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
43
Allocation List
Designation
Abbrev.
Push button S1
S1
I0.0
Push button S2
S2
I0.1
P h bbutton S3
Push
S3
I0 2
I0.2
H1
O0.0
Light H1
S2S3
S1
S3
00
S3
01
S3
10
11
0
S1
Address
Function
I0.0, I0.1, I0.2 carry 1, as long
as push button actuated
I0.0
I0.1
O0.0
S1
S2
I0.2
S2
S1S 3
S1S 2
H1 S1 ( S 2 S3 )
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
44
Example 2:
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
45
State Diagram
g
Transition
Outputs
STATE
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
46
001
Outputs (0)
Outputs (1)
0 to 2
3 to 2
011
Outputs (3)
010
Outputs (2)
4 to 0
2 to 6
110
100
1 to 3
Outputs (6)
4 tto 5
p ((4))
Outputs
6 to 4
7 to 6
101
111
Outputs (5)
Outputs (7)
5 to 7
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
47
The governed logic can be simplified using the state diagram drawn for the desired system.
This simplification is possible if transitions occur from one state to the other state in which
only
l one bit
bi is
i changed
h
d (e.g.,
(
from
f
state 010 to 011),
011) otherwise
h
i we cannot simplified
i lifi d the
h
equation.
1.
2.
3.
4.
SET
F2F1F0
F2F1F0
101
F2
F1
100
TIM001
F2
RESET
Stop
TIM001, A, D
X+, Z+, TIM001
F0
F1
Stop
Current
State
Transition
C diti
Conditions
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
New
State
F0
48
Example
Backward Motion
Motor (M)
Forward Motion
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
49
IInputs:
t
Pushbutton Switch (I)
Output:
Motor forward (MF)
Motor backward (MB)
M=0
M=1
MF: ON
MB: ON
States:
State 1 (0)- Conveyer moves forward
State 2 (1)- Conveyer moves backward
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
50
1. Number each state uniquely and allocate enough bits for a state variable. For
the example, we have two states and hence, one bit is sufficient.
M: State variable
M = 0,
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
51
MB
MF
I
SET
M
I
RESET
M
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
52
M X (Y memory)
where X is the turn off signal and Y is the turn on signal for State M.
In order to study the state diagram approach, the following example is solved step
step-byby
step.
William W. Melek: Introduction to Microprocessor and Digital Logic, ME262, University of Waterloo, S'10
53