Page 1
Since the content of the manual will be revised as the version changes, this version may not be the final version. To download the latest version of the manual, please go to the technical support area of www.fatek.com FATEK AUTOMATION CORP. M-Series PLC Strctured Language ST User Manual...
Page 2
Index Index Chapter 1 Understand Strustured Language (ST)........11 Features of ST Language ......................... 12 Adding ST Language Program ...................... 14 Chapter 2 User Interface of Uperlogic ST ..........11 Interface Overview ..........................2 Supportive Keyboard Instructions ....................3 System Mode ............................5 編譯文本...
Page 3
Index Program Planning ..................錯誤! 尚未定義書籤。 Building Example Program ................. 錯誤! 尚未定義書籤。 Chapter 6 還需要加入手冊的內容 ..............11 M-Series PLC Strctured Language ST User Manual...
Page 4
Before using the product, be sure to read this Manual carefully in order to get familiar with and understand its content. Should you have any questions or comments, please contact the FATEK distributor for detailed warranty services and responsibility limit.
The user needs to check if the system, machinery or device currently used is compatible with the FATEK product. If the user fails to confirm the compatibility or the suitability, then FATEK shall not be liable for the suitability of the product.
Page 6
Errors and negligence The content of this Manual is provided through careful checking process and is considered as correct. However, FATEK shall not be liable for the errors or the negligence that may be found in the text, printing content and proofreading.
Chapter 1 Understand Structured Language (ST) Precautions for safety Signs and meaning of safety precautions The following signs will be used in this Manual in order to provide precautions that will be required for using the M-Series PLC safely. These precautions are extremely important for using the product safely. Please read the safety precautions carefully in order to get familiar with and understand the content and the meaning of the aforesaid instructions.
Page 8
Chapter 1 Understand Structured Language (ST) Warning Do not attempt to dismantle any module or touch the internal side of the module when it is under energized status or it may lead to electrocution injury. Do not attempt to touch any terminal or terminal board when the module is under energized status, or it may lead to electrocution injury.
Page 9
Chapter 1 Understand Structured Language (ST) Precautions Do not touch the power module when the PLC is under energized status or when the power source is disconnected. At this time, the power module might still present extremely high temperature that can cause a scorching injury. When connecting with the terminal board of the power module, the cable should be secured with the appropriately sized Ferrule.
Chapter 1 Understand Structured Language (ST) Precautions for Use When using the M-Series PLC, please observe the precautions provided below. Using the power Please use the voltage specified in the Manual. Incorrect voltage will lead to false action or burning ⚫...
Page 11
Please set the grounding wire correctly for the power module and communication port to avoid ⚫ communication error and equipment malfunction caused by noise interference. It is recommended to use M series dedicated AC power modules to supply power to MPLC related ⚫ modules.
Page 12
Chapter 1 Understand Structured Language (ST) on the system; otherwise, it may result in unexpected action. (1) When changing the operating mode of the PLC (RUN Mode/STOP Mode). (2) When executing compulsory enable/ compulsory disable for any of the data retained in the register.
Page 13
Chapter 1 Understand Structured Language (ST) Precautions for the Application Environment Please follow the instructions described in this Manual for carrying out the installation activities ⚫ correctly. Do not operate the control system in any of the following locations: ⚫ (1) The location exposed to direct sunlight.
Page 14
Chapter 1 Understand Structured Language (ST) Understand Structured Language ST Features of ST Language ........................12 Adding ST Language Program ......................14 M-Series PLC Structured Language ST User Manual...
Page 15
Chapter 1 Understand Structured Language (ST) 1-1 Features of ST Language In the early days of automation control, when editing the logic of the programmable logic controller, it was necessary to insert the program short code (Mnemonic) similar to the combination language into the controller through the writer, and the action required by the project has been achieved.
Page 16
Chapter 1 Understand Structured Language (ST) Complex Information Processing The control program can be written through syntax such as “if" or “for.while.” Compared with the ladder diagram, it can more concisely and clearly describe the complex branch or loop processing of the execution content according to different conditions.
Page 17
Chapter 1 Understand Structured Language (ST) 1-2 Adding ST Language Program Establishing a new Program M-Series PLC Structured Language ST User Manual...
Page 18
Chapter 1 Understand Structured Language (ST) Example of creating MainUint/SubUnit(ST): Right click on [Main Program] , or [Sub Program]. Select [Main Program Add] or [Sub Program Add] and a dialog box will pop up. Select [Structured Text(ST)] and add the corresponding program. Example of creating an interrupt program (ST): Click right mouse button on the node of the special program.
Page 19
Chapter 2 User Interface of Uperlogic ST User Interface of Uperlogic ST Interface Overview ..................錯誤! 尚未定義書籤。 Supportive Keyboard Instructions ............錯誤! 尚未定義書籤。 System Mode ....................錯誤! 尚未定義書籤。 編譯文本/Syntax Check ................. 錯誤! 尚未定義書籤。 M-Series PLC Structured Language ST User Manual...
Chapter 2 User Interface of Uperlogic ST 2-1 Interface Overview For all ST programs in the current project, double-click the name with the left mouse button, and a new editing screen will be selected in the middle. Display the currently available ST syntax and FCM-related information. Double-click the field and the corresponding template will be inserted into the program.
Page 21
Chapter 2 User Interface of Uperlogic ST This pop-up window will follow the user’s input and display the automatically detected prompt program fragments in real time, including available labels, variables, calling functions, etc. Matched strings will be displayed in orange in the window (as shown above). Since not only the name will be searched, but also the annotations behind the search (the display priority is lower), so in addition to directly searching the name of the function, you can also enter the relevant text of the annotation, such as the function ID (as shown below).
Page 22
Chapter 2 User Interface of Uperlogic ST 2-2 Supportive Keyboard Instructions Function Ctrl + C Copy Ctrl + V Paste Ctrl + A Select All Ctrl + X Insert Tab Multiple Select+Tab Select multiple lines and add Tab at the same time. Shift + Tab Back Tab simultaneously according to the cursor or the number of selected rows.
Page 23
Chapter 2 User Interface of Uperlogic ST 2-3 Sytem Mode There are currently three modes of the system software: ST Editor diaplays three status correspondingly. 1. Offline Edit 2. Online Monitor (Read-Only, not for editing) 3. Online Edit M-Series PLC Structured Language ST User Manual...
Page 24
Chapter 2 User Interface of Uperlogic ST 2-4 編譯文本 / Syntax Check ST files must be transferred into programs available for PLC running through syntax check. Usually when writing, users can click the button shown below to manually compile to see if it is correct: If there is an error or a warning prompt, there will be a pop-up window display: The detailed content will be displayed in the window as shown in the figure below, double-clicking the field will jump and prompt the wrong line numbers.
Page 25
Chapter 2 User Interface of Uperlogic ST Every time the system downloads, it will automatically run the checking procedure of the current text during the trial run to ensure that the syntax is correct. When there is an error, it will not be able to download or trial run.
Page 26
Chapter 3 Basic Program Structure of Uperlogic ST Basic Program Structure of Uperlogic ST Introduction ...................... 錯誤! 尚未定義書籤。 Statement ......................錯誤! 尚未定義書籤。 Expression......................錯誤! 尚未定義書籤。 Operand and Operator ................錯誤! 尚未定義書籤。 Comment ......................錯誤! 尚未定義書籤。 Flow Control and Loop ................. 錯誤! 尚未定義書籤。 Variables and Data Type ................
Page 27
Chapter 3 Basic Program Structure of Uperlogic ST 3-1 Introduction This chapter will explain the methods of applying basic ST Language programming. 3-1-1 Character Encoding ST editor supports Unicode(encode in UTF-8). Supports basic characters and most symbols in Japanese, English, Chinese and other languages that appear in program editing. In addition to being used for comments, they can also be used in labels or program and table names.
Page 28
Chapter 3 Basic Program Structure of Uperlogic ST Goto, LBL...etc Bit (Bool) Type: TRUE、FALSE Float: 32-bit Float Constant ex: TagFloat1:=1.1; Delimiter “:” appears in CASE OF 分隔“,” 多個函式參數傳遞使用 Left/Right Round Brackets “(“ , “ )” 1. The start and end of Function Call ex: Fun0 ( S:=R0, D:=R1 );...
Page 29
Chapter 3 Basic Program Structure of Uperlogic ST 3-2 Statement “Statement” is the most basic execution unit in ST Language, which represents a complete work to be executed. A complete statement is not limited to the same line of words; however, it must be ended with “;.”...
Page 30
Chapter 3 Basic Program Structure of Uperlogic ST Type Content Example Distributive Statement Substitute the result on the right into the variable on the left. Flow Control 選擇 Statement (IF, CASE) Select the execution syntax based Syntax on the condition. 循環處理...
Page 31
Chapter 3 Basic Program Structure of Uperlogic ST 3-3 Expression “Expression” is a very important element in the structure of a statement and it represents a “value”, such as a Boolean value of TRUE or FALSE, or an integer value of 20 or -5. It can be an operation expreesion or a constant, and of course it can also be a variable symbol or device, depending on occasions.
Page 32
Chapter 3 Basic Program Structure of Uperlogic ST The below table shows Expression types: Type Data Type of Expression (Computing Result) Example Operation Arithmetic Expression Interger, real number…etc. Expression (according to computing elements) Logic Expression Boolean (TRUE/FALSE) Compare Expression Boolean (TRUE/FALSE) Basic Variables, Constants Defined data type...
Page 33
Chapter 3 Basic Program Structure of Uperlogic ST 3-3-5 Advanced Operation (Exponents) Exponential or trigonometric operations using general-purpose functions. Type Function Name Example General Expression Absolute Value ABS( D:= ); Square Root SQRT FSQR(S:= ,D:= ); √ Natural Logarithm ...
Page 34
Chapter 3 Basic Program Structure of Uperlogic ST 3-4 Operand and Operator Operands and operators are the basic elements that make up an expression. The operand refers to the object involved in the operation, and the operator represents the operation performed. For example, in the expression “D0 + D”1, both “D0”...
Page 35
Chapter 3 Basic Program Structure of Uperlogic ST ■ The part with the same background color have the same priority. ■ AND, OR, XOR, XNOR basically do the role of BitWise (ex R0 AND R1) and the result will be a value. Unless the left and right sides are both Bool(bit) (ex.
Page 36
Chapter 3 Basic Program Structure of Uperlogic ST 3-4-5 Equal to/Not equal to = , <> Compare whether the left operator is equal to the right operators. The result will be TRUE/ FALSE ( 1/ 0) M0 := R0=100; // If R0 value=100, M0 will be TRUE ( 1 ) 3-4-6 Bit shift left and right <<, >>...
Page 37
Chapter 3 Basic Program Structure of Uperlogic ST 3-5 Comment Comments are those used by program developers for easy maintainance in the future. There are single-line or multiline comments appeared with light gray text, and these parts will be ignored by the editor and will not generate operating data.
Page 38
Chapter 3 Basic Program Structure of Uperlogic ST 3-6 Flow Control and Loop When writing ST, some conditions or loop control are usually required for easier design. Introduction as shown below: 3-6-1 IF ELSE When the expression after is TRUE or 1 at the end, the description after will be operated immediately, otherwise the description after ELSE...
Page 39
Chapter 3 Basic Program Structure of Uperlogic ST DR0:=0 //DR0 from 0,2,4,..etc, until it reaches to 30 R10++; // R10++will be run repeatedly END_FOR DR0:=0 //DR0 from 0,1,2,3..etc, until it reaches to 30 R10++; // R10++ will be run repeatedly END_FOR 3-6-3 CASE OF Selection of Integer conditions:...
Page 40
Chapter 3 Basic Program Structure of Uperlogic ST REPEAT: NOTICE: Because of the logic of hardware running, if the WHILE does not jump out of the loop for a long time, the PLC device will not be able to handle other IO states, resulting in system errors. Users should be careful when using it.
Page 41
Chapter 3 Basic Program Structure of Uperlogic ST 3-6-6 LBL, JMP, CALL command can achieve the same effect as LD FUN_65, with a Label of up to 6 ASCII characters. The keywords that can call Label in the ST environment are as follows: JMP_66 , CALL (Please refer to FUN 66 for detailed description) CALL_67 , GOTO (Please refer to FUN 67 for detailed description) Use only in FB:...
Page 42
Chapter 3 Basic Program Structure of Uperlogic ST 3-7 Variables and Data Type In the programming language, the use of variables and data types are an important part. In order to ensure that variables have typed characteristics, it is convenient for programmers to view and debug. ST uses Tag (Global, Local) to give variables a specific type.
Page 43
Chapter 3 Basic Program Structure of Uperlogic ST Line 3: Indicates that the floating-point value of Tag_FlR100 will be converted into an integer value of int32, and there will be a position of DR0, and the decimal point will be removed (ex. Tag_FlR100 is 3.14, and the content of DR0 is 3) Line 5,7: It will convert DR2 (INT32) and R2 (INT16) into floating-point data types, and store them in Tag_FlR100 (ex.
Page 44
Chapter 3 Basic Program Structure of Uperlogic ST Tag_FlR100:=1.2E+3; Tag_FlR100:=1E-3; Unit Symbol G: 1e+9 M: 1e+6 K,k: 1e+3 m: 1e-3 u: 1e-6 n: 1e-9 ----------------------------------------- DR0:=1G; R0:=1K; R0:=1k; DR0:=1M; Tag_FlR100:=1m; Tag_FlR100:=1n; Tag_FlR100:=1u; String Use ASCII string quoted by“ symbol (Currently only the Label command ----------------------------------------- can be used) LBL (...
Page 45
Chapter 3 Basic Program Structure of Uperlogic ST 3-8 Using PLC Register and Memory In addition to using the created Tag to 調用 the corresponding register, users can also directly enter the name of the register to perform operations or flow control, as long as the data type of the register is single word 16bit --->...
Page 46
Chapter 3 Basic Program Structure of Uperlogic ST 3-9 Calling System Built-In Functions The description of the built-in functions will be shown as below: <Function> ( <Parameter 1> := <Input Parameter 1> , ….); Like the ladder diagram, ST has some built-in functions for users to call, which will appear in the toolbox column on the right.
Page 47
Chapter 3 Basic Program Structure of Uperlogic ST 3-9-1 Timer Prototype: Timer( Trigger:= (* Trigger Bit Rising Edge ->ON, Falling Edge ->OFF *), (* Timer 0~1023 *), PV:= (* preset value (0~32767) *), IsTimeout=> (* time out bit *)); Parameter: Trigger (bool) : Rising Edge Start Timer...
Page 48
Chapter 3 Basic Program Structure of Uperlogic ST 3-9-3 R_TRIG / F_TRIG Rising Edge and Falling Edge’s detecting function Prototype: Mode 1: R_TRIG( S:= , D=> ) F_TRIG( S:= , D=> ) Mode 2: R_TRIG( S:= ) F_TRIG( S:= ) Implied with Return Value Parameter: (bool)
Page 49
Chapter 3 Basic Program Structure of Uperlogic ST 3-9-5 Functions with multiple calling modes Like the TRIG detection commands in Chapter 3-9-3 above, these commands support two types, one is directly complete call, the other is to omit the target value as the return value of the function, the following table shows the currently available function with the feature: Parameter Function...
Page 50
Chapter 3 Basic Program Structure of Uperlogic ST 3-9-6 複週期指令集 The following instruction list shows the instructions operating continuously in the background. The way to use it is to place it outside the IF loop to execute it every scan cycle, and determine the operating state of the function according to the EN signal.
Page 51
Chapter 3 Basic Program Structure of Uperlogic ST ReadWriteFileReg WriteSDMem ReadSDMem PID2 DBUF CMCTL ME_START ME_SYSSTOP ME_HOME ME_POS ME_JOG ME_CHGPRM ME_PAUSE ME_RESUME ME_HALT ME_RSTALM ME_STOP ME_SYSINIT ME_RCPR ME_RCPW M-Series PLC Structured Language ST User Manual...
Page 52
Chapter 3 Basic Program Structure of Uperlogic ST ME_CAMR ME_CAMW ME_GEAR_IN ME_VEL_CTL ME_TOR_CTL ME_CAM_GEN ME_AXI_MOV ME_SET_MAP ME_VIR_AXI HSPWM2 TARESUB TAREZEOFFSET 3-9-7 Enable/Disable Interrupt and Special Instructions Please refer to FUN 145, 146 LB parameters input integers from 1 to 49, corresponding to the types of interrupts. For all supported types, please refer to the chapter of special instructions.
Page 53
Chapter 3 Basic Program Structure of Uperlogic ST 3-10 Calling FCM Function The calling method is similar to calling system function, while the functions are built by users themselves. The built functions will be placed in FCM List in the command column on the left. Users can double-click the section to insert the selected function to the text.
Page 54
Chapter 3 Basic Program Structure of Uperlogic ST Calling side: In this way, some temporarily unnecessary variable declarations can be reduced in a timely manner. M-Series PLC Structured Language ST User Manual...
Page 55
Chapter 4 Establishing ST Program in Uperlogic Establishing ST Program in Uperlogic ST Editing Environment in Uperlogic ............錯誤! 尚未定義書籤。 Editing ST Statement ..................錯誤! 尚未定義書籤。 Insert API and FBD ..................錯誤! 尚未定義書籤。 Labeling Function ................... 錯誤! 尚未定義書籤。 M-Series PLC Structured Language ST User Manual...
Page 56
Chapter 4 Establishing ST Program in Uperlogic This chapter explains the precautions for the basic system configuration and the contents related to peripheral devices. 4-1 ST Editing Envorinment in Uperlogic You can add M-series modules to the right of M-series PLC CPU modules to match different applications. Available modules include Digital I/O Module, Analog I/O Module, Temperature Module, Network Module, Load Cell Module, etc.
Page 57
Chapter 4 Establishing ST Program in Uperlogic 4-2 Editing ST Statement Description of the precautions for system configuration. M-Series PLC Structured Language ST User Manual...
Page 58
Chapter 4 Establishing ST Program in Uperlogic 4-3 Insert API and FBD Use generally available standard (above CAT5 shielding level) RJ-45 (Ethernet) connectors 將 M 系列 CPU 模組 EtherCAT 埠與支援 E M-Series PLC Structured Language ST User Manual...
Page 59
Chapter 4 Establishing ST Program in Uperlogic 4-4 Labeling Function If the 上位裝置 or other systems want to connect with the M-series PLC, users can choose any port of USB, RS-485 or EtherNET to connect with it. It can also be connected with M-series PLC through UperLogic.
Page 60
Chapter 5 ST Program Examples ST Program Examples Example Description ..................錯誤! 尚未定義書籤。 Hardware Plannning ..................錯誤! 尚未定義書籤。 Program Planning ..................錯誤! 尚未定義書籤。 Building Example Program ................. 錯誤! 尚未定義書籤。 M-Series PLC Structured Language ST User Manual...
Page 61
Chapter 5 ST Program Examples “UperLogic” is the name of logic editing and testing application software for FATEK M-series PLC, which can be used for PLC logic editing, network setting, servo control, temperature control and other functions. Image of UperLogic functions...
Need help?
Do you have a question about the M Series and is the answer not in the manual?
Questions and answers