0% found this document useful (0 votes)
6 views83 pages

CEI331 PLC Programming

The document provides an overview of Programmable Logic Controllers (PLCs), detailing their components, working principles, programming languages, and applications in industrial automation. It explains the key characteristics of PLCs, such as programmability and real-time control, and describes the scan cycle involved in their operation. Additionally, it outlines various PLC programming languages like Ladder Logic, Function Block Diagram, and Structured Text, each suited for different control tasks.

Uploaded by

Gowtham
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)
6 views83 pages

CEI331 PLC Programming

The document provides an overview of Programmable Logic Controllers (PLCs), detailing their components, working principles, programming languages, and applications in industrial automation. It explains the key characteristics of PLCs, such as programmability and real-time control, and describes the scan cycle involved in their operation. Additionally, it outlines various PLC programming languages like Ladder Logic, Function Block Diagram, and Structured Text, each suited for different control tasks.

Uploaded by

Gowtham
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

lOMoARcPSD|65740826

PLC Notes - Study well

4G/5G Communication Network (Anna University)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

CEI331 PLC Programming


Unit –I Introduction
Programmable Logic Controller (PLC)

1.1 Introduction to PLC Programming

A Programmable Logic Controller (PLC) is a specialized computer used for industrial


automation and control applications. It is designed to perform control tasks that were previously
done by relay-based control systems, with much more flexibility, reliability, and ease of
programming. PLCs are widely used in various industries for automating manufacturing
processes, controlling machinery, and monitoring production lines.

A PLC is a rugged, real-time control system that monitors inputs (sensors, switches) and
processes them to control outputs (motors, valves, actuators) based on pre-programmed logic.
The key characteristics of a PLC are:

1. Programmable: The logic or control system can be reprogrammed to change the


behavior without needing hardware changes.
2. Industrial-grade: Designed to withstand harsh environments (extreme temperatures,
vibrations, moisture, etc.).
3. Real-time control: It executes control tasks in a time-sensitive manner, responding to
input signals and adjusting outputs within a specified time limit.
4. Modular: Many PLCs have modular designs that allow the user to add or replace
components (like I/O modules, communication modules) as needed.

Components of a PLC System

A typical PLC consists of several key components that work together to perform control tasks:

1. CPU (Central Processing Unit):


o The brain of the PLC, responsible for executing the control program.
o It processes inputs, runs the control logic, and sends commands to outputs.
o It also handles communication with other devices and stores program logic.
2. Power Supply:
o Provides the necessary power for the PLC system.
o Can include backup power (e.g., a battery) to ensure the PLC continues to operate
in case of power failure.
3. Input/Output (I/O) Modules:
o Inputs: Signals from external devices such as sensors (temperature, pressure,
level sensors) or switches (start/stop buttons).
o Outputs: Control signals sent to devices like motors, solenoids, lights, or other
actuators.
o I/O modules can be digital (on/off signals) or analog (continuous signals).
4. Memory:
o Stores the control program (ladder logic, function block diagrams, etc.) and
process data.
o It is non-volatile, meaning it retains the data even if power is lost (using flash or
EEPROM memory).
5. Communication Interface:
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

PLCs can communicate with other PLCs or supervisory systems (e.g., SCADA,
o
DCS) using communication protocols like Modbus, Profibus, or Ethernet/IP.
6. Human-Machine Interface (HMI) (Optional but often used):
o Allows operators to interact with the PLC, monitor real-time status, and make
adjustments.
o Often used for displaying control processes, alarms, or diagnostics.

Working of PLC

The operation of a PLC can be understood through its scan cycle, which is the repeated sequence
of steps the PLC performs to monitor and control the system:

1. Input Scan: The PLC reads the status of all connected input devices (e.g., sensors,
switches).
2. Program Execution: The PLC runs the control program, performing logical and
arithmetic operations based on input conditions.
3. Output Scan: The PLC updates the status of all output devices (e.g., turning motors on
or off, opening or closing valves).
4. Housekeeping: The PLC performs any necessary internal functions, like communication
or diagnostics.

This scan cycle is repeated continuously, and the PLC responds in real-time to any changes in
input conditions.

PLC Programming Languages

PLCs can be programmed using various languages, with the most common being:

1. Ladder Logic (LD):


o The most popular PLC programming language, resembling electrical relay
diagrams.
o Uses rungs (logic statements) to represent control sequences.
o Easy to understand for those with an electrical or control background.
2. Function Block Diagram (FBD):
o Represents the control process as interconnected blocks (functions) that perform
specific tasks.
o Commonly used in more complex control processes.
3. Structured Text (ST):
o A high-level, text-based programming language similar to traditional
programming languages (like C or Pascal).
o Used for complex control algorithms.
4. Instruction List (IL):
o A low-level, assembly-like language.
o Not commonly used today but still part of the IEC 61131-3 standard.
5. Sequential Function Chart (SFC):
o Used to design processes that need to be executed in a sequence of steps or
phases.

Each language has its strengths, and the choice depends on the specific application and the user's
familiarity.
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Advantages of Using PLCs

PLCs offer several advantages over traditional relay-based control systems:

1. Flexibility: PLC programs can be easily modified or updated to change control sequences
without rewiring or changing hardware.
2. Reliability: PLCs are designed to operate in harsh industrial environments and provide
real-time responses.
3. Ease of Troubleshooting: With diagnostic tools and software, PLCs provide easier ways
to troubleshoot and detect problems in the control system.
4. Cost-effective: While PLCs have an initial cost, they often reduce long-term maintenance
costs compared to traditional hardwired systems.
5. Scalability: PLCs can be expanded by adding modules for more inputs, outputs, or
specialized functions.
6. Integration with other systems: PLCs can be integrated with SCADA systems, DCS
(Distributed Control Systems), and other automation tools.

Applications of PLCs

PLCs are used in a wide variety of industrial automation applications:

1. Manufacturing Plants: Controlling assembly lines, packaging systems, and robotic


arms.
2. Water Treatment: Monitoring and controlling pumps, valves, and sensors in water
treatment plants.
3. HVAC Systems: Managing heating, ventilation, and air conditioning systems.
4. Transportation: Controlling traffic lights, railway signals, or airport conveyor systems.
5. Food and Beverage Industry: Automating production lines, temperature control, and
packaging.
6. Oil & Gas: Monitoring and controlling valves, pumps, and pressure systems in oil
refineries and pipelines.

Conclusion

PLC programming plays a crucial role in industrial automation, offering a flexible, reliable, and
efficient solution to control complex processes. Understanding PLCs, their architecture,
programming languages, and applications is essential for anyone involved in industrial control,
automation, or process engineering.

1.2 Block Diagram of a PLC (Programmable Logic Controller)

A PLC consists of several key components, each performing a specific function to ensure the
control and automation process runs smoothly. Below is a simplified block diagram of a typical
PLC system:

Block Diagram of PLC


+-------------------+
| Power Supply |
| (24V DC/AC) |
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

+-------------------+
|
V
+-------------------+
| CPU (Central |
| Processing Unit)|
+-------------------+
|
+-----------------+-----------------+
| |
V V
+------------------+ +------------------+
| Input Modules | | Output Modules |
| (Digital/Analog)| | (Digital/Analog) |
+------------------+ +------------------+
| |
+-------------------------------------+
|
V
+-------------------+
| Communication |
| Interface |
+-------------------+
|
V
+-------------------+
| Programming |
| Device/Panel |
+-------------------+

Explanation of the Blocks

1. Power Supply:
o Provides the necessary electrical power for the entire PLC system to operate.
o Typical PLCs operate on a 24V DC or AC supply.
2. CPU (Central Processing Unit):
o This is the brain of the PLC, responsible for processing the input data, executing
the program, and generating the appropriate outputs.
o It controls the entire operation of the PLC.
o It also contains the memory for storing the control program and data.
3. Input Modules:
o The input modules receive signals from external devices such as sensors,
switches, or other input devices.
o These can be either digital inputs (ON/OFF signals) or analog inputs
(continuous signals like temperature, pressure, etc.).
o The signals are then converted into a format that the PLC can process.
4. Output Modules:
o These modules send control signals to external devices like motors, actuators,
solenoids, or lamps based on the processed logic.
o Similar to input modules, outputs can be digital outputs (ON/OFF) or analog
outputs (varying control signals).
o The output modules activate the devices based on the PLC's program logic.
5. Communication Interface:
o This block allows the PLC to communicate with other devices, such as other
PLCs, supervisory systems
Downloaded likeRaj
by Gowtham SCADA, or remote I/O devices.
(gowthamtb2004@[Link])
lOMoARcPSD|65740826

o It typically uses communication protocols such as Ethernet, Modbus, Profibus,


or RS-232.
6. Programming Device/Panel:
o This is the device or interface used to program the PLC. It is where the user writes
and edits the control program.
o The programming device connects to the CPU for downloading the PLC program.
o This could be a PC with programming software, a handheld programmer, or
even a HMI (Human-Machine Interface).

Flow of Operation

1. Input Reading: The input modules receive signals from external devices (e.g., sensors)
and send them to the CPU.
2. Processing: The CPU processes the input signals using the control program and executes
the logic based on the conditions defined in the program (e.g., turning on a motor when a
sensor is activated).
3. Output Control: Based on the processed data, the CPU sends commands to the output
modules, activating or deactivating the corresponding devices (e.g., turning on a motor).
4. Communication: The PLC can also communicate with external devices and systems for
additional control, monitoring, or data collection.

1.3 PLC Programming Languages

PLC programming uses different languages to create control programs based on industrial needs.
These languages are standardized under the IEC 61131-3 standard, which defines five
programming languages for PLCs. The choice of language typically depends on the complexity
of the task, the user's background, and the hardware being used.

Here are the five standard PLC programming languages:

1. Ladder Logic Diagram (LAD)

 Description:
Ladder Logic is the most commonly used PLC programming language. It resembles
electrical relay diagrams and is particularly intuitive for those with an electrical
engineering or control background.
 Structure:
It uses rungs (horizontal lines) that represent logic operations like relays and switches.
The left side of the rung represents input conditions (like a contact), and the right side
represents output actions (like a relay or motor).
 Key Features:
o Easy to visualize and understand.
o Resembles traditional relay logic used in control panels.
o Great for discrete (ON/OFF) control systems, timers, counters, and basic logic.
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 Example:
A simple ladder logic for turning a motor on when a start button is pressed:
 |--[ Start Button ]--( Motor )--|

Here, when the Start Button is pressed, the Motor turns on.

2. Function Block Diagram (FBD)

 Description:
FBD represents control logic as blocks connected by lines. Each block performs a
specific function (e.g., logic, arithmetic, comparison), and the blocks are connected to
define the control process.
 Structure:
The diagram consists of blocks (function blocks), each representing a function such as
timers, counters, or mathematical operations. The blocks are connected with lines that
represent data flow.
 Key Features:
o Good for designing complex control processes.
o Modular and easy to reuse function blocks.
o Typically used for continuous control processes (e.g., PID control).
 Example:
A typical FBD might look like a block that performs an AND operation, where two
inputs need to be TRUE to activate an output.

3. Structured Text (ST)

 Description:
Structured Text is a high-level, text-based programming language similar to traditional
programming languages like C, Pascal, or Python.
 Structure:
It uses statements, functions, and control structures like IF, FOR, WHILE, CASE, etc.,
to create complex control logic in a textual form.
 Key Features:
o Good for complex algorithms, loops, and arithmetic operations.
o High-level language, easy for those with programming experience to learn.
o Can handle more advanced control processes, including bit-level operations.
 Example:
A simple structured text example to turn on a motor when a button is pressed:
 IF Start_Button THEN
 Motor := TRUE;
 END_IF;

This logic turns the motor on if the Start_Button is pressed.

4. Instruction List (IL)


Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 Description:
Instruction List is a low-level, assembly-like language used in PLC programming. It's
less popular now, but it was part of the original PLC programming standard.
 Structure:
The language is composed of simple instructions (like MOV, ADD, AND) that the PLC
executes in sequence. Each instruction corresponds to a specific hardware operation.
 Key Features:
o Low-level programming, similar to machine code or assembly language.
o Allows for precise control of hardware, but more difficult to read and maintain.
 Example:
A simple example in Instruction List to turn on a motor when a start button is pressed:
 LD Start_Button ; Load Start Button state
 AND Motor_Off ; AND with Motor_Off state
 OUT Motor ; Output to Motor
 Note: Instruction List is being phased out in favor of the more user-friendly languages
like Ladder Logic and Structured Text.

5. Sequential Function Chart (SFC)

 Description:
SFC is used for describing processes that must be carried out in a specific sequence. It's
ideal for applications where operations must occur step-by-step, such as batch processes
or state machines.
 Structure:
It uses steps and transitions. A step represents a state or operation in the process, and a
transition defines the condition under which the process moves from one step to another.
 Key Features:
o Ideal for complex, sequential, or cyclical operations.
o Visual representation of the process, making it easy to understand and modify.
o Suitable for operations that involve multiple phases or stages.
 Example:
In a basic SFC, a motor might go through multiple stages:
 Step 1: Start Motor
 Transition: Motor is ON
 Step 2: Run Motor for 10 seconds
 Transition: 10 seconds elapsed
 Step 3: Stop Motor

Comparison of PLC Programming Languages

Language Best For Complexity Suitability


Simple, discrete control Widely used, easy to
Ladder Logic (LD) Low
logic understand for electricians
Function Block Complex control logic with Suitable for process control,
Medium
Diagram (FBD) blocks reusability
Complex algorithms, Best for advanced users and
Structured Text (ST) High
mathematical logic complex control
Low-level, detailed Rarely used now, replaced by
Instruction List (IL) Low
hardware
Downloadedcontrol other languages
by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Language Best For Complexity Suitability


Sequential Function Ideal for processes with
Step-by-step processes Medium
Chart (SFC) multiple stages or states

Choosing the Right Language

 Ladder Logic (LD) is ideal for simple control systems, especially when transitioning
from relay logic.
 Function Block Diagram (FBD) is better for complex process control and when
modularity and reuse of functions are important.
 Structured Text (ST) is suitable for tasks requiring sophisticated calculations, loops, and
conditions.
 Instruction List (IL) is rarely used today but can be useful for low-level hardware
control in legacy systems.
 Sequential Function Chart (SFC) is used when processes need to be executed in a
specific sequence.

Conclusion

The choice of PLC programming language depends on the application, complexity of the control
system, and the experience of the user. Most modern PLC systems support a combination of
these languages, allowing users to select the most appropriate one for each part of the program.

1.4 Basic Instruction Set of a PLC

In PLC programming, instructions are the basic building blocks of the control program. These
instructions are executed in sequence to control the behavior of the system, like turning devices
on or off, performing calculations, or timing operations. Most PLCs support a variety of
instructions, categorized by their functionality.

Here’s an overview of basic instruction sets commonly found in PLCs, especially in Ladder
Logic (LD) and Structured Text (ST):

1. Relay Instructions (Contacts & Coils)

These are the basic instructions in ladder logic, used to represent electrical relay logic.

 NO (Normally Open) Contact (XIC)


o Description: Represents a condition where the input is true (closed contact).
o Usage: If the input is "ON," the instruction becomes active, allowing the logic to
flow to the next part of the rung.
o Example:
o --[ Start_Button ]--( Motor )--
 NC (Normally Closed) Contact
Downloaded (XIO)
by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

o Description: Represents a condition where the input is false (open contact).


o Usage: If the input is "OFF," the instruction becomes active, allowing logic to
flow.
o Example:
o --[ !Stop_Button ]--( Motor )--
 Output Coil (OTE)
o Description: Represents an output device (e.g., motor, valve).
o Usage: If the input conditions are met, the coil will activate the output.
o Example:
o --[ Start_Button ]--( Motor )--
 Latch and Unlatch (OTE, OTL, OTU)
o Description: These are used for "latching" (holding) outputs even after the input
condition goes false.
o OTL: Set (Latch) Output
o OTU: Reset (Unlatch) Output
o Example:
o --[ Start_Button ]--( OTL Motor_Latch )--
o --[ Stop_Button ]--( OTU Motor_Latch )--

2. Timer Instructions

Timers are used to introduce delays or time-based control into PLC programs.

 TON (Timer On Delay)


o Description: Delays the activation of an output for a specified time after an input
condition is met.
o Usage: After the input becomes true, the timer starts and waits for the set time
before activating the output.
o Example:
o --[ Start_Button ]--( TON T1, 10s )--( Motor )--
 TOF (Timer Off Delay)
o Description: Delays the deactivation of an output after the input condition goes
false.
o Usage: When the input goes false, the timer starts and waits for the set time
before deactivating the output.
o Example:
o --[ Stop_Button ]--( TOF T1, 5s )--( Motor )--
 RTO (Retentive Timer On)
o Description: Similar to TON, but the timer retains its value even when the input
is false.
o Usage: The timer keeps counting the time even after the input goes false until the
input becomes true again.
o Example:
o --[ Start_Button ]--( RTO T1, 30s )--( Motor )--

3. Counter Instructions

Counters are used to count events or pulses and perform actions based on the count.

 CTU (Count Up) Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

o Description: Increments the counter each time the input becomes true.
o Usage: The counter counts the number of input transitions (e.g., pressing a
button).
o Example:
o --[ Count_Button ]--( CTU C1, 10 )--( Output )--
 CTD (Count Down)
o Description: Decrements the counter each time the input becomes true.
o Usage: The counter counts down from a preset value.
o Example:
o --[ Reset_Button ]--( CTD C1, 0 )--( Output )--
 RES (Reset Counter)
o Description: Resets the counter value to zero.
o Usage: Used to reset the count of a counter.
o Example:
o --[ Reset_Button ]--( RES C1 )--

4. Comparison Instructions

These instructions are used to compare values or variables.

 Equal (EQU)
o Description: Compares two values and returns true if they are equal.
o Example:
o --[ Value = 5 ]--( Output )--
 Not Equal (NEQ)
o Description: Compares two values and returns true if they are not equal.
o Example:
o --[ Value != 5 ]--( Output )--
 Greater Than (GT)
o Description: Returns true if the first value is greater than the second.
o Example:
o --[ Value > 5 ]--( Output )--
 Less Than (LT)
o Description: Returns true if the first value is less than the second.
o Example:
o --[ Value < 5 ]--( Output )--
 Greater Than or Equal (GEQ)
o Description: Returns true if the first value is greater than or equal to the second.
o Example:
o --[ Value >= 5 ]--( Output )--
 Less Than or Equal (LEQ)
o Description: Returns true if the first value is less than or equal to the second.
o Example:
o --[ Value <= 5 ]--( Output )--

5. Mathematical Instructions

These instructions perform arithmetic operations like addition, subtraction, multiplication, and
division.
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 ADD (Addition)
o Description: Adds two values together.
o Example:
o ADD( Value1, Value2 ) -> Result
 SUB (Subtraction)
o Description: Subtracts one value from another.
o Example:
o SUB( Value1, Value2 ) -> Result
 MUL (Multiplication)
o Description: Multiplies two values together.
o Example:
o MUL( Value1, Value2 ) -> Result
 DIV (Division)
o Description: Divides one value by another.
o Example:
o DIV( Value1, Value2 ) -> Result
 MOD (Modulo)
o Description: Returns the remainder when one value is divided by another.
o Example:
o MOD( Value1, Value2 ) -> Result

6. Data Handling Instructions

These instructions are used to manipulate data or control memory.

 MOV (Move)
o Description: Moves data from one location to another.
o Example:
o MOV( Source_Value, Destination_Value )
 COP (Copy)
o Description: Copies a block of data from one location to another.
o Example:
o COP( Source, Destination, Length )
 FAL (Fill Array with a Value)
o Description: Fills an array with a specific value.
o Example:
o FAL( Array, Value, Length )

7. Bit Manipulation Instructions

These instructions perform bitwise operations on individual bits or memory locations.

 BAND (Bitwise AND)


o Description: Performs a bitwise AND operation between two values.
o Example:
o BAND( Value1, Value2 ) -> Result
 BOR (Bitwise OR)
o Description: Performs a bitwise OR operation between two values.
o Example:
o BOR( Value1, Value2 ) -> Result
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 BXOR (Bitwise XOR)


o Description: Performs a bitwise XOR operation between two values.
o Example:
o BXOR( Value1, Value2 ) -> Result

Conclusion

PLC instruction sets are the foundation for creating control programs that automate industrial
processes. By using these basic instructions—such as relay contacts, timers, counters,
comparison instructions, and arithmetic operations—you can create a variety of control systems.
These instructions work together to process inputs, perform operations, and control outputs.

1.5 Design of Alarms and Interlocks in PLC Systems

In industrial automation, alarms and interlocks are critical for safety, equipment protection,
and reliable operation. A good design ensures that abnormal conditions are detected early and
unsafe operations are prevented automatically.

1. Alarms

What is an Alarm?

An alarm is a warning signal generated by the PLC to alert operators about an abnormal or
unsafe condition that requires attention.

