Pro2 08e SFC SFB PDF

September 15, 2022 | Author: Anonymous | Category: N/A
Share Embed Donate


Short Description

Download Pro2 08e SFC SFB PDF...

Description

 

Using System Blocks

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

18.09.2009 PRO2_08E.1

Co n t en t s

SITRAIN Training for   Automation and Industrial So Solutions lutions

Pag e

Objectives Object ives ........... ................ .......... ........... ............ ........... .......... .......... .......... ........... ............ ............ ........... .......... ........... ........... .......... ........... ............ ........... ......... ......... ........... .......... ......... .....

2

Intere Interesti sting ng Facts Facts abo about ut Lib Librar raries ies ...... ......... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ..... .. Design Desig n and Conte Contents nts of the Standard Standard Library Library ........... ................ .......... .......... .......... ........... ........... .......... .......... .......... .......... .......... ........... ............ .......... .... Interesting Intere sting Facts about Syste System m Functions Functions ........... ................ .......... ........... ........... .......... .......... .......... .......... .......... ........... ............ ............ ............ ........... ..... Overview Overv iew of the System System Functions Functions (Exc (Excerpt) erpt) ........... ................ ........... ........... ........... ........... .......... ........... ........... .......... ........... ............ ............ .......... ....... ... System Sys tem Functi Functions ons tthat hat E Exis xistt in th the e CPU ...... ......... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ..... .. Call of System Functions and System Function Blocks .................................................................. ..................................................................

3 4 5 6 7 8

Example: Exam ple: "READ "READ_CLK" _CLK" (SFC 1)

9

............ ................. .......... .......... ........... ............ ........... ........... ........... ........... ........... ........... ........... .......... ........... ............ ........... ......... ....

TIME_OF_DAY and DATE_AND_TIME Data Types

...................................... ........................................................................ ..................................

10

Example: Exam ple: "BLKMOV "BLKMOV"" (SFC 20) ...... ........... .......... .......... ........... ........... .......... ........... ........... .......... ........... ........... .......... ........... ............ ............ ............ ........... .......... ........ ...  Assignment of Parameters of the ANY Data Type ..................................... ........................................................................... ......................................  Analyzing an Error Message ….................................................................................... …....................................................................................................... ...................

11 12 13

Exercise Exerc ise 1: Recordi Recording ng the the T Time ime Stam Stamp pw with ith SFC 1

...... ........... .......... .......... ........... ........... .......... ........... ............ ........... .......... ........... ............ ......... ...

14

........... ................ .......... .......... ........... ............ ........... .......... .......... ........... ........... .......... ........... ............ ............ ........... ....... ..

15

........... ................ .......... .......... ........... ............ ........... .......... .......... ........... ............ ........... ........... ........... .......... .......... ........... ........... .......... ....... ..

16

 Additional Exercise: Specified Time Time Relay ................................................................................. ...................................................................................... ..... The Librar Library: y: TITI-S7 S7 Conver Convertin ting g Blo Blocks cks (Excer (Excerpt) pt) ...... ......... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ... The Library: Library: IEC Function Function Blocks Blocks (Exce (Excerpt) rpt) ........... ................. ........... ........... ........... .......... ........... ............ ........... .......... .......... .......... ........... ........... ........ ...

17 18 19

The Library: Library: Com Commun munica icatio tion n Blo Blocks cks

...... ......... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... .....

20

...... ......... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ..... ..

21

Exercise Exerc ise 2: Data Backu Backup pw with ith SFC 20 If You Want to Know More

The Librar Library: y: PID Contro Controll Blocks Blocks

The Library Library:: Miscel Miscellan laneou eous s Blocks Blocks (Ex (Excer cerpt) pt)

SITRAIN Training for   Automation and Industrial Solutions

...... ......... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... .....

Pag age e1

22

ST-PRO2 Using System System Blocks Blocks

 

Objectives Upon completion of this chapte chapterr the participant will ...

...

be famil familia iarr wit with h tthe he stand standar ard d llib ibra rari ries es an and d tthe heir ir usage usage,,

...

be ab able le to inte integr grat ate e blo blocks cks fr from om the libr librar ary y iin n a us user er pr prog ogra ram m

...

be ab able le to inte interp rpre rett the the err error or nu numb mber ers s of th the e par param amete eterr "RE "RET_ T_VA VAL L"

SIMATIC S7 Siemens AG 2008. All rights reserved. reserved.

SITRAIN Training for   Automation and Industrial Solutions

Date: File:

18.09.2009 PRO2_08E.2

Pag age e2

SITRAIN Training for   Automation and Industrial So Solutions lutions

ST-PRO2 Using System System Blocks Blocks

 

Interestin Intere stin g Fa Facts cts abou t Lib raries  Are  A rea a of o f Us e:

 

Storage of reusable program components



It is not possible to d irectly transfer into t he CPU CPU and and test

Library Structure:

 

 A l ib rar y may co nt ain sev eral pr og ram fo ld ers



 A l ib rar y m ay n ot co nt ain any " Hard w are"



Each Ea ch p rogram folder c ontains:  the folders "Blocks", "Sources", "Symbols"  the folder "Charts" (only for the option software: S7-CFC)

Using Libraries:

 

With the SIMATIC Manager you can:  create libraries (not with the same names as projects)  copy Blocks and Sources between libraries and projects  archive libraries



With t he LAD/FBD/S LAD/FBD/STL TL Editor you can  store network templates in libraries as Sources and then reuse them whenever you need

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

Overview

18.09.2009 PRO2_08E.3

SITRAIN Training for   Automation and Industrial So Solutions lutions

Libraries are used to store reusable program components for the SIMATIC S7. The program components can be copied into a library from existing projects or they can be created directly in the library regardless of the projects. For the creation of S7 programs in a library, you have the same functions as for projects projec ts – with the excep exception tion of testi testing. ng.

Design

Just as for projects, libraries have a hierarchical design: •

Libra Librari ries es can can con conta tain in S S7 7 prog progra rams ms..



An S7 S7 prog progra ram m ca can n have have exac exactl tly y on one e Blocks folder, one Sources folder, one Charts folder as well as one Symbols object (symbol table).



The Blocks folder contains the blocks that can be downloaded to the S7 CPU. The contained variable tables (VAT) and user-defined data types (UDT) are not downloaded to the CPU. The Sources folder contains the sources for the programs created in the diverse programming languages.

• •

The Charts folder contains the CFC Charts (only for the option software S7-CFC)

When you insert a new S7 program, one Blocks and one Sources folder each as well as one Symbols object is automatically created in it. Using Libraries Libraries

Blocks that are to be used again and again can be stored in libraries. From there, you can copy them into the appropriate user program and they can be called by other blocks.

SITRAIN Training for   Automation and Industrial Solutions

Pag age e3

ST-PRO2 Using System System Blocks Blocks

 

Design De sign and Contents of the Standa Standard rd Li brary

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

SITRAIN Training for   Automation and Industrial So Solutions lutions

18.09.2009 PRO2_08E.4

Introduction

When you install the STEP 7 software, a standard library with the name "Standard Library" is automatically installed on the hard drive.

Opening the Library

To open a library, you either use the command: File   Open or the appropriate icon in the toolbar. Then, a further dialog pops up in which you can select the desired project, library or sample project.

Standard Library

The Standard Library contains the following S7 program p rogram folders: •

Communicat Communication ion Blocks: Blocks: contains contains the the functions functions for connect connecting ing to to dist distribute ributed d peripherals when using an S7-300 PROFIBUS CP,



IEC Functi Function on Blocks: Blocks: c contai ontains ns blocks blocks for IEC functio functions ns such such as, for for handling handling the data types DATE_AND_TIM DATE_AND_TIME E and STRING, Miscellane Miscellaneous ous Blocks Blocks:: contains contains blocks for the the time time st stampin amping g of messag messages es and for time of day synchronization,

• •

Organization Organization Bloc Blocks: ks: con contain tain all all OBs OBs with the the symbolic symbolic identi identifiers fiers ffor or the start information,



PID Contr Control ol Bl Block ocks: s: with with functi function on bl block ocks s for PID PID contro control, l,



S5-S7 S5-S7 Co Converti nverting ng Blocks: Blocks: with the standard standard blocks blocks needed needed fo forr the conversion of S5 programs to S7,



System System Fu Functio nction n Blocks: Blocks: conta contains ins all all S7S7-300/4 300/400 00 sy system stem functions functions (SFCs and SFBs),

• Notes

TI-S7 TI-S7 Conv Converting erting Block Blocks: s: with with generall generally y usable usable standar standard d functions functions,, suc such h as Scaling analog values, etc. When option packages are installed, additional libraries may be created. You can find a description of the S7 Libraries - PID and TI-S7 Converting Blocks Blocks  

 

 

 

under: Documentation English STEP STE P 77- PID ControlToolbar or System SIMATIC and Standard Functions for TI-S7 Converter.

SITRAIN Training for   Automation and Industrial Solutions

Pag age e4

ST-PRO2 Using System System Blocks Blocks

 

Interestin Intere stin g Fa Facts cts about System F Functi uncti ons

The syst em functio ns (SFC (SFCs s and SFBs) SFBs) are stor ed in the CPU‘s CPU‘s operating sys tem

Syst em Software System Soft ware Reference Manual for S7-300 S7-300/400 /400 System Functions and Standard Functions

Extensive Online help available in the STEP STEP 7 softw are

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

Introduction

18.09.2009 PRO2_08E.5

SITRAIN Training for   Automation and Industrial So Solutions lutions

Functionality, that cannot be implemented with STEP 7 instructions (for example DB creation, communication with other PLCs, etc.) can be implemented in STEP7 with the help of system functions (SFCs) or system function blocks (SFBs). SFCs and SFB SFBs s are blocks blocks that are stored stored in the CPU’s operating operating sy system stem instead of in the user memory. For that reason, the actual instruction part is not transmitted but only the SFC’s or SFB’s declaration part during during the reading out of an SFC or SFB from the CPU. With the help of the STL/LAD/FBD Editor, the "block" that is read out can be opened and the declaration part displayed. displayed. A reverse transmission of SFCs and SFBs into the CPU is, is, however, not possible. In the user user program, program, the SFBs SFBs and SFC SFCs s can however however be called called just like like FBs or FCs using the instruction. With SFBs, SFBs, a user DB must also be specified as instance DB forCALL the SFB for that reason. Which SFBs SFBs and SFCs are available depends individually individually on the PLC system (S7-300 or S7-400) used and on the CPU installed. The blocks have, however, regardless of whether they are called in an S7-300 or S7-400, the same numbers, the same functionality and the same call interface.

Manual

 An extensive description of the the system functions can be fou found nd in the manual: •

Online Help

The System System Softw Software are R Refere eference nce Manual Manual for S7-300 S7-300/400, /400, System System Functio Functions ns and Standard Functions.

There is also an extensive description description of the system functions in the STEP 7 software. Call the help menu in the program editor and select the entry: •

Help To Topics   Calling Reference Helps (LAD, FBD, STL, Blocks ... ) to Language Descriptions and Help on Blocks and System  Attributes   Help on SFBs/SFCs.   Jumps

SITRAIN Training for   Automation and Industrial Solutions

Pag age e5

ST-PRO2 Using System System Blocks Blocks

 

