老外写的st语言教程_很详细

上传人:101****457 文档编号:89256807 上传时间:2019-05-22 格式:PPT 页数:53 大小:2.77MB
返回 下载 相关 举报
老外写的st语言教程_很详细_第1页
第1页 / 共53页
老外写的st语言教程_很详细_第2页
第2页 / 共53页
老外写的st语言教程_很详细_第3页
第3页 / 共53页
老外写的st语言教程_很详细_第4页
第4页 / 共53页
老外写的st语言教程_很详细_第5页
第5页 / 共53页
点击查看更多>>
资源描述

《老外写的st语言教程_很详细》由会员分享,可在线阅读,更多相关《老外写的st语言教程_很详细(53页珍藏版)》请在金锄头文库上搜索。

1、1,ST Language,Basic Course,2,ST Language,Key word If there is any unclear or uncorrected, please feel free to speak out,Basic Course,3,Requirements,Hardware The programming language ST is only available for following programmable controllers:,pCO3 Supernode pCO5 pCO compact,BIOS To support ST langua

2、ge, bios version must greater than 5.0,Software Use a version of 1tool = 2.1.x,4,Creation of a solution ST Language,Choosing : - FBD, the application will be mixed, it will consist of a main with Atoms, Macroblocks . but you can use routines (functions and function blocks) written in the ST - ST, th

3、e application will be developed entirely using ST language,5,Basic concepts,When programming in ST, the application can be organised using three fundamental programming elements generically called Program Organization Units (POU): PROGRAM FUNCTION FUNCTION BLOCK,POU,Note: we can define more function

4、s and function blocks, but only one program main,6,The basic types,The following table lists all the properties of basic types (IECType):,7,Declaration of Global variables,There are two ways to declare Global variables: Variable List Textual mode of ST language,Note: if you want to see the variable

5、in the pGD, please declare the variable in the Variable List,8,Assignment operator :=,Syntax,Assign to a variable:,a constant value the value of another variable the result of an expression.,Varaible_name := expression ;,Note: there is a ; in the end of statement,9,Textual declaration,To declare var

6、iables in ST you have to use the following declaration block:,Note: 1. there is no ; in the end of END_VAR; 2. we can give the default value in the declaration.,10,Rules of the identifiers (variables name),az, AZ 09 _,The name of an identifier (variable or constant) can be any combination (see Examp

7、le) of the characters listed below:,Example Rules to create identifiers.,11,The qualifier CONSTANT,Textual declaration of Constants,The keyword CONSTANT can declare a constant. The constants do not occupy space in memory as the variables During compilation instead of the constant is replaced a numer

8、ic value.,12,Comments,Comment using keyword REGION ENDREGION You can hide several lines of code using the keyword REGION ENDREGION. So increase the readability of the code on the screen. The code is replaced with a comment. Clicking on comment it will appear again the code.,The code comments You can

9、 use two ways to make a comment To comment a single code line use “” To comment more code lines use “(*” and “*)”,There is no _ in between END and REGION,13,The qualifier RETAIN,Textual declaration of global variables REATAIN (retentive),Example,Declaration of retentive Global variables.,RETAIN keyw

10、ord declares a variable in T-permanent memory.,Organization of the variables.,Note: pay attention of the default value,14,Cast Functions,Syntax,Variable_name := *_TO_*(value);,The conversion functions are used to convert any of the elementary data types to any other. They must be used to make the da

11、ta type uniform before a function, where this is required.,15,ST operators,For the evaluation of expressions, always use brackets, this avoids errors in the evaluation of the expressions.,Example,Table of the operators priority,An expression is executed only after the evaluation of the operators pri

12、ority. The execution order of an expression and its result are influenced by the operators priority.,Suggestion,A:= NOT X AND Y OR NOT J; Increases readability: A:= NOT(X) AND (Y OR (NOT J);,If Z=0 the other variables have not been evaluated. A := Z AND Y AND (NOT J);,16,Conditional statements: IF,I

13、F THEN ELSE statement Conditional construct: executes a statement block depending on whether or not certain conditions are satisfied.,Syntax,Exercize,If Expression=TRUE, statement_block is executed Otherwise the conditions in the ELSIF blocks are evaluated Finally, if these are all false, the statem

14、ents in the ELSE block are executed.,Boolean (AND, OR, NOT, XOR) Comparison (=, , , =, , =).,Features,IF expression THEN statement_block; ELSIF expression THEN statement_block ; ELSE statement_block ; END_IF;,Note expression contains the operators:,Management of a range -550,950 C with NTC probe.,17

15、,Conditional statements: CASE,CASE OF statement,Syntax,Conditional construct: selects the statements to be executed depending on the value of an integer expression.,CASE expression OF selector_1 : statement_block; selector_2, selector_3 : statemnt_block; selector_4 selector_5 : statemnt_block; selec

16、tor_6, selector_7 selector_8 : statemnt_block; ELSE statemnt_block; END_CASE;,Example,Speed management of a fan.,18,The Function,It can be comparable to a Black box: it works on a Input parameters configuration, and it always produces in Output the same result for the same Inputs. It lets not repeat many times the same code within the project, as instead it is for macroblocks in FBD environment. At each invocation of the function, the

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 其它中学文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号