Plc Programming
Plc Programming
Introduction:
➢Is a process of creating instructions for a
programmable logic Controller (PLC) to follow.
➢These instructions enable the PLC to monitor
inputs and make decisions to control outputs
based on the information.
What is Programmable logic
Controller??
➢Is a special form of microprocessor-based
controller that uses a programmable memory to
store instructions and to implement functions
such as logic, sequencing, timing, counting and
arithmetic in order to control machines and
processes and are designed to be operated by
engineers with perhaps a limited knowledge of
computers and computing languages.
PLC Hardware Architecture
PLC Hardware Architecture
Introduction
The terms sourcing and sinking are used to describe the way
in which d.c. devices are connected to a PLC.
➢With sourcing, using the conventional current flow
direction as from positive to negative, an input device
receives current from the input module, i.e. the input module
is the source of the current. If the current flows from the
output module to an output load then the output module is
referred to as sourcing.
What is Sourcing and Sinking ??
Sinking
➢With sinking, using the conventional current
flow direction as from positive to negative, an
input device supplies current to the input
module, i.e. the input module is the sink for the
current. If the current flows to the output module
from an output load then the output module is
referred to as sinking.
Input-Output Devices
Introduction
➢The input devices considered include digital and
analogue devices such as mechanical switches for
position detection, proximity switches, photoelectric
switches, encoders, temperature and pressure
switches, potentiometers, linear variable differential
transformers, strain gauges, thermistors,
thermotransistors and thermocouples. Output
devices considered include relays, contactors,
solenoid valves and motors.
What is Sensor and Transducer??
Introduction
➢The term sensor is used for an input device that
provides a usable output in response to a specified
physical input. For example, a thermocouple is a sensor
which converts a temperature difference into an electrical
output.
➢The term transducer is generally used for a device that
converts a signal from one form to a different physical
form. Thus sensors are often transducers, but also other
devices can be transducers, e.g. a motor which converts an
electrical input into rotation.
What is Sensor and Transducer??
Mechanical Switches
➢A mechanical switch generates an on−off signal or
signals as a result of some mechanical input causing the
switch to open or close. Such a switch might be used to
indicate the presence of a workpiece on a machining table,
the workpiece pressing against the switch and so closing
it.
Proximity Switches
➢Proximity switches are used to detect the presence of an
item without making contact with it. There are a number
of forms of such switches, some being only suitable for
metallic objects
What is Sensor and Transducer??
Encoders
➢The term encoder is used for a device that provides a
digital output as a result of angular or linear displacement.
An increment encoder detects changes in angular or linear
displacement from some datum position, while an
absolute encoder gives the actual angular or linear
position.
Fluid Flow Measurement
➢A common form of fluid flow meter is that based on
measuring the difference in pressure resulting when a
fluid flows through a constriction.e.g Orifice flow meter
What is Sensor and Transducer??
Temperature Sensors
Is a device used to measure temperature variations and
convert them into electrical signals that can be interpreted
by electronic devices e.g Thermocouple, Resistance
Temperature Detector(RTD), Thermistors
Pressure Sensors
Is a device used to measure pressure and convert them
into electrical signals that can be interpreted by electronic
devices. It detects the force exerted on its surface per unit
area and translates this force into a measurable output.
Pressure sensors are Strain gauge, piezoelectric pressure
sensors.
Number Systems
• The number system used for everyday
calculations is the denary or decimal system.
• This is based on the use of the 10 digits: 0, 1,
2, 3, 4, 5, 6, 7, 8, 9.
• Computers, and hence PLC systems, are based
on counting in twos because it is convenient
for their system, their two digits being
effectively just the off and on signals.
Examples of Numbers in Different
Systems
PLC DATA
• Most PLCs operate with a 16-bit word, the
term word being used for the group of bits
constituting some information.
• This allows a positive number in the range 0 to
+65 535, i.e. 1111 1111 1111 1111, to be
represented or a signed number in the range –
32 768 to +32 767 in two’s complement, the
most significant bit then representing the sign.
• Such signed numbers are referred to as integers.
• INT being used with inputs and outputs in
programs of such 16-bit words
• SINT is used for short integer numbers where
only 8-bits are used, such numbers giving the
range –128 to +127
• DINT is used for double integer numbers where
32 bits are used, such numbers giving the range –
231 to +231 – 1.
• LINT is used for long integer numbers where 64
bits are used, such numbers giving the range –263
to +263 – 1.
• Decimal fractions are referred to as real or
floating point numbers, being represented by the
symbol REAL for inputs and outputs in programs
• BOOL is used for Boolean type data, such data
being on/off values, i.e. 0 or 1, and thus
represented by single bits.
• Time duration, e.g. for the duration of a process,
is represented by the IEC (International
Electrotechnical Commission) standard using the
symbols d for days, h for hours, m for minutes, s
for seconds and ms for milliseconds as, for
example, T#12d2h5s3ms or TIME#12d2h5s for
12 Number systems 51 days 2 hours 5 seconds
and 3 milliseconds.
• Note that # is the symbol used to indicate that
which follows is a numerical quantity.
What programming Language are
commonly used in PLC??
Introduction
➢Ladder logic is a graphical programming
language that represents a program by a
graphical diagram based on the circuit diagrams
of relay logic hardware.
➢The ladder diagram consists of two vertical
lines representing the power rails. Circuits are
connected as horizontal lines, i.e. the rungs of
the ladder, between these two verticals.
PLC ladder programming Conventions
➢The vertical lines of the diagram represent the
power rails between which circuits are
connected. The power flow is taken to be from
the left-hand vertical across a rung
➢Each rung on the ladder defines one operation
in the control process
➢Each rung on the ladder defines one operation
in the control process
➢Each rung must start with an input or inputs
and must end with at least one output.
PLC ladder programming Conventions
➢Electrical devices are shown in their normal
condition. Thus a switch which is normally open until
some object closes it, is shown as open on the ladder
diagram. A switch that is normally closed is shown
closed.
➢A particular device can appear in more than one rung
of a ladder. For example, we might have a relay which
switches on one or more devices. The same letters
and/or numbers are used to label the device in each
situation.
➢The inputs and outputs are all identified by their
addresses, the notation used depending on the PLC
manufacturer. This is the address of the input or output
in the memory of the PLC.
What is normally open Contact??
Introduction
➢This refers to an input device or contact that is
in its open state when there is no actuation or
signal present.
➢In other words, the circuit is not completed
unless the input device is activated such as a
push button being pressed or a sensor detecting
an object.
What is normally closed Contact??
Introduction
➢This refers to an input device or contact that is
in its closed state when there is no actuation or
signal present.
➢In this case, the circuit is completed unless the
input device is activated, and it opens when the
device is activated.
Logic Functions
Introduction
➢There are many control situations requiring actions to be
initiated when a certain combination of conditions is realized.
AND
➢A situation where an output is not energized unless two,
normally open, switches are both closed. Switch A and switch
B have both to be closed, which thus gives an AND logic
situation.
OR
➢An electrical circuit where an output is energised when
switch A or B, both normally open, are closed. This describes
an OR logic gate.
Logic Functions
OR
➢An electrical circuit where an output is
energised when switch A or B, both normally
open, are closed.
NAND
➢ Suppose we follow an AND gate with a NOT
gate . The consequence of having the NOT gate
is to invert all the outputs from the AND gate
Logic Functions
NOR
➢ Suppose we follow an OR gate by a NOT gate. The
consequence of having the NOT gate is to invert the
outputs of the OR gate.
➢An alternative, which gives exactly the same results, is
to put a NOT gate on each input and then an AND gate for
the resulting inverted inputs.
Exclusive OR (XOR)
➢The OR gate gives an output when either or both of the
inputs are 1. Sometimes there is, however, a need for a
gate that gives an output when either of the inputs is 1 but
not when both are 1
What is Latching??
Introduction
➢There are often situations where it is necessary to hold
an output energized, even when the input ceases. A simple
example of such a situation is a motor which is started by
pressing a push button switch.
➢Though the switch contacts do not remain closed, the
motor is required to continue running until a stop push
button switch is pressed.
➢ The term latch circuit is used for the circuit used to
carry out such an operation.
➢It is a self-maintaining circuit in that, after being
energized, it maintains that state until another input is
received
What are Internal Relays??
Introduction
➢In PLCs there are elements that are used to hold
data, i.e. bits, and behave like relays, being able to
be switched on or off and switch other devices on or
off. Hence the term internal relay.
➢A variety of other terms are often used to describe
these elements, e.g. auxiliary relays, markers, flags,
coils, bit storage.
➢Such internal relays do not exist as real-world
switching devices but are merely bits in the storage
memory that behave in the same way as relays.
What are Internal Relays??
Introduction
➢A subroutine is a sequence of program
instruction that performs a specific task,
packaged as a unit.
➢This unit can be used in multiple places within
a program.
➢Subroutine are used to organize programs and
to implement repetitive operations.
TIMERS
What Is timer in PLC programming??
Introduction
➢A timer is a plc instruction that waits a set amount
of time before turning an output on or off.
➢Timers are commonly used in PLC programming
for tasks that require precise time delays or periodic
actions.
➢A common approach is to consider timers to
behave like relays with coils which when energized
result in the closure or opening of contacts after
some preset time.
Types of Timers
➢ ON DELAY timer
➢OFF DELAY timer
➢PULSE timer
➢ON-OFF DELAY timer
What Is ON DELAY timer??
Introduction
➢These are timers which come on after a
particular time delay.
➢TON is used to denote on-delay.
➢The time duration for which a timer has been
set is termed the preset and is set in multiples of
the time base used.
What is OFF DELAY timer??
Introduction
➢Off-delay timers are on for a fixed period of
time before turning off.
➢TOF is used to denote off-delay.
➢After the preset timer time delay, the timer
contacts, which are normally closed, open and
switch off the output.
➢ Thus the output starts as on and remains on
until the time delay has elapsed.
What is PULSE timer??
Introduction
➢Are used to produce a fixed duration output
from some initiating input.
Programming examples
• Traffic Sequence
COUNTERS
What is a counter in PLC
programming??
Introduction
➢A counter in a PLC instruction that counts
occurrence of an event, usually in the form of
input transitions from off to on and triggers a
specific action when a preset count is reached.
➢Counters are provided as built-in elements in
PLCs and allow the number of occurrences of
input signals to be counted.
Types of Counters
➢DOWN COUNTER
➢UP COUNTER
What Is UP Counter??
0 1 1 0 0 1 1 1
➢ With the shift register it is possible to shift stored bits.
Shift registers require three inputs, one to load data into
the first location of the register, one as the command to
shift data along by one location and one to reset or clear
the register of data.
What is Data Handling??
Introduction
➢Scaling of analog data refers to the process of
converting raw sensor measurements or process
variables into meaningful engineering units or
values that are easily interpretable and usable by the
control system or operator interface.
➢ It involves mapping the raw data range (often
represented in terms of voltage, current, or
resistance) to the corresponding range of physical
quantities (such as temperature, pressure, flow rate,
etc.).
What is Close loop Control system??
What is Close loop Control system??
You can control the temperature of a room by switching on an electric fire. The
fire will heat the room up to the maximum temperature that is possible bearing
in mind the rate at which the fire heats the room and the rate at which is loses
heat.
➢This is termed open loop control in that there is no feedback to the fire to
modify the rate at which it is heating the room. To do this you need a
thermostat which can be set to switch the fire on when the room temperature is
below the required value and switch it off when it goes above it. There is
feedback of temperature information in this system and as such it it termed
closed loop control.
➢Closed loop control of some variable, e.g. the control of the temperature in a
room, is achieved by comparing the actual value for the variable with the
desired set value and then giving an output, such as switching on a heater, to
reduce the difference.
➢The actual value of the variable is compared with the set value and a signal
obtained representing the difference or error. A controller then takes this
difference signal and gives an output to an actuator to give a response to
correct the discrepancy. Such a system is called closedloop control.
PID Controller
Introduction
➢A PID controller, which stands for Proportional-
Integral-Derivative controller, is a feedback control
loop mechanism commonly used in industrial
control systems to regulate processes and systems.
➢It continuously calculates an error value as the
difference between a desired setpoint (target value)
and a measured process variable, then applies a
corrective action to minimize the error
Modes of Controls In PID
Proportional Controller
➢ With proportional control the controller gives an
output to the actuator which is proportional to the
difference between the actual value and the set
value of the variable.
controller output = KP x error
Integral Controller
➢ With integral control the controller output is
proportional to the integral of the error with time.
controller output = KI x integral of error with time
Modes of Controls In PID
Derivative Controller
➢With derivative control the controller output is
proportional to the rate at which the error is
changing, i.e. the slope of the error-time.
controller output = KD x rate of change of error