Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 101

PROGRAMMABLE

PROGRAMMABLE LOGIC
LOGIC CONTROLLERS
CONTROLLERS

PART
PART II :: HARDWARE
HARDWARE

March 2003 Abdel-Kawi Sary 1


Conceptual Review

• Historical Review
• Continuous Control
• Sequence & Discrete (ON/OFF) Control
• Alarms & Alarm Levels
• ESD Systems
• Event Monitoring

March 2003 Abdel-Kawi Sary 2


What is a PLC ?

• PLC is a device that is mostly utilized to control


SEQUENCE & INTERLOCK operations.

• Can also, but rarely, be used for analog control

• It consists of TWO main blocks:


- HARDWARE, and:
- SOFTWARE

March 2003 Abdel-Kawi Sary 3


What is a PLC ?
Main Function Blocks are:

• Inputs (via Input Modules)

• Logic, Decision Making, (via Processor, Memory & SW),


and :

• Outputs (via Output Modules)

March 2003 Abdel-Kawi Sary 4


What is a PLC ?

HARDWARE Consists of:


• Processor
• Memory Rack-Mounted Modules
• I/O Modules

• Programming Tool

SOFTWARE Consists of :
• System Software (Firmware), and:
• Application (User) Software

March 2003 Abdel-Kawi Sary 5


What is a PLC ?
HARDWARE:
Programming Output
Unit Modules
Processor
Input Modules

Memory

From Field Devices To Field Devices

March 2003 Abdel-Kawi Sary 6


What is a PLC ?

Input Modules: Receive signals from field devices and


convert them to low voltage levels suitable for the
Processor (typically 5 VDC).

It is the interface between the real (external) world


input (devices) and the PLC.

March 2003 Abdel-Kawi Sary 7


What is a PLC ?

Output Modules: Receive low voltage level signals from


the Processor and convert to voltage level suitable for the
output devices (typically 24 VDC).

It is the interface between the PLC and the real


(external) world output (devices) such as solenoids and
motor starters.

March 2003 Abdel-Kawi Sary 8


PLC Processor
The Processor Consists of :

• CPU : Governs and executes al the functions performed by the PLC

• MEMORY : Stores information & data that is used by the CPU such as :
- System Programs
- Application programs
- Numerical values
- Status of the I/O devices

• POWER SUPPLY :
- Provides power required to operate the processor
- Provides DC power to the I/O modules (optional)

March 2003 Abdel-Kawi Sary 9


PLC Processor
The Processor:
• Examines the input status (open or closed),

• Compares the input status to the user (application) program


& take the proper decision, and then:

• Sets the output instructions (e.g, coils) accordingly


(energize or de-energize).

• Controls the internal & external communications

• Controls the diagnostic program

• In short, it performs the LOGIC functions of the PLC.

March 2003 Abdel-Kawi Sary 10


PLC Memory

Memory: Is used to store data and the control program

Data and programs stored in memory are:


• Executive (PLC Operating System)
• Scratch Pad (for temporary storage)
• Control Program (for Program instructions entered by the
user)
• Data Table (stores data associated with the program,
constants or variables used by the main program or CPU)

March 2003 Abdel-Kawi Sary 11


PLC Memory

I O N
I CAT
P PL RY
A MO
ME
SYSTEM MEMORY

Executive Program Scratch Pad


Translates user program into Used for temporarily storage
Instructions understood by CPU calculations and control data
required to perform functions in
the exec. Program

March 2003 Abdel-Kawi Sary 13


APPLICATION MEMORY

User Program Memory Section Scratch Pad


Stores instructions that indicate Used for temporarily storage of
status of each output based on calculations related to user
the status of related inputs Program execution

Data Table
Stores data related to machine See Next
or process under control

March 2003 Abdel-Kawi Sary 14


APPLICATION MEMORY DATA TABLES

Data Table
Stores data related to machine
or process under control

Output Table Input Table Internal Discrete Register Storage


Storage
Stores Bits Stores the Typically used to
controlling the current status of Stores internal store set points,
status of output input devices for outputs used in accumulated counter
Devices the usage by completing values, calculation
CPU instructions in results
the user
program

March 2003 Abdel-Kawi Sary 15


Other PLC Components
Programming Tool:

• This represents the INTERFACE between the Engineer & the


PLC.

• It is used to download the user program to the PLC and/or


display status, graphics, .. etc.

• Magnetic tapes, keyboards, PCs, hand-held tools …etc, may


