0% found this document useful (0 votes)
14 views

MC&PLC Module-4

The document provides an overview of PLC programming, detailing various programming languages such as Instruction List, Structured Text, Ladder Diagrams, Function Block Diagrams, and Sequential Function Charts. It emphasizes the advantages of graphical representations like Ladder Logic for their simplicity and ease of understanding. Additionally, it outlines key PLC instructions including bit, timer/counter, logical, compare, move, and math instructions.

Uploaded by

shas49331
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)
14 views

MC&PLC Module-4

The document provides an overview of PLC programming, detailing various programming languages such as Instruction List, Structured Text, Ladder Diagrams, Function Block Diagrams, and Sequential Function Charts. It emphasizes the advantages of graphical representations like Ladder Logic for their simplicity and ease of understanding. Additionally, it outlines key PLC instructions including bit, timer/counter, logical, compare, move, and math instructions.

Uploaded by

shas49331
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/ 97

PLC Programming

Instructions
PLC Programming
• When using a PLC, it’s important to design and
implement concepts depending on particular
case.
• A PLC program consists of a set of instructions
either in textual or graphical form, which
represents the logic that governs the process the
PLC is controlling.
PLC Programming
• Classifications of PLC programming languages
I. Textual Language
i. Instruction list
ii. Structured text
II. Graphical Form
i. Ladder Diagrams (LD) (i.e. Ladder Logic)
ii. Function Block Diagram (FBD)
iii. Sequential Function Chart (SFC)
Due to the simple and convenient features, graphical representation
are much preferred to textual languages.
PLC Programming
PLC Programming
I. (i) Instruction list
• Instruction List (IL) is another type of PLC programming
language.

• It uses the mnemonic code. So the syntax of this programming


language is easy to remember.

• AB PLC (Allen Bradley) brand works on the Instruction List (IL)


programming language.
PLC Programming
I. (ii) Structured text
• The “ST” and “STX” are also other abbreviations used for
Structured Text PLC language.

• It uses high-level programming language syntax.

• The syntax of ST is similar to the syntax of a high-level


programming language with loops, variables, conditions, and
operators.
PLC Programming
II. (i) Ladder Diagrams (LD) (i.e. Ladder Logic)
• Ladder logic is the simplest form of PLC programming. It is
also known as “relay logic”.
• The relay contacts used in relay controlled systems are
represented using ladder logic.
• LD is a visual programming language, so it is easier to learn
than other PLC languages.
• With LD, we can program by combining symbols to perform
specific actions.
PLC Programming
II. (i) Ladder Diagrams (LD) (i.e. Ladder Logic)
• LD is one of the most popular types of PLC programming
languages because it is known for being intuitive, having good
debugging tools and good representation for discrete logic.
PLC Programming
II. (ii) Function Block Diagram (FBD)
• Functional Block Diagram (FBD) is a simple and graphical
method to program multiple functions in PLC.
• A function block is a program instruction unit which, when
executed, yields one or more output values.
• It is represented by a block as shown below. It is represented
as a rectangular block with inputs entering on left and output
lines leaving at the right. It gives a relation between the state of
input and output
PLC Programming
II. (ii) Function Block Diagram (FBD)
• It is represented by a block as shown below.
• It is represented as a rectangular block with inputs entering
on left and output lines leaving at the right.
• It gives a relation between the state of input and output
PLC Programming
II. (ii) Function Block Diagram (FBD)
• The advantage of using FBD is that any number of inputs and
outputs can be used on the functional block.
• When using multiple input and output, you can connect the output
of one function block to the input of another.
PLC Programming
II. (iii) Sequential Function Chart (SFC)
• Sequential function charts (SFC) is a PLC programming language
that allows the programmer to code in chronological order.
• The specific code is a sequence of actions that are separate
programming objects. Like the ladder diagram PLC language, the
SFC language is graphically oriented.
• SFC has the benefit of being relatively easy to understand because
you can visualize what is happening and when it is happening in
the procedure of the code.
• Only the active parts of the SFC code are executed, which makes it
easier to troubleshoot and change the code if problems occur.
Ladder diagram (logic) programming

• The most widely used programming language for a PLC is the


ladder logic, which is invented to replace the hardwired relay
control systems.
• It is the simple and widespread adopted language, even a non
programmer with electrical background able to understand
and troubleshoot the program.
• It is a graphical type of language consisting of several logic
functions.
Ladder diagram (logic) programming

• The ladder logic truth table for a normally open (NO) contact
which denotes event ‘A’ is shown below
Ladder diagram (logic) programming

• We can write out the logic expression in the above as rung


as IF A THEN Y.
• Because PLC input A follows the binary concept it has two possible
states, TRUE or FALSE.
• Therefore it results in two possible logic iterations:
• IF A = FALSE THEN Y = FALSE
• IF A = TRUE THEN Y = TRUE
Ladder diagram (logic) programming
• The ladder program above works just fine. But the output will
only be active as long as the input is active.

Ø You will have to hold your finger on the button to keep the
output activated. It would not be very convenient for the
operator to hold down the button all the time.

q We need a way to keep the output active, even though the


operator releases the pushbutton.
Ladder diagram (logic) programming
• Output Latch
Ladder diagram (logic) programming
• How to switch OFF the motor??

• This is not good practice!


Ladder diagram (logic) programming
Ladder diagram (logic) programming

• Consider a hard-wired diagram for a pump control.


Ladder diagram (logic) programming

• The equivalent PLC program for pump control is given below


which is similar to the hardwired logic
Ladder diagram (logic) programming

• The horizontal lines are called rungs.

• The vertical lines are called rails.

• Every rung forms the electrical


connectivity between Positive rail
(P) and Negative rail (N). This
allows the current to flow
between input and output devices.
Ladder diagram (logic) programming
PROGRAMMING
Normally Open Normally Closed
(NO) (NC)

ØPower flows through these contacts when they are closed.


ØThe normally open (NO) is true when the input or output
status bit controlling the contact is 1.
ØThe normally closed (NC) is true when the input or output
status bit controlling the contact is 0.
Coils

ØCoils represent relays that are energized when power


flows to them.
ØWhen a coil is energized it causes a corresponding output
to turn on by changing the state of the status bit controlling
the output to 1. That same output status bit maybe used to
control normally open or normally closed contact anywhere
in the program.
Boxes

ØBoxes represent various instructions or functions that are


executed when power flows to the box. Some of these
functions are timers, counters and math operations.
Ladder diagram (logic) programming
• Let’s discuss technically.
• Consider the below ladder diagram.
Examine if Closed
• The first instruction here is called examine if closed.

• This is a conditional instruction

• As indicated, there is a name above the instruction symbol – I0.0.

• This is the address of the specific bit, this instruction will examine.
In this case, a digital input. It could also just be an internal memory
bit or even an output.
• Examine if closed is also known as normally
open. It works basically the same way as a
normally open contact in en electrical circuit.
Output Coil
• The instruction itself even has a place in the PLC memory. What the
PLC will put there is the result of the instruction. To see what the
PLC uses that result for, we have to look at the next instruction:

• An output coil is used to turn a bit on and off.


NOTE
• As you can see, the symbol is placed in the right side of the
rung. This means, that all the instructions that come before
(in the same rung) act as a condition for that instruction. In
our example that will be the result of the examine if closed
instruction.
See how it works
SCAN
ØA PLC resolves the logic of a ladder diagram (program) rung by
rung, from the top to the bottom. Usually, all the outputs are
updated based on the status of the internal registers. Then the
input states are checked and the corresponding input registers
are updated. Only after the I/Os have been resolved, is the
program then executed. This process is run in a endless cycle.
The time it takes to finish one cycle is called the scan time.
SCAN
Output
Input
begin

Idle

Scan cycle

Resolve
logic
PLC Instructions
• Bit Instruction
• Timer/Counter Instruction
• Logical Instruction
• Compare Instruction
• Move Instruction
• Math Instruction
• Program control Instruction
Bit Instruction
Mnemonic Name Symbol Description

XIC Examine Examines a bit for an On (set,


If Closed high) condition.
XIO Examine Examines a bit for an Off (cleared,
If Open low) condition.
OTE Output When rung conditions are true,
Energize the OTE will either set or clear the
data bit.
OTL Output When enabled, the instruction
Latch signals to the controller to turn on
the addressed bit. The bit remains
on, regardless of the rung
condition.
Bit Instruction
Mnemonic Name Symbol Description

