cfc tutorial

Download CFC Tutorial

Post on 07-Aug-2018

215 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

  • 8/21/2019 CFC Tutorial

    1/156

    SIMATIC CFC Elementary Blocks

    ________________________________________________________

    ____________________________

    ________________________________________________________

    ______________________________________________________________________

    ________________________________________________________

    Block parameters EN, ENO,

    SAMPLE_T

    1

    Startup on S7-300 CPUs

    2

    CFC blocks

    3

    Logic blocks of the data type

    BOOL

    4

    Logic blocks of the data type

    WORD and DWORD

    5

    Blocks for comparing two

    input values of the same

    type

    6

    Blocks for converting data

    types

    7

    Arithmetic blocks of the data

    type REAL

    8

    Arithmetic blocks of the data

    type INT and DINT

    9

    Flip-flop blocks

    10

    Shift blocks

    11

    Multiplexer blocks

    12

    Counter blocks

    13

    Blocks for generating or

    processing pulses

    14

    Blocks for acquiring or

    processing time intervals and

    timebases

    15

    Control blocks

    16

    System function blocks

    (SFBs)

    17

    AS-wide blocks

    18

    Appendix

    19

    SIMATIC

    Process Control System PCS 7

    CFC Elementary Blocks

    Programming and Operating Manual

    03/2009

    A5E02109607-01

  • 8/21/2019 CFC Tutorial

    2/156

    Legal information

    egal information

    Warning notice system

    This manual contains notices you have to observe in order to ensure your personal safety, as well as to preventdamage to property. The notices referring to your personal safety are highlighted in the manual by a safety alertsymbol, notices referring only to property damage have no safety alert symbol. These notices shown below aregraded according to the degree of danger.

    DANGER

    indicates that death or severe personal injurywill

    result if proper precautions are not taken.

    WARNING

    indicates that death or severe personal injury mayresult if proper precautions are not taken.

    CAUTION

    with a safety alert symbol, indicates that minor personal injury can result if proper precautions are not taken.

    CAUTION

    without a safety alert symbol, indicates that property damage can result if proper precautions are not taken.

    NOTICE

    indicates that an unintended result or situation can occur if the corresponding information is not taken intoaccount.

    If more than one degree of danger is present, the warning notice representing the highest degree of danger willbe used. A notice warning of injury to persons with a safety alert symbol may also include a warning relating toproperty damage.

    Qualified Personnel

    The device/system may only be set up and used in conjunction with this documentation. Commissioning andoperation of a device/system may only be performed by qualified personnel. Within the context of the safety notesin this documentation qualified persons are defined as persons who are authorized to commission, ground andlabel devices, systems and circuits in accordance with established safety practices and standards.

    Proper use of Siemens products

    Note the following:

    WARNING

    Siemens products may only be used for the applications described in the catalog and in the relevant technicaldocumentation. If products and components from other manufacturers are used, these must be recommendedor approved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation andmaintenance are required to ensure that the products operate safely and without any problems. The permissibleambient conditions must be adhered to. The information in the relevant documentation must be observed.

    Trademarks

    All names identified by are registered trademarks of the Siemens AG. The remaining trademarks in thispublication may be trademarks whose use by third parties for their own purposes could violate the rights of theowner.

    Disclaimer of Liability

    We have reviewed the contents of this publication to ensure consistency with the hardware and softwaredescribed. Since variance cannot be precluded entirely, we cannot guarantee full consistency. However, theinformation in this publication is reviewed regularly and any necessary corrections are included in subsequenteditions.

    Siemens AGIndustry SectorPostfach 48 4890026 NRNBERGGERMANY

    A5E02109607-01 01/2009

    Copyright Siemens AG 2009.Technical data subject to change

  • 8/21/2019 CFC Tutorial

    3/156

    CFC Elementary Blocks

    Programming and Operating Manual, 03/2009, A5E02109607-01 3

    Table of contents

    1 Block parameters EN, ENO, SAMPLE_T........................... ......................................................................

    11

    2 Startup on S7-300 CPUs ...................................................................................................... ................... 13

    3 CFC blocks.............................................................................................................................................. 15

    4 Logic blocks of the data type BOOL........................... .............................................................................. 17

    4.1 BIT_LGC ......................................................................................................................................17

    4.2 AND: AND operation....................................................................................................................18

    4.3 OR: OR operation ........................................................................................................................19

    4.4 XOR: Exclusive-OR operation .....................................................................................................20

    4.5 NAND: NAND operation...............................................................................................................21

    4.6 NOR: NOR operation ...................................................................................................................22

    4.7 NOT: NOT operation....................................................................................................................23

    5 Logic blocks of the data type WORD and DWORD ................................................................................. 25

    5.1 WRD_LGC ...................................................................................................................................25

    5.2 WAND_W: Word AND operation..................................................................................................26

    5.3 WOR_W: Word OR operation......................................................................................................27

    5.4 WXOR_W: Word exclusive-OR operation ...................................................................................285.5 WNAND_W: Double word AND operation ...................................................................................29

    5.6 WNOR_W: Word NOR operation.................................................................................................30

    5.7 WNOT_W.....................................................................................................................................31

    5.8 WAND_DW ..................................................................................................................................32

    5.9 WOR_DW.....................................................................................................................................32

    5.10 WXOR_DW ..................................................................................................................................33

    5.11 WNAND_DW................................................................................................................................33

    5.12 WNOR_DW..................................................................................................................................34

    5.13 WNOT_DW: Double word NOT operation ...................................................................................34

    6 Blocks for comparing two input values of the same type.......................................................................... 35

    6.1 COMPARE...................................................................................................................................35

    6.2 CMP_I: Comparator for INT values..............................................................................................35

    6.3 CMP_DI: Comparator for DINT values ........................................................................................36

    6.4 CMP_R: Comparator for REAL values ........................................................................................37

    6.5 CMP_T: Comparator for TIME values..........................................................................................38

  • 8/21/2019 CFC Tutorial

    4/156

    Table of contents

    CFC Elementary Blocks

    4 Programming and Operating Manual, 03/2009, A5E02109607-01

    7 Blocks for converting data types ............................................................................................ .................. 39

    7.1 CONVERT................................................................................................................................... 39

    7.2 BY_DW........................................................................................................................................ 417.3 BY_W ....................................