be used as prog’g tools.

March 2003 Abdel-Kawi Sary 16


INPUT / OUTPUT DEVICES
Real World External Devices

• These are NOT part of the PLC but parts of


the Control System

• Input devices may be contacts (N.O. or N.C. ) OR analog


devices(e.g, transmitters)

• Output devices may be motor starters, solenoids, lamps,


horns, heaters, LED displays, …etc.

March 2003 Abdel-Kawi Sary 17


Control System Parts
PLC Parts
PLC AC DISCRETE INPUT MODULES
Voltage Step down Resistors Filtering Capacitor Current Limiting Resistor

AC / DC Bridge
Isolating Optical Coupling:
LED turns “ON” when input exists
Photo Transistor turns “ON” when the LED turns “ON”.
PLC DC DISCRETE OUTPUT MODULES

Fuse &
Metal
Oxide
Varistor
To protect
from
voltage
spikes

Power Transistor
works as an “ON /
OFF” switch
PLC AC OUTPUT MODULES

TRIAC at its low resistance state completes the


circuit to O/P device Fuse & Metal Oxide Varistor
At its high resistance state, it opens the O/P To protect TRIAC from voltage
circuit spikes
Programming Devices
Function:
• Used to enter the user program
• To edit program instructions when modifications are required
• To monitor the status of all the program elements
Types:
• CRT video monitor (some may have to be connected to the PLC to
develop the user program, some can be used independently. A
third type may have a tape or disk drive, therefore, a copy of the
user program can be stored on a tape or disk and loaded to the
processor at any time)
• Mini programmer – sometimes called hand-held programmers -
(displays only one program instruction at a time)

March 2003 Abdel-Kawi Sary 23


PLC Peripherals
These include:
• Thumbwheel switches ( to enter or change values such as set
points, limits and preset timer and counter values)
• Printers (to obtain hard copy of user program, data table, logs and
to generate reports)
• Program Loaders: to record (dump) user program and data table
on tape or disk for reloading the same into the PLC memory later-
on.
• A check to verify no errors is usually done by rewinding and
replaying the tape. The processor will compare the data in
memory with that on the tape and sends an error message if there
is any mismatch.

March 2003 Abdel-Kawi Sary 24


PLC SAFETY CIRCUITS

MCR = Master Control Relay


PROGRAMMABLE LOGIC
CONTROLLERS
PART II: OPERATION

March 2003 Abdel-Kawi Sary 26


Relay Logic Diagrams

RLDs are composed of three main blocks:


• Inputs
• Outputs, and:
• Logic
The inputs are usually process switch contacts, machines’
safeguard switch contacts, limit switches, relay contacts and
pushbuttons.
The outputs may be relay coils/contacts, timer and/or counter
contacts
The logic Circuits are built from a combination of inputs &
internal logic contacts in different arrangements that match
the required functions and determine the energized or de-
energized status of the output coils.

March 2003 Abdel-Kawi Sary 27


Functional Logic Diagrams
INPUT DEVICES LOGIC OUTPUT

STRT PB-100

AND START P-100

STOP PB-101

March 2003 Abdel-Kawi Sary 28


Relay Ladder Logic Diagrams

CR- 001
SEAL CNTCT

PB-100 PB-101 CR- 001


START STOP COIL

CR- 001 PUMP - 100


AUX. CNTCT STRTR

March 2003 Abdel-Kawi Sary 29


PLC Ladder Logic Diagrams
Soft Components

1000

0000 0001 1000

Not Required !!

1000 PUMP - 100


STRTR

March 2003 Abdel-Kawi Sary 30


SCANNING

March 2003 Abdel-Kawi Sary 31


Response Time - 1

March 2003 Abdel-Kawi Sary 32


Response Time-2

The PLC only looks at its inputs during the check input status part of
the scan. Therefore:
• Input 1 will be scanned only in scan 2.
•Input 2 will be scanned only in scan 3.
• When scan 3 was looking at the inputs, signal 3 was not on yet. It
turns off before scan 4 looks at the inputs. Therefore signal 3 is never
seen by the plc.
March 2003 Abdel-Kawi Sary 33
Response Time-3

• In the Previous slide: Input 3 is never seen.


• avoid this we say that the input should be on for at least 1 input
delay time + one scan time.

March 2003 Abdel-Kawi Sary 34


Response Time - 4 : Pulse stretch function.

This function extends the length of the input signal until the plc
looks at the inputs during the next scan.( i.e. it stretches the duration
of the pulse.)

March 2003 Abdel-Kawi Sary 35


Response Time - 5 : Interrupt function.

This function interrupts the scan to process a special routine that you
have written. i.e. As soon as the input turns on, regardless of where the
scan currently is, the plc immediately stops what it is doing and executes
an interrupt routine. After executing the interrupt routine, it goes back to
the point it left off at and continues on with the normal scan process

March 2003 Abdel-Kawi Sary 36


Response Time - 6 : Longest Time

If the input turns ON just at the start of program execution, the output will
actually turn only at the end of the next scan cycle.
This corresponds to the longest time for an output to actually turn on
which is :
. 2 scan cycles - 1 input delay time

March 2003 Abdel-Kawi Sary 37


Relays

March 2003 Abdel-Kawi Sary 38


Replacing Relays

A Contact A Coil
symbol symbol

First step - We have to translate all of the items we're using into symbols
the plc understands.
Second step - We must tell the plc where everything is located
Final step - We have to convert the schematic into a logical sequence of
events

March 2003 Abdel-Kawi Sary 39


BASIC INSTRUCTIONS - 1
NOTE: Normal condition refers to INPUT (or output ) state in
the on-shelf position of field devices (external to the PLC)

• LoaD
The load (LD) instruction is a normally open contact. It is sometimes
also called examine if on (XIO) (as in examine the input to see if it’s
physically on) The symbol for a load instruction is shown below.

A LoaD ( N.O. contact) symbol

• LoadBar
The LoaDBar instruction is a normally closed contact. It is sometimes
also called LoaDNot or examine if closed (XIC) (as in examine the input
to see if it’s physically closed)

A LoaDNot (normally closed contact) symbol

March 2003 Abdel-Kawi Sary 40


BASIC INSTRUCTIONS - 2
NOTE: TRUE means Closed contact (or energized coil)
FALSE means Open contact (or de-energized coil)

LoadBar Load Logic State of Input Devices

True False 0
False True 1

March 2003 Abdel-Kawi Sary 41


BASIC INSTRUCTIONS - 3

Out
The Out instruction is sometimes also called an
OutputEnergize instruction. The output instruction is like a
relay coil. Its symbol looks as shown below.

An OUT (coil) symbol

Outbar
The Outbar instruction is sometimes also called an OutNot
instruction. Some vendors don't have this instruction. The
outbar instruction is like a normally closed relay coil.

Outbar symbol

March 2003 Abdel-Kawi Sary 42


BASIC INSTRUCTIONS - 4

LOGICAL CONDITION OF SYMBOL

LOGIC BITS
OUT LDB LD
(State of Input or output Devices)

False True False Logic 0

True False True Logic 1

March 2003 Abdel-Kawi Sary 43


EXAMPLE - 1

Note the addresses given to each input and output

0000 0001 0500

(LoaD) Symbols (Out) Symbol

March 2003 Abdel-Kawi Sary 44


EXAMPLE - 2

In the previous example change switch 2 (SW2) to a normally closed symbol


(loadbar instruction).
SW1 will be physically OFF and SW2 will be physically ON initially.
The ladder diagram now looks like this:

March 2003 Abdel-Kawi Sary 45


Registers For EXAMPLE - 2

At the PROCESS Initial Conditions, i.e, the input / output devices are
in their on-shelf position; the register bits will be as follows:

REGISTER 00

00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
0 1

REGISTER 05

00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

March 2003 Abdel-Kawi Sary 46


TRUTH TABLE FOR EXAMPLE - 2

Truth table showing ALL possible combinations of


the state of the two inputs.

Register Logic Bits Outputs Inputs

COIL(OUT) SW2(LDB) SW1(LD) COIL(OUT) SW2(LDB) SW1(LD)

0 0 0 False True False

0 1 0 False False False

1 0 1 True True True

0 1 1 False False True

March 2003 Abdel-Kawi Sary 47


Addresses are assigned in a PC system so that the
Controller knows where it can find certain information. The way
these addresses appear can change considerably from
Controller to Controller, but they all have a single purpose — TO
TELL THE CONTROLLER EXACTLY WHERE IT CAN FIND
SPECIFIC INFORMATION.

March 2003 Abdel-Kawi Sary 48


Addresses -2

March 2003 Abdel-Kawi Sary 49


EXAMPLE - 3

• At (or below) LL:


