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

PLC Programming Languages

Uploaded by

Kent
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

PLC Programming Languages

Uploaded by

Kent
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 50

LADDER LOGIC AND PLC

PROGRAMMING LANGUAGES
ICE BREAKER 🧊
LADDER LOGIC AND PLC
PROGRAMMING LANGUAGES
PLC programming languages (IEC 61131-3)
PLCs have evolved in different ways depending on the
manufacturer. Programming software and methods of
handling data can differ immensely from platform to
platform. Because of this, the International
Electrotechnical Commission (IEC) created an open
standard in 1982 that defines what equipment, software,
communications, safety and other aspects of
programmable controllers should look like. After the
national committees had reviewed the first draft, they
decided it was too complex to treat as one document. They
originally split it into five sections:
5 types of PLC Programming
Languages
PLC Programming Languages

PLC programming languages

Textual languages Graphical language

Instruction Structured Ladder Functional Sequential


list text diagram block diagram function chart

Standard IEC 61131 languages associated with PLC programming


PLC Programming Languages: Ladder diagram

• The Ladder diagram language is the most commonly used PLC


language and is designed to mimic relay logic
PB1 CR12 CR SOL
(PB1) (CR1) (CR2) SOL

LS1 A B D Y

C
(LS1)

Hardwired relay control circuit Equivalent ladder diagram


(LD) program
PLC Programming Languages: Ladder diagram
Ladder Logic, also known as Ladder Diagram, is a
graphical PLC programming language based on relay
logic’s circuit diagrams. Ladder Logic consists of two
parallel bars connected by a series of rungs, resembling a
ladder in appearance (hence, the name). There are
contacts and coils on these rungs, which symbolize
inputs (such as a sensor value) and outputs (like a motor
run command) respectively.
PLC Programming Languages: Function Block Diagram
• The Functional block diagram programming uses instructions that
are programmed as blocks wired together on screen to accomplish
certain functions. Typical types of function blocks include logic,
timers, and countersFunctional block Caution
Ladder logic diagram equivalent Sensor 1 Sensor 2 PL 1

AND_BOOL
A B
A
Ladder diagram
B

A BAND_01
OR_BOOL
BAND
A
B Boolean And Caution
B 0
Out PL 1
0
AND_BOOL Sensor 1 In1
A B
A 0
Sensor 2 In2
B
Function block diagram

Function block diagram equivalents to PLC ladder and equivalent function


ladder logic contacts block diagram
PLC Programming Languages: Function Block Diagram

The FBD language is relatively simple, though it does


require some training to use. It’s a great choice for
safety PLCs, PID loops, and when you need to do
encapsulation, reuse code frequently, hide or preserve
data, or do analog input filtering.
PLC Programming Languages: Sequential Function Chart

• Sequential function
Initial
chart programming Step 1
Action

language is similar to a Wire


flowchart loop Transition
Wire
• SFC programming is
Step 2 Action
designed to
accommodate the
programming of more Tr ansition

advanced processes
Step 3 Action

Major elements of a sequential function


chart program Transition

Stop
PLC Programming Languages: Instruction List

Instruction List (IL) is a low level textual language


used in PLC system, which has a structure similar to a
simple machine assembler.
A instructions list provides programs with each
instruction on a new line as a sequence of instructions.
Each instruction is made up of an operator followed by
one or more operands, that is, the operator’s subjects.
Mnemonic codes for instruction list:
PLC Programming Languages: Structured Text

• Structured text is a high level text language primarily used to


implement complex procedures that cannot be easily expressed with
graphical languages

Sensor 1 Sensor 2 SOL 1

Sensor 3 Sensor 4 Sensor 5

PLC ladder and


equivalent IF Sensor_1 AND Sensor_2 THEN
SOL_1 := 1;
structured text
ELSEIF Sensor_3 AND Sensor_4 AND NOT Sensor_5 THEN
program SOL_1 := 1;
END_IF;
PLC Programming Languages: Structured Text

Structured Text (ST) is a high-level PLC programming


language. It’s a textual language, with syntax
comparable to C or C++, so those who have studied
these types of computer programming languages will
have an easier time with it. In ST, statements (such as
IF, for example) are used to perform functions.
LADDER LOGIC
What is ladder logic diagram?

Ladder Logic is one of the top 5 most popular types


of PLC programming languages used in
manufacturing environments. Before Programmable
Logic Controllers, manufacturing plants employed
relay-based circuitry to energize different loads based
on how the relays were wired together. The circuit
patterns used for these drawings are known as ladder
diagrams. Relays were costly, required constant
maintenance, and could not be easily reconfigured.
As PLCs took over this process, it was essential to
keep a similarity of the old system; thus, ladder logic
was created as the first PLC programming language.
What is ladder logic diagram?
• Ladder Logic is labeled as such because the software is laid out
in the shape of a ladder. On the left side, ladder logic
instructions are set as conditions, while the ones on the right
side are instructions that are triggered if the conditions are met.
Each rung of the ladder spans from left to right and is executed
from top to bottom by the PLC.