Purpose of Alarms

 Alert operators to faults or abnormal conditions


 Prevent equipment damage
 Improve plant safety
 Reduce downtime

Types of Alarms

1. Process Alarms
o High / Low temperature
o High / Low pressure
o Level alarms (Tank full / empty)
2. Equipment Alarms
o Motor overload
o Pump failure
o Sensor failure
3. Safety Alarms
o Emergency stop activated
o Fire or gas detection
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

4. System Alarms
o PLC fault
o Power failure
o Communication failure

Alarm Design Steps

1. Define Alarm Conditions


o Decide the limit values (High, High-High, Low, Low-Low)
o Example: Temperature > 90°C → Alarm
2. Detect Alarm Condition in PLC
o Use comparison instructions
o Example:
o IF Temperature > 90 THEN
o Alarm := TRUE;
o END_IF;

3. Alarm Indication
o Visual: Lamp, HMI message
o Audible: Buzzer or horn
4. Alarm Acknowledgement
o Operator confirms alarm (ACK button)
o Alarm remains logged until acknowledged
5. Alarm Reset
o Alarm clears automatically when condition returns to normal
o Or manual reset (depending on design)

Basic Alarm Ladder Logic Example


|--[ Temp > High_Limit ]--( Alarm_Lamp )--|
|--[ Alarm_Lamp ]--( Buzzer )--|
|--[ Ack_Button ]--( Reset Buzzer )--|

2. Interlocks

What is an Interlock?

An interlock is a logical condition that prevents a machine or process from operating unless
certain safety conditions are met.

Purpose of Interlocks

 Ensure safe operation


 Prevent incorrect sequence of operation
 Protect machines and personnel
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Types of Interlocks

1. Safety Interlocks
o Emergency stop
o Door / guard closed
o Safety relay feedback
2. Process Interlocks
o Pump starts only if valve is open
o Motor runs only if lubrication is ON
3. Electrical Interlocks
o Prevent two motors from running together
o Forward and reverse motor interlock
4. Software Interlocks
o Implemented using PLC logic (no physical wiring)

Interlock Design Rules

 Interlocks must override normal operation


 Safety interlocks must be fail-safe
 Interlock logic should be simple and clearly documented
 Alarms should be generated when an interlock is active

Basic Interlock Ladder Logic Example

Motor Start with Interlock Conditions:

|--[ Start ]--[ Safety_OK ]--[ Overload_OK ]--( Motor )--|

Motor will run only if:

 Start button is pressed


 Safety conditions are OK
 No overload trip

Forward–Reverse Motor Interlock Example


|--[ Forward ]--[/ Reverse ]--( Motor_FWD )--|
|--[ Reverse ]--[/ Forward ]--( Motor_REV )--|

This prevents forward and reverse contactors from turning ON at the same time.

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

3. Alarm vs Interlock (Key Differences)


Feature Alarm Interlock

Function Warning to operator Prevents unsafe operation

Action Information only Automatic blocking

Operator Response Required Not required

Safety Level Medium High

4. Best Practices

 Use interlocks for safety, not just alarms


 Avoid excessive alarms (alarm flooding)
 Clearly label alarm messages
 Log alarms with date and time
 Test alarms and interlocks regularly

Conclusion

 Alarms inform operators about abnormal conditions.


 Interlocks prevent unsafe or incorrect operations.
 Proper design of alarms and interlocks improves safety, reliability, and plant efficiency.
 Both are essential parts of PLC-based automation systems.

1.6 Networking of PLC (Programmable Logic Controller)

PLC networking refers to the interconnection of PLCs with other PLCs, computers, HMIs,
SCADA systems, sensors, and actuators to enable data exchange, monitoring, and
coordinated control in an industrial automation system.

1. Need for PLC Networking

 Data sharing between multiple PLCs


 Centralized monitoring and control (SCADA)
 Remote operation and diagnostics
 Integration with HMI and enterprise systems
 Improved reliability and flexibility

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

2. Basic PLC Network Structure


Sensors / Actuators
|
PLC
|
----------------
| |
HMI SCADA
|
Other PLCs

3. Types of PLC Networking

1. PLC–PLC Networking

 Communication between multiple PLCs


 Used for:
o Load sharing
o Coordinated machine operation
o Distributed control systems

Example: Conveyor PLC communicating with Packing PLC

2. PLC–HMI Networking

 HMI displays process data from PLC


 Operator can start/stop machines and view alarms
 Uses Ethernet or serial communication

3. PLC–SCADA Networking

 SCADA supervises multiple PLCs


 Used in large plants (power plants, water treatment)
 Provides data logging, alarms, and reports

4. Communication Media Used

1. Serial Communication

 RS-232
 RS-485
 Used for short distances and simple networks

2. Fieldbus Communication
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 Designed for industrial environments


 High reliability and noise immunity

3. Ethernet-Based Communication

 High speed and flexible


 Most widely used in modern PLCs

5. Common PLC Communication Protocols

1. Modbus

 Modbus RTU (Serial)


 Modbus TCP/IP (Ethernet)
 Simple and widely supported

2. Profibus

 Profibus-DP (Decentralized Peripherals)


 Profibus-PA (Process Automation)
 Common in Siemens PLCs

3. Profinet

 Ethernet-based
 High-speed real-time communication
 Used in industrial automation

4. Ethernet/IP

 Used by Allen-Bradley PLCs


 Based on Ethernet

5. CAN / CANopen

 Used in automotive and machine control

6. DeviceNet

 Based on CAN protocol


 Used for sensors and actuators

6. PLC Network Topologies

1. Bus Topology
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

PLC1 ---- PLC2 ---- PLC3 ---- PLC4

 Simple and cost-effective


 Failure in main cable affects whole network

2. Star Topology
PLC1
|
PLC2 -- Switch -- PLC3
|
PLC4

 Easy troubleshooting
 Widely used with Ethernet

3. Ring Topology
PLC1 ---- PLC2
| |
PLC4 ---- PLC3

 High reliability
 Used in redundant systems

7. Addressing in PLC Networks

 Each device has a unique address


o IP address (Ethernet)
o Node address (Fieldbus)
 Required for correct data communication

8. Data Exchange Methods

 Polling – Master requests data from slaves


 Event-driven – Data sent when change occurs
 Cyclic communication – Continuous data exchange

9. Advantages of PLC Networking

 Centralized control and monitoring


 Reduced wiring and installation cost
 Faster data exchange
 Easy expansion and scalability
 Remote troubleshooting
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

10. Applications of PLC Networking

 Manufacturing plants
 Power stations
 Water treatment plants
 Oil & gas industries
 Building automation

Conclusion

PLC networking enables distributed, flexible, and efficient industrial automation systems.
By using suitable communication protocols and network structures, multiple PLCs and control
devices can work together reliably in real-time environments.

1.7 Overview of Safety in PLC Systems (with Case Studies)

Safety in PLC-based automation is about protecting human life, equipment, and the
environment. Modern industries use Safety PLCs and well-designed safety logic to ensure
machines move to a safe state whenever a fault or abnormal condition occurs.

1. Why Safety is Important in PLC Systems

 Prevent injury or loss of life


 Avoid damage to machines and materials
 Comply with safety standards (IEC, ISO)
 Reduce downtime and legal risks

A normal PLC controls the process, whereas a Safety PLC is specifically designed to perform
safety-related functions.

2. Safety PLC vs Normal PLC


Feature Normal PLC Safety PLC

Purpose Process control Personnel & machine safety

Reliability Standard Very high (redundant design)

Fault Detection Limited Continuous self-diagnostics

Standards General automation IEC 61508, ISO 13849

Output State on Fault Unpredictable Safe state (OFF)


Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

3. Key Safety Functions in PLC Systems

1. Emergency Stop (E-Stop)

 Immediately stops machine operation


 Overrides all normal control logic
 Usually hardwired + monitored by Safety PLC

2. Safety Interlocks

 Prevent machine operation unless safety conditions are satisfied


 Examples:
o Door closed
o Guard in place
o Pressure within limits

3. Safe Start / Safe Stop

 Machine starts only after safety checks


 Controlled stopping to avoid hazards

4. Redundancy

 Dual input channels


 Dual processors
 Cross-monitoring

4. Safety Design Principles

1. Fail-Safe Operation
o On power failure or fault → system goes to safe state
2. Redundancy
o Multiple safety channels for critical signals
3. Diagnostics & Monitoring
o Continuous fault detection
o Detection of short circuits, wire breaks
4. Separation of Safety & Control Logic
o Safety functions handled independently

5. Safety Standards for PLC Systems

 IEC 61508 – Functional safety of electrical systems


 ISO 13849 – Safety of machinery control systems
 IEC 62061 – Safety-related control systems
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 SIL (Safety Integrity Level) – SIL 1 to SIL 4

6. Case Studies

Case Study 1: Emergency Stop in a Conveyor System

Problem:
Operators work near a high-speed conveyor. Accidental entanglement risk exists.

Safety Solution:

 Emergency stop push buttons installed at multiple points


 Connected to a Safety PLC
 E-stop overrides all PLC outputs

PLC Safety Logic:

If E_Stop = TRUE
→ All motors OFF
→ Alarm ON
→ Restart only after manual reset

Result:

 Immediate shutdown during emergency


 Prevents injury and equipment damage

Case Study 2: Safety Door Interlock in CNC Machine

Problem:
Machine should not run when safety door is open.

Safety Solution:

 Safety-rated door switch connected to Safety PLC


 Machine spindle allowed only if door is closed

Logic:

Door_Closed AND Safety_OK → Machine_Run


Door_Open → Machine_Stop

Result:

 Prevents operator exposure to rotating tools


 Complies with ISO 13849 standards
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Case Study 3: Boiler Safety Control Using PLC

Problem:
Boiler explosion risk due to high pressure or low water level.

Safety Measures:

 Pressure and level sensors connected to PLC


 High-High pressure trip
 Low-Low water level trip

Safety Action:

If Pressure > HH OR Level < LL


→ Fuel supply OFF
→ Boiler shutdown
→ Alarm activated

Result:

 Prevents catastrophic failure


 Ensures safe boiler operation

Case Study 4: Two-Hand Safety Control in Press Machine

Problem:
Risk of hand injury during pressing operation.

Safety Solution:

 Two-hand push buttons


 Both buttons must be pressed within a short time

Safety Logic:

Button1 AND Button2 (within 0.5 sec) → Press ON


Else → Press OFF

Result:

 Operator hands remain away from danger zone


 Widely used in industrial press machines