Drain closed & Filing
Pump “ON” and
continues until HLL
• At (or above) HLL:
Drain open & Filing
Pump “OFF” and
continues until LL
• Both level switches
are NC (closed when
not immersed in liquid)

March 2003 Abdel-Kawi Sary 50


EXAMPLE - 3

First Step: Assign address for each input & output


including internal utility relays

Internal Utility
Address Output Address Inputs
Relay

1000 0500 Motor 0000 Low Level Switch

0001 High Level Switch

March 2003 Abdel-Kawi Sary 51


EXAMPLE - 3
First step : Translate all of the items into symbols the plc understands.
Second step : Tell the plc where everything is located (assign addresses)
Second Step: Draw the Ladder Logic as follows:

0000 LSL

0001 LSH

1000 Utility
Relay

0500 Output

March 2003 Abdel-Kawi Sary 52


EXAMPLE – 3 / Program Scan

Scan # 1

False False

Scan # Scan #
2-100 101-1000

March 2003 Abdel-Kawi Sary 53


EXAMPLE – 3 / Program Scan

True True

Scan # Scan #
1001 1002

March 2003 Abdel-Kawi Sary 54


EXAMPLE – 3 / Program Scan

Scan #
1050

March 2003 Abdel-Kawi Sary 55


Latch Instructions
Here we are using 2 momentary push
button switches.
One is physically connected to input
0000 while the other is physically
connected to input 0001.
When the operator pushes switch 0000
the instruction "set 0500" will become
true and output 0500 physically turns
on. Even after the operator stops
pushing the switch, the output (0500)
will remain on. It is latched on.
The only way to turn off output 0500 is
push switch 0001. This will cause the
instruction "res 0500" to become true
thereby unlatching or resetting output
0500

March 2003 Abdel-Kawi Sary 56


Counters - 1
kinds of counters:
• up-counters (they only count up 1,2,3...).
• down counters (they only count down 9,8,7,...).
• up-down counters (they count up and/or down 1,2,3,4,3,2,3,4,5,...)
Further:
• high-speed counters
• normal counters

Typically a high-speed counter is a "hardware" device. The normal counters


listed above are typically "software" counters

Use the normal (software) counters unless the pulses you are counting will
arrive faster than 2X the scan time. (i.e. if the scan time is 2ms and pulses will
be arriving for counting every 4ms or longer then use a software counter

March 2003 Abdel-Kawi Sary 57


Counters - 2

In this counter we need 2 inputs.


One input is the sensor of the
pulses we are counting.

The second is connected to the


reset line. When this input turns
on the current (accumulated)
count value will return to zero.

Example: if we are counting how many widgets pass in front of the sensor
that is physically connected to input 0001 then we would put normally open
contacts with the address 0001 in front of the pulse line.
Cxxx is the name of the counter. If we want to call it counter 000 then we
would put "C000" here.
yyyyy is the number of pulses we want to count before doing something. If
we want to count 5 widgets before turning on a physical output to box them
we would put 5 here.
March 2003 Abdel-Kawi Sary 58
Counters - 3

EXAMPLE: a counter named C 000) to count 100 widgets from input 0001
before turning on output 0500. Sensor 0002 resets the counter.

Input From
Reset Sensor

Counter Name
Input From
Counting
Sensor
No. of Counts
before turning
the output “ON”
Counter
Output
Contact Output

March 2003 Abdel-Kawi Sary 59


Counters - 4
up-down counter : use the same abbreviation
as for the example above (i.e. UDCxxx and
yyyyy)

• In this up-down counter we need to assign 3 inputs.


• The reset input has the same function as before.
• Two inputs for the pulse counting : One input for counting up and the other for
counting down.

March 2003 Abdel-Kawi Sary 60


Counters - 5
Input From
Sensor-1
Input From Counter Name
Sensor-2
No. of Counts
before turning the
Input From
output “ON”
Reset Sensor

Counter Output
Contact
Output

• Call the counter UDC000 and , preset value 1000. (we'll count 1000 total pulses)
• Input sensor-1 will turn ON input 0001 when it sees a target and sensor-2 will also turn
ON input 0003 when it sees a target.
• When input 0001 turns on we count up and when input 0003 turns on we count down.
When we reach 1000 pulses we will turn on output 0500.
• Again note that the counter accumulated value ONLY changes at the off to on
transition of the pulse input.

March 2003 Abdel-Kawi Sary 61


Timers - 1

• TIMER is an instruction that waits a set amount of time before


doing something.
• On-Delay timer : This type of timer simply "delays turning on". In
other words, after our sensor (input) turns on we wait x-seconds
before activating a solenoid valve (output).
• Off-Delay timer : This timer simply "delays turning off". After our
sensor (input) sees a target we turn on a solenoid (output). When
the sensor no longer sees the target we hold the solenoid on for x-
seconds before turning it off.
The on/off delay timers above would be reset if the input sensor
changes its state (on or off ) at any moment during the complete
timer duration
• Retentive or Accumulating timer : This type of timer needs 2
inputs. One input starts the timing event and the other resets it.
This timer holds or retains the current elapsed time when the
sensor turns off in mid-stream.
For example, we want to know how long a sensor is on during a 1
hour period. This timer will give us a total or accumulated time.
It is often called an RTO (retentive timer) or TMRA (accumulating
timer).
March 2003 Abdel-Kawi Sary 62
Timers - 2
When the instructions before the timer symbol are true the timer starts
"ticking". When the time elapses the timer will automatically close its
contacts.
When the program is running on the plc the program typically displays the
elapsed or "accumulated" time for us so we can see the current value.
Typically timers can tick from 0 to 9999 or 0 to 65535 times.
Typically each manufacturer offers several different ticks. Most
manufacturers offer 10 and 100 ms increments (ticks of the clock).
Several manufacturers also offer 1ms as well as 1 second increments.
These different increment timers work the same as above but sometimes
they have different names to show their timebase. Some are:
• TMH (high speed timer),
• TMS (super high speed timer) or:
• TMRAF (accumulating fast timer)

March 2003 Abdel-Kawi Sary 63


Timers - 3

Delay “ON” & Delay “OFF” Timer Symbol

Timer
Name (Tag)
Number of ticks
(Preset Time)

Input From
Sensor)

March 2003 Abdel-Kawi Sary 64


Timers - 4

Input From Timer Name


Sensor) (Tag)

Number of ticks
(Preset Time)
Timer
Output Output
Contact

Delay “ON” & Delay “OFF” Timer Ladder


When input 0001 turns on, timer T000 (a 100 ticks and1 ms increment timer) starts
ticking.
So the timer will be a 100ms (i.e. 0.1 second) When 0.1 seconds have elapsed, the
T000 contacts close and 0500 turns on.
When input 0001 turns off (false) the timer T000 will reset back to 0 causing its
contacts to turn off (become false) thereby making output 0500 turn back off.

March 2003 Abdel-Kawi Sary 65


Timers - 5

Accumulating Timer Ladder


Same symbol as normal timer.
If the enable input turns off before the timer has completed, the
current value will be retained.
When the input turns back on, the timer will continue from where it
left off.

March 2003 Abdel-Kawi Sary 66


Timers - 6

Reset

Input

Resetting Accumulating Timer


The only way to force the timer back to its preset value to start again
(before the timer has completed) is to turn on the reset input.

March 2003 Abdel-Kawi Sary 67


Timers - 7

Timer
Input
SW
Error

Timer
Output
SW
Error

March 2003 Abdel-Kawi Sary 68


Timers - 8

From previous slide note that :


• The worst possible input error would be 1 complete scan time + 1
program execution time.

Remember that a program execution time varies from program to


