资源预览内容
第1页 / 共53页
第2页 / 共53页
第3页 / 共53页
第4页 / 共53页
第5页 / 共53页
第6页 / 共53页
第7页 / 共53页
第8页 / 共53页
第9页 / 共53页
第10页 / 共53页
亲,该文档总共53页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
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 language, 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, the 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 functions 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 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 variables 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 Example) 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 numeric 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 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 keyword 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 data 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 priority. 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,IF 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 statements 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,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; selector_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
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号