




已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Course T530Chapter 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 methods 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 different 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 61131-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 with 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 block 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 executed 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. 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 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 case 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 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 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 difficult 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 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.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 the 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 for 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.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 tomma sidor hr OVANFR.Nedanstende Section Break fr INTE tas bort !Komplettera tom sida vid behov med nedanstende textThis page is intentionally left blank 3BSE 022 868/A 2000/12/5 16:27:00 18-
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025湖南衡阳市水务投资集团有限公司招聘30人模拟试卷有答案详解
- 2025江西赣州市全南县住房和城乡建设局聘用人员招聘2人考前自测高频考点模拟试题及参考答案详解
- 2025甘肃兰州新区交通职业技术学院招聘60人模拟试卷及答案详解(各地真题)
- 2025年黑龙江省鹤岗市辅警考试题库(附答案)
- 2025年国家安监局低压电工知识必考题库及答案
- 2025北京中国热带农业科学院香料饮料研究所第一批工作人员招聘(第2号)模拟试卷附答案详解(黄金题型)
- 2025年珲春市面向普通高校毕业生招聘事业单位工作人员(45人)考前自测高频考点模拟试题及1套参考答案详解
- 2025年咸阳秦都怡心学校招聘考前自测高频考点模拟试题带答案详解
- 2025内蒙古鄂尔多斯市杭锦旗教育领域校园专场招聘专业技术人员14人模拟试卷参考答案详解
- 2025国家体育总局运动医学研究所招聘社会在职2人考前自测高频考点模拟试题附答案详解
- 2025年甘肃省天水市供热有限公司招聘12人笔试历年参考题库附带答案详解
- 2025年一卷政治高考真题及答案
- 安静与智慧主题班会课件
- 云南民族大学附属高级中学2026届高三上学期联考(一)生物试卷(含答案)
- 2025至2030年中国包月视频点播行业市场竞争格局分析及投资方向研究报告
- 皮带机安全知识培训
- 零星维修工程施工组织设计方案方案
- 2025年汽车驾驶员(技师)考试试题及答案(含答案)
- 2025大连国际机场招聘25人笔试历年参考题库附带答案详解
- 2025年浙江铁塔招聘笔试备考题库(带答案详解)
- 2025年上海市(秋季)高考语文真题详解
评论
0/150
提交评论