Note-11 - Structural Programming (Ob, FC, Dan FBD)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

NOTE-11 PLC

STRUCTURAL PROGRAMMING (
OB, FC, DAN FBD)
Aulia El Hakim, S.ST.,M.T
PURPOSE
• Pembahasan Soal Counter !
• Memahami konsep STRUCTURAL PROGRAMMING ( OB, FC, DAN FBD)
OUTLINE

Pembahasan Soal Counter

STRUCTURAL PROGRAMMING ( OB, FC, DAN FBD)


HARDWARE PLC SIEMENS S7-300
MODUL Tipe ID Number
Power Supply ( PS) PS 307 2A 307-1BA01-0AA0
CPU CPU315-2DP 315-2AH14-0AB0
Digital input (DI) DI 16 X DC24 V 321-1BH02-0AA0
Digital Output (DO) DO 16XDC24V / 0.5A 322-1BH01-0AA0
Analaog Input (AI) AI 2X12BIT 331-7KB02-0AB0
Analaog Output (AO) AO 2X12BIT 332-5HB01-0AB0
Operation of CTU (count up)
Operation of CTD (count down)
Operation of CTUD (count up and down)
TUGAS
• A crate shall be immersed into the pool three times with a pneumatic system for washing
the parts.
• Chest after each landing, 3 sec. and the third after this time the cylinder will go up and end
the washing process.
• Pressing the Start button again will start a new cycle.
• A lamp will light as long as the system is operating

Symbol Operand Type Description

Start I 0.1 BOOL Start button (S1)

Crate_ below I 0.2 BOOL Below The Crate


limit switch (S2)
Crate_above I 0.3 BOOL Above The Crate
limit switch (S3)
crate_down Q 0.1 BOOL Crate down (Y1)

crate_ up Q 0.2 BOOL Crate up (Y2)

Lamp Q 0.3 BOOL Working light (H1)


solusi
STRUCTURAL PROGRAMMING ;
PURPOSE;
1-By dividing the project into logical small parts; makes it easy to write programs, follow the program, and
search for errors.
2- Reduces program memory by storing the fixed values to be used in the program outside the program area
and allows you to change those values without entering the program if necessary.
3-It allows the same program to be used in large numbers with different variables.
4- There is the possibility of using some programs that are offered by the PLC manufacturer company and
required by the standards.
STRUCTURAL PROGRAMMING ;

• Why We Use Structural Programming?


• Because it gives us some advantages when writing programs
Blocks used in structural programming;
1- Program blocks
- Organization blocks (OB ...)
- Functions (FC ...)
- Function blocks (FB ...)
2- Data blocks
- General data blocks (DB ...)
- Special data blocks (DI ...)
- User-defined data blocks (UDT ...)
3- System blocks
USING SUB-PROGRAMS

As you know, PLCs work in two ways in terms of program processing.


Linear and structural program processing.
The programs we have done so far have been run with linear logic.
In other words, the entire program was written into OB1 (MAIN) and orders
were executed one after the other.
STRUCTURAL PROGRAMMING

The first part of structural programming is not very different from linear programming.
In this method, the sections that make up the program and which we will accept as logical parts are
written as subprograms and in turn, another program block (OB1) or another subprogram called FC .., FB .
STRUCTURAL PROGRAMMING

The program and data blocks added to the project can be opened by double-
clicking in the ister Project view ” or “ Portal view ” windows.
Projeye eklenen program ve data blokları ister “Project view” ister “Portal view” pencerelerinde çift tıklanarak açılabilir.

At this stage, we will talk about the applications of “Function” (FC) s. We will
explain the use of Block Function Block ”(FB) and“ Data Block ”(DB) later.
Biz şu aşamada “Function” (FC) ların kullanıma ait uygulamalardan bahsedeceğiz. “Function Block” (FB) ve “Data Block” (DB) kullanımını daha sonra anlatacağız.

Because the use of data blocks is very different from the program blocks and is used in Function Blocks by associating
them with data blocks.
Çünkü “Data blok”larının kullanımı program bloklarından çok farklıdır ve “Function Block” larda data bloklarla ilişkilendirilerek kullanılır.
STRUCTURAL PROGRAMMING
If the subprograms are desired, the required
subprogram is executed when the program processing
sequence is on that line or if a desired condition is
fulfilled.

At the end of the sub-program, it is returned to the


place where it was called and the program is resume
ADD NEW FUNCTION BLOCK (PROJECT VIEW)
ADD NEW FUNCTION BLOCK (PROJECT VIEW)
ADD NEW FUNCTION BLOCK (PROJECT VIEW)
DATA Block
USING DATA BLOCKS

These are the memory areas used to store the


intermediate results that occur during the execution of
the program and the fixed values to be used in the
system.

Unlike program blocks (OBs, FCs, FBs), data blocks do


not contain program statements in any way, they only
contain fixed data. (For example, temperature and
pressure values of the boiler measured and recorded
during the day, etc.)
USING DATA BLOCKS
USING DATA BLOCKS
Example-2 AC Asynchronous motor start and stop circuit
If many asynchronous motors will make start stop motion How do we do it ?
For example, we have five engines Do we write five times ?

Power and control connection PLC cable Connection


PARAMETERIZATION OF SUB-PROGRAMS
Parameterization of functions (FC ..) or Parameterization of function blocks (FB ..)

One of the advantages of structural programming is


that it allows us to write programs with formal
operands (the functionality of the program can be
parameterized).
The program is written once with local symbols and is
called with which variables to work with.

If many asynchronous motors will make start


stop motion

If several asynchronous motors are to move


forward and backward
START_ STOP PARAMETERIZATION OF SUB-PROGRAMS
ADD NEW FUNCTION BLOCK
If many asynchronous motors will
make start stop motion
START_ STOP PARAMETERIZATION OF SUB-PROGRAMS
START_ STOP PARAMETERIZATION OF SUB-PROGRAMS
START_ STOP PARAMETERIZATION OF SUB-PROGRAMS

As it is known, in programs, the symbol assigned to the address


is called ”tag”, if the symbol is defined in the ”tag” table, it is
called “Global symbol“. And is seen between the marks ‘’….’’
within the program.

If the variable is defined in the declaration table of the program


block (OB, FC, FB), it is called sembol Local symbol ”. Local
symbols are also used in the function box in the program block
where the function is called with the sign “# ....” during the
function writing.
START_ STOP PARAMETERIZATION OF SUB-PROGRAMS
START_ STOP PARAMETERIZATION OF SUB-PROGRAMS
PARAMETERIZATION OF SUB-PROGRAMS Parameterization of function blocks (FB ..)
The functions (FC ..) do not have memories and the processed information in them is lost as soon as the function (FC) is abandoned.

The parameterization of FCs into a program and the


functionalization of FBs are similar.
There are small differences in calling FBs because they
are associated with a data block.
Each data defined in the FB declaration table is saved
to the data block in the same way.
Therefore, the FB declaration table conforms to the
data block structure.
It has data block parameters such as “Default value”
and “Retain..
PARAMETERIZATION OF SUB-PROGRAMS Parameterization of function blocks (FB ..)

The FB Declaration table parameters include the


Static parameter, which is not in the FC.
This parameter; For function blocks, they are local
data stored in special data blocks and stored until the
next run.
Since the data is saved to a different data block area
each time the FB is called, there is no problem in
using the FB too many times
FB With static storage Fc Does not have static storage
PARAMETERIZATION OF SUB-PROGRAMS Parameterization of function blocks (FB ..)
PARAMETERIZATION OF SUB-PROGRAMS Parameterization of function blocks (FB ..)

As in the case of FC, a data block association window opens when the parameterized FB is imported into the program area.

The name given to FB is automatically assigned to the data block to be associated, and can be changed if desired.
PARAMETERIZATION OF SUB-PROGRAMS Parameterization of function blocks (FB ..)
PARAMETERIZATION OF SUB-PROGRAMS Parameterization of function blocks (FB ..)

Using a multi-instance data block


Every function block (FB) we use in our project wants to associate
time and counting functions with a data block.
This leads to an increase in the number of data blocks in the project.
To prevent this, the FBs can be called up in a separate function block
(FB), with time and counting functions, and the parameters can be
collected in a single data block.

You might also like