资源预览内容
第1页 / 共54页
第2页 / 共54页
第3页 / 共54页
第4页 / 共54页
第5页 / 共54页
第6页 / 共54页
第7页 / 共54页
第8页 / 共54页
第9页 / 共54页
第10页 / 共54页
亲,该文档总共54页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
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 pCO3 pCO5 Supernode 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 typeKeywordDescription ProgramPROGRAM main END PROGRAM Main program that includes read write I O definition of local variables calls to Functions or Function Blocks FunctionFUNCTION END FUNCTION ST statements block with input variables local variables and if specified a return value This can be called at different points of the program Recursion is not allowed Function block FUNCTION BLOCK END FUNCTION BLOCK ST statements block with input variables local variables and output variables This can be called at different points of the program Recursion is not allowed POU Note we can define more functions and function blocks but only one program main 6 The basic types KeywordData typeLower limitUpper limitMemory Space BOOLBooleanFALSE 0 TRUE 1 8 Bit BYTEBit string02558 Bit WORDBit string06553516 Bit DWORDBit string04 294 967 2 95 32 Bit SINTShort Integer 1281278 Bit USINTUnsigned Short Integer 02558 Bit INTInteger 327683276716 Bit UINTUnsigned Integer 06553516 Bit DINTDouble Integer 2 31 2 31 132 Bit UDINTUnsigned Double Integer 02 32 132 Bit REALReal Number 10 3810 3832 Bit Bitstring Integers 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 Button User Button Extend IECType BOOL INT REAL IECType BOOL INT REAL Variable ListTextual mode CarelType Boolean Integer Analo g Global variables declaration Usable in any environment Usable only in the Strategy Editor ST no MASK FBD Strategy Editor You don t see these variables in Variable List 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 In assignment operations the variables involved must all be the same type each statement must use as the statement terminator In assignment operations with BOOL values 1 or TRUE or 0 or FALSE can be used indifferently a constant value the value of another variable the result of an expression Varaible name expression Assignment operator Statement terminator 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 Global variables declared in text mode will not be visible in the Variable List TypeSyntaxDescrition GloabalVAR GLOBAL END VAR Declares a group of global variables shared by program functions or function blocks LocalVAR END VAR Declares a group of local variables to a program function or function 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 Valid identifiers Invalid identifiers Note Mn22MnThe 1st character must not be numeric 3exit 3exit 1 is not included in the set of characters Enrg offEnrg offSpaces are not allowed Drill DrillOnly single underscores are allowed Valve VALVENot case sensitive The variable names are not case sensitive Valve VaLVe e VALVE are the same variable 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 TypeSyntaxDescription Costanti Locali VAR CONSTANT END VAR Declares a group of local constants to a program function or function block Costanti Globali VAR GLOBAL CONSTANT END VAR Declares a group of global constants shared by program functions or function blocks 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 d
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号