• As mentioned above, ladder logic is extremely popular


among PLC programmers. It’s easy to learn, mimics
electrical circuits, and is easy to troubleshoot once
deployed.
Ladder diagram Symbols

Ladder diagrams symbols are the basic building


blocks of a Ladder Circuit Diagram and these
symbols are used in the PLC Programming. Here
are some Symbols which are given below with
their names and we also provide a symbol table,
there you can find all ladder symbols with their
names and their description
Ladder Logic Structure

- Vertical Lines (Rungs): Each rung represents a specific function or


action within the control system.

- Horizontal Lines (Rails): Rails at the top and bottom of the


diagram supply power and ground, respectively.

- Contacts: Symbolize input devices such as sensors, switches, or


pushbuttons.

- Coils: Represent output devices such as relays, motors, or solenoids.


- Branches: Connection points between different elements of the
ladder logic.
ladder Logic diagram
Logic Operations

- AND Gate: Achieved by placing multiple contacts in series on the


same rung.

- OR Gate: Created by placing multiple contacts in parallel on the same


rung.

- NOT Gate: Implemented by using normally closed contacts.


Ladder Logic Basics

Just like computers, PLCs operate with binary signals; each


one can be set to zero or one. In the programming world, this
data type is called a boolean. A boolean takes a single bit in
the memory, can be set to 0 or 1, and is used in most basic
PLC instructions.
The PLC executes the program loaded into it one rung at a
time. As the PLC begins to process the rung, it reads the
instructions on the left and determines if the Logic on that side
of the rung is set to TRUE. The Logic evaluates to TRUE when
a hypothetical current is able to pass through the instructions.
Each instruction has a set of conditions that make it TRUE or
FALSE.
The three most fundamental ladder
logic PLC programming instructions
• Examine If Closed [XIC] This input instruction will look at
the specified boolean bit and evaluate the condition to
TRUE when the bit is set to 1 (or HIGH). While the bit is
set to 0 (or LOW), the instruction will evaluate to FALSE.

• Examine If Opened [XIO]


When the bit is to 0/Low, this input command will assess the
condition to True by checking out the provided boolean bit. The
command will evaluate the condition to False if the bit is set to
1/High. If the condition is True, the rest of the ladder logic rung will
be
The three most fundamental ladder logic
PLC programming instructions

• Output Energize [OTE] - This output instruction will set the


specified bit to 1 (or HIGH) if the input instruction conditions
are TRUE. If they’re FALSE, the Output Energize instruction
will set the bit to 0 (or LOW).
Basic Ladder Logic Rung Analysis

Step 1 - The hypothetical current starts moving from left to


right.
Step 2 - When the hypothetical current encounters and XIC
Instruction, it checks if the condition is TRUE or FALSE. If
the XIC is False, the PLC aborts this rung.
Step 3 - The hypothetical current goes to the next
instruction. Repeats Step 2 until the rung is completed.
Step 4 - The PLC moves to the rung below.
Ladder Logic PLC Programming XIC = OFF Example

In the example above, the XIC Instruction is


tied to the bit “Condition1”. Since the bit is OFF
(or 0), the hypothetical current stops at the
instruction.
Ladder Logic PLC Programming XIC = ON Example

In the example above, the XIC Instruction is tied to


the bit “Condition1”. Since the bit is ON (or 1), the
hypothetical current is allowed to pass through and
goes to the OTE Instruction. The OTE Instruction
sets the “Energize1” bit to HIGH (or 1).
Ladder Logic Structure | Circuit
Branches
Circuit branches create a way for the current to
pass through a different path as the rung
executes. The instructions are executed in the
same way, but now we need to analyze different
paths the current may take.
Ladder Logic PLC Programming Circuit Branch Example

The rung above has the primary rung and a


branch that jumps the first two conditions with a
3rd one.
Ladder Logic PLC Programming Circuit Branch
Advanced Example
Ladder Logic RSLogix 5000 Components
Ladder Logic RSLogix 5000 Components
1 - Ladder Logic Inputs
As we discussed above, the ladder logic instructions on the left side are
called inputs. Their condition is evaluated on a true or false basis. If the
evaluation is concluded with a TRUE, the output of the ladder logic rung is
executed. If it's evaluated to FALSE, the PLC goes to the following rung.

2 - Ladder Logic Rung Comments


