PLC Teaching Module
PLC Teaching Module
PLC Teaching Module
Introduction to PLCs................................................................................................... 2
What does PLC mean?........................................................................................... 2
Traditional PLC Applications.................................................................................2
Disadvantages of PLC control...............................................................................2
Advantages of PLC control................................................................................... 3
Major Types of Industrial Control Systems...............................................................3
PLC....................................................................................................................... 3
DCS...................................................................................................................... 3
Embedded Control................................................................................................ 3
SCADA.................................................................................................................. 3
PLC History................................................................................................................. 3
PLC Hardware............................................................................................................. 4
Hardware Components of a PLC System.................................................................4
Central Processing Unit (CPU)..............................................................................4
System Busses..................................................................................................... 4
Memory................................................................................................................ 4
I/O Sections.......................................................................................................... 5
Power Supply........................................................................................................ 5
Programming Device............................................................................................ 5
PLC Operation............................................................................................................. 5
Input Relays......................................................................................................... 5
Internal Utility Relays........................................................................................... 5
Counters............................................................................................................... 5
Timers.................................................................................................................. 5
Output Relays....................................................................................................... 5
Data Storage........................................................................................................ 6
PLC Communications.................................................................................................. 6
Extension modules.................................................................................................. 6
PLC Manual
Introduction to PLCs
What does PLC mean?
A PLC (Programmable Logic Controllers) is an industrial computer used to monitor
inputs, and depending upon their state make decisions based on its program or logic, to
control (turn on/off) its outputs to automate a machine or a process.
PLC
They are based on the Boolean logic operations whereas some models use timers and
some have continuous control. These devices are computer based and are used to
control various process and equipment within a facility. PLCs control the components in
the DCS and SCADA systems but they are primary components in smaller control
configurations.
DCS
Distributed Control Systems consists of decentralized elements and all the processes
are controlled by these elements. Human interaction is minimized so the labor costs and
injuries can be reduced.
Embedded Control
In this control system, small components are attached to the industrial computer
system with the help of a network and control is exercised.
SCADA
Supervisory Control and Data Acquisition refers to a centralized system and this system
is composed of various subsystems like Remote Telemetry Units, Human Machine
Interface, Programmable Logic Controller or PLC and Communications.
PLC History
PLC development began in 1968 in response to a request from an US car manufacturer
(GE). The first PLCs were installed in industry in 1969.
The 90s have seen a gradual reduction in the introduction of new protocols, and the
modernization of the physical layers of some of the more popular protocols that
survived the 1980s.
The latest standard IEC 1131-3 has tried to merge plc programming languages under
one international standard. We now have PLCs that are programmable in function block
diagrams, instruction lists, C and structured text all at the same time.
PLC Hardware
Hardware Components of a PLC System
Processor unit (CPU), Memory, Input/Output, Power supply unit, Programming device,
and other devices.
CPU makes a great number of check-ups of the PLC controller itself so eventual errors
would be discovered early.
System Busses
The internal paths along which the digital signals flow within the PLC are called
busses.
The CPU uses the data bus for sending data between the different elements,
The address bus to send the addresses of locations for accessing stored data,
The control bus for signals relating to internal control actions,
The system bus is used for communications between the I/O ports and the I/O
unit.
PLC Manual
Memory
System (ROM) to give permanent storage for the operating system and the fixed data
used by the CPU.
RAM for data. This is where information is stored on the status of input and output
devices and the values of timers and counters and other internal devices. EPROM for
ROMs that can be programmed and then the program made permanent.
I/O Sections
Inputs monitor field devices, such as switches and sensors.
Outputs control other devices, such as motors, pumps, solenoid valves, and lights.
Power Supply
Most PLC controllers work either at 24 VDC or 220 VAC. Some PLC controllers have
electrical supply as a separate module, while small and medium series already contain
the supply module.
Programming Device
The programming device is used to enter the required program into the memory of the
processor.
The program is developed in the programming device and then transferred to the
memory unit of the PLC.
PLC Operation
Input Relays
These are connected to the outside world. They physically exist and receive signals from
switches, sensors, etc. Typically, they are not relays but rather they are transistors.
Counters
These do not physically exist. They are simulated counters and they can be
programmed to count pulses. Typically, these counters can count up, down or both up
and down. Since they are simulated they are limited in their counting speed. Some
manufacturers also include highspeed counters that are hardware based.
Timers
These also do not physically exist. They come in many varieties and increments. The
most common type is an on-delay type. Others include off-delay and both retentive and
non-retentive types. Increments vary from 1ms through 1s.
PLC Manual
Output Relays
These are connected to the outside world. They physically exist and send on/off signals
to solenoids, lights, etc. They can be transistors, relays, or triac depending upon the
model chosen.
Data Storage
Typically, there are registers assigned to simply store data. Usually used as temporary
storage for math or data manipulation. They can also typically be used to store data
when power is removed from the PLC.
PLC Communications
Extension modules
PLC I/O number can be increased through certain additional modules by system
extension through extension lines. Each module can contain extension both of input and
output lines.
Extension modules can have inputs and outputs of a different nature from those on the
PLC controller. When there are many I/O located considerable distances away from the
PLC an economic solution is to use I/O modules and use cables to connect these, over
the long distances, to the PLC.
Remote PLCs
In some situations, a number of PLCs may be linked together with a master PLC unit
sending and receiving I/O data from the other units.
Cables
Twisted-pair cabling, often routed through steel conduit. Coaxial cable enables higher
data rates to be transmitted and does not require the shielding of steel conduit.
Fiber-optic cabling has the advantage of resistance to noise, small size and flexibility.
Parallel communication
Parallel communication is when all the constituent bits of a word are simultaneously
transmitted along parallel cables. This allows data to be transmitted over short
distances at high speeds. Might be used when connecting laboratory instruments to the
system.
Parallel standards
The standard interface most commonly used for parallel communication is IEEE-488,
and now termed as General Purpose Instrument Bus (GPIB).
PLC Manual
Parallel data communications can take place between listeners, talkers, and controllers.
There are 24 lines: 8 data (bidirectional), 5
Serial communication
Serial communication is when data is transmitted one bit at a time. A data word has to
be separated into its constituent bits for transmission and then reassembled into the
word when received. Serial communication is used for transmitting data over long
distances. Might be used for the connection between a computer and a PLC.
Serial standards
RS-232 communications are the most popular method of plc to external device
communications. RS 232 is a communication interface included under SCADA
applications. Other standards such as RS422 and RS423 are similar to RS232 although
they permit higher transmission rates and longer cable distances.
ASCII
ASCII is a human-readable to computer-readable translation code (each letter/number is
translated to 1s and 0s). Its a 7-bit code, so we can translate 128 characters (2^7 is
128).
Protocols
It is necessary to exercise control of the flow of data between two devices so what
constitutes the message, and how the communication is to be initiated and terminated,
is defined. This is termed the protocol. One device needs to indicate to the other to start
or stop sending data. Interconnecting several devices can present problems because of
compatibility problems. In order to facilitate communications between different devices
the International Standard Organization (ISO) in 1979 devised a model to be used for
standardization for Open System Interconnection (OSI).
START/STOP Bits
Start bit
This is a synchronizing bit added just before each character we are sending. This is
considered a SPACE or negative voltage or a 0.
Stop bit
This bit tells us that the last character was just sent. This is considered a MARK or
positive voltage or a 1.
PLC Manual
Parity bit
Parity bit is added to check whether corruption has occurred. Common forms of parity
are: None, Even, and Odd. During transmission, the sender calculates the parity bit and
sends it. The receiver calculates parity for the character and compares the result to the
parity bit received. If the calculated and real parity bits dont match, an error occurred
and we act appropriately.
Baud rate
it is the number of bits per second that are being transmitted or received. Common
values (speeds) are 1200, 2400, 4800, 9600, 19200, and 38400.
Software handshaking
Software handshaking (flow control) is used to make sure both devices are ready to
send/receive data. The most popular character flow control is called XON/XOFF. The
receiver sends the XOFF character when it wants the transmitter to pause sending data.
When its ready to receive data again, it sends the transmitter the XON character.
RS-232 Communications
with each other so that when one steps they all step. They are asynchronous in that
they follow the band leader to keep their timing).
We use a binary system to transmit our data in the ASCII format. PLCs serial port is used
for transmission/reception of the data, it works by sending/receiving a voltage, With
RS232, normally, a 1 bit is represented by a voltage -12 V, and a 0 by a voltage +12 V.
(The voltage between +/- 3 volts is considered There are 2 types of RS-232 devices.)
When plc and external device are both DTE, (or both DCE) devices they cant talk to
each other. The solution is to use a null-modem connection.
2. Where, in data memory, will we put the data we receive from the external device?
RS-485 interface
By using repeaters, however, both the total number of devices and maximum distance
can be extended.
The four wire network would be bidirectional (a simultaneous two way conversation can
happen) whereas the two wire network works only in one direction.
It is either a 3 or 5 wire system. The third or fifth wire is actually a ground wire.
The RS-485 disadvantage is that it is harder to program, because it uses the same 2
wires to send and receive data. And in any given network, only one node can transmit
data, other nodes can only receive at that particular moment. On the advantages side,
PLC Manual
it supports long distance communications with no problems. It also uses lower interface
signal levels than the RS-232, which makes the interface circuit harder to damage.
ISO/OSI model
* physical,
* electrical,
* protocol and
* user standards.
PLC Manual
Each layer is self contained and only deals with the interfaces of the layer immediately above and
below. It performs its tasks and transfers its results to the layer above or the layer below.
It enables manufacturers of products to design products operable in a particular layer that will
interface with the hardware of other ma ISO/OSI Protocols
ControlNet
The ControlNet network uses the Common Industrial Protocol (CIP) to combine the functionality of
an I/O network and a peer-to-peer network. ControlNet take precedence over program uploads and
downloads and messaging. Supports a maximum of 99 nodes.
DeviceNet
DeviceNet is mainly used in industrial and process automation. It is based on CAN technology.
It is a low-cost communication link to connect industrial devices to a network and eliminate expensive
hard wiring. Power and communication supplied over a 4-wire bus. Supports up to 62 devices on the
same bus network.
ModBus
ModBus is an open, serial communication protocol based on the master/slave architecture. The bus
consists of a master station, controlling the communication, and of a number of slave stations.
MODBUS is an application layer messaging protocol, positioned at level 7 of the OSI model, that
provides client/server communication between devices connected on different types of buses or
networks. MODBUS is used to monitor and program devices; to communicate intelligent devices with
sensors and instruments; to monitor field devices using PCs and HMIs. MODBUS is an ideal
protocol for RTU applications where wireless communication is required.
* Question/answer (polling): The master sends an inquiry to any of the stations, and waits for the
answer.
* Broadcast: The master sends a command to all the stations on the network, and these execute the
command without providing feedback.
PLC Manual
The transmission mode defines the bit contents of the message bytes transmitted along the network,
and how the message information is to be packed into the message stream and decoded. The mode
of transmission is usually selected with other serial port communication parameters as part of the
device configuration.
1. ASCII Mode: Each character byte in a message is sent as 2 ASCII characters. This mode allows
time interval of up to a second between characters during transmission without generating errors.
2. RTU Mode: Each 8-bit message byte contains two 4-bit hexadecimal characters, and the message
is transmitted in a continuous stream. The greater effective character density increases throughput
over ASCII mode at the same baud rate.
PROFIBUS
PROFIBUS-DP purpose is for larger devices like PCs and PLCs to talk with multiple smaller devices
like sensors, drives, valves, etc. It uses RS-485 for transmission of data. It uses a shielded twisted
pair cable and enables data transmission speeds up to 12 Mbit/sec.
A maximum of 9 segments (trunk line) are allowed on a network. The devices are the branches
coming off the trunk line. Up to 32 individual devices can be connected to a single segment. That
number can be expanded up to 126 if repeaters are used. Each PROFIBUS segment can be a
maximum of 1200 meters in length. There are 10 defined communication speeds and each has a
maximum defined cable length thats permitted.
Master /Slave
PROFIBUS uses a master/slave configuration for communication. It is usually a single master device
(aPLC) that talks with multiple slave devices (sensors). The master devices poll the slaves when
PLC Manual
they have the token. Slave devices only answer when asked a question. They are passive and the
master can be said to be active. The slave devices just collect data and pass it to the master device
when asked to do so.
Ethernet
Ethernet is one of the most widely implemented LAN architecture. It uses a bus, star or tree
topologies. It uses the CSMA/CD access method to handle simultaneous demands. It supports data
transfer rates of 10 Mbps, Fast Ethernet (100 Base-T)- 100 Mbps, and Gigabit Ethernet 1000
Mbps.
This is a system where each computer listens to the cable before sending anything through the
network. If the network is clear, the computer will transmit. If some other node is already
transmitting on the cable, the computer will wait and try again when the line is clear.
TCP/IP PROTOCOL
Most manufacturers who offer Ethernet compatibility to implement supervisory functions over
equipment controlling plant floor functions use a transmission control protocol/internet protocol
(TCP/IP) for layers 3 and 4 of the OSI model. Some PLC manufacturers offer programmable
controllers with TCP/IP over-Ethernet protocol built into the PLC processor. This allows the PLC to
connect directly to a supervisory Ethernet network. Note that the PLC can also have a control
network with other PLC manufacturers.
correctly with external environment. These terms are applied only for DC
modules.
Sinking I/O circuits on the I/O modules receive (sink) current from sourcing field devices.
Sinking output modules used for interfacing with electronic equipment.
Sourcing I/O: Sourcing output modules used for interfacing with solenoids.
PLC AC I/O circuits accommodate either sinking or sourcing field devices. Solid-state DC
I/O circuits require that they used in a specific sinking or sourcing circuit depending on
the internal circuitry.
Example of input lines can be connection of external input device. Sensor outputs can
be different depending on a sensor itself and also on a particular application.
In practice we use a system of connecting several inputs (or outputs) to one return line.
These common lines are usually marked COMM on the PLC controller housing.
PLC Manual
DC Inputs
transistor type devices to them. When we are using a sensor have to worry about its
output configuration. If we are using a regular switch (toggle or pushbutton) we typically
dont have to worry about whether we wire it as NPN or PNP.
AC Inputs
switched through a limit switch or other switch type. AC input modules are less common
than DC input modules, because todays sensors typically have transistor outputs. If
application is using a sensor it probably is operating on a DC voltage.
Typically an AC input takes longer than a DC input for the PLC to see.
Its quite common for a plc to require that the input be on for 25 ms (or more) before its
seen. This delay is required because of the filtering which is needed by the PLC internal
circuit.
Relay,
PLC Manual
Transistor, or
Triac.
Make sure that the maximum current it will consume is within the specifications of the
plc output.
Relay Outputs
One of the most common types of outputs available is the relay output. Existence of
relays as outputs makes it easier to connect with external devices. A relay is non-
polarized and typically it can switch either AC or DC.
Transistor Outputs
Transistor type outputs can only switch a dc current. The PLC applies a small current to
the transistor base and the transistor output closes. When its closed, the device
connected to the PLC output will be turned on.
A transistor typically cannot switch as large a load as a relay. If the load current you
need to switch exceeds the specification of the output, you can connect the plc output
to an external relay, then connect the relay to the large load.
Typically a PLC will have either NPN or PNP transistor type outputs. Some of the
common types available are BJT and MOSFET. A BJT type often has less switching
capacity than a MOSFET type. The BJT also has a slightly faster switching time.
A transistor is fast, switches a small current, has a long lifetime and works with dc only.
A relay is slow, can switch a large current, has a shorter lifetime and works with ac or
dc.
Triac Output
Triac output can be used to control AC loads only. Triac output is faster in operation and
has longer life than relay output.
turn on. This back current is like a voltage spike coming through the system. This could
be dangerous to output relays. Typically, a diode, varistor, or other snubber circuit
should be used to protect the PLC output from any damage.
*Voltage level.
*Current input.
*Conversion speed. There are two basic types of A/D converter. The first will perform a
conversion every 20 ms (the period of the a.c. mains voltage), which gives a good clean
reading free from worries of line frequency interference.
The second will convert in 2-20 us, giving the possibility of measuring transient data.
*At very high rates the PLC may only have time to act as a data logger, storing the data
as it is read, and analyzing it
*The conversion speed of an analog output is generally <100 us and rarely a problem.
* Once the resolution of the module is selected we have only to consider the following
points:
Voltage level.
Current output. It is often an advantage to use a current loop output (4-20 mA).
In many cases analog inputs are used not only to monitor variables but also as a
feedback to control a process by controlling relay outputs or varying an analog output.
PLC Manual
The required control accuracy must be defined in the specification, as must the
maximum required rate of change.
*The speed;
*The positioning accuracy. There are many possible solutions available each of which
offers a trade-off between speed of movement and positioning accuracy.
By knowing the number of any type of I/O lines we need and the number of lines
available on a given module, the final shopping list of modules and the size of the PLC
system are determined. In addition, build in at least 20 per cent extra capacity to allow
to future modifications or to solve problems identified during commissioning.
Input selection
*Voltage level.
*Response speed.
Output Selection
* Voltage level.
* Output resistance and electrical noise can be an issue in cases where low level signals
are to be switched.
In most cases the voltage is higher, giving a reduction in current for any particular load,
the consequent reduction in the wire size required giving a reduction in wiring costs.
PLC Manual
The following terms, common for analog input and output modules, used to describe
their performance;
Resolution defines how accurately the analog to digital (A/D) or digital to analog (D/A)
converter within the module can represent an analog voltage as a binary number, or
vice versa.
Isolation refers to the ability of each input or output to work at voltage levels
independent of the system ground.
PLC Networks
As control systems become more complex, they require more effective communication
schemes between the system components. Some machine and process control systems
require that programmable controllers be interconnected, so that data can be passed
among them
The term local area network (LAN) is used to describe a communication network
designed
to link computers and their peripherals within the same building or site. A LAN is a high-
speed, mediumdistance communication system.
For most LANs, the maximum distance between two nodes in the network is at least one
mile, and the transmission speed ranges from 1 to 20 megabaud. Also, most local
networks support
PLC Manual
Industrial Network
A special type of LAN, the industrial network, is one which meets the following criteria:
PLC Programming
Programming Languages
A program loaded into PLC systems in machine code, a sequence of binary code
numbers to represent the program instructions.
Assembly language based on the use of mnemonics can be used, and a computer
program called an assembler is used to translate the mnemonics into machine code.
Programming Devices
Programming Console
PC
Hand Programmer
Ladder logic uses graphic symbols similar to relay schematic circuit diagrams.
Ladder diagram consists of two vertical lines representing the power rails. Circuits are
connected as horizontal lines between these two verticals.
Output on right side can not be connected directly with left side.
A particular input a/o output can appear in more than one rung of a ladder.
The inputs a/o outputs are all identified by their addresses, the notation used
depending on the PLC manufacturer.
* Or (O) instruction.
Function block is represented as a box with the function name written in.
please note:
LD: load
O: or
PLC Instructions
Data move Instructions: MOV, COP, FLL, TOD, FRD, DEG, RAD (degrees to radian).
PLC Manual
Comparison instructions: EQU (equal), NEQ (not equal), GEQ (greater than or equal),
GRT (greater than).
Mathematical instructions.
Program flow control instructions: MCR (master control reset), JMP, LBL, JSR, SBR, RET,
SUS, REF
Specific instructions:
BSL, BSR (bit shift left/right), SQO (sequencer output), SQC (sequencer compare), SQL
(sequencer load).
Internal Relays
Used to hold data, and behave like relays, being able to be switched on or off and switch
other devices on or off. They do not exist as real-world switching devices but are merely
bits in the storage memory.
In programs with multiple input conditions or arrangements. For latching a circuit and
for resetting a latch circuit. Giving special built-in functions with PLCs.
Such relays retain their state of activation, even when the power supply is off. They can
be used in circuits to ensure a safe shutdown of plant in the event of a power failure and
so enable it to restart in an appropriate manner.
The set instruction causes the relay to self-hold,, i.e. latch. It then remains in that
condition until the reset instruction is received.
The unlatch instruction is often called a RES (reset), OTU (output unlatch) or RST
(reset).
Timers
Timer is an instruction that waits a set amount of time before doing something (control
time). Timers count fractions of seconds or seconds using the internal CPU clock. The
time duration for which a timer has been set is termed the preset and is set in multiples
of the time base used.
Most manufacturers consider timers to behave like relays with coils which when
energized result in the closure or opening of contacts after some preset time. The timer
is thus treated as an output for a rung with control being exercised over pairs of
contacts elsewhere. Others treat a timer as a delay block which when inserted in a rung
delays signals in that rung reaching the output.
Timers Types
On-Delay timer- simply delays turning on. It is called TON, TIM or TMR.
Off-Delay timer- simply delays turning off. It is called TOF and is less common than
the on-dellay type.
The on/off delay timers above would be reset if the input sensor wasnt on/off for the
complete timer duration.
Retentive or Accumulating timer- holds or retains the current elapsed time when the
sensor turns off in mid-stream. It is called RTO or TMRA.
When the instructions before the timer symbol are true the timer starts ticking.
PLC Manual
When the time elapses the timer will automatically close its contacts.
When the program is running on the plc the program typically displays the current
value.
Typically timers can tick from 0 to 9999 (16-bit BCD) or 0 to 65535 times (16-bit
binary).
Timer Accuracy
Software Errors
Input error depending upon when the timer input turns on during the scan cycle.
Output error depending upon when in the ladder the timer actually times out and
when the plc finishes executing the program to get to the part of the scan when it
updates the outputs.
Total software error is the sum of both the input and output errors.
Hardware Error
There is 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 (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.
Counters
A counter is set to some preset value and, when this value of input pulses has been
received, it will operate its contacts.
The counter accumulated value ONLY changes at the off to on transition of the pulse
input.
Typically counters can count from 0 tto 9999, -32,768 to +32,767 or 0 to 65535.
PLC Manual
The normal counters are typically software counters they dont physically exist in
the plc but rather they are simulated in software. A good rule of thumb is simply to
always use the normal (software) counters unless the pulses you are counting will arive
faster than 2X the scan time.
Counter Types
Up-counters counts from zero up to the preset value. These are called CTU, CNT, C, or
CTR.
Down-counters count down from the preset value to zero. These are calllled CTD.
For CTU or CTD counter we need 2 inputs, but in CTUD we need 3 (up, down and
preset).
1. Where the pulses that we want to count are coming from. Typically this is from one of
the inputs.
Counter Formats
Some manufacturers consider the counter as a relay and consist of two basic elements:
One relay coil to count input pulses and one to reset the counter, and the associated
contacts of the counter being used in other rungs.
Others (Siemens for example) treat the counter as an intermediate block in a rung from
which signals emanate when the count is attained.
Sequencers
The sequencer is a form of counter that is used for sequential control. It replaces the
mechanical drum sequencer that was used to control machines that have a stepped
sequence of repeatable operations.
The PLC sequencer consists of a master counter that has a range of presets counts
corresponding to the different steps and so, as it progresses through the count, when
each preset count is reached can be used to control outputs.
Advanced Instructions
Timers, counters and individual relays are all concerned with the handling of individual
bits, i.e. single on-off signal. PLC operations involve blocks of data representing a value,
such blocks being
termed words.
The number of bits determines the size of the number that can be stored (2n 1).
The single instruction is commonly called MOV (move) copies a value from one address
to another.
We write an address here. Allso, the data can be moved to the physical outputs.
Data comparison
The data comparison instruction gets the PLC to compare two data values.
Thus it might be to compare a digital value read from some input device with a second
value contained in a register.
equal to (= or EQU),
PLCs almost always include math functions to carry out some arithmetic operations:
Subtraction (SUB) The capability to subtract one piece of data from another.
Division (DIV) The capability to divide one piece of data from another.
Overflow
PLC Manual
Typically the memory locations are 16-bit locations. If a result is greater than the value
that could be stored in a memory location then we get an overflow. The plc turns on an
internal relay that tells us an overflow has happened. We get an overflow if the number
is greater than 65535
(2^16=65536).
Depending on the plc, we would have different data in the destination location. Some
use 32-bit math which solves the problem. If were doing division, and we divide by zero
the overflow bit turns on.
Advanced Instructions II
Continuous control of some variable can be achieved by comparing the actual value of
the variable with the desired set value and then giving an output depending on the
control law required. Many PLCs provide the PID calculation to determine the controller
output as a standard routine. All that is then necessary is to pass the desired
parameters, i.e. the values of Kp, Ki, and KD, and input/output locations to the routine
via the PLC program.
Control instructions are used to enable or disable a block of logic program or to move
execution of a program from one place to another place.
Shift Registers
The master control instruction typically is used in pairs with a master control reset.
Different formats are used by different manufacturers:
The zone being controlled begins with a rung that has the first MC instruction, which
status depends on its rung condition. This zone ends with a rung that has the second
MCR instruction only.
When the rung with the first MCR instruction is true, the first MCR instruction is high
and the outputs of the rung in the controlled zone can be energized or denergized
acording to their rung conditions. When the this rung is false, all the outputs in the zone
are denrgized, regardless their rung conditions.
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.
Jump Instructions
The JUMP instructions allow to break the rung sequence and move tthe program
execution from one
There are:
RETURN / END
A Return from Subroutine instruction marks the end of Subroutine instruction. When the
rung condition of this instruction is true, it causes the PLC to resume execution in the
calling program file at the rung following the Jump to Subroutine instruction in the
calling program.
When a Return from Subroutine instruction is not programmed in a subroutine file, the
END instruction automatically causes the PLC to move execution back to the rung
following the Jump to Subroutine instruction. A Jump to Subroutine instruction can be
used either in a main application program or a subroutine program to call another
subroutine program.
Shift Registers
The shift register is a number of internal relays grouped together (normally 8, 16, or 32)
which allow stored bits to be shifted from one relay to another. The grouping together of
internal relays to form a shift register is done automatically by a PLC when the shift
register function is selected. This is done by using the programming code against the
internal relay number that is to be the first in the register array.
Shift registers can be used where a sequence of operations is required or to keep track
of particular items in a production system. The shift register is most commonly used in
conveyor systems, labeling or bottling applications, etc.
Programming Examples I
Example 1:
Write a program (instruction list) to put the number (4000) in a memory location, and the number (41)
in another location. divide the first one by the second and put the result in a memory location.
solution:
PLC Manual
Example 2:
Make a program to increase the counter by one with each pulse from the pulse generator SM0.4
(on rising edge) , and decrease another counter by the same pulse.
Solution:
steps of solution would be like this:
PLC Manual
Programming Examples II
Example 3:
Put a value in memory location vw200, and using shifting method, move this value to the output of
the PLC.
Solution:
PLC Manual
when we press the PLC input button (I0.0), the PLC will put the value (980) inside memory location
vw200, and when the rising edge of the pulse arrives, the contents of memory location will be shifted
to the left for one bit (the instruction SLW = shift left word). we could put 2 after # to shift two bits
to left. If we put 7 after the #, the overflow indicator will be activated (SM1.1=1) which will activate the
output in question.
here is the ladder diagram:
PLC Manual
Example 4:
Using two timers, write a program so we have a pulse on PLC output with (TON = 10 sec.) and
(TOFF = 10 sec.)
*TON: timer output on, TOFF: timer output off.
Solution:
Example 5:
Using up-counter (CTU), make the PWM algorithm.
solution:
there is inside the PLC places for generating a series of pulses with fixed durations, one of these
places is SM0.5, it generates a pulse of 1 second (on time is 0.5 sec and off time is 0.5 sec). another
PLC Manual
solution:
We need first to identify the inputs and outputs of the system, so we can set relations between the outside
world and the inputs/outputs of the programmable logic controller.
PLC Manual
This table makes it clear: (remember NC: normally closed, NO:normally open)
PLC Manual
.. and here is the ladder diagram and instruction list for the system:
Programming Examples IV
Example A:
Use the instructions (set, reset) with the timer (SM0.4) to turn an output on/off after several pulses
from the SM0.4 timer.
PLC Manual
Example B:
The next figure represents the process of making tea every day in the morning for seven days (water
in the tank is enough for 7 days only)
PLC Manual
Procedure:
When pressing the start button, the valve 1 (V1) opens,so the water pass through the valve to the
heating tank. And when the water level reaches the float switch (FS), the valve should close and
heating must begin.
When the temperature reach the required level the thermostat disconnects the heater and opens
valve 2 (V2) for 10 seconds then the alarm bell is activated (as a sign that the tea jug is filled now
with hot water)
PLC Manual
Programming Examples V
In this alarm system, there are 4 (danger) inputs to protect the factory, so that in case of any danger
signals any of these inputs, it will give an certain alarm.
Using programmable logic controllers, we will write a program according to the following
requirements:
1. If only one of the inputs (sensors) is turned on, nothing will happen.
2. If two of the inputs are turned on, the Red Pilot Light will be activated.
3. If three of the inputs is turned on at same time, it would trigger an Alarm (SIREN)
4. If all the four inputs are ON together, it would trigger an alarm to the Fire Department. which
indicates that all of the four signals together means fire will erupt.
INPUT Output
IN1 A NO
IN2 B NO Out 17 Red Pilot Light
IN3 C NO Out 18 Alarm *Siren
IN4 D NO Out 19 Fire Department
And the Ladder Logic Diagram for this alarm system is something like this:
Programming Examples VI
The following figure represents an industrial operation of thermal processing of metals, the machine
hardens the metal in the shape of a steel ring. the hardening process is done by heating the steel
PLC Manual
ring to a very high temperature, then it goes through a sudden cooling. So the piece we want to
harden is heated by passing very high currents through a coil that heats the piece, then we cool it
very quickly by sending cold water through the holes in each side.
the LSU returns to the normal state normally open (NO) after the piece has gone down.
10. when the piece goes to the buttom, the switch LSPP will be ON again.
11. the system after that will be in a RESET state.
12. then we could put a new piece and repeat the whole process.
Use the programmable logic controller to make a control circuit using two normally open (NO)
switches, to control the feed to a coil through the switches (SW1, SW2) as in the following circuit
figure,
PLC Manual
We connect the switches (SW1, SW2) to the inputs of the programmable logic controller (IN1, IN2)
and the COIL connected to the output of the PLC, (Q1) as in this figure:
And controlling the feed of the COIL happens using the program (instruction list) inside the PLC, look
at the following figure: