1、ABB DCS 系统 培训课程 系列讲座 Code sortingChapter 18 Code sorting18.1 General Information 18.1.1 DescriptionThis chapter describes the different methods of code sorting and how to handle loops.18.1.2 ObjectivesOn completion of this chapter you will be able to: Describe the differences between different metho
2、ds of code sorting Describe the advantages of each method Analyze and solve loops in the program code.18.1.3 Reference DocumentationUse the online help: Contents tab, Control Module Diagram Editor Working with Control Modules18.2 Lesson 1 - Code sorting18.2.1 DescriptionThis chapter describes the di
3、fferent methods of code sorting and how to handle loops.18.2.2 ObjectivesOn completion of this lesson you will be able to: Describe the differences between different methods of code sorting Describe the advantages of each method Analyze and solve loops in the program code.18.2.3 According to IEC 611
4、31-3The execution order of function blocks follows the program flow as implemented by the programmer.18.2.4 Control Module Code Sorting- introductionFor Control Modules, the compiler analyzes each code block (ST, IL, FBD, and LD - SFC is treated somewhat differently, see remark below) separately wit
5、h respect to which variables that are read and written, respectively, by each block. The compiler then determines the optimal execution order. A code block that assigns a value to a variable has to be executed before the block that reads the variable value (compare figure below in which the code blo
6、ck in control module 1 must be executed before the code block in control module 2).The technique is called code sorting and means that the optimal execution order will be based on data flow instead of program flow (as is the case for function blocks). Code sorting guarantees that the code will be ex
7、ecuted in correct order. Code sorting suppresses time-delays and results in that a new control module automatically becomes correctly placed in the process.For any from control modules called Function Blocks, it is only the parameter interface (In, Out, or In_out) that affects the code-block sorting
8、. That is, no analysis is made on how the Function Blocks actually use the parameters. In addition, Function Block references to external variables do not affect the execution order of control module code blocks.Code sorting has no effect on control modules connected to different tasks.Within a SFC
9、code block only the N action parts (not P1 or P2 actions) are sorted.18.2.5 Loop handlingHowever, in case both the control modules use the same variable for both reading and writing, the compiler gives a warning message that a loop exists, meaning that the execution order cannot be resolved:This cas
10、e yields the following error information:In the example above, the Request value determines the Deliver value, which, in turn, determines the Request value. This condition is shown in the automatically generated text file, where the figures within parentheses refer to which code block the respective
11、 parameter depends on. Provided that circular dependence actually exists (and is not merely a result of a programming error), the problem can be solved by assigning a State-qualifier to the Delivered variable and introducing a new code block in Control Module 1, Code_Block_12:The loop dependency is
12、now eliminated; Delivered:old stores the value from the previous scan and Delivered:new contains the updated value from the current scan. Hence, the execution order becomes Code_Block_11 - Code_Block_21 - Code_Block_12. The approach is particularly valuable for complex applications, which are diffic
13、ult to monitor manually.18.2.5.1 Remarks on StateState can only be specified for local variables of type bool, int, uint, dint, and real. If you for some reason want to override the sorting and thereby avoid the State implications, you can assign the nosort attribute to the variable.18.2.5.2 Remarks
14、 on NoSortIncorrectly used, the nosort attribute may cause improper execution and application failure. Nosort should typically be used only when the code block connections themselves unambiguously determine the execution order Use nosort only if you know the data flow characteristics in detail.18.2.
15、6 Code Sorting AdvantagesThe advantages of code sorting are best illustrated with a couple of examples: First consider a PID cascade loop (used for updating the PID integrators in case of manual operation), in which data flow in both directions between the master and the slave. This is handled by th
16、e Back code blocks at the end of the scan. This is not possible to do with function blocks if you want to work in an object-oriented way and avoid time delays.Second, now consider an application according to the illustration below. Lets say that some time after the application was set up, the need f
17、or a third conveyer arises. Because of the code sorting, a Control Module representing the functionality of the new conveyer becomes added and connected in the right place in the application logic (provided that the application has been properly designed in the specification phase).18.3 Exercise 18.
18、1 Code sortingPlease do exercise 18.1Du kan tag bort denna osynliga text men ltnedanstende Page Break ligga kvar !Lt ven den efterfljande sidan ligga kvar !This page is intentionally left blankThis page is intentionally left blankOsynlig text:Nsta sida mste brja p UDDA sidnummerLmna EN eller TV tomm
19、a sidor hr OVANFR.Nedanstende Section Break fr INTE tas bort !Komplettera tom sida vid behov med nedanstende textThis page is intentionally left blank TABLE OF CONTENTSChapter 18 Code sorting 118.1 General Information 118.1.1 Description 118.1.2 Objectives 118.1.3 Reference Documentation 118.2 Lesso
20、n 1 - Code sorting 218.2.1 Description 218.2.2 Objectives 218.2.3 According to IEC 61131-3 218.2.4 Control Module Code Sorting- introduction 218.2.5 Loop handling 318.2.5.1 Remarks on State 418.2.5.2 Remarks on NoSort 418.2.6 Code Sorting Advantages 518.3 Exercise 18.1 Code sorting 6Du kan ta bort denna osynliga text men ltnedanstende Page Break ligga kvar !Lt ven den efterfljande sidan ligga kvar !This page is intentionally left blank
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1