You are on page 1of 6

31-May-21

PLC
Lecture 4 : Block types and Introduction to PLC programming
Instructor :
Yusuf Abdul-Rahman
MSc in Control Engineering
usfece@gmail.com
00967-739757628

Blocks in PLC devices (Siemens)


Siemens PLCs ( S7 versions ) provides three categories of Blocks in their programming
environment from which the user program may be developed. These three categories are:

1. User-blocks are S7-blocks that you are able to create and insert program and data.

2. System blocks are blocks integrated as a part of the S7 PLC operating system.

3. Standard blocks support applications such as PID control and communication drivers. Several
groups of Standard blocks are supplied as libraries with step7 while other may be purchased
separately.

1
31-May-21

Block types
There are several types of blocks we can use within an S7 user program these are: System blocks
( SFC, SFB, SDB ), Organization blocks OB, Data blocks DB, Function blocks FB , and Functions FC.

Organization blocks OB : Represent the interface between the operating system and the user
program. They are where you can write the main program. They have specific numbers from OB1
to OBn . Some are used for specific interrupts. An important note is that each group of OBs have
certain priority classes. When create a new project using PLCs programming environment ( such
as; SIMATIC manager ) you will notice that OB1 is created automatically and you can create others
of you need to.

Cont.
Data blocks DB : DBs are areas for storing user data. There are two types of DBs in S7 PLCs :
 Shared DB (Global DB) which is used to store data that may be read from or written to by any block

 Instance DB is a data block assigned to specific Function Block as a required memory . The specific FB
has read/write access to the instance FB.

2
31-May-21

Cont.
Function blocks FB : FBs belong to the blocks that you program yourself. A FB is a block with
memory. The parameters that are transferred to the FB and the static variable are saved in
instance DB. A FB contains a program that is always executed whenever the FB is called by
different logic block.

Functions FC : FCs belong to the blocks that you program yourself. A FC is a logic block without
memory. The temporary variables belonging to the FC are saved in local data stack and this data
will be lost when the FC is executed.

Cont.
Call Shared DB Call Instance DB
OB1 OB1
FC FB DB
Return DB Return Execute
Execute
Shared DB
The temporary data will be lost after execution
DB

The temporary data will NOT be lost after execution

3
31-May-21

Advantages of using Blocks in PLC programming


1. Ease to understand the long programs.

2. Organizing the program

3. Ease to edit programs

4. Ease to diagnoses the errors as long as we can check each block individually

For fresh PLC programmers, you might not see these as advantages but additional complexity to
PLC programming, this is not true though.

FC vs FB
Both blocks can be mainly used to:
• Divide and organize the user program.
• Rationalize the programming.
• Optimize the programming.

Differences

FC FB
Does Not need instance DB for need instance DB for each call
each call

Can be called from FC,OB or FB Can be called from FC,OB or FB

4
31-May-21

What is a PLC program ?


Program
The PLC program describes how the signals from the
momentary (fast) contact switches are logically linked to Organization
Block OB
the outputs. Each program consists of organization
blocks (OBs) which is set by default to OB1 and this OB
Instructions
consists of instructions by which the CPU executes any
electrical control system . This program has can be Instructions
represented using many programming languages.

Programming languages
PLC programs can be written using five most common programming languages according to
International Electrotechnical Commissions IEC :

1. Function Block Diagrams FBD : It describes the functions between the input and ouput
using graphical blocks ( simple blocks are similar to Logic gates )

2. Sequential Function Charts SFC : it describes the function between input and outputs using
steps and transitions ( similar to Flow chart )

3. Logic Ladder Diagram LLD (LD) : it comes from the relay-logic, so it is close to classic control.
It uses networks which consist of open and close contact to energize or de-energize coils.

5
31-May-21

Cont.
4. Structured Text Language STL: It is a high level language which uses texts to describe the
function between the input and output. It is similar to C language.

5. Instruction List IL: it is similar to assembly language.

You can read more about each language mentioned above but in this course we will be
discussing our examples using Ladder Logic Diagram LLD.

Basic examples
if we want to write a PLC program to turn on an indicator using two switches which must be
pressed together in the same time.

Using FBD Using STL Using LD

You might also like