Overview Ove rview of the System Function s (Excerpt) (Excerpt) S7-300

S7-400

SFC 20 SFC 21 SFC 22 SFC 23 SFC 24 SFC 25

X X X -

X X X X X X

Program Control

Replace. value in Ac cu. 1 Replace. Multi computing interrupt Triggerr cycle tim e Trigge Stop state Delay (Wait)

SFC 44 SFC 35 SFC 43 SFC 46 SFC 47

X X X X

X X X X X

Handling the Clock

Set time-of-day Read Rea d time-of-day Synchronize

SFC 0 SFC 1 SFC 48

X X -

X X X

Run-time Meter 

Set counter  Start and stop Read out Read system time

SFC 2 SFC 3 SFC 4 SFC 64

X1) X1) X1) X

X X X X

Function Group

Copy and Block Function

Function

Block

Block move Pre-assign field Create DB Delete DB Test DB Compress

1)

1) not for CPU 312IFM

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

Copy and Block Functions

SITRAIN Training for   Automation and Industrial So Solutions lutions



SFC 20 copies copies the conten contents ts of a memory memory area (source (source)) into another another memory memory area (destination)



SFC SFC 21 fil fills ls a mem memory ory area area (desti (destinat nation ion field field)) wit with h the conte contents nts of a prepredefined memory area (source field) SFC 22 creat creates es a non-i non-init nitial ialize ized d DB in the the work work memor memory y SFC 23 deletes deletes a DB in in the work m memory emory and ifif necessary necessary in the load mem. mem. SFC 24 determin determines es whether whether a DB exists exists in the work work memory memory (with length) length) SFC 25 compresse compresses s the memory, memory, since since gaps gaps occur occur when when block block correc corrections tions are made and these gaps are closed when compression takes place SFC 44 (Call (Call iin n OB 122) deposi deposits ts a replacemen replacementt value value for for a faulty faulty input module in the Accumulator. Usage in OB121 is also possible.

• • • • •

Program Progra m Control

18.09.2009 PRO2_08E.6

• • • •

SFC 35 35 trig trigger gers s the sy synch nchron ronize ized d star startt of OB 60 60 in all CPUs CPUs when when multicomputing SFC 43 resta restarts rts tthe he cycle cycle time time monit monitori oring ng of the CPU SFC SFC 46 puts puts the the CPU CPU int into o the the Stop Stop sta state te SFC 47 impleme implements nts waitin waiting g times times in the user user program program of up to 32767 32767 µs

Handling the Clock

• • •

Run-Time Meter

The CPU has a specific number of run-time meters with which it can record the operating time of equipment, for example. • SFC 2 sets sets the runrun-tim time e meter meter to a pre-ass pre-assign igned ed va value lue • SFC 3 start starts sa and nd stops stops the run-tim run-time e mete meter  r  • •

SFC 0 sets sets the real real-ti -time me cl clock ock date date and and time time o on n the CPU CPU SFC 1 reads reads the curren currentt da date te and and time time of tthe he CPU CPU SFC 48 synchron synchronizes izes all tthe he slave slave cl clocks ocks on a bus segmen segment. t. T The he CPU CPU with with the call must be parameterized as the master clock.

SFC 4 reads reads the the curren currentt op opera eratin ting g hou hours rs an and d the stat status us SFC 64 reads reads the the CPU‘s CPU‘s system system time. time. T The he system system time is a cyclic cyclic tim time e counter that counts up every 10 ms (S7-300) or 1 ms (S7-400).

SITRAIN Training for   Automation and Industrial Solutions

Pag age e6

ST-PRO2 Using System System Blocks Blocks

 

System Funct Funct ion s that Exist in the C CPU PU

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

General

18.09.2009 PRO2_08E.7

SITRAIN Training for   Automation and Industrial So Solutions lutions

In the "Performance Data" you can, among other things, query online which system functions are available on a CPU. SIMATIC Manager   PLC   Diagnostic/Settings Performance Data

SITRAIN Training for   Automation and Industrial Solutions

Pag age e7

  Module

Information ...  

ST-PRO2 Using System System Blocks Blocks

 

Call Ca ll of System Function s a and nd System F Funct unct ion Bl ocks System Functions: CALL

SFC

20

EN

SRCBLK :=  RET_VAL:=  DSTBLK := 

??. ?

Cal l i n STL

SRCBLK    RET_V _VA AL

??. ?

DSTBLK

??. ?

Cal l i n L A D

DB5

System Function Blocks: CALL

SFB

EN

3,DB5

IN:=  PT:=  Q :=  ET:= 

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

System Function Blocks

SFC20   ENO ENO

SFB3  

ENO ENO

...

IN

Q

  ...

...

PT

ET

...

18.09.2009 PRO2_08E.8

SITRAIN Training for   Automation and Industrial So Solutions lutions

 A system function block SFB SFB is a function block that iis s integrated in the operating system of an S7-CPU. S7-CPU. For that reason, SFBs SFBs are not downloaded into the CPU as part of the user program. Just like FBs, SFBs SFBs are blocks "with a memory". They They have to be instantiated in the user program.

System Functions

 A system function is a function function that is integrated in the operating operating system of the S7-CPU. SFCs can be called from the user program just like FCs. Just like FCs, SFCs are blocks "without a memory".

Call

When a system function is called called it is automatically copied copied into the associated user program. Furthermore, all system functions are stored in the Standard Library, S7 Program System System Function Blocks. F From rom this library, the SFCs and SFBs SFBs can also be copied into the user program. There is a completed symbol list (with English identifiers) in the library from which the symbols of the blocks used are automatically entered in the symbol list of the user program.

SITRAIN Training for   Automation and Industrial Solutions

Pag age e8

ST-PRO2 Using System System Blocks Blocks

 

Example: " RE READ_C AD_CLK LK"" (S (SFC FC 1)

SFC1  

EN

ENO RE RET_ T_VA VAL L

?? ??.? .?

CDT   ??.?

Para rame mete terr

Declara claratio tion n

Data Type ype Memor mory y Ar Are ea

Desc scrip riptio tion n

ENO (BR Bit)

OUTPUT

BOOL

I, Q, M, D, L

= '1' if error-free exeuction of of the function = '0' if faulty execution of the function

RET_VAL

OUTPUT

INT

I, Q, M, D, L

= 0 if error-free execution of the function = Error code if execution with errors

CDT

OUTPUT

DT

D, L

Date and Time

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

SFC1 "READ_CLK"

18.09.2009 PRO2_08E.9

SITRAIN Training for   Automation and Industrial So Solutions lutions

The SFC 1 "READ_CLK" (read system clock) reads out the time in the CPU and provides as a result a time stamp consisting of a date and the time of day.

SITRAIN Training for   Automation and Industrial Solutions

Pag age e9

ST-PRO2 Using System System Blocks Blocks

 

TIME_OF_DAY and DATE_AND_TIME Data Types Structure of TIME_OF_ DAY (TOD): Numberr of milliseconds si nce 0:00 Numbe 0:00 o‘clock

Struc tur e of DATE_AND_T DATE_AND_TIME IME (DT): (DT): Byte n 1)