OTU Output When enabled, it clears (unlatches)


Unlatch the data bit. The bit remains Off,
regardless of rung condition.

ONS One Shot Enable/disable outputs for one


scan when rung is true. The status
of the storage bit determines
whether this instruction enables or
disables the rest of the rung.
OSR One Shot This instruction is a retentive input
Rising instruction that triggers an event to
occur once. It either sets or clears
the output bit, depending on the
storage bit status
Bit Instruction
Mnemonic Name Symbol Description

OSR One Shot This instruction is a retentive


Rising input instruction that triggers an
event to occur once. It either sets
or clears the output bit,
depending on the storage bit
status
OSF One Shot This instruction either sets or
Falling clears the output bit, depending
on the storage bit’s status.
Timer/Counter Instruction
Mnemonic Name Symbol Description

TON Timer On A non-retentive timer that


Delay accumulates time when the
instruction is enabled. The
accumulated value is reset when
rung conditions go false.

TOF Timer Off A non-retentive timer that


Delay accumulates time when the rung
makes a true-to-false transition.
Timer/Counter Instruction
Mnemonic Name Symbol Description

RTO Retentive A retentive timer that accumulates


Timer On time when the instruction is
enabled. Retains its accumulated
value when rung conditions
become false.

TON Count Up An instruction that counts false-to-


true rung transitions. It counts
upward and the accumulated value
is incremented by one count on
each of these transitions.
Time/Counter Instruction
Mnemonic Name Symbol Description

TOF Count This instruction counts downward


Down on each false-to-true rung
transition. The accumulated value
is decremented by one count on
each of these transitions.

RTO Retentive A retentive timer that accumulates


Timer On time when the instruction is
enabled. Retains its accumulated
value when rung conditions
become false.
Time/Counter Instruction
Mnemonic Name Symbol Description

CTU Count Up An instruction that counts false-to-


true rung transitions. It counts
upward and the accumulated value
is incremented by one count on
each of these transitions.

CTD Count This instruction counts downward


Down on each false-to-true rung
transition. The accumulated value
is decremented by one count on
each of these transitions.
Time/Counter Instruction
Mnemonic Name Symbol Description

RES Reset This instruction is used to reset a


timer, counter or control structure.
The accumulated value of these
instructions are cleared when the
RES instruction is enabled.
Logical Instruction
Mnemonic Name Symbol Description
AND Bitwise Performs a logical AND operation
AND by using the bits in Source A and
Source B and placing the result in
the Destination.

OR Bitwise Performs a logical OR operation by


OR using the bits in Source A and
Source B and placing the result in
the Destination.
Logical Instruction
Mnemonic Name Symbol Description
XOR Bitwise Performs a bitwise XOR operation
Exclusiv using the bits in Source A and
e OR Source B and stores the result in
the Destination.

NOT Bitwise Executes a bitwise NOT operation


NOT by using the bits in the Source and
placing the result in the
Destination
Compare Instruction
Mnemonic Name Symbol Description

EQU Equal This instruction is used to test


whether two values are equal. If
Source A is equal to Source B, the
instruction is logically true.
GEQ Greater Determines whether Source A is
Than or greater than or equal to Source B.
Equal To If the value at Source A is greater
than or equal to the value at
Source B, then the instruction is
true.
Compare Instruction
Mnemonic Name Symbol Description

GRT Greater This instruction is used to test


Than whether one value (Source A) is
greater than another value
(Source B).

LEQ Less Determines whether one value


Than or (Source A) is less than or equal to
Equal To another (Source B).

LES Less This instruction determines


Than whether Source A is less than
Source B.
Compare Instruction
Mnemonic Name Symbol Description

LIM Limit This instruction is used to test for


values within the range of the Low
Limit to the High Limit.

MEQ Mask Passes the Source and Compare


Equal To values through a Mask and
compares the results.
Compare Instruction
Mnemonic Name Symbol Description

NEQ Not This instruction tests whether


Equal To Source A is not equal to Source B.
Move Instruction
Mnemonic Name Symbol Description
MOV Move Copies the Source (which remains
unchanged) to the Destination.

MVM Masked Copies the Source to a Destination


Move and allows segments of the data to
be masked.

CLR Clear Clears all the bits of the


Destination.
Move Instruction
Mnemonic Name Symbol Description
DTR Data Passes the Source value through a
Transiti Mask and compares the result
onal with the Reference value.

SWPB Swap Rearranges the bytes of a tag and


Byte stores the bytes in the new order.
Instructi
on
Move Instruction
Mnemonic Name Symbol Description
SWP Swap Swaps the lower and higher bytes
Byte of a specified number of words.
Instructi
on
BTD Bit Field Copies the specified bits from the
Distribu Source, shifts the bits to the
te appropriate position, and writes
the bits into the Destination.
Math Instruction
Mnemonic Name Symbol Description
ADD Add Adds Source A to Source B and
stores the result in the Destination.

SUB Subtract Subtracts Source B from Source A


and places the result in the
Destination.
Math Instruction
Mnemonic Name Symbol Description
MUL Multiply Multiplies Source A by Source B
and stores the result in the
destination.

DIV Divide Divides Source A by Source B and


places the result in the
Destination.
Math Instruction
Mnemonic Name Symbol Description
MOD Modulo Divides Source A by Source B and
stores the remainder in the
Destination.

SQR Square Calculates the square root of the


Root source and places the integer
result in the Destination.
Math Instruction
Mnemonic Name Symbol Description
NEG Negate Changes the sign (+, -) of the
Source and stores the result in the
Destination.

ABS Absolute Takes the absolute value of the


Source and places the result in the
Destination.
Program control Instruction
Mnemonic Name Symbol Description
JSR Jump to This instruction jumps execution
Subroutine to a specific routine and initiates
the execution of this routine,
called a subroutine.
SBR Subroutine Stores recurring sections of
program logic.

RET Return Used to return to the instruction


following the a JSR operation.

JMP Jump to Skips sections of ladder logic.


Label
Program control Instruction
Mnemonic Name Symbol Description
LBL Label Target of the JMP instruction with
the same label name.
MCR Master Used in pairs to create a program
Cont. Res. zone that can disable all rungs
between the MCR instructions.
AFI Always Disables all instructions on a rung.
False
NOP No This instruction functions as a
Operation placeholder.
Program control Instruction
Mnemonic Name Symbol Description
TND Temporary When enabled, it lets the
End controller execute logic only up to
this instruction.
IOT Immediate This instruction immediately
Output updates the specified output data.
Normally Open Contact

Operation:

• If the condition is TRUE then the expression is CLOSED.


Common Uses:
• Start Push buttons
• Selector switches
• Digital instrumentation
• Internal programming
Normally Closed Contact

Operation:

• If the condition is TRUE then the contact is OPEN.

Common uses:

• Stop Push buttons

• Fail safe instrumentation.

• Motor Thermal Overloads

• Internal programming
Output
Operation:

• If the input condition is TRUE then the output is ON.

Common uses:

• Motor Contactors

• Actuators

• Indication lamps

• Warning sirens

• Internal programming
Timer Delay On
Operation:

• If the input condition is TRUE then the timer begins.

• When the pre-set time has been reached the output turns ON.

• If the input condition goes FALSE, at any stage, the timer stops and

the output turns OFF as well.


Timer Delay On
Common uses:

• Time delay for Sirens

• Star/Delta Motor Starters

• Sequence start delays

• De-bounce time delay to fix digital instrumentation flicker


Timer Delay Off
Operation:
• If the input condition is TRUE then the output turns ON.
• Then if the input condition goes FALSE the timer begins.
• When the pre-set time has been reached the output turns OFF.
• If the input condition goes TRUE, at any stage, the timer stops and the
output turns ON as well.

Common Uses:
• Run on time Delay
Interpret the control logic of following
ladder program
Interpretation
• L1 is true when Start or L1 contact is true.
• L2 is true when L1 or L2 contact is true.
Name the elements a, b, c and d shown in the ladder
diagram and specify the condition to make c true
• a – Examine if closed (XIC) or Normally open contact

• b – Examine if open (XIO) or Normally closed contact

• c – Output

• d - Rung
Three switches are connected to the inputs of the PLC.
A lamp is connected at the output. Predict the output
o f t he fo l lo wi ng l a d de r p ro g ra m fo r t he gi ve n
conditions
ON
OFF
OFF OFF
ON
PLC Programming
Ladder diagram (logic) programming