7. Advantages of Using Safety PLCs

 High reliability andDownloaded


fault tolerance
by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 Compliance with international safety standards


 Reduced accident rates
 Easier diagnostics and maintenance

8. Conclusion

 Safety in PLC systems is non-negotiable in modern automation


 Safety PLCs ensure fail-safe operation and high reliability
 Real-world case studies show how safety logic prevents accidents
 Proper safety design saves lives, equipment, and cost

1.8 Process Safety Automation: Levels of Process Safety Using PLCs

Process safety automation is the systematic use of control systems—especially PLCs and
Safety PLCs—to prevent accidents such as fires, explosions, toxic releases, and equipment
damage in industrial processes. Safety is achieved in layers, so that if one layer fails, another
layer protects the process.

This concept is commonly called Layers of Protection (LOP).

1. Concept of Process Safety Levels

Process safety is implemented in multiple levels, ranging from basic control to emergency
response. PLCs play a major role in Levels 1 to 3.

Level 5 – Emergency Response


Level 4 – Physical Protection
Level 3 – Safety Instrumented System (SIS)
Level 2 – Alarms & Operator Intervention
Level 1 – Basic Process Control System (BPCS)

2. Level 1: Basic Process Control System (BPCS)

Role of PLC

 Normal operation and control of the process


 Maintains variables such as temperature, pressure, flow, and level within limits

Functions

 PID control
 Start/stop sequencing
 Normal interlocks
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Example

 PLC controls reactor temperature at 80°C using a control valve


 Motor starts only if lubrication is ON

Safety Contribution

 Prevents deviation under normal conditions


 Not safety-certified

3. Level 2: Alarms and Operator Intervention

Role of PLC

 Detect abnormal conditions


 Warn operators to take corrective action

Functions

 High / Low alarms


 Visual and audible alarms
 Alarm logging and acknowledgment

Example

 Temperature > 90°C → Alarm


 Operator manually reduces heater power

Safety Contribution

 Reduces risk by early warning


 Depends on human response

4. Level 3: Safety Instrumented System (SIS)

Role of Safety PLC

 Automatically take the process to a safe state


 Independent of basic control PLC

Functions

 Emergency shutdown (ESD)


 Trip systems
 Safety interlocks
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Standards

 IEC 61508
 IEC 61511

Example
If Pressure > High-High
→ Close fuel valve
→ Stop pump
→ Trip system

Safety Contribution

 Highest protection using automation


 Designed for SIL 1 to SIL 4

5. Level 4: Physical Protection Systems

Not PLC-based (mostly)

 Pressure relief valves


 Rupture disks
 Fire suppression systems

Example

 Safety relief valve opens if pressure exceeds limit

Safety Contribution

 Acts when automation fails

6. Level 5: Emergency Response

Human & External Systems

 Emergency evacuation
 Fire brigade response
 Disaster management plans

Example

 Plant evacuation during toxic gas leak

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

7. Role of PLCs in Process Safety Automation


Safety Level PLC Type Used Role

Level 1 Normal PLC Process control

Level 2 Normal PLC / HMI Alarms

Level 3 Safety PLC Emergency shutdown

Level 4 Mechanical Last-line protection

Level 5 Human systems Emergency response

8. Case Study: Chemical Reactor Safety

Scenario

Exothermic reaction with risk of runaway temperature and pressure.

Safety Levels Applied

 Level 1 (BPCS)
PLC controls temperature using PID loop.
 Level 2 (Alarm)
High temperature alarm alerts operator.
 Level 3 (SIS)
Safety PLC trips heater and opens vent valve at High-High temperature.
 Level 4 (Physical)
Pressure relief valve opens if pressure continues to rise.
 Level 5 (Emergency)
Plant evacuation if toxic release occurs.

9. Advantages of Multi-Level Safety Using PLCs

 Reduces dependence on a single protection system


 Improves overall plant safety
 Meets international safety standards
 Minimizes accident severity

10. Conclusion

 Process safety automation is achieved through multiple safety levels


 PLCs and Safety PLCs are key components of Levels 1–3
 Layered protection ensures fail-safe and reliable operation
 Widely applied in chemical, oilGowtham
Downloaded by & gas,Rajpower, and pharmaceutical industries
(gowthamtb2004@[Link])
lOMoARcPSD|65740826

1.9 IEC 61131-3 Standard (PLC Programming Standard)

The IEC 61131-3 is the international standard for programmable controllers, especially for
PLC programming languages and software structure. It is the most important standard for
automation engineers because it defines:

✅ Programming languages
✅ Program organization
✅ Data types and structures
✅ Software architecture

1. What is IEC 61131-3?

IEC 61131 is a series of international standards for PLCs.


The Part 3 (IEC 61131-3) specifically defines:

📌 Programming languages
📌 Software organization
📌 Data types
📌 Functions and function blocks
📌 Execution model

2. Main Features of IEC 61131-3

A. Standard Programming Languages

IEC 61131-3 defines 5 standard PLC programming languages:

Language Type Use

Ladder Diagram (LD) Graphical Easy for electricians

Function Block Diagram (FBD) Graphical Process control

Structured Text (ST) Textual Complex algorithms

Instruction List (IL) Textual Low-level (obsolete)

Sequential Function Chart (SFC) Graphical Sequential operations

Note: IL is being phased out in modern PLCs.

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

B. Standard Data Types

IEC 61131-3 defines basic and derived data types:

Basic Data Types


Type Description

BOOL True/False

INT 16-bit integer

DINT 32-bit integer

REAL Floating point

BYTE 8-bit

WORD 16-bit

DWORD 32-bit

STRING Text

Derived Data Types


Type Description

ARRAY Collection of elements

STRUCT User-defined structure

ENUM Enumerated type

POINTER Memory address

C. Program Organization Units (POUs)

IEC 61131-3 defines Program Organization Units which are building blocks of PLC software:

1. Program
2. Function Block
3. Function

Program

 Main control logic


 Can call functions and function blocks

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Function Block

 Reusable software component


 Has internal memory (stateful)

Function

 Reusable code
 No internal memory (stateless)

D. Configuration, Resources, Tasks

The standard defines a hierarchy for software structure:

Configuration
└── Resource (CPU)
└── Task
└── Program

 Configuration: The complete PLC project


 Resource: A CPU or controller
 Task: A scheduled execution unit
 Program: Contains logic and calls FBs/Functions

E. Execution Model

 PLC runs programs in scan cycles


 Tasks can be:
o Periodic (every fixed time)
o Aperiodic (event-triggered)

3. Advantages of IEC 61131-3

✅ Standardization across different PLC brands


✅ Portability of programs
✅ Reusability of function blocks
✅ Improved readability and maintenance
✅ Supports modular programming

4. Example: Ladder Diagram vs Structured Text

Ladder Diagram (LD)


Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

|--[ Start ]--[ Stop ]--( Motor )--|

Structured Text (ST)


IF Start AND NOT Stop THEN
Motor := TRUE;
ELSE
Motor := FALSE;
END_IF;

Both represent the same logic but in different forms.

5. Summary

IEC 61131-3 is the standard foundation for PLC programming, defining:

 5 programming languages
 Data types
 Program structure
 Execution model
 Modular programming

1.10 Application of International Standards in Process Safety Control

Industrial process safety is governed by international standards to ensure:

✔ Safety of personnel
✔ Protection of equipment
✔ Environment protection
✔ Compliance with legal requirements
✔ Consistency across industries

Key International Standards Used in Process Safety Control

1. IEC 61508 – Functional Safety

 Applies to: Electrical/Electronic/Programmable Electronic safety systems


 Goal: Ensure safety functions perform reliably
 Concept: Defines Safety Integrity Level (SIL)

SIL Levels

SIL Risk Reduction Factor

SIL 1 10 – 100

SIL 2 100 – 1000 Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

SIL Risk Reduction Factor

SIL 3 1000 – 10000

SIL 4 10000 – 100000

2. IEC 61511 – Safety Instrumented Systems (SIS)

 Applies to: Process industries (chemical, oil & gas, pharmaceuticals)


 Defines: Lifecycle for Safety Instrumented Systems
 Includes:
o Hazard analysis
o SIS design
o SIL verification
o Validation and maintenance

3. IEC 61131-3 – PLC Programming Standard

 Standardizes PLC programming languages


 Ensures reliability and consistency in control logic
 Supports modular design using function blocks

4. ISO 13849 – Safety of Machinery

 Applies to: Industrial machinery safety


 Defines: Performance Levels (PL)
 Used for safety-related parts of control systems
 Helps to evaluate reliability of safety functions

5. IEC 62061 – Functional Safety of Machinery Control Systems

 Similar to ISO 13849 but more aligned with IEC 61508


 Used for safety of electrical control systems of machines

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

How These Standards Are Applied in Process Safety Control


1. Hazard and Risk Assessment

Before automation design, the process is analyzed using:

 HAZOP (Hazard and Operability Study)


 FTA (Fault Tree Analysis)
 FMEA (Failure Modes and Effects Analysis)

These methods identify hazards and required safety measures.

2. Determination of SIL / PL

Based on risk assessment:

 Determine SIL level (IEC 61508/61511)


 Or PL level (ISO 13849)

Example:

Hazard Required SIL

Low risk SIL 1

Medium risk SIL 2

High risk SIL 3

Very high risk SIL 4

3. Design of Safety Instrumented System (SIS)

Safety PLC + Safety I/O

SIS is implemented using:

 Safety PLC (SIL certified)


 Safety-rated sensors and actuators
 Redundant wiring and modules

Typical SIS Architecture


Sensor → Safety PLC → Final Control Element (Valve/Motor)
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Example:

 High-high pressure sensor → Safety PLC → Shutdown valve

4. Safety Logic Implementation

Safety logic is developed using:

 IEC 61131-3 languages (LD, FBD, ST)


 Safety function blocks
 Redundant channels
 Diagnostic checks

Example logic:

IF (Pressure_HH) THEN
Shutdown_Valve := ON;
END_IF;

5. Verification and Validation

Standards require:

✔ Verification: Check if system is built correctly


✔ Validation: Check if system meets safety requirements

This includes:

 Testing
 Simulation
 Proof testing
 Documentation

6. Maintenance and Proof Testing

Safety systems must be maintained to keep SIL level:

 Periodic testing
 Calibration
 Firmware updates
 Safety audits

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Process Safety Control Example (SIL 2)

Scenario: Reactor Overpressure

Hazard: Reactor pressure rises beyond safe limit


SIS Action: Shutdown fuel supply and open vent valve

Safety Function
If Pressure > High-High (HH)
→ Shutdown valve closes
→ Vent valve opens
→ Alarm triggers

