老外写的ST语言教程很详细ppt课件.ppt
《老外写的ST语言教程很详细ppt课件.ppt》由会员分享,可在线阅读,更多相关《老外写的ST语言教程很详细ppt课件.ppt(53页珍藏版)》请在三一办公上搜索。
1、1,ST Language,Basic Course,2,ST Language,Key wordIf there is any unclear or uncorrected, please feel free to speak out,Basic Course,3,Requirements,HardwareThe programming language ST is only available for following programmable controllers:,pCO3 Supernode pCO5 pCO compact,BIOSTo support ST language,
2、 bios version must greater than 5.0,SoftwareUse 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 appl
3、ication 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
4、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 ListTextual mode of ST language,Note: if you want to see the variable in the
5、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
6、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),a.z, A.Z 0.9 _,The name of an identifier (variable or constant) can be any combination (see Example)
7、of the characters listed below:,ExampleRules 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 val
8、ue.,12,Comments,Comment using keyword REGION ENDREGIONYou 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 commentsYou can use two
9、ways to make a commentTo 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 declare
10、s 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 uni
11、form 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
12、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 . E
13、LSE 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
14、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,Conditio
15、nal 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
16、, 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
17、 times the same code within the project, as instead it is for macroblocks in FBD environment. At each invocation of the function, the same code will be always executed.,What does a Function do?,It read Inputs, no outputs, but can have a return valueIt executes the code of the functionIt writes the r
18、esult in a Return ValueA function doesnt have a memory stateIt always produces the same result for the same inputs.,The function Add_3,What does a Function contain?,The list of parameters that are passed as inputsProbable Local variables, only for its internal useThe code of the function,What is a F
19、unction?,19,FUNCTION statement,The table below lists all properties of a function.,Summary,20,Pass by value (VAR_INPUT),In the pass by value the Actual Parameters are copied in Formal Parameters.,Actual Parameters,Formal Parameters,Modifications dont have effect on Actual Parameters.,21,Pass by Refe
20、rence (VAR_IN_OUT),Pass by Reference,Actual Parameters,Formal Parameters,Modification,Sometimes it is necessary to modify the variable value passed to the function, and render such modification outside immediately visible. This modality is called Pass by Reference and it is realized using keyword VA
21、R_IN_OUT.In Pass by Reference the Formal Parameter point to the same cell of memory that contains the value of Actual Parameter.,22,Variables scope,23,RETURN statement,Syntax,The RETURN statement is used to exit from a Function, Function Block or the Program before the end.,FUNCTION My_functionlist_
22、statements_1;RETURN;list_statements_2;END_FUNCTION,1st Example,2sd Example,In the case of a Function or Function Block, the statement interrupts execution after list_statements_1, and passes control to the calling POU without executing list_statements_2.In the case of the Program, the statement clos
23、es the Program.,24,ARRAY statement,Syntax,Exercize,Array_name: ARRAYelem_1.elem_n OF Type;where:,Simulation,elem_1 and elem_n are INT numbers or constants (they cannot be variables) and represent the limits of the arrayelem_n = elem_1, the difference +1 indicates the number of elements in the arrayT
24、ype identifies the elementary data type elements inside the array or Structure type,25,Array Breakthrough (exceeded limits),Example,Run-Time error on Simulator,Run-Time error on pCO Place 2 integer variables on a Mask related to library functions: The position of error in the Strategy Editor ST: go
25、in simulation and then press insert High part and Low part,When a variable is used to access the elements of an array, care must be paid to ensure the size of the array is not exceeded. If run-time the index value exceeds the size of the array, this will entail the re-boot of the pCO.,NoteTo reset e
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 老外 ST 语言 教程 详细 ppt 课件

链接地址:https://www.31ppt.com/p-1374116.html