Lecture 4-PLC Basics Programming New
Lecture 4-PLC Basics Programming New
1
Contents
2
PLC Programming
Languages
In general, the known standard languages for PLC S7-1200/1500 are as follows
LAD-LADDER is a graphical programming language. The representation is based on circuit diagrams
FBD-Function Block Diagram is a graphical depiction of process flow using simple and complex
interconnecting blocks used in Boolean algebra
SCL-Structure Language Control is a high level, Pascal-based programming language. SCL
instructions use standard programming operators such as assignment (), mathematical functions ( for
addition, for subtraction, for multiplication, and for division)
o Example:
4
Boolean Constants &
Operations
5
Boolean Algebra
The mathematical study of the binary number system and logic is called Boolean algebra
Boolean algebra is a means for expressing the relationship between a logic circuit’s inputs and
outputs.
The inputs are considered logic variables whose logic levels at any time determine the output levels
The Boolean equations are used to express the mathematical function of the logic gate
A logic gate is a circuit with several inputs but only one output that is activated by particular
combinations of input conditions
The two-state binary concept, applied to gates, can be the basis for making decisions
The purpose of this algebra is to provide a simple way of writing complicated combinations of
logic statements
There are many applications where Boolean algebra could be applied to solving PLC
6
Boolean Algebra
Commutative law:
Associate Law:
(
Distributive Law:
Relationship between basic operators of Boolean algebra to the basic AND, OR, and NOT functions
7
Circuit design based
Boolean expression
𝑌 = 𝐴 . 𝐵 +𝐶 𝑌 =( 𝐵 . 𝐶 + 𝐷 ). 𝐴
8
Truth Table
A truth table is a means for describing how a logic circuit’s output depends on the logic levels
present at the circuit’s inputs
A x y z
?
Y
B 0 0 0
0 1 0
1 0 0
1 1 1
9
AND, OR, & NOT
x y z
0 0 0
0 1 1 x z
1 0 1 0 1
1 1 1 1 0
z=x•y=xy z=x+y z = x = x’
x z
y x z
y x z
10
Universal Logic Gates
NAND Logic Gate: NOR Logic gate:
If all inputs are TRUE, the output turns If all inputs are FALSE, output becomes TRUE;
FALSE; otherwise, the output is TRUE otherwise, the output is FALSE
11
Combinational Logic
Circuits Design
Sum of Products (SOP): ;
Product of Sums (POS):
Notes: SOP can be converted to POS via De Morgan’s Theorems and vice versa
Design of Combinational Logic Circuits is based on two approaches: Algebraic Simplification
and Karnaugh Map (K-Map) Method
By Algebraic Simplification, simplify the expression
Solution:
By K-map method, K-map’s format and simplification rule (based on adjacent cells) are used
12
Combinational Logic
Circuits Design
13
Combinational Logic
Circuits Design
K-map Simplification rule:
Place 1s in the squares corresponding to the 1s in truth
table; place 0s in the other squares.
Examine the map for adjacent 1s and loop those 1s which
are not adjacent to any other 1s (called as isolated 1s)
Next, look for those 1s which are adjacent to only one
other 1. Loop any pair containing such a 1.
Loop any octet even if it contains some 1s that have
already been looped.
Loop any quad that contains one or more 1s that have are
not already been looped, making sure to use the
minimum numbers of loops.
Loop any pair necessary to include any 1s that have not
yet been looped, making sure to use the minimum
numbers of loops.
Form the OR sum of all the term generated by each loop.
14
Hardwired Logic vs
Programmed Logic
Hardwired logic refers to logic control functions that are determined by the way devices are
electrically interconnected.
Implemented by relays and relay ladder schematics (used in industry)
Hardwired logic is fixed and changeable only by altering the way devices are electrically
interconnected
Programmable control is based on the basic logic functions and easily changed
Functions AND, OR, and NOT are used either singly or in combinations to form instructions that will
determine if a device is to be switched on or off
The form in which these instructions are implemented to conveys to the PLC is called the language
The most common PLC language is ladder logic
15
Hardwired Logic vs
Programmed Logic
16
PLC Ladder Logic
Ladder-logic program is similar to the line diagram used in
hardwired relay control system
Two vertical bars representing L1 and L2 span the entire
A contact symbol A coil symbol
diagram are called the power/voltage bus bars
PLC contact symbolism is a simple way of expressing the
control logic in terms of symbols
A rung is the contact symbolism required to control an output
A complete ladder logic program consists of several rungs
Each rung is a combination of input conditions (symbols) connected
from left to right with the symbol that represents the output at the
far right
17
PLC Ladder Logic
Control circuit for a ladder-logic program rung
composes of three basic sections: the signal, the
decision, and the action
The PLC input module scans the input signals and the
CPU executes the ladder-logic program in relation to the
A ladder diagram logic
input status and makes a decision network/rung
The output module updates and drives all output devices
In a ladder-logic network,
Every instruction is examined if TRUE (note: assigned to
the value of 1)
If TRUE, continuity of the rung is maintained or power
An example of ladder-logic network
flow is maintained 18
NO and NC
Normally Open Contact (NO)
Closed (ON) when the assigned bit value in memory
is equal to 1
Normally Closed Contact (NC)
Open (ON) when the assigned bit value in memory
is equal to 0
Observations:
1. When switch SS1 is opened, the instruction NC in the
PLC network is TRUE, the power flows through the
network (solid line)
2. The switch SS1 is in closed position, NC instruction is
FALSE, the power does not flow through the network
19
Output coil
The output-coil instruction writes a value for an output bit in the PLC memory based on the
power flow status preceding the instruction
The output signals for the associated control actuators are wired to the output coil terminals
Coils are assigned unique memory bit addresses (no two coils can have the same address except
for the set reset (SR) instruction)
Memory bit associated with the coil instruction is updated every scan of the ladder as follows:
If the output-coil memory bit is set to 1, power flows through that output coil
If the output coil memory bit is set to 0, power will not flow through that output coil
20
Hardwire connection &
Instruction Status
21
Summary
Common Languages for PLC S7-1200: LAD-LADDER, FBD-Function Block Diagram, SCL-
Structure Language Control
The PLC operates on the binary principle (refers to the thought of as existing in only one of two
states “0” and “1”) and depends on logic (binary logic)
A combinational circuit can be designed based on Boolean Algebra and logic gates AND, OR,
NOT and Universal gates NAND, NOR,…
Hardwired logic refers to logic control functions that are determined by the way devices are
electrically interconnected.
Programmable control is based on the basic logic functions and easily changed
Normally Open Contact (NO):Closed (ON) when the assigned bit value in memory is equal to 1
Normally Closed Contact (NC): Open (ON) when the assigned bit value in memory is equal to 0
The output-coil instruction writes a value for an output bit in the PLC memory 22