SIL Requirement

 SIL 2 (Risk reduction factor 100–1000)

Role of PLCs and Safety PLCs


Component Role in Safety

Normal PLC Basic control and alarms (BPCS)

Safety PLC Safety instrumented functions (SIS)

HMI/SCADA Monitoring & alarm management

Safety Relays Simple safety functions (E-stop)

Conclusion

International standards ensure that process safety control systems are:

✔ Reliable
✔ Consistent
✔ Testable
✔ Maintained throughout lifecycle
✔ Compliant with legal requirements

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Unit – II IEC61131-3

2.1 Rails

In IEC 61131-3, the term “rails” is not a standard technical term. However, in the context of
PLC programming (Ladder Diagram), “rails” refer to the vertical power lines on the left
and right sides of a ladder diagram.

So in IEC 61131-3 ladder logic, rails are:


Rails in IEC 61131-3 Ladder Diagram
✔ Definition

Rails are the vertical lines on both sides of a ladder diagram representing:

 Left rail = Power supply (logic source)


 Right rail = Return path

They form the boundary of the ladder diagram, and the rungs (horizontal lines) connect between
these rails.

Structure of Ladder Diagram


Left Rail | Rung 1 | Right Rail
|----------|
| Rung 2 |
|----------|

Meaning of Rails

 Left Rail
Acts as the logical Downloaded
power source (like the live wire in electrical diagrams).
by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 Right Rail
Acts as the return path (like neutral wire).

All logic conditions are evaluated from left to right, just like current flowing from left rail to
right rail.

How Ladder Logic Works

A typical rung looks like this:

|--[ XIC ]--[ XIO ]--( OTE )--|

Here:

 Input conditions are placed between rails


 Output coil is connected at the right end
 If the input logic is TRUE, the output gets activated

Why Rails are Important

 Provide standardized visual structure


 Helps in easy understanding and debugging
 Represents the flow of logic clearly

Example Ladder Rung


Left Rail ──[ Start ]──[ NOT Stop ]──( Motor )── Right Rail

This means:

 Motor turns ON if Start is pressed AND Stop is not pressed.

Summary
Term Meaning in IEC 61131-3 Ladder Diagram

Rails Vertical power lines on both sides

Rungs Horizontal logic lines connecting rails

Left rail Logic source (power)

Right rail Logic return

2.2 Rungs in IEC 61131-3 (Ladder Diagram)


Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

In IEC 61131-3, Ladder Diagram (LD) is one of the standard PLC programming languages. A
rung is a horizontal line in a ladder diagram that represents a single logic statement or control
operation.

What is a Rung?

A rung is the basic building block of ladder logic.


It connects the left rail to the right rail and contains:

✔ Input conditions (contacts)


✔ Output actions (coils, timers, counters)

Structure of a Rung
Left Rail ───[ Contacts ]──( Output )── Right Rail

Meaning

 The left side of a rung represents input conditions


 The right side represents the output action
 Logic flows from left to right

Example of a Simple Rung


|--[ Start ]--[ NOT Stop ]--( Motor )--|

Meaning

 Motor ON when:
o Start button is pressed
o Stop button is NOT pressed

Types of Instructions in a Rung

A rung can include:

1. Contacts (Input Conditions)

Symbol Meaning

[ ] Normally Open (XIC)

[ / ] Normally Closed (XIO)

2. Coils (Outputs)

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Symbol Meaning

( ) Output Coil (OTE)

(S) Set (Latch)

(R) Reset (Unlatch)

3. Function Blocks

 Timers (TON, TOF)


 Counters (CTU, CTD)
 Comparators, Math functions

Example with Timer


|--[ Start ]--( TON T1, 5s )--( Motor )--|

Meaning:

 When Start is pressed, timer T1 starts


 After 5 seconds, Motor turns ON

Multiple Outputs in One Rung


|--[ Condition ]--( Motor )--( Lamp )--|

Meaning:

 Both Motor and Lamp turn ON when condition is TRUE

Multiple Branches in a Rung

A rung can have parallel branches (OR logic) or series branches (AND logic).

Series (AND)
|--[ A ]--[ B ]--( Output )--|

Parallel (OR)
|--[ A ]----------------( Output )--|
|--[ B ]----------------( Output )--|

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Summary
Term Meaning

Rung Horizontal logic line in Ladder Diagram

Input contacts Conditions (AND/OR)

Output coil Action (Motor/Lamp etc.)

Flow Left → Right

2.3 Relay Logic in IEC 61131-3 (Ladder Diagram)

Relay Logic is the basic logic used in Ladder Diagram (LD) programming. It is modeled after
electrical relay circuits, where contacts and coils are used to control machines.

In IEC 61131-3, Ladder Diagram is one of the standard languages and relay logic is the
foundation of ladder programming.

What is Relay Logic?

Relay logic is a method of implementing control using:

 Contacts (input conditions)


 Coils (outputs)
 Relays (intermediate devices)

It mimics the behavior of electromechanical relays.

Basic Elements of Relay Logic

1. Contacts

Represent input conditions (like switches or sensors)

Symbol Name Meaning

[ ] NO (Normally Open) TRUE when input is ON

[ / ] NC (Normally Closed) TRUE when input is OFF

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

2. Coils

Represent output devices (like motors, lamps)

Symbol Name Meaning

( ) Output Coil (OTE) Turns ON output

(S) Set Coil (OTL) Latches output

(R) Reset Coil (OTU) Unlatches output

3. Relay

A relay is basically a coil with contacts.

 When the coil is energized, the relay contacts change state.

Relay Logic Rules in IEC 61131-3

Rule 1: Left to Right Logic Flow

 Logic is evaluated from left rail to right rail.

Rule 2: Contacts Form Logic Conditions

 Series contacts = AND logic


 Parallel contacts = OR logic

Rule 3: Coils Represent Outputs

 Coil energizes when conditions on the left are TRUE.

Basic Relay Logic Examples

Example 1: Start-Stop Motor Control


|--[ Start ]--[ /Stop ]--( Motor )--|

Meaning

Motor turns ON if:


Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 Start button pressed


 Stop button NOT pressed

Example 2: Latching Circuit (Seal-in)


|--[ Start ]--( Motor )--|
|--[ Motor ]--------------|

Meaning

Motor stays ON even after Start is released.

Example 3: Forward–Reverse Motor Control (Interlock)


|--[ Fwd ]--[/Rev]--( Motor_Fwd )--|
|--[ Rev ]--[/Fwd]--( Motor_Rev )--|

Meaning

 Motor cannot run forward and reverse at same time

How Relay Logic is Used in PLC (LD)

PLC Ladder Logic is designed to be familiar to electricians and technicians because:

✔ It resembles relay wiring diagrams


✔ Easy to understand and debug
✔ Simple for ON/OFF control

Comparison: Relay Logic vs PLC Logic


Relay Logic (Hardwired) PLC Ladder Logic

Uses physical relays Uses virtual contacts/coils

Hard to modify Easy to modify

Expensive wiring Less wiring

Limited diagnostics Better diagnostics

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Key Points

 Relay logic is the foundation of Ladder Diagram


 IEC 61131-3 standardizes ladder logic
 Ladder logic uses contacts and coils
 Logic is evaluated left to right
 Series = AND, Parallel = OR

2.4 Latch Switch in IEC 61131-3 (Ladder Diagram)

In IEC 61131-3, a latch switch is implemented using latching logic, which is commonly done
using SET (OTL) and RESET (OTU) coils in Ladder Diagram (LD).

This is used to hold an output ON even after the input is removed (like a memory).

What is a Latch Switch?

A latch switch (or seal-in circuit) is a circuit that:

✔ Turns ON when a start condition occurs


✔ Remains ON even after the start condition is removed
✔ Turns OFF only when a reset condition occurs

Why Latch is Used?

Used in industrial control for:

 Motor starters
 Pumps
 Conveyor belts
 Automatic systems that need to stay ON

Latch Logic Using OTL and OTU

OTL (Output Latch / Set)

 Used to set (latch) the output ON

OTU (Output Unlatch / Reset)

 Used to reset (unlatch) the output OFF

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Example: Motor Start-Stop with Latch

Ladder Diagram
|--[ Start ]------( OTL Motor )--|
|--[ Motor ]------( OTL Motor )--|
|--[ Stop ]------( OTU Motor )--|

Explanation

 When Start is pressed → Motor is latched ON


 The Motor stays ON because the Motor contact is in parallel (seal-in)
 When Stop is pressed → Motor is unlatched OFF

How It Works
Condition Result

Start pressed Motor ON (latched)

Start released Motor remains ON

Stop pressed Motor OFF (unlatched)

Equivalent Logic in Structured Text (ST)


IF Start THEN
Motor := TRUE; // Latch ON
ELSIF Stop THEN
Motor := FALSE; // Reset OFF
END_IF;

Applications of Latching

 Motor running after start


 Automatic systems
 Process holding state
 Alarm latching

Important Points

 OTL = Set / Latch


 OTU = Reset / Unlatch
 Latch is like memory bit
 It remembers the state until reset

2.5 Timers in IEC 61131-3

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

In IEC 61131-3, timers are standard function blocks used in PLC programming. They help you
create time-based control actions, such as delays, pulse generation, and time measurement.

Types of Timers in IEC 61131-3

IEC 61131-3 defines three basic timer types:

1 TON (Timer ON Delay)

Action: Delays turning ON an output after the input becomes TRUE.

Symbol
TON

Operation

 When input is TRUE → timer starts


 After preset time → output becomes TRUE
 If input becomes FALSE before time expires → timer resets

Example

If Start is ON for 5 seconds, then Motor turns ON.

2 TOF (Timer OFF Delay)

Action: Delays turning OFF an output after the input becomes FALSE.

Symbol
TOF

Operation

 When input becomes FALSE → timer starts


 Output remains TRUE until preset time expires
 If input becomes TRUE again → timer resets

Example

If Stop is pressed, Motor turns OFF after 3 seconds.


Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

3 TP (Pulse Timer)

Action: Generates a fixed pulse when the input becomes TRUE.

Symbol
TP

Operation

 When input turns TRUE → output turns TRUE for preset time
 After time expires → output becomes FALSE
 If input stays TRUE, the pulse still remains fixed

Example

When Start is pressed, a lamp lights for 2 seconds only.

Timer Parameters (Standard IEC 61131-3)


Parameter Meaning

IN Input signal to start the timer

PT Preset Time (duration)

Q Output status (TRUE/FALSE)

ET Elapsed Time

Timer Example (TON)

Ladder Diagram
|--[ Start ]--( TON T1, PT=5s )--|
|--[ T1.Q ]--( Motor )--|

Explanation

 Start ON → timer counts 5 seconds


 After 5 seconds → T1.Q becomes TRUE → Motor ON

Timer Example (TOF)

Ladder Diagram
|--[ Motor ]--( TOF T2, PT=3s )--|
|--[ T2.Q ]--( Lamp )--|
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Explanation

 Motor turns OFF → timer counts 3 seconds


 After 3 seconds → Lamp turns OFF

Timer Example (TP)

Ladder Diagram
|--[ Start ]--( TP T3, PT=2s )--|
|--[ T3.Q ]--( Buzzer )--|

Explanation

 Start pressed → buzzer sounds for 2 seconds only

Practical Applications

 Delay start of motor


 Time-based sequencing
 Debouncing switches
 Generating pulses
 Time-based alarms

Important Notes

 Timers are function blocks (not simple instructions)


 Timer output Q is TRUE only after timing conditions are met
 ET gives real-time elapsed time

2.6 Counters in IEC 61131-3 (PLC Programming)

In IEC 61131-3, counters are standard function blocks used in PLC programming to count
events like pulses, items, or operations. Counters are widely used in industrial automation for
counting objects on conveyors, batching, production totals, etc.

Types of Counters in IEC 61131-3

IEC 61131-3 defines three main types of counters:

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

1 CTU (Count Up)

Counts upward each time the input signal changes from FALSE to TRUE (rising edge).

Use

 Counting number of products


 Counting pulses

Inputs & Outputs

Input Meaning

CU Count Up input

R Reset

PV Preset Value

CV Current Value

Q Output (TRUE when CV ≥ PV)

2 CTD (Count Down)

Counts downward each time the input signal changes from FALSE to TRUE.

Use

 Counting remaining items


 Batch counting

Inputs & Outputs

Input Meaning

CD Count Down input

R Reset

PV Preset Value

CV Current Value

Q Output (TRUE when CV ≤ 0)

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

3 CTUD (Count Up/Down)

A counter that can count both up and down based on inputs.

Use

 Elevator floor counting


 Inventory counting

Inputs & Outputs

Input Meaning

CU Count Up

CD Count Down

R Reset

PV Preset Value

CV Current Value

QU Output when CV ≥ PV

QD Output when CV ≤ 0

Basic Counter Logic Examples

Example 1: CTU (Count Up)

Goal

Count number of items passing a sensor. When count reaches 10 → turn ON output.

Ladder Logic
|--[ Sensor ]--( CTU C1, PV=10 )--|
|--[ C1.Q ]--( Output )--|

Meaning

 Each pulse from sensor increments counter


 When counter reaches 10 → output turns ON

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Example 2: CTD (Count Down)

Goal

Start with 20 items and count down with each item removed. When count reaches 0 → stop
process.

Ladder Logic
|--[ ItemRemoved ]--( CTD C2, PV=20 )--|
|--[ C2.Q ]--( Stop )--|

Example 3: CTUD (Count Up/Down)

Goal

Elevator floor count:

 Up button increments
 Down button decrements

Ladder Logic
|--[ UpButton ]--( CTUD C3 )--|
|--[ DownButton ]--( CTUD C3 )--|

🔹 Counter Reset

Counter reset is done using the R input.

|--[ ResetButton ]--( C1.R )--|

Key Points

 Counters count on rising edge (FALSE → TRUE)


 CV shows the current count value
 PV is the preset value to compare
 Q output indicates when count condition is met

Applications of Counters

 Batching systems
 Product counting
 Part sorting
 Production monitoring
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 Filling operations

2.7 Boolean Logic in IEC 61131-3 (PLC Programming)

Boolean logic is the foundation of PLC programming. In IEC 61131-3, Boolean logic is used to
control the flow of logic in Ladder Diagram (LD), Function Block Diagram (FBD), and
Structured Text (ST).

A Boolean variable can only have two values:

Value Meaning

TRUE 1

FALSE 0

Basic Boolean Operations


1 AND (Logical Conjunction)

 Output is TRUE only if all inputs are TRUE

A B A AND B

0 00

0 10

1 00

1 11

Ladder (Series Contacts)


|--[ A ]--[ B ]--( Output )--|

Structured Text
Output := A AND B;

2 OR (Logical Disjunction)

 Output is TRUE if any one input is TRUE

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

A B A OR B

0 00

0 11

1 01

1 11

Ladder (Parallel Contacts)


|--[ A ]----------------( Output )--|
|--[ B ]----------------( Output )--|

Structured Text
Output := A OR B;

3 NOT (Logical Negation)

 Output is TRUE when input is FALSE

A NOT A

0 1

1 0

Ladder (Normally Closed Contact)


|--[ /A ]--( Output )--|

Structured Text
Output := NOT A;

4 NAND (NOT AND)

 Output is TRUE when AND condition is FALSE

A B A NAND B

0 01

0 11

1 01 Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

A B A NAND B

1 10

Structured Text
Output := NOT (A AND B);

5 NOR (NOT OR)

 Output is TRUE when OR condition is FALSE

A B A NOR B

0 01

0 10

1 00

1 10

Structured Text
Output := NOT (A OR B);

6 XOR (Exclusive OR)

 Output is TRUE when only one input is TRUE

A B A XOR B

0 00

0 11

1 01

1 10

Structured Text
Output := A XOR B;

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Boolean Logic in Ladder Diagram

Series Contacts = AND


|--[ A ]--[ B ]--( Output )--|

Parallel Contacts = OR
|--[ A ]---------------( Output )--|
|--[ B ]---------------( Output )--|

Normally Closed Contact = NOT


|--[ /A ]--( Output )--|

Boolean Logic in IEC 61131-3 (Structured Text)

Example
IF (Start AND NOT Stop) OR Reset THEN
Motor := TRUE;
ELSE
Motor := FALSE;
END_IF;

Common Industrial Use Cases

 Start/Stop motor control


 Safety interlocks
 Alarm logic
 Conveyor sequencing
 Process control logic

Summary Table
Boolean Operator Ladder Symbol Structured Text

AND Series contacts A AND B

OR Parallel contacts A OR B

NOT NC contact NOT A

XOR Exclusive OR A XOR B

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Boolean Operator Ladder Symbol Structured Text

NAND NOT(AND) NOT (A AND B)

NOR NOT(OR) NOT (A OR B)

2.8 Math Instructions & Data Manipulation Instructions in IEC 61131-3

In IEC 61131-3, math instructions and data manipulation instructions are part of standard
function blocks used for processing numeric data and managing variables in PLC programs.

These instructions are commonly used in Structured Text (ST) and Function Block Diagram
(FBD), and are also available in Ladder Diagram (LD) in most PLC software.

1. Math Instructions (Arithmetic Operations)

These are basic arithmetic operations used on numeric data types (INT, DINT, REAL, etc.)

A. Addition (+)
C := A + B;

Example:
If A = 10, B = 20 → C = 30

B. Subtraction (-)
C := A - B;

Example:
If A = 30, B = 10 → C = 20

C. Multiplication (*)
C := A * B;

Example:
If A = 5, B = 6 → C = 30

D. Division (/)
C := A / B;

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Example:
If A = 20, B = 4 → C = 5

E. Modulus (MOD)
C := A MOD B;

Example:
If A = 20, B = 6 → C = 2 (remainder)

F. Exponentiation (Power)
C := A ** B;

Example:
If A = 2, B = 3 → C = 8

2. Comparison Instructions

Used to compare values and return Boolean results (TRUE/FALSE).

Instruction Meaning

= Equal

<> Not equal

< Less than

<= Less than or equal

> Greater than

>= Greater than or equal

Example
IF Temperature >= SetPoint THEN
Heater := FALSE;
END_IF;

3. Data Manipulation Instructions

These instructions are usedDownloaded


to modify, move, or
by Gowtham Rajconvert data.
(gowthamtb2004@[Link])
lOMoARcPSD|65740826

A. Move (MOV)

Copies value from source to destination.

MOV(Source, Destination);

Example
MOV(TempValue, DisplayValue);

B. Load (LD) and Store (ST)

Used in ladder logic for data handling.

C. Copy (CPY)

Copies data from one variable to another (similar to MOV).

D. Set / Reset

Used for Boolean variables.

SET(Output);
RESET(Output);

E. Shift Instructions

Used for bit manipulation and data shifting.

Instruction Meaning

SHL Shift left

SHR Shift right

ROL Rotate left

ROR Rotate right

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

F. Bitwise Operations
Instruction Meaning

AND Bitwise AND

OR Bitwise OR

XOR Bitwise XOR

NOT Bitwise NOT

G. Type Conversion

Used to convert between data types:

Function Meaning

INT_TO_REAL() Convert INT to REAL

REAL_TO_INT() Convert REAL to INT

WORD_TO_DWORD() Convert WORD to DWORD

BOOL_TO_INT() Convert BOOL to INT

Example Program in Structured Text (ST)


VAR
A : INT := 10;
B : INT := 5;
C : INT;
D : REAL;
END_VAR

C := A + B; // Math operation
D := INT_TO_REAL(C); // Type conversion

IF C >= 15 THEN
Output := TRUE;
END_IF;

Applications

 Process calculations (flow, pressure, temperature)


 Batch control
 PID calculations
 Data logging
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 Scaling analog values

Summary Table
Category Instructions

Math +, -, *, /, MOD, **

Comparison =, <>, <, <=, >, >=

Data Manipulation MOV, CPY, SET, RESET, SHL, SHR, ROL, ROR

Type Conversion INT_TO_REAL, REAL_TO_INT, etc.

2.9 Requirement of Communication Networks for PLC in IEC 61131-3

IEC 61131-3 standardizes PLC programming, but it also recognizes the need for
communication between PLCs and other automation devices. Although IEC 61131-3 does not
define network protocols, it provides guidelines and structures that support communication
and distributed control systems.

Why Communication Networks are Needed in IEC 61131-3 Systems?

IEC 61131-3 defines standard software architecture and program organization, which makes
it easier to build distributed automation systems using communication networks.

1. Distributed Control and Multiple PLCs

Modern industrial systems often have multiple PLCs distributed across a plant.
Communication is required for:

✔ Sharing process data


✔ Coordinated control
✔ Centralized monitoring

2. Task and Program Synchronization

IEC 61131-3 defines:

 Tasks
 Programs
 Resources
 Configurations

For distributed systems, tasks in different PLCs must synchronize using network
communication.
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

3. Data Exchange Between PLCs and Other Devices

PLC programs often need data from:

 Sensors
 Drives
 HMIs
 SCADA
 MES / ERP

IEC 61131-3 supports standard data types and structures, making data exchange easier.

4. Remote Programming and Monitoring

IEC 61131-3 supports:

✔ Online monitoring
✔ Online editing
✔ Diagnostics

These functions require network communication between PC and PLC.

How IEC 61131-3 Supports Communication Networks

IEC 61131-3 defines data types and structures which are essential for communication:

Standard Data Types

 BOOL, INT, REAL, BYTE, WORD, DWORD, STRING

Derived Data Types

 ARRAY, STRUCT, ENUM

These types allow consistent data exchange across devices and systems.

IEC 61131-3 Communication Concepts

1. Configuration & Resource Model

IEC 61131-3 defines a hierarchy:

Configuration
└─ Resource (CPU)
└─ Task
└─ Program
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

This structure helps in:

 Defining distributed control systems


 Assigning tasks to different PLCs
 Scheduling and synchronization

2. Tasks for Deterministic Control

Tasks are used to define:

 Periodic execution
 Event-based execution

In a networked system, tasks may depend on data received from other PLCs.

3. Standardized Program Organization Units (POUs)

IEC 61131-3 uses:

 Programs
 Function Blocks
 Functions

These POUs can be reused across different PLCs in a network.

Communication in IEC 61131-3 Systems (Practical)

Example: Data Exchange between PLCs

A PLC can send:

 Status data (BOOL, INT, REAL)


 Sensor values
 Control commands

to another PLC using:

 Ethernet/IP, Profinet, Modbus, OPC UA (not defined by IEC 61131-3 but supported by
PLC vendors)

Important Note

IEC 61131-3 does not define specific network protocols (like Modbus, Profinet, etc.).
Instead, it provides:

✔ Standard programming structures


✔ Data types

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

✔ Program organization
✔ Execution model

which enable easy integration with communication networks.

Summary Table
Requirement IEC 61131-3 Support

Distributed control Configuration/Resource model

Data exchange Standard data types & structures

Synchronization Tasks and event-driven execution

Remote monitoring Online monitoring & debugging

Interoperability Standard POUs & data formats

2.10 PLC to PC Communication in IEC 61131-3

IEC 61131-3 does not define network protocols, but it supports communication through:

✔ Standard data types


✔ Program Organization Units (POUs)
✔ Tasks and execution models
✔ Vendor-specific communication function blocks

So, PLC-to-PC communication is implemented using standard PLC programs defined in IEC
61131-3, but the network protocol is chosen by the PLC vendor (e.g., Modbus TCP, OPC UA,
Ethernet/IP).

How IEC 61131-3 Supports PLC to PC Communication


1 Standard Data Types

IEC 61131-3 provides standardized data types such as:

 BOOL, INT, REAL, STRING, etc.

These help in consistent data exchange between PLC and PC.

2 Program Organization Units (POUs)

PLC programs are built using:


Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 Program
 Function Block
 Function

Communication logic can be written as:

 Function Blocks (for communication)


 Functions (for data processing)

3 Tasks and Cyclic Execution

Communication tasks can be defined in IEC 61131-3 as:

 Periodic tasks (every 50 ms, 100 ms, etc.)


 Event-driven tasks (on change of data)

This ensures deterministic communication.

4 Data Exchange Mechanisms

Data transfer between PLC and PC is done using:

A) Shared Variables

 PLC variables can be mapped for external access


 PC reads/writes these variables

B) Communication Function Blocks

 Vendor-provided FBs for:


o Modbus TCP
o OPC UA
o Ethernet/IP
o Profinet

Typical Architecture
PLC (IEC 61131-3 Program)
|
Ethernet / Serial
|
PC (SCADA / HMI / Data Logger)

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Common Protocols Used

Even though IEC 61131-3 does not define protocols, these are commonly used:

Protocol Use

Modbus TCP Simple read/write registers

OPC UA Secure industrial data exchange

Ethernet/IP Allen-Bradley PLCs

Profinet Siemens PLCs

MQTT IIoT communication

Example: Using Modbus TCP in IEC 61131-3

PLC Side

 Define variables as holding registers


 Use Modbus TCP function block to send data

PC Side

 Use Modbus client (e.g., Python, SCADA) to read registers

Example: Using OPC UA in IEC 61131-3

PLC Side

 Define variables and expose them via OPC UA server


 Use IEC 61131-3 programs to update variables

PC Side

 Use OPC UA client software to read/write data

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

IEC 61131-3 Concepts Used for Communication


IEC 61131-3 Concept Role in Communication

Data Types Standardize variable formats

POU (Function Block) Encapsulate communication logic

Tasks Periodic or event-driven data exchange

Variables Shared or mapped for PC access

Typical Steps for PLC–PC Communication (IEC 61131-3)

Step 1: Define Variables


VAR_GLOBAL
Temp : REAL;
Pressure : REAL;
MotorStatus : BOOL;
END_VAR

Step 2: Create Communication FB


FB_ModbusTCP(Host := '[Link]', Port := 502);

Step 3: Map Variables to Protocol Registers

 Temp → Holding register 40001


 Pressure → Holding register 40002
 MotorStatus → Coil 00001

Step 4: Use Tasks

 Update data every 100 ms


 Read PC commands every 50 ms

Summary

IEC 61131-3 provides the programming framework, while communication protocols are
implemented using vendor-specific libraries and function blocks.

IEC 61131-3 supports PLC–PC communication through:

 Standard data types


 POUs (FBs, Functions)
 Tasks and cyclic execution
 Shared variables and mapping
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

2.11 FBD Equivalent to Ladder Logic (LL) in IEC 61131-3

Function Block Diagram (FBD) and Ladder Logic (LD) are both graphical programming
languages in IEC 61131-3.
Although they look different, many ladder logic circuits can be represented in FBD using logic
blocks and contacts.

Basic Equivalent Mapping


Ladder Logic (LL) FBD Equivalent

Series contacts (AND) AND block

Parallel contacts (OR) OR block

Normally Closed contact (NOT) NOT block

Output coil Output block

Timer Timer block (TON/TOF/TP)

Counter Counter block (CTU/CTD/CTUD)

Latch/Unlatch Set/Reset block

1) AND Logic (Series Contacts)

Ladder Logic
|--[ A ]--[ B ]--( Q )--|

FBD Equivalent
A ----| AND |---- Q
B ----|

2) OR Logic (Parallel Contacts)

Ladder Logic
|--[ A ]--------------( Q )--|
|--[ B ]--------------( Q )--|

FBD Equivalent
A ----| OR |---- Q
B ----| Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

3) NOT Logic (Normally Closed Contact)

Ladder Logic
|--[ /A ]--( Q )--|

FBD Equivalent
A ----| NOT |---- Q

4) AND + OR Combination

Ladder Logic
|--[ A ]--[ B ]--------------( Q )--|
|--[ C ]---------------------------|

FBD Equivalent
(A AND B) ----|
| OR |---- Q
C ------------|

5) Latching Circuit (Seal-in)

Ladder Logic
|--[ Start ]--( M )--|
|--[ M ]-------------|
|--[ Stop ]--( /M )--|

FBD Equivalent

Use SET/RESET block or RS Flip-flop

Start ----| SET |---- M


Stop ----| RESET |--- M

6)Timer (TON)

Ladder Logic
|--[ Start ]--( TON T1 )--|
|--[ T1.Q ]--( Motor )--|

FBD Equivalent
Start ----| TON |---- T1.Q ---- Motor

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

7) Counter (CTU)

Ladder Logic
|--[ Pulse ]--( CTU C1 )--|
|--[ C1.Q ]--( Output )--|

FBD Equivalent
Pulse ----| CTU |---- C1.Q ---- Output

General Rules for Conversion

Rule 1: Series Contacts = AND

 In FBD use AND block

Rule 2: Parallel Contacts = OR

 In FBD use OR block

Rule 3: NC Contact = NOT

 In FBD use NOT block

Rule 4: Coils = Output Blocks

 In FBD use Output variable

Example: Full Ladder to FBD Conversion

Ladder
|--[ A ]--[ B ]--( X )--|
|--[ C ]----------------|

FBD
A ----| AND |----|
B ----| | |
| OR |---- X
C --------------|

2.12 FBD Programming in IEC 61131-3

Function Block Diagram (FBD) is one of the five programming languages defined by IEC
61131-3 for PLC programming. FBD is a graphical language that represents control systems
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

using function blocks, connected with data flow paths. It is commonly used in process control
systems, automation, and industrial applications.

FBD Basics

 Function Blocks (FBs) are the building blocks of FBD programming. Each block
represents a specific function or operation.
 Connections (lines) represent the flow of data between blocks.
 Inputs and Outputs are the variables used to transfer data into and out of blocks.

Key Components:

1. Function Block (FB): Encapsulates a specific functionality (e.g., AND, OR, Timer,
Counter).
2. Variables (Inputs/Outputs): Inputs and outputs are the data associated with each
function block.
3. Connections: Lines that represent data flow, linking blocks together.

Basic FBD Elements

1. Function Block (FB)


o Example: A block that performs a mathematical operation or logical operation.
2. |---------|
3. | FB |
4. |---------|
5. | IN |
6. | OUT |
7. |---------|

8. Variables
o Inputs: Data coming into the function block.
o Outputs: Results produced by the function block.
9. Data Flow
o Arrows or lines are used to show how data flows between function blocks.

Basic FBD Programming Concepts

1) AND Function Block

 The AND block has multiple inputs and produces an output that is true when all inputs
are true.

FBD Representation:
A ----|
| AND |---- Q
B ----| Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 Q is TRUE only when A AND B are TRUE.

2) OR Function Block

 The OR block has multiple inputs and produces an output that is true if any one input is
true.

FBD Representation:
A ----|
| OR |---- Q
B ----|

 Q is TRUE if A OR B is TRUE.

3) NOT Function Block

 The NOT block inverts the input value.

FBD Representation:
A ----| NOT |---- Q

 Q is the opposite of A.

Timers and Counters in FBD

1) TON (Timer ON Delay)

 The TON (Timer ON Delay) function block starts counting when the input is TRUE.
After the preset time has passed, the output is set to TRUE.

FBD Representation:
Start ----| TON |---- Q
|
| T1

 T1 is the timer's internal value (time elapsed).


 Q is TRUE after the preset time T#10s (for example) when Start is TRUE.

2) CTU (Counter Up)

 The CTU (Counter Up) function block increments a counter each time the input signal
goes from FALSE to TRUE.

FBD Representation:
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Pulse ----| CTU |---- Q


|
| C1 (Counter)

 Q is TRUE when the counter C1 reaches the preset value.

Advanced FBD Example: Control System

Example: Motor Control System

In this example, we’ll use FBD to create a simple motor control system that starts and stops a
motor based on inputs:

 StartButton turns the motor on.


 StopButton turns the motor off.
 A Timer is used to delay the stop action.

FBD Representation:
StartButton ----|
| AND |---- Motor
StopButton ----|
| NOT |
|
Timer (TON)

 StartButton activates the AND block to turn the motor on.


 StopButton deactivates the motor after a delay via the NOT block and TON Timer.

Function Block Types in FBD

In IEC 61131-3, function blocks are used for many operations. Some common function blocks
include:

1) Mathematical Operations

 Add, Subtract, Multiply, Divide


 Example: SUM block adds multiple values.

2) Logical Operations

 AND, OR, NOT


 Example: XOR block performs an exclusive OR operation.

3) Timers

 TON (Timer ON Delay)


 TOF (Timer OFF Delay)
 TP (Pulse Timer) Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

4) Counters

 CTU (Counter Up)


 CTD (Counter Down)
 CTUD (Counter Up/Down)

FBD Programming Example

Let’s design a simple Start-Stop Motor Control using FBD.

Problem

 Motor should start when StartButton is pressed.


 Motor should stop after 10 seconds when StopButton is pressed.

FBD Diagram
StartButton ----|
| AND |---- Motor
StopButton ----|
| NOT |
|
Timer (TON)

 StartButton turns the motor ON.


 StopButton waits for 10 seconds before turning the motor OFF using the TON Timer.

FBD Programming Summary


Concept FBD Component Description

AND
AND block Logic is true when all inputs are true.
Operation

OR Operation OR block Logic is true when at least one input is true.

NOT
NOT block Inverts the input signal.
Operation

TON (Timer ON
Timer (TON) Delays the output when the input is true.
Delay)

Counts the number of pulses and triggers an output when a preset


Counter (CTU) CTU (Counter Up)
value is reached.

Set/Reset Set and Reset


Used for latched or sticky outputs.
Latch blocks

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

2.13 Instruction List (IL) in IEC 61131-3

Instruction List (IL) is one of the five programming languages defined in IEC 61131-3 for
PLC programming.
It is a low-level textual language, similar to assembly language, designed for simple and fast
PLC programs.

Note:
IL is deprecated in later versions of IEC 61131-3 and many modern PLCs do not support it.
However, it is still important for understanding older PLC programs and exam purposes.

Key Features of IL

✅ Text-based (assembly-like)
✅ Compact and fast execution
✅ Suitable for simple logic
✅ Often used in older PLCs

Basic Structure of IL Program

IL program consists of:

 Instructions
 Operands (variables)
 Labels
 Comments

Common IL Instructions
Instruction Meaning

LD Load a value
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Instruction Meaning

LDI Load inverted value (NOT)

AND Logical AND

OR Logical OR

ANDN AND with NOT

ORN OR with NOT

ST Store result

STN Store inverted result

SET Set bit (latch)

RST Reset bit

NOT Invert

ADD Addition

SUB Subtraction

MUL Multiply

DIV Divide

TON Timer ON delay

CTU Counter Up

Example IL Program (Start-Stop Motor)

Problem

Motor starts when Start button is pressed and stops when Stop button is pressed.

IL Code
LD Start
ANDN Stop
ST Motor

Explanation

 LD Start → Load Start input


Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

 ANDN Stop → AND with NOT Stop (Stop is normally closed)


 ST Motor → Store result in Motor output

IL Instructions (Detailed)

1) Load Instructions

Instruction Meaning

LD Load input to accumulator

LDI Load inverted input

2) Logical Instructions

Instruction Meaning

AND AND operation

OR OR operation

ANDN AND with NOT

ORN OR with NOT

NOT Invert the accumulator

3) Store Instructions

Instruction Meaning

ST Store accumulator to output

STN Store inverted accumulator

4) Set / Reset

Instruction Meaning

SET Latch output

RST Reset output Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Instruction Meaning

Example: Latching (Seal-in) in IL

Problem

Motor should latch ON after Start pressed and turn OFF on Stop.

IL Code
LD Start
SET Motor
LD Stop
RST Motor

Advantages of IL

✅ Simple and fast


✅ Compact code
✅ Easy for small programs

Disadvantages of IL

❌ Hard to read for complex logic


❌ Not user-friendly
❌ Deprecated in modern PLCs
❌ Less maintainable

IL vs Ladder Diagram
Ladder Diagram Instruction List

Graphical Textual

Easy to understand Faster to write for experts

Used by electricians Used by programmers

Better for complex systems Hard for large programs


Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Ladder Diagram Instruction List

2.14 Sequential Function Chart (SFC) in IEC 61131-3

Sequential Function Chart (SFC) is one of the five programming languages defined in IEC
61131-3.
It is a graphical language used for sequential control systems, where processes occur in steps
and transitions.

SFC is ideal for:

✔ Batch processes
✔ Start-up and shutdown sequences
✔ Step-by-step operations
✔ Process control with multiple states

Key Components of SFC

1 Steps

 Represent states or stages of a process.


 A step can be active or inactive.
 Each step can execute one or more actions.

2 Transitions

 Connect steps.
 Each transition has a condition.
 When the condition is TRUE, the active step transfers control to the next step.

3 Actions

 Actions are executed when the step is active.


 Can be continuous or one-shot.

SFC Structure
Step 1 --[Transition 1]--> Step
Downloaded 2 --[Transition
by Gowtham 2]--> Step 3
Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Types of Actions
Action Type Description

N (Normally) Continuous action while step is active

S (Set) Set output when step becomes active

R (Reset) Reset output when step becomes inactive

P (Pulse) Pulse output once when step becomes active

T (Toggle) Toggle output on step activation

How SFC Works (Basic Operation)

1. Initial step is activated


2. Actions of active step execute
3. Transition condition is checked
4. If TRUE → next step becomes active
5. Repeat until final step

Example: Simple Conveyor Control

Objective

Conveyor starts, runs for 10 seconds, then stops.

SFC Diagram
[Step 1: Start Conveyor]
|
[T1: StartButton]
|
[Step 2: Conveyor Running]
|
[T2: Timer Done]
|
[Step 3: Stop Conveyor]

Explanation Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

 Step 1: Wait for Start button


 Transition 1: When Start button pressed → Step 2 activates
 Step 2: Conveyor runs and timer starts
 Transition 2: After timer completes → Step 3 activates
 Step 3: Conveyor stops

SFC Example in IEC 61131-3

Step Actions (Pseudo Code)


Step1: // Waiting state
Conveyor := FALSE;

Step2: // Running state


Conveyor := TRUE;
Timer(IN := TRUE, PT := T#10s);

Transition2:
IF Timer.Q THEN
Step2 := FALSE;
Step3 := TRUE;
END_IF;

Advantages of SFC

✅ Easy to visualize sequential processes


✅ Ideal for batch and process control
✅ Supports parallel branches
✅ Easy to maintain and modify
✅ Clear representation of states

Applications of SFC

 Chemical batch processes


 Packaging systems
 Start-up and shutdown sequences
 Complex state machines
 Multi-stage manufacturing processes

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

SFC vs Ladder Diagram


SFC Ladder Diagram

Sequential control Relay logic control

State-based Logic-based

Good for batch processes Good for continuous control

✅ Summary Table
Component Meaning

Step State of the process

Transition Condition to move to next step

Action Operation performed during step

Initial Step Starting point

Final Step End of sequence

2.15 Structured Text (ST) in IEC 61131-3

Structured Text (ST) is one of the five programming languages defined by IEC 61131-3.
It is a high-level textual language, similar to Pascal or C, used for complex algorithms, math
operations, data handling, and structured programming.

ST is widely used in:

✔ Process control
✔ Motion control
✔ Data manipulation
✔ Complex logic
✔ PID control

Key Features of Structured Text

✅ High-level language
✅ Easy for complex calculations
✅ Supports loops, conditions, arrays, structures
✅ Best for algorithm-based programming
✅ Very readable for programmers

Downloaded by Gowtham Raj (gowthamtb2004@[Link])


lOMoARcPSD|65740826

Basic Syntax of ST

Variable Declaration
VAR
A : INT;
B : REAL;
Motor : BOOL;
END_VAR

Basic Operations in ST

1) Assignment
A := 10;
B := 3.14;
Motor := TRUE;

2) IF-ELSE Statement
IF Start AND NOT Stop THEN
Motor := TRUE;
ELSE
Motor := FALSE;
END_IF;

3) CASE Statement
CASE Mode OF
0: Motor := FALSE;
1: Motor := TRUE;
2: Motor := NOT Motor;
ELSE
Motor := FALSE;
END_CASE;

4) FOR Loop
FOR i := 1 TO 10 DO
Sum := Sum + i;
END_FOR;

5) WHILE Loop
WHILE A < 10 DO
A := A + 1;
END_WHILE;
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Functions and Function Blocks in ST

Function

A reusable code block that returns a value.

FUNCTION Add : INT


VAR_INPUT
X : INT;
Y : INT;
END_VAR
Add := X + Y;
END_FUNCTION

Function Block

A reusable block with internal memory (state).

FUNCTION_BLOCK FB_Latch
VAR_INPUT
Set : BOOL;
Reset : BOOL;
END_VAR
VAR_OUTPUT
Q : BOOL;
END_VAR

IF Set THEN
Q := TRUE;
ELSIF Reset THEN
Q := FALSE;
END_IF;
END_FUNCTION_BLOCK

Timers and Counters in ST

TON Timer
TON(Timer := Start, PT := T#5s);
IF Timer.Q THEN
Motor := TRUE;
END_IF;

Counter
IF Pulse THEN
Count := Count + 1;
END_IF;

Example Program (Start-Stop Motor)


IF Start AND NOT Stop THEN
Downloaded by Gowtham Raj (gowthamtb2004@[Link])
lOMoARcPSD|65740826

Motor := TRUE;
ELSE
Motor := FALSE;
END_IF;

Advantages of ST

✅ Better for complex algorithms


✅ Supports structured programming
✅ Easy to maintain
✅ Better for data handling

Applications

 PID control
 Complex math operations
 Data processing
 Batch control
 Motion control

Summary
Feature Description

Language Type High-level textual

Similar to Pascal / C

Best for Complex logic and math

Supports Loops, arrays, functions, structures

Part of IEC 61131-3 standard

Downloaded by Gowtham Raj (gowthamtb2004@[Link])

You might also like