SIMATIC S7 Programming 2
Total Page:16
File Type:pdf, Size:1020Kb
1. Status Bit-Dependent Instructions 2. Accumulator Functions Information and Training Automation and Drives 3. Instructions with REAL Numbers 4. Indirect Addressing and Address Register SIMATIC S7 Instructions 5. STEP 7 Data Types and Variables Programming 2 6. Block Calls and Multi-Instance Model Course ST-7PRO2 7. Using Libraries AL: N ECCN: N Export Regulations 8. Synchronous and Asynchronous Error AL Number of European resp. German export list. Goods with labels not equal to ”N” are subject to Handling export authorization. ECCN Number of US export list (Export Control Classification Number). Goods with labels not equal to ”N” are 9. Program Generation Using the Text Editor subject to re-export authorization for export to certain countries. Indication Goods labeled with ”AL not equal to N” (here: technical documentations) are subject to 10. Basic and Extended S7 Communication European or German export authorization when being exported out of the EU. Goods labeled with ”ECCN equal to N” (here: technical documentations) are subject to US re-export authorization. 11. The S7-400 Power PLC System Even without a label, or with label ”AL:N” or ”ECCN:N”, authorization may be required due to the final whereabouts and purpose for which the goods are to be used. 12. Distributed I/O and Parameter Assignment Decisive are the export labels stated on order acknowledgements, delivery notes and invoices. 13. Engineering Tools for S7/M7 This document was produced for training purpose. Siemens assumes no responsibility for its contents. The reproduction, transmission or use of this document or its 14. Solutions to the Exercises contents is not permitted without express written authority. Offenders will be liable to damages. All rights, including rights created by patent grant or registration of a utility model or design, are reserved. 15. Appendix: Indirect Access to FC and FB Parameters SIEMENS AG 2007 Name: ___________________________ Course: from ____________ to ____________ Instructor: ___________________________ Infoline Tel: 01805 23 56 11 Fax: 01805 23 56 12 Internet: http://www.ad.siemens.de/training Release A5.1 (for STEP7 Version 5.x) Status Bit-Dependent Instructions SIMATIC S7 Date: 08.04.2007 Information and Training Center Knowledge for Automation Siemens AG 1999. All rights reserved. File: PRO2_01E.1 Contents Page Register and Memory Areas of an S7-CPU …................................................................................ 2 Status Word Structure ..................................................................................................................... 3 Checking the Status Bits ................................................................................................................. 4 Instructions with Status Bits ........................................................................................................... 5 BR Bit and ENO in a Block Call or Complex Functions …………................................................. 6 Jump Functions Dependent on Status Bits .................................................................................... 7 Jump Functions Dependent on Condition Codes ........................................................................... 8 Programming Jump Distributors ...…............................................................................................. 9 Programming Loop Instructions ….………...................................................................................... 10 Instructions for Block End ……..................................................................................................... 11 Exercise 1.1: Jump After a Subtraction ....................................................................................... 12 Exercise 1.2: Jump After a Multiplication ….................................................................................. 13 Exercise 1.3: Programming a Jump Distributor …........................................................................ 14 Training Center ST-7PRO2 for Automation and Drives Page 1 Status Bit-Dependent Instructions Register and Memory Areas of an S7-CPU Accumulators ACCU4 32 Bit only Load Memory S7-400 ACCU3 32 Bit - Logic Blocks - Data Blocks ACCU2 32 Bit ACCU1 32 Bit Work Memory L, A, O,... - Logic Blocks Address Register - Data Blocks AR1 32 Bit T, S, =,... I/O Area AR2 32 Bit Data Block Register System Memory - Process-image input table open DB DB Length - Process-image output table - Bit memories - Timers openDI DILength - Counters 16 Bit 16 Bit - Local Data Stack Status Word - Interrupt Stack - Block Stack Status Bits 16 Bit S7-CPU Register S7-CPU Memory Areas SIMATIC S7 Date: 08.04.2007 Information and Training Center Knowledge for Automation Siemens AG 1999. All rights reserved. File: PRO2_01E.2 CPU Register The registers of a CPU are used to address or to process data. The data can, with the help of relevant commands (L, T,...), be exchanged between the CPU memory areas and the registers: • Accumulators : Two (with S7-300) or four (S7-400) accumulators are used for arithmetic, comparison or other byte, word and double word instructions. • Address register : Two address registers are used as pointers for the register indirect addressing of the memory. • Data block register : The data block registers contain the numbers of the opened (active) data blocks. Thus it is possible that two DBs are open simultaneously; one DB with the help of the DB register, the other as instance DB with the DI register. When a DB is opened, its length (in bytes) is automatically loaded in the associated DB length register. • Status Word : Contains various bits, that reflect the result or the status of individual instructions within the program execution. Memory Areas The memory of the S7-CPU can be divided into four areas: • The load memory is used to store the user program without symbolic address assignment or comment. The load memory can be RAM or FLASH EPROM memory. • The work memory (integrated RAM) is used to store the relevant portion of the S7 program needed for the program execution. Program execution takes place exclusively from the work memory. • The I/O area permits a direct access of the inputs and outputs of the connected signal modules. • The system memory (RAM) contains areas, such as the process-image input and output tables, bit memories, timers and counters. In addition, it contains the local data stack, block stack and interrupt stack. Training Center ST-7PRO2 for Automation and Drives Page 2 Status Bit-Dependent Instructions Status Word Structure Meaning of the bits in the status word Bit Assignment Value Meaning 0 /FC 20 First check bit 1 RLO 21 Result of logic operation 2 STA 22 Status 3 OR 23 Or 4 OS 24 Stored overflow 5 OV 25 Overflow 6 CC 0 26 Condition code 7 CC 1 27 Condition code 8 BR 28 Binary result 9...15 Unassigned 29 ..2 10 SIMATIC S7 Date: 08.04.2007 Information and Training Center Knowledge for Automation Siemens AG 1999. All rights reserved. File: PRO2_01E.3 Status Word The individual bits of the status word, give information about the result or the status of instructions as well as errors that have arisen. You can integrate the status bit’s signal state directly into your program using binary logic operations and thus control the program flow. First Check The status word’s bit 0 is called the first check bit. The signal state ”0” in the /FC bit indicates, that with the next logic instruction a new logic string starts in your program. The diagonal stroke in front of the abbreviation FC indicates that the /FC bit is negated. Result of Logic The status word’s bit 1 is the RLO bit (RLO= ”Result of Logic Operation”). It is Operation used as temporary memory in binary logic operations. An instruction in a string of logic instructions checks, for example, the signal state of a contact and gates the result of check (status bit) according to the rules of boolean logic with the RLO bit. The result of logic operation is in turn stored in the RLO bit. Status Bit The status bit (bit 2) saves the value of an addressed bit. The status bit always shows, for scanning (A, AN, O,...) or write instructions (=, S, R,) the status of the addressed bit (for write instructions, the status of the address after execution of the instruction). OR Bit The OR bit is required when you perform an AND before OR logic operation with the instruction O. The OR bit indicates that a previously performed AND logic operation has delivered the value “1”, whereby the result of the OR logic operation is already determined as being “1”. OV Bit The OV bit (overflow) displays an error in a math instruction or a comparison instruction with floating point numbers. The bit is set according to the result of the performed math or comparison instruction. Training Center ST-7PRO2 for Automation and Drives Page 3 Status Bit-Dependent Instructions Checking the Status Bits Checking in STL A OV Scan overflow display A OS Scan stored overflow A BR Scan BR flag Checking the Condition Code (CC0, CC1) A == 0 Result equal to 0 A > 0 Result greater than 0 A <> 0 Result not equal to 0 A =< 0 Result less than or equal to 0 etc. A UO Instruction is unordered Checking in LAD and in FBD M 4.0 OV M 4.0 S >0 S SIMATIC S7 Date: 08.04.2007 Information and Training Center Knowledge for Automation Siemens AG 1999. All rights reserved. File: PRO2_01E.4 OS Bit The OS bit (overflow stored) is set together with the OV bit. The OS bit remains set after a renewed math instruction, that is, it is not changed by the result of the next math