• The most widely used programming language for a PLC is the


ladder logic, which is invented to replace the hardwired relay
control systems.
• It is the simple and widespread adopted language, even a non
programmer with electrical background able to understand
and troubleshoot the program.
• It is a graphical type of language consisting of several logic
functions.
Ladder diagram (logic) programming

• The ladder logic truth table for a normally open (NO) contact
which denotes event ‘A’ is shown below
Ladder diagram (logic) programming

• We can write out the logic expression in the above as rung


as IF A THEN Y.
• Because PLC input A follows the binary concept it has two possible
states, TRUE or FALSE.
• Therefore it results in two possible logic iterations:
• IF A = FALSE THEN Y = FALSE
• IF A = TRUE THEN Y = TRUE
Ladder Logic Diagram
• There are seven basic parts of a ladder diagram that are
essential to know how to draw ladder logic diagrams.

• Rails – There are two rails in a ladder diagram which are


drawn as vertical lines running down the far most ends of the
page. If they were in a relay logic circuit they would represent
the active and zero volt connections of the power supply
where the power flow goes from the left hand side to the
right hand side.
Ladder Logic Diagram
• Rungs – The rungs are drawn as horizontal lines and connect
the rails to the logic expressions. If they were in a relay logic
circuit they would represent the wires that connect the power
supply to the switching and relay components.

• Inputs – The inputs are external control actions such as a push


button being pressed or a limit switch being triggered. The
inputs are actually hardwired to the PLC terminals and
represented in the ladder diagram by a normally open (NO) or
normally closed (NC) contact symbol.
Ladder Logic Diagram
• Outputs – The outputs are external devices that being are
turned on and off such as an electric motor or a solenoid
valve. The outputs are also hardwired to the PLC terminals
and are represented in the ladder diagram by a relay coil
symbol.

• Logic Expressions – The logic expressions are used in


combination with the inputs and outputs to formulate the
desired control operations.
Ladder Logic Diagram
• Address Notation & Tag Names – The address notation
describes the input, output and logic expression memory
addressing structure of the PLC. The tag names are the
descriptions allocated to the addresses.
Ladder Logic Diagram
• Comments – Last but by not least, the comments are an
extremely important part of a ladder diagram. Comments are
displayed at the start of each rung and are used to describe
the logical expressions and control operations that the rung,
or groups of rungs, are executing. Understanding ladder
diagrams is made a lot easier by using comments.
Ladder Logic Diagram
Rules for PLC Ladder Diagram
Programming
1. Inputs can be used in Series as well as Parallel to
form a connection
2. Outputs (or coil) can be used only in Parallel
3. One Input can be used in multiple times in one
program
4. One Output cannot be used multiple times in one
program, except in Set/Reset and Latch/ Unlatch
functions
5. Input Address cannot be used as an Output
Address
6. Outputs Address can be used as Inputs Address
Ladder diagram (logic) programming

• Consider a hard-wired diagram for a pump control.


Ladder diagram (logic) programming

• The equivalent PLC program for pump control is given below


which is similar to the hardwired logic
Ladder diagram (logic) programming

• The horizontal lines are called rungs.

• The vertical lines are called rails.

• Every rung forms the electrical


connectivity between Positive rail
(P) and Negative rail (N). This
allows the current to flow
between input and output devices.
Ladder diagram (logic) programming
Implementing logic gates using PLC bit
instructions
Implementing logic gates using PLC bit
instructions
Implementing logic gates using PLC bit
instructions
Implementing logic gates using PLC bit
instructions
Ladder program for staircase wiring
staircase wiring-1

staircase wiring-2
Induction motor controls as in direct
on Line (DOL) starter
ON Timer circuit
Star-Delta starter
• Inputs
ØI:0/0 – Overload
ØI:0/1 - Stop
ØI:0/2 - Start
• Outputs
ØO:0/0 – Mains
ØO:0/1 - Delta
ØO:0/2 - Star
Star-Delta starter
• At the starting, mains contactor and star contactor are closed.

• After 5 seconds, star contactor is opened.

• After 0.3 seconds, delta contactor is closed.


Star-Delta starter

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy