pro1_05e [읽기 전용] [호환 모드]

Upload: nguyen-anh-tu

Post on 02-Jun-2018

235 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 PRO1_05E [ ] [ ]

    1/26

    Contents Page

    The STEP 7 Programming Languages .......................................................................... 2

    Starting the LAD/STL/FBD Editor ...................................................................................................... 3

    Components of the LAD/STL/FBD Editor ........................................................................................ 4

    Selecting the Programming Language ............................................................................................ 5

    Programming in LAD/FBD ............................................................................................................... 6

    Programming in STL ...................................................................................................................... 7

    Saving a Block ............................................................................................................................. 8

    Calling a Block in OB1 .................................................................................................................. 9

    Downloading Blocks into the PLC ............................................................................... 10

    Simple Program Debugging ............................................................................................................ 11

    Downloading and Saving Modified Blocks ....................................................................................... 12

    Exercise: Selecting the Mnemonics ............................................................................................... 13

    Exercise: Opening and Editing FC 1 .................................................................................................. 14Exercise: Changing the Programming Language ............................................................................ 15

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

    Exercise: Downloading a Block into the PLC .................................................................................... 17

    Exercise: Calling FC 1 in OB 1 ....................................................................................................... 18

    Exercise: Debugging FC 1 (in LAD) ................................................................................................. 19

    Exercise: Expanding the Program in the FC 1 Block ....................................................................... 20

    Editor Customization: "Editor" Tab ..................................................................................... 21

    Editor Customization : "STL" Tab .......................................................................................... 22

    Editor Customization : "LAD/ FBD" Tab ................................................................................ 23

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 1

    or us om za on : rea e oc a ........................................................................

    Editor Customization : "Source Files" Tab . ............................................................................ 25Editor Customization : "Symbol Selection" Tab ...................................................................... 26

  • 8/10/2019 PRO1_05E [ ] [ ]

    2/26

    Introduction There are several programming languages in STEP 7 that can be used dependingon pre erence an now e ge. y a er ng o spec c ru es, e program can ecreated in Statement List and can then be converted into another programming

    language.

    LAD Ladder Diagram is very similar to a circuit diagram. Symbols such as contacts andcoils are used. This programming language appeals to those who grew up withcontactors.

    STL The Statement List consists of STEP 7 instructions. You can program fairly freelywith STL (sometimes to the point of being unable to follow it anymore). Thisprogramming language is preferred by programmers who are already familiar withother programming languages.

    FBD The Function Block Diagram uses boxes for the individual functions. The characterin the box indicates the function (e.g. & --> AND Logic Operation). This

    programming language has the advantage that even a non-programmer such as aprocess engineer can work with it. Function Block Diagram is available as ofVersion 3.0 of the STEP7 Software.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 2

  • 8/10/2019 PRO1_05E [ ] [ ]

    3/26

    Starting the Editor You can start the LAD/STL/FBD Editor by selecting Start -> Simatic -> STEP 7- , , - rogramm ng oc s.

    The following quicker way of starting the Editor is recommended :

    1. Select the "Blocks" object in the project window of the SIMATIC Manager.

    2. Double-click any block to open the Editor.

    Program When using the LAD and FBD programming languages you can insert simpleElements graphical program elements directly into the program from the toolbar.

    You can click the "Program Elements" icon to open another window containing moreprogram elements. The contents of this window depend on the programminglanguage selected (LAD/FBD/STL).

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 3

  • 8/10/2019 PRO1_05E [ ] [ ]

    4/26

    Components When you start the LAD/STL/FBD Editor, two windows are automatically opened:"e ec ara on a e an e co e sec on. e user can a so open a r rogram

    Elements" window.

    Declaration Table The declaration table belongs to the block. It is used for declaring variables andparameters for the block.

    The declaration table is discussed in detail in the chapter Functions and FunctionBlocks".

    ,required.

    Entries are checked for correct syntax.

    Program The contents of the "Program Elements" window depends on the programmingElements language selected.

    You can double-click elements in the list ("browser") to insert them into the programat the cursor position.

    .

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 4

  • 8/10/2019 PRO1_05E [ ] [ ]

    5/26

    View You choose the View menu to switch from one STEP 7 programming language toano er:

    LAD (Ladder Diagram)

    FBD (Function Block Diagram)

    STL (Statement List).

    LAD/FBD => STL You can convert program sections that have been written in the graphicalprogramming languages into STL. You should, however, be aware that the result ofthis conversion is not always the most efficient solution in Statement List.

    STL => LAD/FBD It is not always possible to convert program sections written in STL into LAD orFBD. The sections of the program that cannot be converted are left in STL.

    No sections of the program are lost on conversion.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 5

  • 8/10/2019 PRO1_05E [ ] [ ]

    6/26

    Elements Frequently used LAD and FBD elements appear as icons in the toolbar. You clickem w e mouse o nser em a e se ec e pos on n e program.

    Toolbar icons in LAD:

    Toolbar icons in FBD:

    You can insert other program elements from the browser in the "Program Elements"window: n any pos on w rag rop in a selected position by double-clicking the element in the browser.

    Networks When you click the "New Network icon in the toolbar, a new network isadded after the current network.

    Note If you want to insert a new network before NW1, you must select the block name("FC1: Plant" in the example above) before you click the "New Network" icon.

    Empty Box You can use the Empty Box to insert LAD or FBD elements more quickly. Theelements can be inserted directly without having to select them from the browser.

    After you have selected the position in the network where you want to insert anelement, click on the Empty Box icon in the toolbar.

    By entering the first letters of an element name, a list with the elements which startwith these letters appears and you can make a selection.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 6

  • 8/10/2019 PRO1_05E [ ] [ ]

    7/26

    Statements The user needs to know the statements for writing a program in STL. You cano a n n orma on a ou e syn ax an unc ona y rom e on- ne e p:Help -> Help on STL.

    The following information is available:

    "Statement List Instructions", a description of all the statements thatexist in this programming language

    "Working with Statement List", a description of

    Statement List View and General Syntax

    Entering and Viewing Constant Data

    Types of Blocks

    Switch Contacts and Signal States

    Program Elements When you are using the STL Editor, the "Program Elements" window contains onlya list of the existing blocks which can be called from the current block.

    Networks Networks are inserted in the same way as in the LAD/FBD Editor (see previouspage).

    Making Changes You use the "Insert" key to toggle between "Overwrite" and "Insert" mode.The current setting appears in the status bar.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 7

  • 8/10/2019 PRO1_05E [ ] [ ]

    8/26

    Saving a Block When you have finished editing a block, you can save it on the hard disk of theprogramm ng ev ce:

    by selecting the menu options File -> Save or

    by clicking the disk icon in the toolbar.

    .

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 8

  • 8/10/2019 PRO1_05E [ ] [ ]

    9/26

    Cyclic So that a newly created block is integrated in the cyclic program execution of thexecu on , mus e ca e n .

    The simplest way of inserting the block call is through the browser (see picture

    above).

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 9

  • 8/10/2019 PRO1_05E [ ] [ ]

    10/26

    Downloading You download the blocks into the PLC with the SIMATIC Manager by:

    clicking the icon or

    selecting the menu options PLC -> Download.

    Before you do this, you must select the blocks you want to download:

    All blocks: Select the "Blocks" object in the left-hand pane of theproject window.

    Several blocks: Hold down the CTRL key and select the blocks youwant.

    One block: Select the block.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 10

  • 8/10/2019 PRO1_05E [ ] [ ]

    11/26

    Requirements Before you can activate the monitoring mode, you must open the block you want tomon or e er o ne or on ne w e or.

    Note: In order to test a block in the offline mode, it must first be downloaded

    into the PLC.

    Activation / There are two ways of activating/deactivating the Monitor" test function:Deactivation

    click the Spectacles icon

    select the menu options Debug -> Monitor.

    View The program status is displayed in different ways depending on the programminglanguage selected (LAD/STL/FBD).

    When the monitoring function is activated, you cannot change the programminglanguage in which the block is viewed (LAD/FBD/STL)..

    Note You will find more information about testing programs in the chapter "TestFunctions".

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 11

  • 8/10/2019 PRO1_05E [ ] [ ]

    12/26

    Making Corrections You can make corrections to blocks that have been opened either online oro oc s o ne; owever, no n e es mo e.

    You normally download the modified block to the PLC, test it, make further

    corrections if necessary and finally save it on the hard disk when it has beenfully debugged.

    If you do not want to test the program straight away, you can just save thechanges on the hard disk to start with. The old version of the block is thenerased in this case.

    If you make corrections to a number of blocks and don't want to overwrite,

    blocks to the CPU first without saving them on the hard disk of the PG.You can save them on the hard disk of the PG when you have tested thewhole program successfully.

    Insert/Over-write The insert mode is set by default for LAD or FBD. By pressing the Insert (Ins) key,

    you activate the over-write mode. After that, you can, for example, modify the typeof timer for a timer (e.g. change ON delay to OFF delay), without rewiring the inputsand outputs.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 12

  • 8/10/2019 PRO1_05E [ ] [ ]

    13/26

    Remember ! You can select the language and the mnemonics you want to use in the SIMATICanager.

    Goal To select the desired mnemonics.

    What to Do 1. Start the SIMATIC Manager, if it is not already open.

    2. Select the menu options Options -> Customize.

    3. Choose the language and the desired mnemonics in the Language tab andconfirm with OK.

    Result You will use one of the following representations when writing your program.

    Example of an STL statement with German mnemonics:

    U E 1.0 // UND Eingang 1.0

    Example of an STL statement with English mnemonics:

    A I 1.0 // AND Input 1.0

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 13

  • 8/10/2019 PRO1_05E [ ] [ ]

    14/26

    Remember ! You must open the FC 1 block before you can start editing it. So that the block cane execu e , mus e ca e n .

    Goal To open FC 1, which was created in the S7 program "My Program" and to enter the

    following logic operations in the code section of the block.

    What to Do 1. In the SIMATIC Manager, double-click on the Blocks folder in the programMy_Program to open it.

    2. Select the menu options View -> Offlineor alternatively:

    2a. Click on the Offline icon in the toolbar.

    3. Open FC 1 (and the LAD/STL/FBD Editor) by double-clicking its block icon.

    4. Select the menu options View -> LAD in the LAD/STL/FBD Editor.

    5. Enter the program shown belowin Ladder Diagram using the icons

    in the toolbar.

    Editing Tips To position the first element, move the cursor to the network line.Position the cursor above the symbol concerned (using the mouse or the TAB key) toenter the addresses.You can use the TAB key to jump from one element to another.

    Result I 0.0 I 0.1 Q 8.0 (Q 4.0)

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 14

  • 8/10/2019 PRO1_05E [ ] [ ]

    15/26

    Remember ! After you have opened a block for editing or testing, you can choose one of theprogramm ng anguages , or .

    If you write your program in LAD/FBD and switch to STL view, all your entries will

    be converted into a list of statements. This method does not always produce themost efficient program code.

    Goal To select the programming language for editing a block.

    What to Do 1. Open the FC1 block in the LAD/STL/FBD Editor.

    . e ec your programm ng anguage rom e ew menu.

    Result Your program will be displayed in one of the following programming languages:

    LAD:

    I 0.0 I 0.1 Q 8.0 (Q 4.0)

    STL: A I 0.0AN I 0.1= Q 8.0 (Q4.0)

    FBD:

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 15

    I 0.0 &

    Q 8.0 (Q4.0)I 0.1 =

  • 8/10/2019 PRO1_05E [ ] [ ]

    16/26

    Remember ! After you have created a program block, you should save it on diskette or on the" ar s o preven rom e ng os . ou o s w e norma n ows ave

    facility, using one of the two methods shown above.

    If you use the menu options File => Save As, you must specify the project,program and block name you want to use.

    After you have saved the block, you can select, in the SIMATIC Manager, theproject/program directory in which the block was saved. When the block isdisplayed, you can use the SIMATIC Manager like the "Explorer to copy the blockto several CPUs or to move it somewhere else.

    Goal To save a program block.

    What to Do 1. Select the menu options File -> Save or click the Save icon

    or2. Select the menu options File -> Save As and enter the details.

    Result 1. The program block is saved with the block name you specified when you.

    2. With Save As, the program block is saved with the new name you enter.

    Note When you save a program it is not copied to the CPU.(You do this with the Download option)

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 16

  • 8/10/2019 PRO1_05E [ ] [ ]

    17/26

    Remember ! After you have created and edited a block, you must transfer it to the CPU in ordero e a e o es .

    You can download the just opened block into the PLC with the LAD/STL/FBD

    Editor.

    With the SIMATIC Manager, you can download blocks without opening them.

    Goal To download a block (FC 1) with the LAD/STL/FBD Editor.

    What to Do With the LAD/STL/FBD Editor open ....

    1. Select the menu options PLC -> Download or click on the Downloadicon

    2. Answer the question in the dialog box:

    If you answer Yes", the block already in the CPU will be overwritten and lost. Ifyou answer "No", the old block will remain in the CPU and the new one will not bedownloaded.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 17

    Choose Yes" for this exercise, so that you can then test the block you have

    edited.

    Result Your new program block is written to the CPU.

  • 8/10/2019 PRO1_05E [ ] [ ]

    18/26

    Remember ! The FC 1 function must be called in OB 1 so that it can be executed cyclically.

    Goal To call FC 1 in the organization block OB 1.

    What to Do 1. In the LAD/STL/FBD Editor, open the OB 1 block from the S7 Program"My Program".

    2. Select a location in the rung of Network 1.

    3. Open the "Program Elements" browser by clicking on the icon.

    4. Open the "FC Blocks" entry in the browser and using the mouse drag FC 1to Network 1 in OB 1.

    5. Save the FC 1 block.

    6. Download the block to the CPU.

    Result The OB 1 block is cyclically executed in the CPU; and therefore also the FC 1function.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 18

  • 8/10/2019 PRO1_05E [ ] [ ]

    19/26

    Remember ! To monitor the program execution of a block, it must be open online or offline. Ife oc s open o ne, mus e own oa e o e e ore you can es .

    Display If the result of a check is positive, the relevant symbol is displayed with solid lines.

    If not, it is displayed with dashed lines.

    If the RLO=1, the rung is shown as a solid line. If not, it appears as a dashed line.

    You can change the thickness and color of the lines in the LAD/STL/FBD Editorby selecting the menu options Options => Customize => LAD/FBD.

    Goal To test a block while it is being executed in the CPU.

    What to Do 1. Open FC 1 offline.

    2. Select the menu options Debug -> Monitor or click on thespectacles icon

    Result Depending on the switch settings at inputs I 0.0 and I 0.1, you will see one of thedisplays shown in the slide.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 19

  • 8/10/2019 PRO1_05E [ ] [ ]

    20/26

    Remember ! You can only make program corrections after the program status has beencomp e e . o a e program correc ons can a e e ec , you ave o own oathe block once more to the CPU.

    Goal To expand and test the program in FC 1.

    What to Do 1. Deactivate the program status by clicking on the spectacles icon.

    2. Select the location between the first and the second contact.

    3. Insert a branch using the icon

    4. Insert a contact in the parallel branch.

    5. Close the parallel branch using the icon

    6. Save the block.

    7. Download the block in the CPU.

    8. Test the block with the test function "Program Status".

    Result The output can also be controlled with the condition in the parallel branch.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 20

  • 8/10/2019 PRO1_05E [ ] [ ]

    21/26

    Text You select the font and the size of the text to be used for programming here.

    View You can display blocks:

    with symbolic or absolute addressing

    with or without symbol information

    with or without block and network comments

    in the language in which they were written or in a preset language(LAD/STL/FBD).

    Data Blocks You can display data blocks in the following views:

    declaration view or

    data view .

    New Block You use the STL, LAD, FBD buttons to select the language in which you wantto write a new block.

    Multi-instance function blocks are discussed in an advanced programming course.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 21

  • 8/10/2019 PRO1_05E [ ] [ ]

    22/26

    Status Fields When you monitor the status of a block in STL, only the status fields you activate ins a og ox w e sp aye .

    The following options are available:

    Status Bit The status bit is displayed.

    RLO The result of logic operation (RLO) is displayed.

    Standard Status A timer word, counter word or the contents of ACCU 1 aredisplayed - depending on the operation used.

    Address The address registers are used with indirect addressing.Registers *)

    Accumulator 2 The contents of ACCU 2 are displayed.

    DB Registers *) The contents of the relevant data block register aredisplayed.

    Indirect *) This display is only possible with memory-indirectaddressing.

    Status Word The status word is displayed. Default The Default button selects the standard system setting for

    the Status field.The status bit, RLO and standard status are displayed.

    Activate New Breakpoints ImmediatelyThis option is only relevant for the the test function

    Breakpoint.

    Note*) The topics Indirect Addressing , DB Registers and the structure of the statusword are discussed in an advanced programming course.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 22

  • 8/10/2019 PRO1_05E [ ] [ ]

    23/26

    Layout Here you select the print format:

    DIN A4 Portrait

    DIN A4 Landscape maximum size.

    Width of Address You can set the limit for the maximum number of characters in an address nameField to a number between 10 and 24. This changes the width of the program element in

    LAD and FBD. With symbolic representation, a line break takes place according tothe Width of Address Field.

    Element The program elements can be displayed in different ways:Representation 2-dimensional or

    3-dimensional.

    Line/Color You use this box to choose how you want the following to be displayed Selected Element (color)

    Status Fulfilled (color and line)

    Status Not Fulfilled (color and line)

    Type Check When you edit a block, the type of address entered in bit logic instructions is alwayschecked.You can deactivate the Type Check for Addresses for comparisons, mathematicaloperations etc. ( for experienced users only! ).

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 23

  • 8/10/2019 PRO1_05E [ ] [ ]

    24/26

    Generate When you modify blocks and save them, the reference data is automatically " "e erence a a up a e , e enera e e erence a a op on n e rea e oc a s

    checked.

    If this option is not checked, the reference data is not updated at first. But the nexttime you open the Displaying S7 Reference Data" window, you must decidewhether you want to update the reference data and for which blocks.

    Note: The topic "Reference Data" is discussed in detail in the ChapterTroubleshooting".

    " " _System Att ribute... with a process control system (PCS7) and is not dealt with in this course.

    Store Process The "Store Process Diagnostics Data" option is only relevant when using theDiagnostics Data "PDIAG" option package and is not dealt with in this course.

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 24

  • 8/10/2019 PRO1_05E [ ] [ ]

    25/26

    Note Compiling source code blocks is discussed in more detail in the Chapter Functions"an unc on oc s .

    Training Centerfor Automation and Drives

    ST-7PRO1Editing BlocksPage 25

  • 8/10/2019 PRO1_05E [ ] [ ]

    26/26

    Note Here you select the structure of the symbol selection list.ou can ac va e an eac va e e sp ay o e s w en you ma e en r es us ng

    the menu options View -> Display ->Symbol Selection in the Program Editor.

    If the Symbol Selection is activated, a list with the current symbols from the symboltable is displayed when you enter variables in LAD and FBD. In the list that isdisplayed, the symbol is marked that is best suited to the character chain at thecursor position. It can be accepted by pressing the Return key.