Program Languages And Structure Reference Manual

Transcription

Unity Pro35006144 07/2011Unity ProProgram Languages and StructureReference Manual35006144.1007/2011www.schneider-electric.com

The information provided in this documentation contains general descriptions and/ortechnical characteristics of the performance of the products contained herein. Thisdocumentation is not intended as a substitute for and is not to be used fordetermining suitability or reliability of these products for specific user applications. Itis the duty of any such user or integrator to perform the appropriate and completerisk analysis, evaluation and testing of the products with respect to the relevantspecific application or use thereof. Neither Schneider Electric nor any of its affiliatesor subsidiaries shall be responsible or liable for misuse of the information containedherein. If you have any suggestions for improvements or amendments or have founderrors in this publication, please notify us.No part of this document may be reproduced in any form or by any means, electronicor mechanical, including photocopying, without express written permission ofSchneider Electric.All pertinent state, regional, and local safety regulations must be observed wheninstalling and using this product. For reasons of safety and to help ensurecompliance with documented system data, only the manufacturer should performrepairs to components.When devices are used for applications with technical safety requirements, therelevant instructions must be followed.Failure to use Schneider Electric software or approved software with our hardwareproducts may result in injury, harm, or improper operating results.Failure to observe this information can result in injury or equipment damage. 2011 Schneider Electric. All rights reserved.235006144 07/2011

Table of ContentsSafety Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .About the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Part I General Presentation of Unity Pro . . . . . . . . . . . . . .Chapter 1 Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11131517Capabilities of Unity Pro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Project Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .User Application and Project File Formats . . . . . . . . . . . . . . . . . . . . . . . .Configurator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Data Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Program Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Function Block Diagram FBD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Ladder Diagram (LD) Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .General Information about SFC Sequence Language . . . . . . . . . . . . . . .Instruction List IL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Structured Text ST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .PLC Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Export/Import. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .User Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Debug Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Diagnostic Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Operator Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182224252932404345475051525354556263Part II Application Structure. . . . . . . . . . . . . . . . . . . . . . . . .65Chapter 2 Description of the Available Functions for Each Type ofPLC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67Functions Available for the Different Types of PLC. . . . . . . . . . . . . . . . . .Chapter 3 Application Program Structure . . . . . . . . . . . . . . . . . . . .3.1 Description of Tasks and Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Presentation of the Master Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Presentation of the Fast Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Presentation of Auxiliary Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Overview of Event Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35006144 07/2011676970717273753

3.2 Description of Sections and Subroutines . . . . . . . . . . . . . . . . . . . . . . . . .Description of Sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Description of SFC sections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Description of Subroutines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3.3 Mono Task Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Description of the Master Task Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . .Mono Task: Cyclic Execution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Periodic Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Control of Cycle Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Execution of Quantum Sections with Remote Inputs/Outputs . . . . . . . . .3.4 Multitasking Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Multitasking Software Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Sequencing of Tasks in a Multitasking Structure . . . . . . . . . . . . . . . . . . .Task Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Assignment of Input/Output Channels to Master, Fast and Auxiliary TasksManagement of Event Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Execution of TIMER-type Event Processing . . . . . . . . . . . . . . . . . . . . . .Input/Output Exchanges in Event Processing . . . . . . . . . . . . . . . . . . . . .How to Program Event Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . .476777980818284858687899092949799100104105Chapter 4 Application Memory Structure . . . . . . . . . . . . . . . . . . . . .1074.1 Memory Structure of the Premium, Atrium and Modicon M340 PLCs . . .Memory Structure of Modicon M340 PLCs . . . . . . . . . . . . . . . . . . . . . . .Memory Structure of Premium and Atrium PLCs. . . . . . . . . . . . . . . . . . .Detailed Description of the Memory Zones . . . . . . . . . . . . . . . . . . . . . . .4.2 Memory Structure of Quantum PLCs. . . . . . . . . . . . . . . . . . . . . . . . . . . .Memory Structure of Quantum PLCs . . . . . . . . . . . . . . . . . . . . . . . . . . .Detailed Description of the Memory Zones . . . . . . . . . . . . . . . . . . . . . . .108109112114115116119Chapter 5 Operating Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1215.1 Modicon M340 PLCs Operating Modes . . . . . . . . . . . . . . . . . . . . . . . . . .Processing of Power Outage and Restoral of Modicon M340 PLCs . . . .Processing on Cold Start for Modicon M340 PLCs . . . . . . . . . . . . . . . . .Processing on Warm Restart for Modicon M340 PLCs . . . . . . . . . . . . . .Automatic Start in RUN for Modicon M340 PLCs . . . . . . . . . . . . . . . . . .5.2 Premium, Quantum PLCs Operating Modes . . . . . . . . . . . . . . . . . . . . . .Processing of Power Outage and Restoral for Premium/Quantum PLCsProcessing on Cold Start for Premium/Quantum PLCs . . . . . . . . . . . . . .Processing on Warm Restart for Premium/Quantum PLCs. . . . . . . . . . .Automatic Start in RUN for Premium/Quantum . . . . . . . . . . . . . . . . . . . .5.3 PLC HALT Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .PLC HALT Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122123125129132133134136141144145145Chapter 6 System Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1476.1 System Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .System Bit Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Description of System Bits %S0 to %S7 . . . . . . . . . . . . . . . . . . . . . . . . .Description of System Bits %S9 to %S13 . . . . . . . . . . . . . . . . . . . . . . . .14814915015235006144 07/2011

Description of System Bits %S15 to %S21 . . . . . . . . . . . . . . . . . . . . . . . .Description of System Bits %S30 to %S59 . . . . . . . . . . . . . . . . . . . . . . . .Description of System Bits %S65 to %S79 . . . . . . . . . . . . . . . . . . . . . . . .Description of System Bits %S80 to %S96 . . . . . . . . . . . . . . . . . . . . . . . .Description of System Bits %S100 to %S123 . . . . . . . . . . . . . . . . . . . . . .System Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Description of System Words %SW0 to %SW11 . . . . . . . . . . . . . . . . . . .Description of System Words %SW12 to %SW29 . . . . . . . . . . . . . . . . . .Description of System Words %SW30 to %SW47 . . . . . . . . . . . . . . . . . .Description of System Words %SW48 to %SW59 . . . . . . . . . . . . . . . . . .Description of System Words %SW70 to %SW100 . . . . . . . . . . . . . . . . .Description of System Words %SW108 to %SW116 . . . . . . . . . . . . . . . .Description of System Words %SW123 to %SW127 . . . . . . . . . . . . . . . .Atrium/Premium-specific System Words . . . . . . . . . . . . . . . . . . . . . . . . . .Description of System Words %SW60 to %SW65 . . . . . . . . . . . . . . . . . .Description of System Words %SW128 to %SW143 . . . . . . . . . . . . . . . .Description of System Words %SW144 to %SW146 . . . . . . . . . . . . . . . .Description of System Words %SW147 to %SW152 . . . . . . . . . . . . . . . .Description of System Word %SW153 . . . . . . . . . . . . . . . . . . . . . . . . . . .Description of System Word %SW154 . . . . . . . . . . . . . . . . . . . . . . . . . . .Description of Premium/Atrium System Words %SW155 to %SW167 . . .Quantum-specific System Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Description of Quantum System Words %SW60 to %SW66 . . . . . . . . . .Description of Quantum System Words %SW98 to %SW109 . . . . . . . . .Description of Quantum System Words %SW110 to %SW177 . . . . . . . .Description of Quantum System Words %SW180 to %SW702 . . . . . . . .Modicon M340-Specific System Words. . . . . . . . . . . . . . . . . . . . . . . . . . .Description of System Words: %SW142 to %SW145, %SW146 and%SW147, %SW150 to %SW154, %SW160 to %SW167 . . . . . . . . . . . . 01203204206207208209212213216222Part III Data Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . .2256.26.36.46.5Chapter 7 General Overview of Data . . . . . . . . . . . . . . . . . . . . . . . .General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .General Overview of the Data Type Families . . . . . . . . . . . . . . . . . . . . . .Overview of Data Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Overview of the Data References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Syntax Rules for Type\Instance Names . . . . . . . . . . . . . . . . . . . . . . . . . .Chapter 8 Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8.1 Elementary Data Types (EDT) in Binary Format. . . . . . . . . . . . . . . . . . . .Overview of Data Types in Binary Format. . . . . . . . . . . . . . . . . . . . . . . . .Boolean Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Integer Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Time Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35006144 07/20112222272282292312332342352362372392442465

68.2 Elementary Data Types (EDT) in BCD Format . . . . . . . . . . . . . . . . . . . .Overview of Data Types in BCD Format . . . . . . . . . . . . . . . . . . . . . . . . .The Date Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Time of Day (TOD) Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Date and Time (DT) Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8.3 Elementary Data Types (EDT) in Real Format . . . . . . . . . . . . . . . . . . . .Presentation of the Real Data Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . .8.4 Elementary Data Types (EDT) in Character String Format . . . . . . . . . . .Overview of Data Types in Character String Format . . . . . . . . . . . . . . . .8.5 Elementary Data Types (EDT) in Bit String Format . . . . . . . . . . . . . . . . .Overview of Data Types in Bit String Format. . . . . . . . . . . . . . . . . . . . . .Bit String Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8.6 Derived Data Types (DDT/IODDT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Programming Example for a Derived Function Block (DFB). . . . . . . . . . . 575 Chapter 19 Use of the DFBs from the Different Programming Languages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .