Industry Sector, IA&DT SCE Training Curriculum for Integrated Automation Solutions Totally Integrated Automation (TIA) Siemens Automation Cooperates with Education TIA Portal Module 040-020 Startup Programming in High-Level Languages with S7-SCL and SIMATIC S7-300 SCE Training Curriculum TIA Portal Module 040-020, Edition 03/2013 Page 1 of 30 SCE_EN_040-020_R1209_Startup Programming in High-Level Languages with S7-SCL and SIMATIC S7-300 To be used only at Educational and R&D Facilities Unrestricted /
Industry Sector, IA&DT Suitable SCE trainer packages for these training curriculums SIMATIC controllers SIMATIC S7-300 with CPU 314C-2PN/DP Order no.: 6ES7314-6EH04-4AB3 SIMATIC S7-300 with CPU 314C-2PN/DP (upgrade) Order no.: 6ES7314-6EH04-4AB4 SIMATIC S7-300 with CPU 315F-2PN/DP Order no.: ES7315-2FH14-4AB1 SIMATIC ET 200S with CPU IM151-8 F PN/DP Order no.: 6ES7151-8FB00-4AB1 SIMATIC STEP 7 software for training SIMATIC STEP 7 Professional V11 - Single license Order no.
Industry Sector, IA&DT PAGE: 1. 2. 3. 4. 4.1 Preface ....................................................................................................................................................... 4 Notes on S7-SCL Programming Language ................................................................................................ 6 The S7-SCL Development Environment .................................................................................................... 7 Example Task Tank Content ....
Industry Sector, IA&DT 1. Preface The content of the SCE_EN_040-020 module is part of the 'Other Programming Languages' training unit and represents a fast entry point for programming the SIMATIC S7 300 with the S7-SCL programming language with the TIA Portal.
Industry Sector, IA&DT Required hardware and software 1 PC Pentium 4, 1.7 GHz 1 (XP) – 2 (Vista) GB RAM, approx.
Industry Sector, IA&DT 2. Notes on S7-SCL Programming Language S7-SCL (Structured Control Language) is a high-level programming language based on PASCAL, which allows structured programming. The language corresponds to the SFC "Sequential Function Chart" language specified in the standard DIN EN-61131-3 (IEC 61131-3). In addition to high-level programming language elements, S7-SCL contains typical elements of the PLC such as inputs, outputs, timers, bit memories, block calls etc. as language elements.
Industry Sector, IA&DT 3. The S7-SCL Development Environment To use and deploy S7-SCL there is a development environment that is oriented to specific features of both S7-SCL and STEP 7. This development environment consists of an editor/compiler and a debugger. S7-SCL for S7-300/400 Editor / compiler Debugger Editor / compiler The S7-SCL editor is a text editor with which texts can be edited. The central task you use the editor for is to create and edit blocks for STEP 7 programs.
Industry Sector, IA&DT 4. Example Task Tank Content 4.1 Description of task Our first program is one to program the calculate the content of tank. The tank has the shape of an upright cylinder. The fill level of the content is measured by an analog sensor. In the task, the value of the fill level should already existed standardized in the meter unit. A function FC 140 'calculate_tank content' is to be programmed in the program. The diameter and the fill level in meter unit are the passed parameters.
Industry Sector, IA&DT 4.3 Program structure Program execution is written in what are referred to as blocks. The Main [OB1] organization block is provided as default. This block represents the interface to the CPU operating system and is automatically called and cyclically processed by this operating system.
Industry Sector, IA&DT 4.4 Interface of the block calculate_tankcontent [FC140] The interface of the block must be declared before the program can be written. In the interface declaration, the local tags known only in this block are defined. The tags or interface parameters are divided into two groups: Block parameters that form the block interface for the call in the program. Type Designation Function Available in Input parameters Input Parameters whose values are read by the block.
Industry Sector, IA&DT The interface parameters for the 'calculate_tankcontent [FC140] block used in our sample program are as follows. Interface of the function FC140: Type IN IN OUT calculate_tankcontent Name Fill level Diameter Content Data type REAL REAL REAL Comment in meters in meters in liters The function call in a block programmed in FBD appears as follows. Function call: Representation in FBD FC140 calculate_tankcontent Fill level: REAL Diameter: REAL REAL :content 4.
Industry Sector, IA&DT 5. Programming the Tank Content Calculation for SIMATIC S7-300 in S7-SCL The following steps enable you to create a project for SIMATIC S7-300 and to program the solution for the task: 5.1 Creating a project and configuring hardware 1. The central tool is the 'Totally Integrated Automation Portal', which is opened here with a double-click. ( TIA Portal V11) 2. Programs for SIMATIC S7-300 are managed in projects. Such a project is now created in the portal view.
Industry Sector, IA&DT 3. 'First steps' for configuring are suggested. We want to start with 'Configure a device'. ( First steps Configure a device) 4. The next step is 'Add new device' with the 'Device name Controller 001'. Choose the 'CPU 315F-2 PN/DP' with the appropriate order number from the catalog. ( Add new device Controller 001 PLC SIMATIC S7-300 CPU CPU 315F-2 PN/DP 6ES7 315-2FH130AB0 V2.
Industry Sector, IA&DT 5. The software now switches automatically to the project view containing the opened hardware configuration in the device view. To ensure that the software will access the correct CPU later, the 'ETHERNET address' of the CPU has to be set. ( Properties General ETHERNET address IP address: 192.168.0.80 Subnet mask: 255.255.255.0) 6. Additional modules can be added for the hardware catalog (on the right).
Industry Sector, IA&DT 7. We also select the 'AI8x12Bit' signal module with 8 analog input and the 'PS307 2A' power supply module and drag these to the respective slots 5 and 1.
Industry Sector, IA&DT 5.2 Creating a program 1. Open the Default tag table' and enter the 'operands' with their name and data type. ( Controller 001[CPU315F-2 PN/DP] PLC-tags Default tag table Enter operands) SCE Training Curriculum TIA Portal Module 040-020, Edition 03/2013 Page 16 of 30 SCE_EN_040-020_R1209_Startup Programming in High-Level Languages with S7-SCL and SIMATIC S7-300 To be used only at Educational and R&D Facilities Unrestricted / © Siemens AG 2013.
Industry Sector, IA&DT 2. To create the function calculate_tankcontent [FC140], select 'Controller 001 [CPU 315F-2 PN/DP]' in the project tree and then 'Program blocks'. Then, double-click 'Add new block'. Select 'Function (FC)' and assign the name 'calculate_tankcontent'. Change the programming language to 'SCL'. You can change the numbering by switching from automatic to manual. Enter the number 140. Click 'OK' to accept your entries.
Industry Sector, IA&DT 3. The 'calculate_tankcontent [FC140]' block opens automatically. Enter the 'Input and output parameters' of the block as specified. All local tags should also be provided with a 'sufficiently descriptive comment' for better understanding. ( Enlarge interface of block FC140 Enter interface parameters) Diagram 0-1 Note: To avoid confusion with the PLC tags it is helpful to write the local tags with small letters.
Industry Sector, IA&DT 4. Once the local tags have been declared, you can start to create the program shown here. The square function 'SQR' is used to square a number for this purpose. The number to be squared is enclosed in brackets. To insert the function, drag it to the position of use in the program. ( Instructions (menu on the right) Basic instructions Mathematical functions SQR) 5. Supplement the program as specified below.
Industry Sector, IA&DT 6. The program can now be saved ( Save 7. and compiled Compile . ) Syntax errors that occur are recognized during compilation and display in the 'Menu Info/Compile'. ( Info Compile) SCE Training Curriculum TIA Portal Module 040-020, Edition 03/2013 Page 20 of 30 SCE_EN_040-020_R1209_Startup Programming in High-Level Languages with S7-SCL and SIMATIC S7-300 To be used only at Educational and R&D Facilities Unrestricted / © Siemens AG 2013.
Industry Sector, IA&DT 8. The function can now be called in the 'Main [OB1]'. Before we double-click to open the 'Main [OB1]' block, we select 'FBP' as its programming language. ( Main [OB1] Switch programming language FBD) 9. The 'calculate_tankcontent [FC140]' function can then be moved into Network 1 of the Main [OB1] block using a drag-and-drop operation. The interface parameters of the 'calculate_tankcontent [FC140]' function have to be connected to the global PLC tags, as shown here.
Industry Sector, IA&DT 10. The button ( is used to resave the project. ) 11. To load the program blocks and the device configuration to the CPU, first select the 'Controller 001 [CPU 315F-2 PN/DP]' folder and then click the Download to device icon . ( Program blocks ) Note: During downloading the project is automatically recompiled and checked for errors.
Industry Sector, IA&DT 12. An overview for checking the steps to be executed is shown before the download process starts. Click 'Load' to start loading the program. ( Load) 5.3 Test program 1. Clicking the icon (Monitoring on/off) allows you to monitor the state of the simulated input and output tags on the 'calculate_tankcontent' block.
Industry Sector, IA&DT 2. Since no analog sensor exists and thus no corresponding process value is available, we have to specify the values 'Diameter_tank1' and 'Fill-level_tank1' using the watch table. Create a 'new watch table' and enter the two values. To see the current values, switch 'Monitoring mode on'. ( Controller 001 Watch and force table New watch table Diameter_tank1, Fill-level_tank1 3. ) To specify the values, you have to enter a modify value in the 'Modify value' column.
Industry Sector, IA&DT 4. The program in OB1 can now be checked. ( 5. The values of the individual tags can be monitored in the SCL editor. To do this, switch 'Monitoring mode on'. ( ) ) Note: When you click the current values of the tags programmed in this row are displayed.
Industry Sector, IA&DT 5.4 Expanding the program Next, we will check whether faulty information is contained in the input parameters of the 'calculate_tankcontent' block. Another value 'high_max' is also passed to the block. This indicates the height of the tank. The block is now to analyze whether the fill-level of the tank is less than zero or greater than the specified tank height. It is also to be checked whether the diameter was specified as less than zero.
Industry Sector, IA&DT 1. Expand the 'Tag table' of the block as specified above. ( Controller 001[CPU 315F-2 PN/DP] PLC- tags Default tag table Enter operands 2. Expand the 'Interface parameters' of the block as specified above.
Industry Sector, IA&DT 3. Next, expand the program as specified below and check it for syntax errors by compiling it. Save the program and load it to the controller. (Write program SCE Training Curriculum TIA Portal Module 040-020, Edition 03/2013 ) Page 28 of 30 SCE_EN_040-020_R1209_Startup Programming in High-Level Languages with S7-SCL and SIMATIC S7-300 To be used only at Educational and R&D Facilities Unrestricted / © Siemens AG 2013.
Industry Sector, IA&DT 4. Because the parameters of the block were changed, the call must be updated in OB1. Open OB1 and scroll to the position of the block call. Right-click to open the shortcut menu and then click 'Update'. ( Controller 001 [CPU 315F-2 PN/DP] Program blocks Main [OB1] Right mouse button Update) 5. The old and the new interface will now be displayed. Click 'OK' to confirm.
Industry Sector, IA&DT 6. Complete the values at the input parameter 'high_max' and output parameter 'er' as specified below. Compile, save and load the program to the controller. (Add other parameters 7. ) Check the changes in the 'Monitoring mode' of the 'calculate_tankcontent' block. Note: You can change the display format of the current value by right-clicking the value and opening the shortcut menu.