Every programming language allows the user to add documentation to
their software. In ladder logic, this opportunity comes with every rung,
instruction and data structure. By adding a comment above the rung,
you're making it easier for the person after you to understand your train of
thought and troubleshoot the logic as needed. Furthermore, the comments
may be used to indicate a change or temporary fix of a certain problem
that was encountered by a PLC programmer.
Ladder Logic RSLogix 5000 Components
Ladder Logic RSLogix 5000 Components
3 - Ladder Logic Outputs
There are many instructions that will execute on the output side. In the example
we covered above, our focus was on the OTE Instruction. However, the
screenshot above also includes TON or Timer On Delay Instructions. As you gain
experience as a PLC programmer, you'll encounter and master additional
instructions.

4 - Ladder Logic Rails


Each rung of ladder logic lies between the two side rails (just like a regular
ladder). These rails are what energizes each rung as they are executed. In the
screenshot above, you can see two rails within the RSLogix / Studio 5000
environment. The rails remain grayed out until the main routine calls the
program. In the screenshot, the rails are green, which means that this specific
logic is being executed.
Ladder Logic RSLogix 5000 Components
Ladder Logic RSLogix 5000 Components
5 - Tag Names
Each instruction will be tied to one or more tags. Each tag
requires a data structure element as well as a name or label.
In the examples we looked at above, tags were labeled as
"Condition1", "Condition2", "Condition3", etc. In
production circumstances, tags would typically reflect the
physical element they control or a set of PLC based tags.
For example, tags that control motors may have the label of
MTR1_Start, MTR2_Stop, MTR2_Status, etc. Furthermore,
tags may also have a description that allows the user to give
the tag a text-based description.
Ladder Logic Programming in RSLogix 5000
Basics
Examine If Open [XIO]
The XIO will energize the output if the exact opposite of the XIC is
true. In other words, the output will energize if the boolean value is
FALSE.

Output Energize [OTE]

The OTE is an output instruction and will set a boolean to TRUE if all the
preceding conditions are TRUE leading to it. The OTE would also set the
boolean to FALSE should there be no TRUE path of inputs leading to it. The
Output Energize instruction is used to set digital outputs on field devices such
as valves, motor contactors, relays, solenoids and more.
Ladder Logic Programming in RSLogix
5000 Basics
Examine If Closed [XIC]
We've looked at these instructions at the start of the tutorial. It's the
essential input check you can make on your data. In short, if the
boolean assigned to the XIC is TRUE, the output will go through. If it's
FALSE, it won't. Although it may seem that this would have limited
utility, many of the advanced constructs within PLCs have a boolean
state. For example, a Variable Frequency Drive may have an array of
boolean structures that are tied to different faults. Therefore, you may
create the same number of XIC instructions to verify which failure is
present on the drive
Ladder Logic Programming in RSLogix 5000
Basics
Timer ON [TON]
Timers are a basic data-structure of PLCs. They allow the user to create
a condition that will start an internal timer and execute an action based
on what the user has programmed.

Timer TON Instruction in RSLogix 5000 Ladder Logic Example


Limit Switches
Limit switches are electromechanical devices that are
used to detect the presence or absence of an object.
They are commonly used in industrial automation to
control machines and equipment. Limit switches are
typically connected to a PLC (programmable logic
controller), which is a computer that controls the
machine or equipment.
examples of how limit switches are
used with PLC ladder logic:
• Conveyor belt control: A limit switch can be used to
detect when a product reaches the end of a conveyor
belt. The PLC can then use this information to stop the
conveyor belt or to divert the product to another
conveyor belt.
• Machine safety: Limit switches can be used to
protect workers from injury. For example, a limit
switch can be used to stop a machine if a worker's
hand enters a dangerous area.
examples of how limit switches are used
with PLC ladder logic:
• Product counting: Limit switches can be used to count
products as they move along a conveyor belt. The PLC
can then use this information to track inventory or to
control production.
• Machine sequencing: Limit switches can be used to
sequence the operation of a machine. For example, a
limit switch can be used to start a pump when a tank
reaches a certain level, or to stop a conveyor belt
when a product reaches a certain location.
Limit Switches
Limit switches are a versatile and reliable way to control
machines and equipment. By using limit switches with PLC
ladder logic, engineers can create complex and
sophisticated control systems.

Limit Switch | Examples of common industrial limit switches that are wired to a PLC
and programmed using Ladder Logic
QUIZ TIME!
REFERENCES:
https://www.controleng.com/articles/plc-programmin
g-language-fundamentals-for-improved-operations-m
aintenance/

https://www.solisplc.com/tutorials/how-to-read-ladde
r-logic
THANK YOU!!!

You might also like