Year  (9 (90 0 ... 89 89))

Month (01 ... 12)

Byte n+2

Day (01 ... 31)

Hour  (00 ... 23)

Byte n+3

Byte n+4

Minutes (00 ... 59)

Seconds (00 ... 59)

Byte n+5

Weekday (1..7)

Milliseconds (000 ... 999)

Byte n+6

Byte n+1

Byte n+7

1=Sunday 2=Monday 3=Tuesday 4=Wednesday 5=Thursday 6=Friday 7=Saturday

 All  Al l Valu es iin n BCD f or ormat mat

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

18.09.2009 PRO2_08E.10

SITRAIN Training for   Automation and Industrial So Solutions lutions

TIME_OF_DAY

 A variable of the TIME_OF_DAY TIME_OF_DAY data type occupi occupies es a doubleword. It contains the number of milliseconds since the beginning of the day (0:00 o‘clock) as unsigned integer. (such as: TOD#23:59:59.999).

DATE_AND_TIME

The DATE_AND_TIME data type represents a point in time, consisting of the date and the time. Instead of DATE_AND_TIME DATE_AND_TIME you can also use the abbreviation DT. DATE_AND_TIME or DT are key words and can therefore also be written in DATE_AND_TIME lower case. In the declaration, you can pre-assign an initial value to a variable (not as block parameter in an FC, as in/out parameter parameter in an FB or as temporary variable). The pre-assignment must be of the type: • DT#yea DT#year-m r-mont onth-d h-dayay-hou hours: rs:min minute utes:s s:seco econds nds.mi .milli llisec second onds s You don‘t have to specify the milliseconds. Variables of the DATE_AND_TIME DATE_AND_TIME data type can can either be processed with the help of absolute accesses to the individual components or with the associated functions of the IEC library.

SITRAIN Training for   Automation and Industrial Solutions

Page Page 10

ST-PRO2 Using System System Blocks Blocks

 

Example: " BLK MO MOV" V" (S (SFC FC 20 20))

SFC20  

EN ??.?

ENO

 

SRC_BLK 

RE RET_ T_VA VAL L

?? ??.? .?

DST_ DST_BL BLK K

??.? ??.?

Para rame mete terr

Declara claratio tion n

Data Type ype Memor mory y Ar Are ea

Desc scrip riptio tion n

SRC_BLK

INPUT

A NY

I, Q, M, D, L

Memory area to be copied (=source field).

ENO (BR Bit)

OUTPUT

BOOL

I, Q, M, D, L

= '1' if error-free execution of the function = '0' if faulty execution of the function

RET_VAL

OUTPUT

INT

I, Q, M, D, L

= 0 if error-free execution of the function = Error code if execution with errors

DST_BLK

OUTPUT

ANY

I, Q, M, D, L

Memory area in which copying is to take place (destination field)

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

SFC20 "BLKMOV"

18.09.2009 PRO2_08E.11

SITRAIN Training for   Automation and Industrial So Solutions lutions

The system function "BLKMOV" "BLKMOV" (block move) copies tthe he contents of a memory area (= source field) into another memory area (= destination field). Permitable Permi table source areas (fields) (fields) are: •

pa part rts s of of d dat ata a bl bloc ocks ks

·



bit memories

·



process image input table

·



process image output table

Notes

Source and destination areas may not overlap. If the specified destination area is larger than the source area, then only as much data is copied into the destination area as is contained in the source area. If the specified destination area is smaller the source area, then only as much data as fits into the destination areathan is copied. The source area can also be located located in a data block that iis s only stored in the load memory (DB that was compiled with the keyword UNLINKED ) !

SITRAIN Training for   Automation and Industrial Solutions

Page Page 11

ST-PRO2 Using System System Blocks Blocks

 

 As si gn m en entt o f Par am ameter eter s o f t h e A ANY NY Dat Data a Typ e Pointer Display: 

P#[Da P# [Data ta block.]Bit address address Type Type Number  Number  P#DB10.DBX1 P#DB1 0.DBX12.0 2.0 REAL REAL 20 Pointer Pointer to an area in in DB10, DB10, beginnin beginning g with Byte 12, consisting of 20 addresses of data type REAL (ARRAY[1..20] OF REAL) P#I 10.0 BOOL 8

Pointer to a field of 8 bits in IB10

Declaration De claration of Ad dress: 



absolute:

DB5.DBD10

Data type: DWORD, Replication factor: 1 DB number: 5, Pointer: P#DBX10.0

IW32 T 35

Type: WORD, WF: 1, DB Nr: 0, Pointer: P#I 32.0 Type: TIMER, Nr.: 35

symbolic: #Motor_1.speed "Pump".Start

With elementary data types, the compiler establishes the correct data type, replication factor 1 and pointer 

Note With symbolic assignment (ARRAY, STRUCT, STRING, UDT), the data type identifier 02 (BYTE) and the area length in bytes is merely established by the compiler and entered in the ANY pointer  SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

18.09.2009 PRO2_08E.12

SITRAIN Training for   Automation and Industrial So Solutions lutions

 As si gn ment

 A parameter of the "ANY" "ANY" data type can be assigned using the pointer display as well as by direct declaration of address (variables).

Pointer Display

With assignment using the pointer display (for example: P#DB5.DBX10.0 INT 8) the STL/LAD/FBD Editor sets up an ANY pointer that corresponds cor responds in type and in number with the declarations.  Assignment in the pointer display display always makes sense when a data area is to be addressed for which no variable was defined or for example, no suitable variable (ARRAY or STRUCT, for example) can be defined (P, PII, PIQ, M, for example). In addition, the absolute pointer display must be used when the correct information about the replication factor and the data type is required within the called block (for example, ARRAY[1..8] OF REAL).

 Ad dr ess Display

 A parameter of the "ANY" type can also be directly assigned with the address to which the ANY pointer is to point. This declaration can take place absolute or using the symbolic variable name. With the declaration of an absolute address, the STL/LAD/FBD Editor automatically determines the associated data type (BOOL, BYTE, WORD, DWORD,), a replication factor of "1", the DB number as well as the areacrossing pointer to the first bit of the address and enters these values in the pointer structure. Likewise, the STL/LAD/FBD Editor determines the correct information using the address when the declaration takes place using the symbol name and the variable that is entered is of the elementary data type.

Note

If a variable is of the complex data type (for ( for example, ARRAY[1..8] OF REAL), then the STL/LAD/FBD Editor merely enters information in bytes about the area occupied by the variable (that is,: replication replication factor: 32, data type: BYTE).

SITRAIN Training for   Automation and Industrial Solutions

Page Page 12

ST-PRO2 Using System System Blocks Blocks

 

 A  An n al alyzi yzin n g an Er Erro ro r Mess ag age e 



The scan of t he BR-bit BR-bit (binary result) return s RLO=0 RLO=0 for proc essing wit h fault and RLO=1 RLO=1 for fault-free processing. 

Scan of BR for STL STL wit h A BR



Scan in LAD/FBD LAD/FBD using the outp ut parameter ENO ENO

Most of the system functions return an error code with the follo wing confi guration in th e output parameter parameter RET_ RET_VAL VAL (INT (INT): ): 

RET_VAL=W#16#8 X Y Z

Error class, error‘s individual number (SFC specific) or event num ber (general) (general) X>0: X>0: general error, X= No. of fault y parameter  X=0: X=0: SF SFC C specific error oc curred "8" signals: e error rror occurred 

Example: 

W#16#8081 is an SFC specific error code.



W#16#823A is a general error code; the error was caused by Parameter No. 2.

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

Error Information

Note

18.09.2009 PRO2_08E.13

SITRAIN Training for   Automation and Industrial So Solutions lutions

 A processed SFC shows you in the user program, whether the CPU could successfully execute the SFC function or not. You receive corresponding error information in two ways: •

in the the B BR R bi bitt of the the st stat atus us wor word d an and d



in the the o outp utput ut para paramet meter er RET_V RET_VAL AL (retu (return rn value value). ).

You should always proceed as follows before evaluating the SFC specific output parameter: •

fir first st of of all evalua evaluate te tthe he BR BR bi bitt of the the statu status s word. word.



subseq subsequen uently tly chec check k the ou outpu tputt parame parameter ter RET_V RET_VAL. AL.

If a faulty processing of the SFC is signalized through the BR bit or a general error code is found in RET_VAL, you may not analyze the SFC specific output parameter. General Ge neral Error s

The general error code indicates errors that can occur with all system functions.  A general error code consists of the following following two numbers: •

a paramete parameterr num number ber between between 1 and 127, whereby whereby 1 indicates indicates tthe he first first parameter, 2 the second parameter etc., of the SFC called.



an event event number number betwe between en 0 and 1 127. 27. T The he event event number number indicates indicates a synchronous error.

 An extensive description of the the general error codes can be found in the manual: "System Functions and Standard Functions" or in the Online Help. Specific Spe cific Errors

Several system functions (SFCs) have a return value that provides a specific error code. This error code indicates that an error that belongs to a specific system function occurred during the processing of the function.  A description of the specific error code can be found in the Online Help Help for the associated system function (keyword "Error Information").

SITRAIN Training for   Automation and Industrial Solutions

Page Page 13

ST-PRO2 Using System System Blocks Blocks

 

Exercise 1: Record Record ing the Time S Stamp tamp wi th SFC 1 DB 18 FB 18

Year/Month Day Hours/Minutes Seconds ms/weekday

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

18.09.2009 PRO2_08E.14

SITRAIN Training for   Automation and Industrial So Solutions lutions

Functi on (FB 18) 18) The parts transported while in AUTO mode are counted for each bay. The total Count Pa Parts/Sta rts/Statistic tistic quantity and the quantities of the individual bays as well as their percentage utilization are stored in the statistic variable "Statistic_Values" (declared according to UDT18, see slide). Task

In the next exercise a data backup backup of the variable #Statistic_Values #Statistic_Values is carried out. But first, the time stamp for the data backup is to be entered in the variable "DB_DataBackup".DateTime .

Wh at t o Do

1. Create the new data block "DB_DataBackup" (DB 10) with the variable shown in the slide. 2. In FB 18, call the system function SFC 1 for reading out the system time and pass the variable "DB_DataBackup".DateTime onto its OUT parameter CDT (see slide). 3. Select the screen "Conv" and switch off the AUTO mode (Q 4.3) and then switch it back on again. 4. With the test function "Monitor/Modify Variables" monitor the data block b lock operands or components of the variable "DB_DataBackup".DateTime shown in the slide.

Note

Monitoring data block variables of the data type Date_and_Time (DT) is not possible with the test function "Monitor Data Block". The test function "Monitor Variable" provides help because you can monitor the individual components of the DT variable (see slide).

SITRAIN Training for   Automation and Industrial Solutions

Page Page 14

ST-PRO2 Using System System Blocks Blocks

 

Exercise Exercis e2 2:: Data Backup w ith SF SFC C2 20 0

DB 18 FB 18

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

18.09.2009 PRO2_08E.15

SITRAIN Training for   Automation and Industrial So Solutions lutions

Functi on (FB 18) 18) The parts transported while in AUTO mode are counted for each bay. The total Count Pa Parts/Sta rts/Statistic tistic quantity and the quantities of the individual bays as well as their percentage utilization are stored in the statistic variable "Statistic_Values" (declared according to UDT18, see slide). Task

For purposes of data backup, all values of the static variable "Statistic_Values" are to be stored in the data block "DB_DataBackup" (DB 10) every time "L_AUTO" (rising edge of Q 4.3 = #ON_Edge) is turned on, before the values are overwritten with 0. That way, the old statistic values are still available even after the system has been turned on.

Wh at t o Do

1. In FB 18, call the SFC 20 block and check the program function as follows: 2. Open "DB_DataBackup" (DB 10) in the data view and activate the "Monitor" test function. 3. On the touchpanel select the "Statistic" screen and make note of the current quantities and utilization of the individual bays. 4. Select the "Conv" screen, switch the AUTO mode off and then switch it on again and in the process observe whether the statistic values are transferred into the data block. 5. Select the "Statistic" screen once more and check whether the current values shown have been reset to 0.

SITRAIN Training for   Automation and Industrial Solutions

Page Page 15

ST-PRO2 Using System System Blocks Blocks

 

If You You Want to Kno w More

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

Note

18.09.2009 PRO2_08E.16

SITRAIN Training for   Automation and Industrial So Solutions lutions

The following pages contain either further information or are for reference to complete a topic.

SITRAIN Training for   Automation and Industrial Solutions

Page Page 16

ST-PRO2 Using System System Blocks Blocks

 

 Add  A dd i ti o nal Exer ci se: Speci Sp eci fi ed Ti Tim m e Rel Relay ay

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

18.09.2009 PRO2_08E.17

SITRAIN Training for   Automation and Industrial So Solutions lutions

General

With the IEC Function Function Blocks, tthe he Standard Library provide provides s very useful complex functions, such as how a specified time relay can be used for a system expansion.

Task

In a new FC119, create a specified time relay with the help of the IEC Function Blocks from the Standard Library. The relay is to be used to switch an oil heater on at 8:00 o‘clock in the morning and switch it off at 16:00 o‘clock. The heater is energized through the output Q 5.3. In the Standard Library S7 program "System "System Function Bloc Blocks", ks", use the SFC 1 to read the current time from the real-time clock in the CPU. With the FC8 function from the S7 program "IEC Function Blocks", the current time can be extracted from the time stamp of SFC1. Then the times 8:00 o‘clock and 16:00 o o‘clock ‘clock can then be compared using 2 comparison functions. To simulate these times, the desired time in the CPU is adjust adjusted ed in each case using the menu options PLC   Set Date and Time. Time .

What to Do

1. Create an FC 119 accord according ing to to the task 2. Also Also call call the FC FC 11 119 9 block block in O OB B1 3. Download Download the bl blocks ocks and test test the function function by changi changing ng the time time in the CPU.

Note

So that in Network 2, a direct comparison of the time can be programmed in LAD or FBD, either switch off the type check or copy the variable #time into a variable of the DINT data type. To switch off the type check use the menu options Options   Customize and deactivate the option "Type Check of Addresses" in the LAD/FBD tab.

SITRAIN Training for   Automation and Industrial Solutions

Page Page 17

ST-PRO2 Using System System Blocks Blocks

 

The Library: TI-S TI-S7 7 Converting Bloc ks (Excerpt) (Excerpt) Block

Sy m b o l

Des c r i p t i o n

FC 80 FC 81 FC 82 FC 83 FC 84 FC 85

TONR IB L K MOV RSET SET A TT FIFO

St ar t t i m e as s t o r ed ON Del ay In d i r ec t l y t r an s f er d at a ar ea Res et m em o r y b i t o r p er i p h er al r an g e Set m em o r y b i t o r p er i p h er al r an g e En t er v al u e i n t ab l e Ou t p u t f i r s t v al u e i n t ab l e

FC 86 FC 87 FC 88 FC 89 FC 90 FC 91 FC 92 FC 93 FC 94 FC 95 FC 96 FC 97 FC 98 FC 99 FC 105

TB L _FIND L IFO TB L TB L _WRD WSR WRD_TB L SHRB SEG A TH HTA ENCO DECO B CDCPL B ITSUM SCA L E

Fi n d v al u e i n t ab l e Ou t p u t l as t v al u e i n t ab l e Ex ec u t e t ab l e o p er at i o n Co p y v al u e f r o m t ab l e Sav e d at e i n s h i f t r eg i s t er   Lo g gii ca cal ly ly g ga at e v al ue ue w iitt h t ab ab le le el em em en en t an d s av av e Sh i f t b i t i n t o s h i f t r eg i s t er   Gen er at e b i t s eq u en c e f o r 7 s eg m en t d i s p l ay Co n v er t A SCII c h ar ac t er s t r i n g i n t o h ex ad ec i m al n u m b er   C o n v er t h he ex ad ec i m al nu nu m b er in in t o A SCII c h ar ac t er s stt r i n g Set p r es et b i t i n t h e w o r d Read b i t n u m b er o f l eas t s i g n i f i c an t s et b i t Gen er at e t en ‘ s c o m p l em en t Co u n t n u m b er o f s et b i t s Sc al e an al o g v va al u e (c o n v er t to to ph ph y s i c al q qu u an t i t y )

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

18.09.2009 PRO2_08E.18

SITRAIN Training for   Automation and Industrial So Solutions lutions

FC 80

The FC80 function starts the "timer "timer function as storing ON Delay (TONR)". The FC80 accumulates time until the current value of elapsed time (#ET) equals or exceeds the preset value (#PV).

FC 81

With the indirect move of a data area function (IBLKMOV), you can move a block of data consisting of either bytes, words, integers (16 bits), double words or double integers (32 bits) from a source block to a destination block. The #S_DATA and #D_DATA POINTERS point to structures of the POINTER data type which identify the starting star ting locations of the source and destination data. The area length to be copied is determined through special parameters.

FC 82/83

Sets the signal state of each bit in a specified range to "1" (FC83), or to "0" (FC 82), if the MCRunchanged. bit is "1". If the MCR bit is "0", the signal state of each bit in the range remains

FC 84 84 - FC 92 92

These functions are table functions functions to implement FIFO functions, for example. The values are to be entered in the word format; the length can be set.

FC 93 93 - FC 99 99

This group provides various conversion functions.

FC 105

Converts the digitalized value of an analog channel into a physical quantity (such as weight).

SITRAIN Training for   Automation and Industrial Solutions

Page Page 18

ST-PRO2 Using System System Blocks Blocks

 

The Lib rary: IE IEC CF Funct unct ion Bloc ks (Excerpt) (Excerpt) Blo ck

Sy m b o l

Des c r i p t i o n

FC 3 FC 6 FC 7 FC 8 FC 9 FC 12 FC 14 FC 18 FC 23 FC 28

D_TOD_DT DT_DA TE DT_DA Y DT_TOD EQ_DT GE_DT GT_DT L E_DT L T_DT NE_DT

Co mb mb iin n e v ar iia ab le le Dat e an d TIME_OF_DA Y as DT DT Ex t r ac t d at e f r o m v ar i ab l e o f t y p e DT Ex t r ac t da day o f w eek ffrr o m va var i ab l e o f ty ty p e DT Ex t r ac t t i m e-o f -d ay f r o m v ar i ab l e o f t y p e DT Co m p ar e 2 v ar i ab l es o f t y p e DT f o r eq u al t o Co m p pa ar e 2 v ar ia iab l e es s o f t yp yp e DT f or or g r eat er er t h an o r eq u al t o Co m p ar e 2 v ar i ab l es o f t y p e DT f o r g r eat er t h an Co m p ar e 2 v ar i ab l es of of t y p e DT f o r s sm m al l er th th an o r eq eq u al t o Co m p ar e 2 v ar i ab l es o f t y p e DT f o r s m al l er t h an Co m p ar e 2 v ar i ab l es o f t y p e DT f o r u n eq u al

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

18.09.2009 PRO2_08E.19

SITRAIN Training for   Automation and Industrial So Solutions lutions

FC 3

The FC 3 function combines combines the data formats DATE and TIME_OF_DAY (TOD) and converts these formats into the data format DATE_AND_TIME (DT).

FC 6

The FC 6 function extracts the data format DATE from the format DATE_AND_TIME.

FC 7

The FC 7 function extracts the day of the week from the format DATE_AND_TIME. DATE_AND_TIM E. The weekday exists in the data format INTEGER and begins with 1 = Sunday to 7 = Saturday.

FC 8

The FC 8 function extracts the data format TIME_OF_DAY from the format DATE_AND_TIME. DATE_AND_TIM E. The input value can only be assigned with a symbolically defined variable.

FC 9 - FC 28 28

The functions compare the contents of two variables in the DATE_AND_TIME format for same, greater than, smaller than, etc., and output the result as a return value. The return value is signal state "1", when the comparison of both times is fulfilled.

SITRAIN Training for   Automation and Industrial Solutions

Page Page 19

ST-PRO2 Using System System Blocks Blocks

 

The Library: Library: Communication Blocks

Bloc k

Sy m b o l

D es c r i p t i o n

FC 1

DP_SEND

Sen d d at a t o PROFIB US CP

FC 2

DP_RECV

Rec ei v e d at a f r o m PROFIB US CP

FC 3

DP_DIA G

L o ad d i ag n o s t i c d at a o f a s t at i o n

FC 4

DP_CTRL

Sen d c o n t r o l t as k s t o t h e CP

Exclusively in the configuration: Exclusively S7-300 CPU with CP 342-5 CP 342-5

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

Overview

18.09.2009 PRO2_08E.20

SITRAIN Training for   Automation and Industrial So Solutions lutions

The library functions FC1, FC2, FC3 FC3 and FC4 are used exclusively exclusively in the following configuration: •

S7-300 S7-300 CPU CPU with with exte externa rnall PR PROFI OFIBU BUS S CP 342-5 342-5

In all other cases, that is, for S7-300 with integrated PROFIBUS-DP interface and for the entire S7-400 system, the corresponding functions are implemented with the standard load and transfer commands (L ... , T...) or through SFC14 (DPRD_DAT), SFC15 (DPWR_DAT), SFC11 (DPSYC_FR) and SFC13 (DPNRM_DG). FC1

The DP_SEND block transfers the data of a specified DP output area to the PROFIBUSCP for output to the distributed peripherals.

FC2

The DP_RECV block receives the process data of the distributed peripherals as

FC3

well as status information in a specified DP input area. The DP_DIAG FC block is used to request diagnostic information. The following types of job are possible:

FC4



Requ Reques estt DP DP s sta tati tion on li list st;;



Requ Reques estt DP dia diagn gnos osti tic c li list st;;



Reques Requestt DP single single dia diagno gnosis sis (statu (status); s);



Read Read input input / outpu outputt data data of a DP s slav lave e acycli acyclical cally; ly;



Read DP mode.

The DP_CTRL FC block transfers control jobs to the PROFIBUS CP. The following types of job are possible: •

Gl Glob obal al cont contro roll acy acycl clic ic / cyc cycli lic; c;



Dele Delete te olde olderr d dia iagn gnos osti tic c dat data; a;



Set cu curr rren entt DP DP m mod ode; e;



Se Sett DP DP mod mode e ffor or PL PLC/ C/CP CP stop stop;;



Read Read in inpu put/ t/ou outp tput ut da data ta cy cycl clic ical ally ly;;



Set the operat operating ing mod mode e of of the the DP slave. slave.

SITRAIN Training for   Automation and Industrial Solutions

Page Page 20

ST-PRO2 Using System System Blocks Blocks

 

The Library: PID PID Contr Contr ol B locks

Bloc k

Sy m b o l

D es c r i p t i o n

FB 41

CONT_C

c o n t i n u o u s PID c o n t r o l b l o c k

FB 42

CONT_S

PI c o n t r o l l er wi wi t h b i n ar y ma man i p u l at ed v al u e output

FB 43

PUL SE SEGEN

Pu lls s e g en en er er at at o orr fo fo r PID c o on n ttrr ol ol le ler w i tth h p ul ul se se output

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

FB 41

18.09.2009 PRO2_08E.21

SITRAIN Training for   Automation and Industrial So Solutions lutions

The SFB "CONT_C" (continuous controller) is used on SIMATIC S7 programmable logic controllers to control technical processes with continuous input and output variables. During parameter assignment, you can activate or deactivate sub-functions of the PID controller to adapt the controller to the process. You can use the controller as a PID fixed setpoint controller or in multi-loop controls as a cascade, blending or ratio controller. The functions of the controller are based on the PID control algorithm of the sampling controller with an analog output signal, if necessary extended by including a pulse generator stage to generate pulse duration modulated output signals for two or three step controllers with proportional actuators.

FB42

The SFB "CONT_S" (step controller) is used on SIMATIC S7 programmable logic controllers to control technical processes with binary manipulated value output signals for integrating actuators. During parameter para meter assignment, you can activate or deactivate sub-functions of the PI step controller to adapt the controller to the process. You can use the controller as a PI fixed setpoint controller or in secondary control loops in cascade, cascade, blending or ratio ratio controllers, however not as the primary controller. The functions of the controller controller are based on the PI control algorithm of the sampling controller supplemented by the functions for generating the binary output signal from the analog actuating signal.

FB43

The SFB "PULSEGEN" (pulse generator) is used to structure a PID controller with pulse output for proportional actuators. Using SFB "PULSEGEN", PID two or three step controllers with pulse duration modulation can be configured. The function is normally used in conjunction with the continuous controller "CONT_C".

SITRAIN Training for   Automation and Industrial Solutions

Page Page 21

ST-PRO2 Using System System Blocks Blocks

 

The Libr ary: M Miscellaneous iscellaneous Blo cks (Auszug)

Bloc k

Sy m b o l

D es c r i p t i o n

FB 6 60 0

SET_SW

St an d ar d /Day l i g h t -s av i n g s ti t i m e ad ad j u s t m en t

FB 62

TIMESTMP

Mes sa sag e es s w it it h t im im ee-s ta tam p f ro ro m IM 153-2

FC 60

L OC_TIME

Det er m i n e l o c al t i m e

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved. reserved.

18.09.2009 PRO2_08E.22

SITRAIN Training for   Automation and Industrial So Solutions lutions

FB 60

The FB supports Standard/Daylight-saving Time adjustment for CPUs that do not have the time status. The The block adjusts the CPU clock to the the currently applicable time according to the adjustment rules in the Rule DB.

FB 62

The FB TIMESTMP ttransmits ransmits time-stamped messages of an IM153-2 to its instance DB. There, There, data are availa available ble for further processing in the user program.

FC 60

The FC reads the time-of-day status and the time of the CPU and calculates the local time from it. This function is not available for all CPUs. If it is not, the FC 60 gives out an error message.

Time-of-Day Time-of-D ay Statu s

You can determine the current time-of-day status of your CPU with the SFC 51 "RDSYSST". The time-of-day status contains the following information: •

corr correc ecti tion on fact factor or for for the the cloc clock k



Standa Standard/ rd/Day Daylig lightht-sav saving ing Time Time iiden dentif tifica icatio tion n



Announced Announced hour of transi transition tion (the (the nex nextt time time the hour hour changes, changes, the clock clock is adjusted from Standard to Daylight-saving or vice versa).

SITRAIN Training for   Automation and Industrial Solutions

Page Page 22

ST-PRO2 Using System System Blocks Blocks

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF