【西门子自动化课程】 (25)
- 格式:doc
- 大小:699.00 KB
- 文档页数:18
Training document for the company-wideautomation solutionTotally Integrated Automation (T I A)MODULE D4PROFIBUS DP withMaster CPU 315-2DP / Slave ET 200MThis 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.Exceptions require written permission by Siemens A&D SCE (Mr. Knust: E-Mail:michael.knust@hvr.siemens.de). Offences are subject to possible payment for damages caused. All right s are reserved for translation and any case of patenting or GM entry.We thank the company Michael Dziallas Engineering and the instructors of vocational schools as well as further persons for the support with the production of the document.PAGE:1. Forward ........................................................................................................ 42. Notes to the Operation of the CPU 315-2DP ................................................... 63. Notes to the Operation of the ET 200M .......................................................... 64. Commissioning the Profibus ( Master CPU 315-2DP / Slave ET200M) ............7The following symbols stand for the specified modules:InformationProgramming Example exercise Notes1. FORWARDThe module D4 is assigned content wise to Industrial field bus systems.Learning goal:In this module, the reader should learn how the PROFIBUS DP is taken into operation with the CPU315-2DP as a master and the ET 200M as a slave. The module shows the principle procedure bymeans of a short example.Requirements:For the successful use of this module, the following knowledge is assumed:∙Knowledge in the use of Windows 95/98/2000/ME/NT4.0∙Basics of PLC- Programming with STEP 7 (e.g. Module A3 - ‘Startup’PLC programming with STEP 7)∙Basics of the PROFIBUS DP (e.g. Appendix IV – Basics offield bus systems with SIMATIC S7-300)Required hardware and software1 PC, Operating system Windows 95/98/2000/ME/NT4.0 with- Minimal: 133MHz and 64MB RAM, approx. 65 MB free hard disk space - Optimal: 500MHz and 128MB RAM, approx. 65 MB free hard disk space 2 Software STEP 7 V 5.x3 MPI- Interface for the PC (e.g. PC- Adapter)4 PLC SIMATIC S7-300 with the CPU 315-2DP Example configuration:- Network: PS 307 2A - CPU: CPU 315-2DP5 Distributed I/O ET 200M with at least one digital in- and output. Example configuration:- Power supply: PS 307 2A - PROFIBUS terminal: IM 153-1 - Digital inputs: DI 16x DC24V- Digital outputs: DO 16x DC24V / 0.5 A 6 PROFIBUS cable with 2 PROFIBUS slots1 PC2 STEP 74 SIMATIC S7-300 with CPU 315-2DP5 ET 200M2.NOTES FOR THE OPERATION OF THE CPU 315-2DPThe CPU 315-2DP is a CPU that is made available with an integrated PROFIBUS DP interface. For the CPU 315-2DP, the following PROFIBUS protocol profiles are available at your disposal: -DP- Interface as a master or slave in accordance with EN 50170. PROFIBUS-DP (Distributed I/O) is the protocol profile for the connection of distributed I/O/Field equipment with fast reaction time.A further characteristic is that the addresses of the in- and output modules can be parameterized by this CPU.The CPU capability is given with the following data:- 16K Statements. 48Kbyte RAM (integrated) 80Kbyte RAM - 1024 Byte DI/DO - 128 Byte AI/AO- 0.3 ms / 1K Instructions - 64 Counters - 128 Timers- 2048 Memory bitsNote: The CPU 315-2DP is appointed here on the PROFIBUS as a master.3.NOTES TO THE OPERATION OF THE ET 200MThe ET 200M is a distributed I/O system with a small, compact configuration. The modules areidentical with the standard modules of the SIMATIC S7-300. By the actuators of the CPU, there is only one interface module (e.g. IM153-1) that functions as a slave on the PROFIBUS DP. The PROFIBUS address is adjusted by a binary coded DIL- switch block.Another possible adjustment of the PROFIBUS address is with the power recovery. Therefore, the ET 200M must be turned off and then back on.4.COMMISSIONING THE PROFIBUS ( MASTER CPU315-2DP / SLAVE ET200M )In the following example, the commissioning of a mono master system with the CPU315-2DP as a master and an ET 200M as a slave is described.For the testing of the configuration, a program will be written in which a display lamp H1 is triggered by the simultaneous activation of two buttons S0 and S1.Assignment list: I0.0 S0 Button selection 1 I0.1 S1 Button selection 2 Q0.0 H1Display lamp1. The central tool in STEP 7 is theSIMATIC Manager , which is opened here with a double click ( →SIMATIC Manager).2. STEP 7- Programs are administered in projects . Such a project will be created ( → File → New).3. Give the Name ET200M to the project ( → ET200M → OK).4. Highlight your project and insert a PROFIBUS Subnet (→ ET200M → Insert → Subnet →PROFIBUS).5. Then insert a SIMATIC 300-Station (→ Insert → Station → SIMATIC 300-Station).6. Open the configuration tool for the Hardware with a double click (→ Hardware).7. Open the hardware catalog with a click on the symbol (→ ).There you will see the directories are divided into the following:- PROFIBUS-DP, SIMATIC 300, SIMATIC 400 and SIMATIC PC Based Control,all module racks, modules and interface modules for the configuration of your hardware configuration are made available.Insert a Rail with a double click( → SIMATIC 300 → RACK-300 → Rail).After the insert, a configurations table for the configuration of the Rack 0 appears automatically.8. Now all modules can be chosen out of the hardware catalog and inserted into the configurationtable and are also inserted into your rack.To insert, you must click on the name of the respective module, hold the mouse button and Drag& Drop the module into a line of the configurations table. We will begin with the power supply PS 307 2A (→ SIMATIC 300 → PS-300 → PS 307 2A).Note: If your hardware differs from what is shown above, then you must select the appropriate modules from the catalog and insert them into the rack. The part numbers of the individual modules, which are found on the components, are indicated in the footer of the catalog.9. In the next step, we drop the CPU 315-2DP into the second card location. This allows for the partnumber and version of the CPU to be read off. (→ SIMATIC 300 → CPU-300 → CPU 315-2DP → 6ES7 315-2AF03-0AB0 → V1.1 ).10. By the entering of the CPU, the following window appears, in which you assign a PROFIBUSaddress to the CPU 315-2DP and must already choose the first PROFIBUS net. When you want to alter the parameter of the PROFIBUS net, you must highlight it and then click on Properties ( → Properties).11. Now you can choose the Highest PROFIBUS Address (here → 126), the Transmission Rate(here → 1,5 Mbit/s) and the Profile (here → DP). (→ OK).12. Then a bar chart for the Master system is shown to the right of the CPU315-2DP, in which you canarrange the PROFIBUS. This happens by clicking the desired module(Here the IM 153-1, an ET 200M interface module) from the hardware catalog in the pathPROFIBUS-DP . By Drag & Drop click with the mouse, it can be dropped into the master system.(→ PROFIBUS DP → ET 200M → IM 153-1→ 6ES7 153-1AA83-0X B0 ).13. By the entering of the slave, the following window is displayed in which you must assign a PROFIBUS address to the slave. This address must be identical with the address that you created in the rotary switch of the IM 153-1 ( → 5 → OK ).14. In the next step we see the input module for 16 inputs on fourth slot place of the ET 200M. Therethe order number of the module is read off the front (→ PROFIBUS DP → ET 200M → IM 153-1→ DI-300 → SM 321 DI16xDC24V).15. In the next step we see the output module for 16 outputs on fifth slot place of the ET 200M. Therethe order number of the module is read off the front (→ PROFIBUS DP → ET 200M → IM 153-1→DO-300 → SM 322 DO16xDC24V/0.5A).Note: The order number of the module is displayed in the footer of the catalog.16. The addresses of the I/O modules can now be modified.This happens by a double click on the corresponding input and output modules in the ET 200M and is adjusted in the register Address .In any case these addresses should be required. An automatic address allocation takes place in the sequence similar to how the slaves are entered ( → DO 16xDC24V/0,5A → Adresses → OK ).17. The configuration table should first be saved and compiled with a click on and then downloadedinto the PLC with. The mode switch on the CPU must be on STOP! ( →→)18. The CPU 315-2DP is then activated as the target module for the download activity (→ OK).19. The station address of the CPU in the MPI net is then chosen. You are only connected withthe CPU so you can accept with OK (→ OK).20. From the SIMATIC Manager , you can open the block OB1 with a double click in the editor LAD,STL, FBD: Program blocks ( → OB1).21. Optional: Enter the properties of the OB1 for documentation and accept with OK ( OK).21. With LAD, STL, FBD: Program blocks, you now have an editor which gives you the possibilty togenerate your STEP 7- Program. Here the organization block OB1 was already opened with the first network. In order to generate your first logical operation, you must highlight the first network.Now you can write your first STEP 7- Program. Several programs can usually be divided intonetworks. Open a new network by clicking on the network symbol .The STEP 7- Program to be tested can now be downloaded into the PLC.In our case, the OB1 is the only block. Save the organization block with and click on download . The mode switch of the CPU must be on STOP! ( →→)22. Through the switching of the mode switch to RUN, the program is started and after a click on thesymbol for monitoring, the program in the OB1 can be monitored (→).。
【西门子自动化课程】 (25)解决方案培训教材第二部分第五章使用功能块的结构化编程那个手册由西门子自动化与驱动集团教育合作部(automation and drive technology, Siemens A&D Cooperates with Education)以培训为目的编写。
西门子对其内容不做任何形式的保证。
手册的传播或者复制,包括其内容的使用与发表,仅作为公共教育及职业培训之用。
其他情形需要西门子自动化与驱动集团教育合作部的书面许可(Knust先生,E-Mail:michael.knust@hvr.siemens.de)。
违者必究。
西门子保留所有权力,包括翻译,以及专利权、有用新型或外观设计专有权。
感谢Michael Dziallas Engineering公司、职业学校的教师们,和其他有关朋友为本手册的编写做出的奉献。
1. 前言这部分的内容属于STEP 7编程晋阶中的环节。
学习目标:通过本章的学习,读者将学会如何样用含内部变量的功能块来进行结构化的编程。
产生一个功能块定义内部变量在功能块中给内部变量编程在组织块中调用和参数化一个功能块差不多要求:为了这部分内容的顺利进行,我们期望读者具备以下的基础知识: • Windows 95/98/2000/ME/NET 的差不多操作知识• 使用STEP 7 差不多的PLC 编程(比如,在A3部分讲的用STEP 7来启动一个PLC 程序)• 差不多的结构化编程(比如,附录四在S7-300上的差不多PLC 编程) 差不多STEP 7 编程2-3天 第一部分STEP 7 编程晋级2-3天 第二部分工业总线系统2-3天 第四部分 序列编程 2-3天 第三部分 过程可视化 2-3天 第六部分 SIMATIC S7 IT-通讯1-2天 第五部分需要的硬件和软件:1 PC , Windows 95/98/2000/ME/NET的操作系统,以及最小:133MHz,64MB 的RAM ,65MB的空余磁盘空间。
西门子PLC培训教程2024(全)目录CONTENCT •PLC基础知识•西门子PLC硬件组成及选型•西门子PLC软件编程环境搭建•基本指令集与程序结构设计•高级功能应用与扩展•故障诊断与排除技巧分享01PLC基础知识PLC定义与发展历程PLC定义可编程逻辑控制器(Programmable Logic Controller,PLC)是一种数字运算操作的电子系统,专为在工业环境下应用而设计。
发展历程从1960年代末期的初创阶段,到1970年代中期的成熟阶段,再到1980年代以后的高速发展阶段,PLC技术不断革新,应用领域也不断扩展。
PLC工作原理及特点工作原理PLC采用循环扫描的工作方式,即按照用户程序存储器中存放的先后顺序逐条执行指令,直到程序结束,然后重新返回第一条指令,开始下一轮新的扫描。
特点PLC具有可靠性高、抗干扰能力强、编程简单、易于维护等特点。
此外,PLC还具有丰富的I/O 接口模块和强大的通信功能,可方便地与其他设备进行数据交换。
西门子(Siemens )欧姆龙(Omron )三菱(Mitsubishi )罗克韦尔(Rockwell )常见PLC 品牌与型号介绍作为全球知名的电气和自动化解决方案提供商,西门子PLC 以其高性能、稳定性和广泛的应用领域而著称。
常见型号有S7-200、S7-300、S7-400等。
欧姆龙PLC 以其紧凑的设计、高速的处理速度和丰富的功能而备受赞誉。
常见型号有CP1H 、CP1L 、CJ2M 等。
三菱PLC 以其高性能、低价格和广泛的应用领域而深受用户喜爱。
常见型号有FX3U 、FX5U 、Q 系列等。
罗克韦尔PLC 以其强大的处理能力、灵活的编程方式和广泛的应用领域而著称。
常见型号有MicroLogix 、ControlLogix 、CompactLogix 等。
02西门子PLC硬件组成及选型CPU模块功能与选型方法CPU模块功能作为PLC的核心部件,CPU模块负责执行用户程序、处理数据、控制输入输出等操作,直接影响PLC的性能和速度。
Training Document for Comprehensive AutomationSolutionsTotally Integrated Automation (T I A)MODUL E04PROFINETwithIO Controller CPU 315F-2 PN/DPandIO Device ET 200SThis document has been written by Siemens AG for training purposes for the project entitled "Siemens Automation Cooperates with Education (SCE)".Siemens AG accepts no responsibility for the correctness of the contents.Transmission, use or reproduction of this document is only permitted within public training and educational facilities. Exceptions require the prior written approval by Siemens AG (Michael Knustmichael.knust@).Offenders will be liable for damages. All rights, including the right to translate the document, are reserved, particularly if a patent is granted or utility model is registered.We would like to thank the following: Michael Dziallas Engineering, the teachers at vocational schools, and all others who helped to prepare this document.PAGE1. Preface .................................................................................................................. 4 2. Notes on Using the CPU 315F-2 PN/DP ............................................................. 6 3. Notes on Using the ET 200S with IM151-3 PN HF (7)4. Starting Up the PROFINET(IO Controller CPU 315F-2 PN/DP/IO Device ET 200S) .....................................8The following symbols are used as a guide through Module E04:InformationProgramming Sample Exercise Notes1. PREFACEIn terms of its contents, Module E04 is part of the teaching unit entitled ’IT Communication withSIMAT IC S7’.Learning Objective:In Module E04, the reader learns how the PROFINET -with the CPU 315F-2PN/DP as IO controllerand the ET 200S as IO device- is started up. Module E04 illustrates the method in principle, using ashort example.Prerequisites:To successfully work through Module E04, the following knowledge is assumed:∙Knowledge in handling Windows∙Fundamentals of PLC programming with STEP 7 (for example, Module A3 - 'Startup’ PLC Programming with STEP 7)●Fundamentals of network engineering (for example, Appendix V - Basics of NetworkEngineering)Hardware and software required1PC, operating system Windows 2000 Professional starting with SP4/XP Professional starting with SP1/Server 2003 with 600MHz and 512RAM, free hard disk storage 650 to 900 MB, MS Internet Explorer 6.0 and network card2Software STEP7 V 5.43 PLC SIMATIC S7-300 with the CPU 315F-2 PN/DPSample configuration:- Power supply: PS 307 2A- CPU: CPU 315F-2 PN/DP4 Distributed periphery ET 200S for PROFINET with 2 digital inputs and 4 digital outputsSample Configuration:- Interface Module IM151-3 PN HIGH FEATURE- Power module PM-E DC 24V...48V/AC 24V (230V)- Electronic module: 2DI Standard DC 24V- Electronic module: 4DO Standard DC 24V/0.5A6 Ethernet connection between PC, CPU 315F-2 PN/DP and ET200S with IM 151-3 PN1 PC2 STEP 73 SIMATIC S7-300 with CPU 315F-2 PN/DP4 ET200S with IM 151-3 PN HIGH FEATURE2. NOTES ON USING THE CPU 315F-2 PN/DPThe CPU 315F-2 PN/DP is a CPU that is shipped with two integrated interfaces.-The first interface is a combined MPI/PROFIBUS-DP interface that can be used on the PROFIBUS DP as master or slave for connecting distributed periphery/field devices with veryfast response timing.In addition, the CPU can be programmed here by means of MPI or also PROFIBUS DP -The second interface is an integrated PROFINET interface.It allows for using the CPU as A PROFINET IO controller for operating distributed periphery onPROFINET. The CPU can also be programmed using this interface!-Fault-tolerant periphery devices can also be used on both interfaces.Notes:- In Module E04, the CPU 315F-2 PN/DP is used on the PROFINET as IO controller.- To run this CPU, a Micro Memory Card is required!-The addresses for input and output modules can be parameterized at this CPU.3. NOTES ON USING THE ET200S WITH THE IM 151-3 PN HFThe SIMATIC ET 200S is a decentral IO device configured in a highly modular mode. It can beoperated with different interface modules:IM 151-1 BASIC, IM 151-1 STANDARD and IM 151-1 FO STANDARD for connecting a maximum of63 IO modules (all types except PROFIsafe) to the PROFIBUS DP; alternatively, bus connection withRS 485 Sub-D connector or by means of an integrated fiber-optic connectionIM 151-1 HIGH FEATURE for connecting a maximum of 63 IO modules (all types, including clocked mode for PROFIsafe) to PROFIBUS DP; bus connection with RS485 Sub-D connectorIM 151-3 PN for connecting a maximum of 63 IO modules (all types, including the clocked mode forPROFIsafe) to PROFINET IO controllers; bus connection by means of RJ45 connectorIM 153 PN HF (HIGH FEATURE) for connecting a maximum of 63 IO modules (all types; includingthe clocked mode for PROFIsafe) to PROFINET IO controllers; bus connection with 2 x RJ45connectorIM 151-7/F-CPU, IM 151-7/CPU or IM 151-7/CPU FO for connecting a maximum of 63 IO modules(all types; PROFIsafe only with IM151-7/F CPU) to PROFIBUS DP; alternatively bus connection withRS 485 Sub-D connector or by means of an integrated fiber-optic connection; with integrated CPU314 of the SIMATIC S7-300, for preprocessing process data.The following IO modules can be used:Power modules for individual grouping of load and encoder supply voltages and their monitoringDigital electronic modules for connecting digital sensors and actuatorsAnalog electronic modules for connecting analog sensors and actuatorsSensor module for connecting IQ sense sensorsTechnology modules Electronic modules with integrated technological functions, such as counting,positioning, data exchange, etc.Frequency converters and motor starter modulesFor training purposes, an integrated system is provided, suitable for teaching many technologiesNotes:- In Module E04, the interface module IM151-3 PN HF is used as PROFINET IO device.- A micro memory card is required for running the IM151-3 PN HF!4.STARTING UP THE PROFINET (IO CONTROLLER CPU 315F-2 PN/DP/IO DEVICE ET200S) Below, the startup of a PROFINET network with the CPU 315F-2 PN/DP as IO controller and the ET200S as IO device is described. To test the configuration, a program is written. In this program, an indicator lamp P1 is activated when two buttons, S0 and S1, are operated simultaneously.Assignment List: I0.0 S0 Button Selection 1 I0.1 S1 Button Selection 2 O0.0 P1 Indicator lamp1. The central tool in STEP 7 is the ’SIMATIC Manager’. Here, it is called with a double click. (→SIMATIC Manager)2. STEP7 programs are managed in projects. We are now setting up such a project. (→ File →New)3. Now, the project is assigned the ’Name’ ’ET200S_PN’ (→ ET200S_PN → OK)4. Highlight your project and insert an ’Industrial Ethernet Subnet’. (→ ET200S_PN → Insert →Subnet → Industrial Ethernet)5. Then a ’SIMATIC 300 Station’ is inserted. (→ Insert → Station → SIMATIC 300 Station)6. With a double click, open the configuration tool ’Hardware’. (→ Hardware)7. Open the hardware catalog by clicking on the symbol '’. (→ )There, arranged in the following directories:PROFIBUS DP, PROFIBUS PA, PROFINET IO, SIMATIC 300, SIMATIC 400, SIMATIC PC Based Control, and SIMATIC PC Station,all racks, modules and interface modules are provided for configuring your hardware. Insert ’Rail’ with a double click. (→ SIMATIC 300 → RACK-300 → Rail)After that, a configuration table is displayed automatically for configuring Rack 0.8. From the hardware catalog, you can now select all modules that are also in your real rack, andinsert them in the configuration table.To this end, click on the name of the respective module, hold the mouse key and drag themodule to a line in the configuration table.We are starting with the power unit ’PS 307 2A’. (→ SIMATIC 300 → PS-300 → PS 307 2A)Note: If your hardware differs from the one displayed here, simply select the corresponding modules from the catalog and insert them in your rack. The order numbers of the individual modules -that are also indicated on the components- are displayed in the footer of the catalog..9. Next, we are dragging the ’CPU 315F-2 PN/DP’ to the second slot. The order number and theversion of the CPU can be read off the front of the CPU. (→ SIMATIC 300 → CPU-300 → CPU 315F-2 PN/DP → 6ES7 315-2FH10-0AB0 → V2.3)10. When entering the CPU, the following window appears. In it, assign an ’IP Ad dress’ to the CPU 315F-2 PN/DP, specify the ’Subnet screen form’ and select the ’Ethernet’ network that has already been generated. Optional: for net-overreaching communication, a ’RouterAddress ’ can be selected. Confirm your inputs with ’OK’ (→ IP Address: 192.168.1.10 → Subnet form screen: 255.255.255.0 → Ethernet(1) → Use Router → Address: 192.168.1.1 → OK)Notes on networking on the Ethernet (additional information in Appendix V of the Training ArrayDocument):MAC Address:The MAC address consists of 2 parts: a fixed and a variable part. The fixed part ("Basic MAC address“) indicates the manufacturer (Siemens, 3COM, ...). The variable part of the MAC address differentiates the various Ethernet stations, and should be assigned unique world-wide. On each module, a MAC address assigned by the factory is imprinted.Value range for the IO address:The IP address consists of 4 decimal numbers from the value range 0 to 255. They are separated by a period; for example, 141.80.0.16Value range of the subnet screen form:This screen form is used for recognizing whether a station or its IP address is part of the local subnet, or whether it can only be accessed by means of a router.The subnet screen consists of 4 decimal numbers from the value range 0 to 255, separated by a period; for example: 255.255.0.0In binary representation, the 4 decimal numbers of the subnet screen form have to contain, from the left, a series of gapless values "1" and from the right, a series of gapless values "0".The values "1" determine the area of the IP address for the network number. The values "0" determine the area of the IP address for the station address.Example:Correct values: 255.255.0.0 Decimal = 1111 1111.1111 1111.0000 0000.0000 0000 binary255.255.128.0 Decimal = 1111 1111.1111 1111.1000 0000.0000 0000 binary255.254.0.0 Decimal = 1111 1111.1111 1110.0000 0000.0000.0000 binary Incorrect value: 255.255.1.0 Decimal = 1111 1111.1111 1111.0000 0001.0000 0000 binary Value range for the address of the network transition (Router):The address consists of 4 decimal numbers from the value range 0 to 255, separated by a period; for example, 141.80.0.1.The relationship of IP addresses, router address and the subnet screen form:The IP address and the address of the network transition may differ only at those positions where there is an "0“ in the subnet screen form.Example:You entered: for subnet screen form 255.255.255.0; for IP address 141.30.0.5 and for the router address 141.30.128.1.The IP address and the address of the network transition may have a different value only in the 4th decimal number. In the example, however, the 3rd position is already different.In the example, you have to change alternatively:- the subnet screen form to: 255.255.0.0 or- the IP address to: 141.30.128.5 or- the address of the network transition to: 141.30.0.111. After you have made the network settings, a bar appears on the right of the CPU315-2 PN/DP,the ’PROFINET IO System’, where you can arrange PROFINET IO devices. This is done by clicking on the desired module (here ’ET 200S’ with ’IM151-3PN HF’) in the hardware catalog in the path ’PROFINET IO’ and dragging it to the ’PROFINET IO System’. (→ PROFINET IO → I/O → ET 200S → IM151-3PN HF)12. By double clicking on ’IM151-3 PNHF ’, its properties are opened. (→ IM151-3 PNHF)13. Each IO device has to be assigned a ’Device name’ that is unique within the PROFINET IO system and an IP address on the ’Ethernet’. (→ Device name: IM151-3PNHF → Ethernet)14. After the ’IP Ad dress’ was assigned, it has to be accepted with ’OK’.(→ IP Address: 192.168.1.11 → OK → OK)15. From the hardware catalog, you can now select all additional modules that are inserted in yourreal ET200S and add them to your configuration table. To this end, click on the name of the respective module, hold the mouse key, and drag the module to a line in the configuration table.We are starting with the power module ’PM-E DC24V...48V/AC24...230V’ by dragging it to Slot 1.(→ PROFINET IO → I/O → ET 200S → IM151-3 PN HF → PM → PM-EDC24V...48V/AC24...230V)16. Next, we are dragging the digital input module ’2DI DC24V ST’ to the second slot. The ordernumber and the version can be read from the module. (→ PROFINET IO → I/O → ET 200S → IM151-3 PN HF → DI → 2DI DC 24V ST)17. Then, we drag the digital output module ’4 DO DC 24V/0.5A ST’ to the 3rd slot. The order numberand the version can be read from the module. (→ PROFINET IO → I/O → ET 200S → IM151-3 PN HF → DO → 4 DO DC 24V/0.5A ST)18. Now, the addresses of the inputs and outputs in the ET 200S can be changed. This is done bydouble clicking on the corresponding input or output submodules in the ET 200S and setting them under the tab ’Addresses ’. These addresses should be noted down for each case. Addresses are assigned automatically in the sequence in which the submodules are entered. (→ 4DO DC 24V/0.5A ST → Addresses → OK)19. By clicking on '’, the configuration table is saved and compiled (→)20. Now, highlight the IO device and assign it a name ’Assign device name’. (→ IM151-3PNHF→PLC → Ethernet → Assign device name)Note: A precondition for this is that the PG/PC interface is set to TCP/IP, and the network card of the PC is correctly configured. For example: IP address 192.168.1.99, Subnet 255.255.255.0 and router address 192.168.1.1. (refer to Module E02).Note: Make sure your programming device is connected to the ET200S via the Ethernet.21. We now select the ET200S to assign the name ’Assign name’. (→ ET200S → Assign name)Note: If several IO devices are on the network, the device can be identified using theimprinted MAC address.22. The new device name is then displayed in the area ’Available devices’. ’Close’ the dialog. (→Close)23. Clicking on '’ loads the configuration table to the PLC. The operating mode switch on the CPUshould be on Stop! ()Note: Make sure your programming device is connected to the CPU via the Ethernet.24. The CPU 315F-2 PN/DP is confirmed a destination module of the loading process. (→ OK)25. In the dialog below, you can have the connected devices in the network ’Display’(ed). (→ Display)26. Then, the CPU’s MAC address in the Ethernet is selected. If you are connected to only one CP U,accept with ’OK’. (→ OK)Note: If several IO controllers are on the network, the device can be identified with theimprinted MAC address.27. Now, the correct IP address has to be assigned to the IO controller if it has not been set correctlyyet. Confirm the following dialog with 'Yes’. (→ Yes)<<The selected station does not have an IP address. Do you want to assign the address192.168.1.10 now?>>28. After you loaded the hardware configuration, you can start creating the program. Fromthe ’SIMATIC Manager’, select the block ’OB1’ with a double click. (→ OB1)29. Select the ’Programming language FBD’ and accept with ’O K’. (→ FBD →OK)30. With ‘LAD, STL, FBD – Program S7 blocks’, you now have an editor with which you cangenerate your STEP7 program accordingly. To this end, OB1 has already been opened with the first network. To generate your initial operations, highlight the first network. Now you can write your first STEP7 program. In STEP7, individual programs are usually arranged in networks. Anew network is opened by clicking on the network symbol '’. The STEP7 program that is to be tested can now be loaded. In our case, this is only OB1. Save OB1 '’ and click on Load '’. The CPU’s key switchshould be on STOP! (→ ‚’ →)31. By setting the operating mode switch to RUN, the program is started. By clicking on the symbol'’ for monitoring, the program can be monitored in ’OB1’. (→)Note: Make sure the CPU is connected to the ET200S via the Ethernet.。
全集成自动化(T I A)
解决方案培训教材
第二部分第五章
使用功能块的结构化编程
这个手册由西门子自动化与驱动集团教育合作部(automation and drive technology, Siemens A&D Cooperates with Education)以培训为目的编写。
西门子对其内容不做任何形式的保证。
手册的传播或者复制,包括其内容的使用与发表,仅作为公共教育及职业培训之用。
其他情况需要西门子自动化与驱动集团教育合作部的书面许可(Knust先生,E-
Mail:michael.knust@hvr.siemens.de)。
违者必究。
西门子保留所有权力,包括翻译,以及专利权、实用新型或外观设计专有权。
感谢Michael Dziallas Engineering公司、职业学校的教师们,和其他有关朋友为本手册的编写做出的贡献。
1. 前言
这部分的内容属于STEP 7编程晋阶中的环节。
学习目标:
通过本章的学习,读者将学会怎样用含内部变量的功能块来进行结构化的编
程。
产生一个功能块
定义内部变量
在功能块中给内部变量编程
基本要求:
为了这部分内容的顺利进行,我们希望读者具备以下的基础知识:
∙Windows 95/98/2000/ME/NET的基本操作知识
∙使用STEP 7 基本的PLC编程(比如,在A3部分讲的用STEP 7来启动一个PLC程
序)
基本的结构化编程(比如,附录四在S7-300上的基本PLC编程)
需要的硬件和软件:
1 PC , Windows 95/98/2000/ME/NET的操作系统,以及
最小:133MHz,64MB 的RAM ,65MB的空余磁盘空间。
最佳: 500MHz,128MB 的 RAM,65MB 的空余磁盘空间。
2 STEP 7 5.x 软件。
3 一个PC用MPI接口。
4一个装有CPU 315-2DP的 PLC SIMATIC S7—300
组态举例:
-电源: PS 307 2A
-CPU : CPU 315-2DP
-数字式输入:DI 16x DC 24V
-数字式输出: DO 16x DC 24V/0.5A
2. 应用功能块和功能结构化编程的注意事项
可执行程序是写在STEP 7的块中的。
组织块OB1总是可以使用的。
程序执行是和CPU操作系统的接口相关的,每次从相应的块中自动调用,并被循环执行。
对于复杂的控制任务,我们总是把程序分成小的,易管理的,实现一定功能并按一定顺序执行的程序块。
这些块被块调用指令(Call xx/UC xx/CC xx)调用。
如果程序块执行完毕,程序将跳回先前调用它的位置继续执行。
为了能实现结构化编程,STEP 7提供了以下途径:
∙功能块(Function block)
功能块分配有一定的存储区。
如果一个功能块被调用,将会给它分配一个数据块。
在这种情况下,该数据块可以被功能块调用。
可以给一个功能块分配不同的数据块。
在功能中可以嵌套调用功能和功能块。
∙功能(Function)
一个功能没有分配存储区。
在功能执行结束时,功能的背景数据将会丢失。
在功能中可以嵌套调用功能和功能块。
程序的结构可以如下:
注意:必须首先产生这些程序块,才可以使用它们。
还有一种可能是使用
局部变量以标准形式来编辑功能块和功能。
所有的功能都可以随时被调用,但是调用功能块时必须先调用相应的数据块。
3.
生成功能块和变量声明表:
当用STEP 7生成程序块时,所有程序块的编辑都应当按照定义好的变量表来进
行。
因此,在编程时不能使用输入,输出和存储位,定时器,计数器等的绝对地址。
单个变量和常数的定义就在这里进行。
在接下来的程序中,将编写一个带有变量声明表的功能块。
功能块中包括一个
控制面板和一个循环次数计数器。
Band motor 由‘S0’键来启动,由‘S1’键停止。
程序循环执行的次数由一个双字来保存。
程序中将用到下述地址:
输入:
- In-Button S0=I 0.0 - Out-Button S1=I0.1
输出:
- Band motor =Q 4.0
存储位:
- 循环次数计数器=MD20
为了完成这个例子,我们需要执行下述步骤,而且还须做好硬件组态:
1.双击打开 SIMATIC Manger 。
( SIMATIC Manager )
3.生成一个新的项目,并命名为Testproject_FB。
(→ Testproject_FB)
5. 点亮Blocks图标。
(→ Blocks)
6 Array
7. 输入功能块的名称‘FB1’点击OK接受设置。
( → FB1 → OK)
8
9. 使用LAD, STL, FBD 等编程工具就可以开始编辑你的功能块了。
另外,变量必
须在FB1(功能块1)变量表中详细定义。
这些变量的类型可以是:‘in ’,‘out ’,‘stat ’,‘temp ’。
输入参数(IN )在功能块,功能,系统功能块,系统功能中使用。
有了输入参数的帮助,可以对正在执行的块赋值
输出参数(ON )在功能块,功能,系统功能块,系统功能中使用。
有了输出参数的帮助,计算结果对调用的程序块赋值。
输入/输出型参数(IN-OUT )在功能块,功能,系统功能块,系统功能中使用。
有了输入/输出型参数,就可以对被调用模块赋值,执行程序然后将结果赋给被调用程序中的同一变量。
静态数据(STAT )仅在功能块和系统功能块中使用。
静态数据是一个功能块的背景数据,存放在相应的背景数据块中。
因此,这些数据将保存到下一个功能块的执行。
临时变量(TEMP )应用在所有的块中。
临时变量是一个功能块的背景数据,在块处理过程中,数据被保存到相应的背景数据堆栈中,程序块处理过程结束后, 将不能使用。
注意:
的指针,它将保存到下一个功能块开始运行。
由于以上原因,当程序块循环执行,内存中若干位需要连续保存某个变量时,只有功能块才适
用。
定义变量时要给出一些相应的限制。
根据需要输入的初始值和注释选择相应的数据类型。
例子如下:
注意:在变量声明表中,可以显示每一个选定的变量类型。
同时在FC中,类型是从‘in’,‘out’,‘temp’,‘in _out’中选择的,在FB中,类型是从‘in’,
‘out’,‘temp’,‘in _out’和‘stat’中选择的。
如果需要添加一个特定类
型的变量,需将光标放到最后一列,在按‘enter’键,就会出现新的一行。
为您的数据选择
数据类型
绝对地址是由STEP 7自动
生成的,地址的格式是:
字 . 节位
声明列表中详细规
定了变量的类型
数据块中的数据必须通过数据类型来确定
以下是STEP 7中的标准数据类型。
10.现在程序可以利用变量输入了(变量前面有标志‘#’)。
这些变量可以在下
面用STL编写的程序中看到。
CPU处在STOP模式,保存功能块FB1并下载到CPU中。
11.在SIMATIC Manager中,双击OB1,编程调用FB1。
12.接收设置,点击OK.
13.利用LAD、STL或者FBD编写已经生成的组织块OB1。
功能块FB1必须按照
以下指示和背景数据块一起调用。
CALL FB1,DB10 <回车>
因此,点击“YES”后背景数据块会自动生成。
14.所有‘in’、‘out’和‘in_out’类型的变量将被显示,从而可以给它们分配实
际参数。
15. 在这个例子中,所有变量的分配如下,然后将CPU 置于STOP模式,保存
OB1并下载。
注意:在这个例子中,FB1可以被不同的数据块和输入输出地址反复调用。
因此它是这一类特殊任务的标准块。
16. 先将CPU置于停止模式,然后在‘SIAMATIC Manager’中选择背景数据块‘DB10’并下载到CPU中。
17.将开关置于‘RUN’状态,程序运行。
当I0.0闭合,电动机开动。
开关I0.1闭合,电动机停止转动。
在内存位MD20记录了OB1调用FB1的频率,从而可以知道OB1执行的周期。
因为OB1程序很短所以这个频率很高。