13
SIEMENS SIEMENS SIEMENS SIEMENS Automation and Drive Technology T I A Training Document Page 1 of 13 Module 3 Programming Training document for company-wide automation solution Totally Integrated Automation (T I A) Module 3 Programming

Module 3 Programming

Embed Size (px)

DESCRIPTION

Free

Citation preview

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 1 of 13 Module 3 Programming

    Training document for company-wide

    automation solution

    Totally Integrated Automation (T I A)

    Module 3

    Programming

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 2 of 13 Module 3 Programming

    This document was provided by Siemens A&D SCE (automation and drive technology, Siemens A&D Cooperates with Education) for training purposes. Siemens does not make any type of guarantee regarding its contents. The passing on or duplication of this document, including the use and report of its contents, is only permitted within public and training facilities.

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 3 of 13 Module 3 Programming

    Introduction Programming is the actual development phase where code is written to solve your automation task. By breaking your task into smaller units, each piece can be written and tested in a variety of different standard programming language.

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 4 of 13 Module 3 Programming

    Create a linear program In a linear program, all of the program instructions are located in one contiguous code block. This structure is similar to a fixed-wired relay circuit replaced by a programmable logic controller. The system processes the individual instructions successively, with the entire program executed every scan.

    Step 1 : Open the project and select the programs Blocks folder, then double-click on OB1.

    This will open the main code block (Organization Block 1) that executes every scan. When this block opens the first time, you can select the programming language of choice in the pop-up overlay under Created in Language. For this example, select LAD.

    Step 2 : Open the Program Elements instruction catalog by clicking on the icon in the toolbar or by using the menu items Insert > Program Elements. In the Ladder Program Editor, use the programming icon in the toolbar to insert the program elements (contacts, coils, etc).

    Step 3 : Place the instruction on the network by drag and drop or double-click. To enter the address, place the cursor above the element with the Tab key or a mouse-click. For this example, use the following address I0.0, I0.1, Q0.0 on the first network.

    Note : Make sure that your language options are selected for English mnemonics (In the SIMATIC Manager, select the menu items Options > Customize > Language > English.

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 5 of 13 Module 3 Programming

    Step 4 : Insert a new line of code by using the New Network icon in the toolbar. You can also use the menu items Insert > New Network. Select the Move folder and drag and drop the Move instruction onto the new network.

    Step 5 : Position the cursor above the question marks and enter the address. For example, use MW20 and MW22.

    Step 6 : To save your work to your computer, click the Save icon in the toolbar.

    Note : You can also save your work by using the file menu items, File > Save.

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 6 of 13 Module 3 Programming

    Select the programming language STEP 7s basic Program Editor support three standard programming languages :

    LAD (Ladder Logic) FBD (Function Block Diagram) STL (Statement List)

    This section shows you how to select and change the programming language. Inaddition to these basic choices, SIEMENS offers several additional programming languages within STEP 7 to fit your development needs.

    Step 1 : From the SIMATIC Manager, open your project and program to the Blocks folder. Select block (OB, FB or FC) in the Block folder and double-click on it to open the Program Editor. For this example, double-click on OB1.

    Step 2 : In the Program Editor select the View menu and choose from three programming language choices, LAD / STL / FBD.

    You can also use the hot-keys to make your choices :

    Ctrl + 1 = LAD Ctrl + 2 = STL Ctrl + 3 = FBD

    Note : STEP 7 also supports additional programming languages.

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 7 of 13 Module 3 Programming

    Use symbolic names Symbolic addressing make it possible for you to work with your process or machine names, such as CONVEYOR, instead of absolute address, such as Q4.7. Symbols make a program easier to develop, read, and support as symbols relate the program to the process or application. As program variables, blocks, data type, etc can have symbol names.

    Step 1 : From the SIMATIC Manager, open the project and select your S7 program folder. Across from the Program folder will be a Symbols icon. Double-click on this Symbols icon to launch the Symbol Editor and open this symbol file.

    Step 2 : Build your spreadsheet of symbol names by entering the name in the Symbol field. Then use TAB-key to move the additional fields (Address, Data Type, Comment). For this example, complete the Symbol Table as shown in the screen capture.

    Note : Save your work by selecting the Save icon in the toolbar.

    Step 3 : Open the Program Editor by double clicking on code block in the Block folder in the SIMATIC Manager.

    You can use the symbolic names several ways. To access all the option, turn on all symbol choices. Use the menu options. View > Display with > Symbol Representation, Symbol Information and Symbol Selection.

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 8 of 13 Module 3 Programming

    Step 4 : To use the Symbol names within program.

    1. In the addressing field, type in the first letter of symbol name. Pick the symbol name from the pop-up list.

    2. In the address field, right-mouse click to use the insert sybol selection. The pick the symbol name to be used.

    3. In the absolute address (ex I0.0) and the symbol name will be pulled in from the symbol table.

    4. Type in the entire name of the symbol address.

    Create a subroutine Soubroutine is simply group of logic saved in a code block that has been developed to solve a particular task. By dividing or partitioning program into block, each application task can be developed and tested, the used later in the program as needed. Subroutine in STEP7 called Functions (FC) and Function Blocks (FB). Instruction in the block determine the sequence, in which the subroutines are processed Example include controling various operating modes in a manufacturing process or performing calculation or data collection on a time/event basis.

    Step 1 : Open your project and select the Programs Block folder. Then select the menu items Insert > S7 Block > Function.

    In the overlay, change the function number, symbol name/comment and the programming language. For this example, use FC2, Alarm as the symbol name, Analog Test as the symbol comment and LAD as the programming language. Select OK to continue.

    Note : You can also use the right-mouse click to access the Insert > Function.

    Step 2 : From the SIMATIC Manager, double-click on the FC2 icon to open it into the Ladder Program Editor.

    Note : Make sure that you have your language options are selected for English mnemonic.

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 9 of 13 Module 3 Programming

    Step 3 : Open the Program Element catalog by selecting the icon in the toolbar.

    For this example, open the Comparator group and select the GT_I (Greater Than_Integer) box instruction and drag onto the network. (This instruction campares one value against another and turns on its output when the evaluation is true).

    Use PIW288 in the top address, and the constant 1200 in the bottom address.

    Step 4 : From the toolbar, select the coil icon and place it at the end of the network. For this example, use the address Q4.2 as its address above the instruction.

    Note : This address PIW288 means, Peripheral Input Word 288.

    Step 5 : Using the Save icon in the toolbar, save this subroutine Function.

    The result is that this dedicated subroutine has been saved in the Block folder of your program and is now available to be used in the Program Elements catalog under the folder FC blocks.

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 10 of 13 Module 3 Programming

    Create a reusable subroutine A reusable subroutine allows you to develop code once that can be used over and over. Similar or repetitive process/machine control functions can be written in a generic solution in a block of instructions. By passing information (parameters) to this block, the subroutine becomes application specific. The use of these reusable blocks is called a structured program. Within STEP 7, these subroutines can either be Functions (FCs) or Function Blocks (FBs).

    Step 1 : Open your project to its program folder. Select the programs Block folder, then use the menu option Insert > S7 Block > Function.

    Note : You can also right mouse click and select Insert New Object > Function.

    Step 2 : Double-click on the new subroutine FC1 icon. Use the symbol name TripAdd, symbol comment Add subroutine, and LAD in the next screen. Select OK to confirm.

    Step 3 : If not visible, view the variable declaration table (local variable names used by this subroutine) by splitting the window using your mouse cursor to move the window bar.

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 11 of 13 Module 3 Programming

    Step 4 : Define the local interface of the subroutine. Insert names for the variable used in the function and assign their data type as shown :

    In var1 INT In var2 INT In var3 INT Out result INT Temp temp INT

    Open the Program Elements, and insert two ADD_I (Add Integer) instructions onto the LAD network from the integer fct folder. These instructions will be in series on the code line.

    Step 5 : Use the local variable names of the variable declaration table in the LAD instruction on the network as shown (the equation is solved like this : var1 + var2 = temp, then temp + var3 = result). Then select save icon in the toolbar.

    Note : After saving this subroutine function, it appears as reusable function in the FC Block folder of the Program Elements catalog.

    Download a program After you created, edited and saved a program, the next step is to download this code to the CPU. Downloading copies the code from your PC (offline) to the CPU (online). Within STEP 7, you can use Simatic Manager to download the entire program or multiple block. You can use the program editor to download individual blocks that are open.

    Opt. 1 : Download the entire program in the Simatic Manager, select the block folder of your program to be downloaded and click the download icon in the toolbar. This downloads the entire contents of the Blocks folder.

    Note : When downloading entire program, it is suggested that the CPU key in the STOP position.

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 12 of 13 Module 3 Programming

    Opt. 2 : Download the individual blocks in the Simatic Manager, select the specified block or blocks in the Blocks folder of your program and click on the download icon in the toolbar. You can also use the menu options PLC > Download or press Ctrl + L.

    Display program status In the Program Editor, you can display the program status in the three programming language Ladder Logic/Statement List/Function Block Diagram (LAD/STL/FBD). LAD : Display the instruction status, power flow and the box instruction input/output values. FBD : Display power flow, instruction status and block instruction input/output values. STL : Display the operand status, the Result of Logic Operation (RLO) and the register values for

    instruction/combinations. Additional status options are available.

    Step 1 : From the SIMATIC Manager, open your project and select your CPU station or program. To go ONLINE with the CPU, click the Online icon in the toolbar. This will build a directory of all the code blocks within the CPU.

    Step 2 : Double-click the code block that you want to open in the CPU to display the status. In this example, select OB1.

  • SIEMENSSIEMENSSIEMENSSIEMENS Automation and Drive Technology

    T I A Training Document Page 13 of 13 Module 3 Programming

    Step 3 : In the Program Editor, click the eyeglass from the toolbar. As a result you will see the status and the colored signal flow. You can also turn on the status by selecting the menu options Debug > Monitor.

    Note : Status is updated when the CPU is in RUN mode.