program (depends how many instructions are in the program

• The worst possible output error would be 1 complete scan time.

• Therefore, the total worst possible timer error would be equal to:
1 scan time + 1 program execution time + 1 scan time

= 2 scan times + 1 program execution time.

March 2003 Abdel-Kawi Sary 69


Timers - 9
• There is also a hardware input error as well as a hardware
output error.
• The hardware input error is caused by the time it takes for
the plc to actually realize that the input is on when it scans
its inputs. Typically this duration is about 10ms. This is
because many PLCs require that an input should be
physically on for a few scans before it determines its
physically on. (to eliminate noise or "bouncing" inputs)
• The hardware output error is caused by the time it takes
from when the plc tells its output to physically turn on until
the moment it actually does. Typically a transistor takes
about 0.5ms whereas a mechanical relay takes about 10ms.

March 2003 Abdel-Kawi Sary 70


Timers - 10

If we know what error to expect, we can then think about whether this
amount of error is acceptable for our application. In most
applications this error is insignificant but in some high speed or very
precise applications this error can be VERY significant.
If the error becomes too big for the application, consider using an
external "hardware" timer.

March 2003 Abdel-Kawi Sary 71


One Shot Instruction -1
• A one-shot is used to make something happen for ONLY 1 SCAN.
• Most manufacturers have one-shots that react to an off to on transition
and a different type that reacts to an on to off transition.
• Some names for the instructions could be difu/difd (differentiate
up/down), sotu/sotd (single output up/down), osr (one-shot rising) and
others.
• They all, however, end up with the same result regardless of the name.
•A difd looks the same but inside the symbol it says "difd".
• For those manufacturers that don't include a differentiate down
instruction, you can get the same effect by putting a NC (normally closed)
instruction before it instead of a NO (normally open) instruction

One-Shot Symbol

March 2003 Abdel-Kawi Sary 72


One Shot Instruction - 2
EXAMPLE

let's set up a flip/flop circuit. In


simple terms, a flip/flop turns
something around each time an
action happens.
Here we'll use a single
pushbutton switch (Input 0000).
The first time the operator pushes
it we want an output to turn on. It
will remain "latched" on until the
next time the operator pushes the
button. When he does, the output
turns off.
We use the ONE-SHOT where we
do some things that MUST
happen only once.

March 2003 Abdel-Kawi Sary 73


One Shot Instruction - 3

•First Scan after Input 0000 has


become true:
- Rung 1-
When NO (normally open) input 0000
becomes true DIFU 1000 becomes true.
- Rung 2-
NO 1000 is true, NC 1000 turns false.

NC 1001 remains true,


NO 1001 remains false,

Since we have a true path, (NO 1000 &


NC 1001) OUT 1001 becomes true.

- Rung 3-
NO 1001 is true therefore OUT 0500
turns true.

March 2003 Abdel-Kawi Sary 74


One Shot Instruction - 4
Scan # 2:
- Rung 1- NO 0000 remains true.
Since the DIFU instruction is only
true for one scan. (i.e. the rising
edge of the logic before it on the
rung) DIFU 1000 now becomes
false.
- Rung 2-
NO 1000 turns false, NC 1000 turns
true.

Due to the previous scan:


NC 1001 remains false
NO 1001 remains true,

Since we STILL have a true path,


(NO 1001 & NC 1000) : OUT 1001
remains true.

- Rung 3- NO 1001 is true


therefore OUT 0500 remains true.
March 2003 Abdel-Kawi Sary 75
One Shot Instruction - 5

•After 100 scans:


NO 0000 turns off (becomes false). The
logic remains in the same state as
"scan#2" shown above. (difu doesn't react,
therefore, the logic stays the same on
rungs 2 and 3).

• On scan 101
NO 0000 turns back on. (becomes true)

- Rung 1-
When NO (normally open) input 0000
becomes true DIFU 1000 becomes true.
- Rung 2-
NO 1000 is true, NO 1001 remains true, NC
1001 becomes false, NC 1000 also
becomes false. Since we no longer have a
true path, OUT 1001 becomes false.
- Rung 3-
NO 1001 is false therefore OUT 0500
becomes false.
March 2003 Abdel-Kawi Sary 76
Master Controls

• Master controls can be thought of as "emergency stop switches".


• IMPORTANT- We're not implying that this instruction is a
substitute for a "hard wired" ESD-stop switch.
• The master control instruction typically is used in pairs with a
master control reset.

Master control Master control


reset. reset.

• Many manufacturers make them act differently

March 2003 Abdel-Kawi Sary 77


Example Master Controls -- 1
Manufacturer X- In this example, rungs 2 and 3
are only executed when input 0000 is on (true).

If input 0000 is not true the plc pretends that the


logic between the mc and mcr instructions does
not exist. It would therefore bypass this block of
instructions and immediately go to the rung after
the mcr instruction.
Conversely, if input 0000 is true, the plc would
execute rungs 2 and 3 and update the status of
outputs 0500 and 0501 accordingly.

So, if input 0000 is true, program execution goes to rung 2. If input 0001 is
true 0500 will be true and hence it will turn on when the plc updates the
outputs.
If input 0002 is true (i.e. physically off) 0501 will be true and therefore it
will turn on when the plc updates the outputs.
MCR just tells the plc "that's the end of the mc/mcr block".
March 2003 Abdel-Kawi Sary 78
Example Master Controls - 2

Manufacturer Y-
In this example, rungs 2 and 3 are always executed regardless of the status of input
0000.
If input 0000 is not true the plc executes the MC instruction. (i.e. MC becomes true)
It then forces all the input instructions inside the block to be off.
If input 0000 is true the MC instruction is made to be false.
Then, if input 0000 is true, program execution goes to rung 2.
If input 0001 is true 0500 will be true and hence it will turn on when the plc updates
the outputs.
If input 0002 is true (i.e. physically off) 0501 will be true and therefore it will turn on
when the plc updates the outputs.
MCR just tells the plc "that's the end of the mc/mcr block".
When input 0000 is false, inputs 0001 and 0002 are forced off regardless if they're
physically on or off. Therefore, outputs 0500 and 0501 will be false.

March 2003 Abdel-Kawi Sary 79


Example Master Controls - 3
The difference between manufacturers X and Y above is that in the Y scheme
the scan time will be the same (well close to the same) regardless if the block
is on or off. This is because the plc sees each instruction whether the block
is on or off.
Most all manufacturers will make a previously latched instruction (one that's
inside the mc/mcr block) retain its previous condition.
If it was true before, it will remain true.
If it was false before, it will remain false.
Timers should not be used inside the mc/mcr block because some
manufacturers will reset them to zero when the block is false whereas other
manufacturers will have them retain the current time state.
Counters typically retain their current counted value.

Here's the part to note most of all. When the mc/mcr block is off, (i.e. input
0000 would be false in the ladder example shown previously) an OUTB
(OutBar or OutNot) instruction would not be physically on. It is forced
physically off.

March 2003 Abdel-Kawi Sary 80


Example Master Controls - 4

• In summary:
• Most manufacturers use the manufacturer Y execution
scheme shown above.
• When in doubt, read the manufacturers instruction
manual. Better yet, just ask them.

March 2003 Abdel-Kawi Sary 81


SHIFT REGISTERS - 1
In many applications it is necessary to store the status of an event that has
previously happened.
But what do we do if we must store many previous events and act upon them
later.
Answer: we call upon the shift register instruction.

We use a register or group of registers to form a train of bits (cars) to store


the previous on/off status.
Each new change in status gets stored in the first bit and the remaining bits
get shifted down the train to the left or to the right.
We should note that not all manufacturers have shift registers that shift data
to the right but most all do have left shifting registers.

March 2003 Abdel-Kawi Sary 82


SHIFT REGISTERS - 2

Location of the first


A 4-bit Shift Register bit of the shift register
Instruction Symbol
Location of the last bit
of the shift register

Data- The data input gathers the true/false statuses that will be shifted down the
train. When the data input is true the first bit (car) in the register (train) will be a 1.
This data is only entered into the register (train) on the rising edge of the clock input.
Clock- The clock input tells the shift register to "do its thing". On the rising edge of
this input, the shift register shifts the data one location over inside the register and
enters the status of the data input into the first bit. On each rising edge of this input
the process will repeat.
Reset- The reset input does just what it says. It clears all the bits inside the register
we're using to 0.
March 2003 Abdel-Kawi Sary 83
EXAMPLE SHIFT REGISTERS – 1
Imagine an ice-cream cone machine. We have 4
steps.
First we verify the cone is not broken.
Next we put ice cream inside the cone (turn on output
0500)
Next we add peanuts (turn on output 0501)
Finally we add sprinkles (turn on output 0502)
If the cone is broken we obviously don't want to add
ice cream and the other items. Therefore we have to
track the bad cone down our process line so that we
can tell the machine not to add each item.

We use a sensor to look at the bottom of the cone (input 0000) If its on then
the cone is perfect and if its off then the cone is broken. An encoder tracks
the cone going down the conveyor (input 0001) A push button on the
machine will clear the register (input 0002)

March 2003 Abdel-Kawi Sary 84


EXAMPLE SHIFT REGISTERS – 2
Initially, the register 1000 looks like this:

10xx Register

00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

0 0 0 0

A good cone comes in front of the sensor (input 0000). The sensor (data
input) turns on.
1000 will not turn on until the rising edge of the encoder (input 0001).
Finally the encoder now generates a pulse and the status of the data input
(cone sensor input 0000) is transferred to bit 1000.
The register now looks like:

10xx Register
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
1 0 0 0

March 2003 Abdel-Kawi Sary 85


EXAMPLE SHIFT REGISTERS – 3
As the conveying system moves on, another cone comes in front of the
sensor. This time it's a broken cone and the sensor remains off.
Now the encoder generates another pulse. The old status of bit 1000 is
transferred to bit 1001. The old status of 1001 shifts to 1002. The old status of
1002 shifts to 1003. And the new status of the data input (cone sensor) is
transferred to bit 1000. The register now looks like:

10xx Register

00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

0 1 0 0

Since the register shows that 1001 is now on, the ladder says that output
0500 will turn on and ice cream is put in the cone.

March 2003 Abdel-Kawi Sary 86


EXAMPLE SHIFT REGISTERS – 4

As the conveying system continues to move on, another cone comes in front
of the sensor. This time it's a good cone and the sensor turns on. Now the
encoder generates another pulse. The old status of bit 1000 is transferred to
bit 1001. The old status of 1001 shifts to 1002. The old status of 1002 shifts to
1003. And the new status of the data input (cone sensor) is transferred to bit
1000. The register now looks like:

10xx Register

00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

1 0 1 0

Since the register shows that 1002 is now on the ladder says that output 0501
will turn on and peanuts are put on the cone.

March 2003 Abdel-Kawi Sary 87


EXAMPLE SHIFT REGISTERS – 5
Since 1001 now holds the status of a broken cone, 0500 remains off in the ladder above
and no ice-cream is inserted into this cone.
As the conveying system continues to move on, another cone comes in front of the
sensor. This time it's also a good cone and the sensor turns on. Now the encoder
generates another pulse. The old status of bit 1000 is transferred to bit 1001. The old
status of 1001 shifts to 1002. The old status of 1002 shifts to 1003. And the new status
of the data input (cone sensor) is transferred to bit 1000. The register now looks like:

10xx Register

00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

1 1 0 1

Since the register shows that 1003 is now on the ladder says that output 0502 will turn
on and sprinkles are put on the cone. Since 1002 now holds the status of a broken
cone, 0501 remains off in the ladder above and no peanuts are put onto this cone.
Since the register shows that 1001 is now on the ladder says that output 0500 will turn
on and ice cream is put in that cone.

March 2003 Abdel-Kawi Sary 88


EXAMPLE SHIFT REGISTERS - 6
As the conveying system continues to move on, another cone comes in front
of the sensor. This time it's another broken cone and the sensor turns off.
Now the encoder generates another pulse. The old status of bit 1000 is
transferred to bit 1001. The old status of 1001 shifts to 1002. The old status
of 1002 shifts to 1003. And the new status of the data input (cone sensor) is
transferred to bit 1000. The register now looks like:

10xx Register
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

0 1 1 0

Notice that the status of our first cone has disappeared. In reality its sitting
in location 1004 but it's useless for us to draw an application with 16
processes here. Suffice it to say that after the bit is shifted all the way to the
left it disappears and is never seen again. In other words, it has been shifted
out of the register and is erased from memory. Although it's not drawn, the
operation above would continue on with each bit shifting on the rising edge
of the encoder signal.
March 2003 Abdel-Kawi Sary 89
EXAMPLE SHIFT REGISTERS – 7
The shift register is most commonly used in conveyor systems, labeling or
bottling applications, etc. Sometimes it's also conveniently used when the
operation must be delayed in a fast moving bottling line.
For example, a solenoid can't immediately kick out a bad can of beer when
the sensor says its bad. By the time the solenoid would react the can would
have already passed by. So typically the solenoid is located further down the
conveyor line and a shift register tracks the can to be kicked out later when
it's more convenient.

March 2003 Abdel-Kawi Sary 90


March 2003 Abdel-Kawi Sary 91
Numbers

Base 10 Decimal

Base 2 Binary
Base 8 Octal

Base 16 Hexadecimal

Bit # 0 1 2 3 4 5 6 7
Y= Ax0 Ax1 Ax2 Ax3 Ax4 Ax5 Ax6 Ax7
A = Constant x = Base Y = Equivalent Decimal Number

March 2003 Abdel-Kawi Sary 92


Example Binary Numbers

Y=

Bit # 0 1 2 3 4 5 6 7
1*20 1*21 Ax2 1*23 1*24 1*25 1*26 1*27
Y= 1 2 4 8 16 32 64 128

A = Constant = 1 x = Base = 2 Y = Equivalent Decimal Number

March 2003 Abdel-Kawi Sary 93


PLC WIRING

I/O PLC
Devices
Field Devices Wiring & Power - 1

March 2003 Abdel-Kawi Sary 95


Field Devices Wiring & Power - 2

March 2003 Abdel-Kawi Sary 96


Field Devices Wiring & Power - 3

March 2003 Abdel-Kawi Sary 97


March 2003 Abdel-Kawi Sary 101

You might also like