0% found this document useful (0 votes)
2 views91 pages

Plc Programming

PLC programming involves creating instructions for a programmable logic controller (PLC) to monitor inputs and control outputs. The document covers various aspects of PLCs including hardware architecture, input-output devices, number systems, programming languages, and logic functions. It also discusses timers, counters, and specific programming concepts such as latching and subroutines.

Uploaded by

ronald
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views91 pages

Plc Programming

PLC programming involves creating instructions for a programmable logic controller (PLC) to monitor inputs and control outputs. The document covers various aspects of PLCs including hardware architecture, input-output devices, number systems, programming languages, and logic functions. It also discusses timers, counters, and specific programming concepts such as latching and subroutines.

Uploaded by

ronald
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 91

PLC PROGRAMMING

What is 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

The processor unit or central processing unit (CPU)


➢Is the unit containing the microprocessor and this
interprets the input signals and carries out the control
actions, according to the program stored in its memory,
communicating the decisions as action signals to the
outputs.
The power supply unit
➢Is needed to convert the mains a.c. voltage to the low
d.c. voltage (5 V) necessary for the processor and the
circuits in the input and output interface modules.
PLC Hardware Architecture

The programming device


➢Is used to enter the required program into the
memory of the processor. The program is developed
in the device and then transferred to the memory
unit of the PLC.
The memory unit
➢ Is where the program is stored that is to be used
for the control actions to be exercised by the
microprocessor and data stored from the input for
processing and for the output for outputting.
PLC Hardware Architecture

The input and output sections


➢ Are where the processor receives information
from external devices and communicates
information to external devices. The inputs might
thus be from switches, or other sensors such as
photo-electric cells, temperature sensors, or flow
sensors, etc. The outputs might be to motor
starter coils, solenoid valves, etc.
What is Sourcing and Sinking ??

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??

The international Electrotechnical Commission


(IEC) standard 61131-3 specifies five languages
for PLC Programming:
➢Ladder Diagram(LD)
➢Structured Text(ST)
➢Function Block Diagram(FBD)
➢Instruction List (IL)
➢Sequential Function Chart (SFC)
What is PLC Ladder programming??

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??

➢In using an internal relay, it has to be activated


on one rung of a program and then its output
used to operate switching contacts on another
rung, or rungs, of the program.
➢To distinguish internal relay outputs from
external relay outputs, they are given different
types of addresses. Different manufacturers tend
to use different terms for internal relays and
different ways of expressing their addresses.
FLIPFLOPS
SET AND RESET

➢Another function which is often available is the ability


to set and reset an internal relay.
➢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 term flip-flop is often used.
➢The SET and RESET coil symbols are often combined
into a single box symbol.
➢The term memory box is used by them for the
SET/RESET box, the box shown is termed a SR or reset
priority memory function in that reset has priority.
PROGRAM CONTROL FLOW
JUMP and CALL

A function often provided with PLCs is the


conditional jump. We can describe this as:

IF (some condition occurs)


THEN perform some instructions
ELSE perform some other instructions.
What is a Subroutine??

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??

Up-counters count from zero up to the preset


value, i.e. events are added until the number
reaches the preset value. When the counter
reaches the set value, its contacts change state
What is DOWN Counter??

➢Down-counters count down from the preset


value to zero, i.e. events are subtracted from
the set value. When the counter reaches the
zero value, its contacts change state
What is a shift register in PLC
programming??
➢ A shift Register is a group of memory locations that are
manipulated in the way that the data is moved or
“shifted” through each location upon triggering
condition.
➢ A register is a number of internal relays grouped
together, normally 8, 16 or 32.

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??

➢Data handling involves managing and


manipulating data within the PLC.
➢It involves tasks such as moving data from one
location to another, converting data types and
programming arithmetic operations.
Data Movement

➢Data transfers might be to move a preset value


to a timer or counter, or a time or counter value
to some register for storage, or data from an
input to a register or a register to output.
➢A data transfer from the accumulated value in
a counter to a register would have a source
address of the form C5:18.ACC and a
destination address of the form N7:0.
Data Comparison
The data comparison instruction gets the PLC to
compare two data values.
PLCs generally can make comparisons for:
➢ less than (< or LT or LES)
➢ equal to (= or = = or EQ or EQU)
➢ less than or equal to (≤ or <= or LE or LEQ)
➢ greater than (> or GT or GRT)
➢ greater than or equal to (≥ or >= or GE or GEQ)
➢ not equal to (≠ or <> or NE or NEQ).
Arithmetic Operations
• Some PLCs are equipped to carry out just the
arithmetic operations of addition and
subtraction, others the four basic arithmetic
operations of addition, subtraction,
multiplication and division, while others can
carry out these and various other functions
such as the exponential.
Types of analog Signals

Voltage Analog I/O


➢Voltage analog signal transmission is reliable
only at short distances. The longer the cable, the
more significant the voltage drop due to the
increased resistance of the wiring.
➢The most common operating range of voltage
I/O is 0v to 10v, so change of even a fraction of
volt can cause serious signal inaccuracy.
Types of analog Signals

Current Analog I/O


➢Current signal transmission does not suffer from
degradation at longer distances, being a constant current
output that adjusts its own output voltage as the
resistances of the wire length changes.
➢The standard operating range of a current signal is 4mA
to 20mA. The bottom limit at 4mAmeans there is still
output from the sensor even if the physical quantity is at
its lowest value. In contrast, the bottom limit of a voltage
signal is 0v, and there is no absolute certainty that the 0v
is caused by a sensor reading or a broken connection.
What is Scaling of Analog Data

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

You might also like