FATEK M Series User Manual
FATEK M Series User Manual

FATEK M Series User Manual

Structured language st
Hide thumbs Also See for M Series:

Advertisement

Quick Links

Structured Language ST
User Manual
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

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the M Series and is the answer not in the manual?

Questions and answers

Summary of Contents for FATEK M Series

  • 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: Table Of Contents

    Index Index Preface ........................2 Understand Structured Language ST ............12 1-1 Features of ST Language ..........................13 1-2 Adding ST Language Program ......................... 15 User Interface of Uperlogic ST ............... 18 Interface Overview ..........................19 Supportive Keyboard Instructions ....................22 Sytem Mode ............................
  • Page 3 Index 3-11 Multi-cycle instruction ........................70 3-12 Enable/Disable Interrupt and Special Instructions ..............73 3-13 Variable names with special meanings ..................82 3-14 Calling FCM Function .......................... 86 3-15 Function notes ............................88 ST Editing Environment Support Function List ......... 89 Name comparison between Ladder and ST editing environment instructions...
  • Page 4: Preface

    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.
  • Page 5: Precautions On Using The Product

    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.
  • Page 7: Precautions For Safety

    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.
  • Page 10: Precautions For Use

    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) Operating Before supplying power to the MPLC to start the operations, ensure that the setting of the data  register is correct without any mistakes. Before executing any of the following tasks, confirm that it will not bring about any adverse impact ...
  • 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: Understand Structured Language St

    Chapter 1 Understand Structured Language (ST) Understand Structured Language ST 1-1 Features of ST Language ..........................13 1-2 Adding ST Language Program ......................... 15 Structured Language ST User Manual...
  • Page 15: Features Of St Language

    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: Adding St Language Program

    Chapter 1 Understand Structured Language (ST) 1-2 Adding ST Language Program Establishing a new Program 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. Structured Language ST User Manual...
  • Page 19 Chapter 1 Understand Structured Language (ST) Example of creating an interrupt program (ST): Click right mouse button on the node of the special program. Interrupt Program Add Select the interrupt signal and the program type (ST) to be processed. Structured Language ST User Manual...
  • Page 20: User Interface Of Uperlogic St

    Chapter 2 User Interface of Uperlogic ST User Interface of Uperlogic ST Interface Overview ..........................19 Supportive Keyboard Instructions ....................22 Sytem Mode ............................23 Syntax Check ............................24 Mouse hover prompt ........................26 Add observed variables ........................27 Quick mouse and keyboard operations ..................
  • Page 21: Interface Overview

    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 22 Chapter 2 User Interface of Uperlogic ST This pop-up window will follow the user’s input (Match than 3 characters or [+number]) 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 23 Chapter 2 User Interface of Uperlogic ST Drag this area to display the area label. It will be more convenient to modify the program based on the label when writing ST programs. This area supports online editing mode and can be used for program debugging and correction. BirdView ScrollBar, convenient for briefly viewing the program overview Structured Language ST User Manual...
  • Page 24: Supportive Keyboard Instructions

    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 25: Sytem Mode

    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(The top of the ST editing window displays a black background) 2. Online Monitor (Read-Only, not for editing) (The top of the ST editing window displays a cyan background) 3.
  • Page 26: Syntax Check

    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: Structured Language ST User Manual...
  • Page 27 Chapter 2 User Interface of Uperlogic ST 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. 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.
  • Page 28: Mouse Hover Prompt

    Chapter 2 User Interface of Uperlogic ST 2-5 Mouse hover prompt In order to facilitate debugging and writing programs, the interface supports a prompt window that will appear when the mouse is hovering over variables or function text, giving users tips for writing programs or debugging. A.
  • Page 29: Add Observed Variables

    Chapter 2 User Interface of Uperlogic ST 2-6 Add observed variables In online editing and online monitoring modes, right-clicking on the text editor will pop up a menu where you can add the variable that the mouse cursor is pointing to, or automatically add all variables of the current text to the status observation page.
  • Page 30: Quick Mouse And Keyboard Operations

    Chapter 2 User Interface of Uperlogic ST 2-7 Quick mouse and keyboard operations ST text editor provides many common functions to improve the convenience of program editing. A. Select the entire row Clicking the mouse where the row number is displayed will select the row, and you can continuously select the entire row up or down.
  • Page 31: Structured Text Color Adjustment

    Chapter 2 User Interface of Uperlogic ST 2-8 Structured text color adjustment The font color of the ST editing environment can be adjusted to suit user habits. Structured Language ST User Manual...
  • Page 32: Quick Call/Create Table

    Chapter 2 User Interface of Uperlogic ST 2-9 Quick call/create table For some commands, click the button in the upper left corner of the pop-up window to call/create the corresponding table. Support List Instruction ID PID2 ASCWR TPCTL2 HSPSO MPARA MHSPO AHSPO ModBUS...
  • Page 33: Basic Program Structure Of Uperlogic St

    Basic Program Structure of Uperlogic ST Introduction ............................32 Statement ..............................34 Expression..............................37 Operand and Operator ........................42 Comment ............................... 47 Flow Control and Loop ........................48 Variables and Data Type ........................56 Using PLC Register and Memory ....................64 Calling System Built-In Functions ....................
  • Page 34: Introduction

    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 35 Constant Interger: 3-7-4 Defaulted as “signed int” Constant Ex: R0:=1; R0:=-2; “Unsigned int” Ex: Tag0:=0xFF; String: Use only on Label Goto, LBL...etc Bit (Bool) Type: TRUE、FALSE Float: 32-bit Float Constant ex: TagFloat1:=1.1; Delimiter “:” appears in CASE OF 3-6-3 Case 分隔“,”...
  • Page 36: Statement

    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 “;.” In addition, a statement is also allowed to contain multiple or multi-level sub-statement, and regardless of the position of the statement, it must be followed by a “;”...
  • Page 37 Shown below are some statements of Uperlogic ST Language: Type Content Example Distributive Statement Substitute the result on the right into the variable on the left. Flow Control Conditional Statement (IF, CASE) Select the execution syntax based 3-6-1 Syntax on the condition. Do-Whlie Statement (FOR, Execute multiple times depending 3-6-2...
  • Page 38 (It can be used in combination with Conditional statements and do-whlie statements)) Structured Language ST Manual...
  • Page 39: Expression

    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 40 The below table shows Expression types: Type Data Type of Expression (Computing Example Result) Operation Arithmetic Interger, real number…etc. R0+R2 Expression Expression (according to computing elements) Logic Expression Boolean (TRUE/FALSE) R0 AND R2 Compare Boolean (TRUE/FALSE) R0 > R2 Expression Basic Variables, Defined data type...
  • Page 41 Structured Language ST Manual...
  • Page 42 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:= ); √�� Trigonometric Functions SIN、ASIN B=SIN A FSIN( S:= , D:= ); COS、ACOS B=COS A FACOS( S:= , D:= );...
  • Page 43 Structured Language ST Manual...
  • Page 44: Operand And Operator

    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” and “D1” are operands, and the “+” sign is the operator. As seen from the examples in the previous section, an expression can be a combination of a group of operands and operators, but it can also be represented by an operand alone;...
  • Page 45 Like mathematical forms, operators themselves have a priority order for performing operations. When the priority levels are the same, the order of the operation will be from left to right. The following table is a list of operators in ST syntax in Uperlogic Data Form Example of Expression Priority Level...
  • Page 46 The individual Operator will be introduced later. 3-4-1 The function is the same as a mathematical formula, and the expression in the round brackets is prioritized for operation. R0:= (R0+2)*3-(R2+3)*56 ; // R0=1;R2=2 // R0= - 271 3-4-2 Arithmetic +, -,* , / Operate addition, subtraction, multiplication and division for the operators on both sides.
  • Page 47 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 48 3-4-10 Logic Operand AND ( & )、OR ( | )、XOR、XNOR Perform logic operations (Bitwise) on the left and right operators, and the result of the value will be the same as the type of the operator. R0:= R1 AND R2; // Perform bitwise AND operation on the values of R1 and R2 and store them in R0 // If R1=1(0b0_0001) R2=15(0b0_1111) then R0 =1(0b0_0001) DR0:= R10 &...
  • Page 49: Comment

    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. 3-5-1 Single-Line Comment Ligh gray will appear after the symbol, and will not generate the operating program codes.
  • Page 50: Flow Control And Loop

    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 51 3-6-2 For Loop Parameters: (*Reg*):Counter register Repeat the statement from END_FOR until the counter register reaches the target value. Each time it is repeated, an incremental value or decremental value is added to the target value (*Start*):Initial value (*End*):Target value (*<...
  • Page 52 3-6-3 Case Of Selection of Integer conditions: It will read the value of the target register, and run after the specified conditions are fully read: the following description . If none are satisfied, the description after ELSE will be run Conditions only support integer constants or constants within the range symbols R0 = 1...
  • Page 53 3-6-4 WHILE LOOP & REPEAT Repeat the run description until the condition is (not) met WHILE LOOP: 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 54 3-6-5 BREAK / EXIT In the loop situation of FOR, WHILE, REPEAT, you can leave the loop early with BREAK or EXIT at the appropriate time When R0 is greater than or equal to 100, it will run BREAK and jump out of the WHILE loop. 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.
  • Page 55 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 be used to call Label in the ST environment are as follows: JMP_66, GOTO (for detailed description, please refer to FUN 66) CALL,CALL_67 (for detailed description, please refer to FUN 67) Structured Language ST Manual...
  • Page 56 When using the Label function in a subroutine, the LBL instruction combined with RETURN will have different results. R0=2, because the Label of A.B is called at the same time and the result is RETURN. R0=1, because only the Label of A is called, and the result is RETURN R0=2, because the Label of A is called, but RETURN is after the Label of B R0=3, because the Label of "Sub-unit 0"...
  • Page 57 If you need to use tags in the FCM environment, you need to use the LBL_F、FLBL_165 instructions. The Label keyword can only be called in FCM GOTO_F (Label that can only be used in FB) FJMP_166 Structured Language ST Manual...
  • Page 58: Variables And Data Type

    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. The following introduces the data types and usage supported by ST.
  • Page 59 In order to cooperate with program operations of different data types, the following will demonstrate how to create different types of labels. The Rx.Dx register is defaulted to INT16, and the DRx.DDx register is defaulted to INT32 integer variable. Double-click to select the Global Tag->Add new Tag Structured Language ST Manual...
  • Page 60 If the selected address and data type are not supported, a reminder will pop up to block it. Structured Language ST Manual...
  • Page 61: Floating Point

    3-7-1 Bool / Bit As long as the data represented is a bit or a value comparison operation (ex. <, >, <> ... etc.), these results are all Bool (Bit) type, and or 1, TRUE, FALSE can be used here accepted as a constant representing type Bool.
  • Page 62 Among them, when using floating-point operations, there will be some defaulted implicit behaviors. The descriptive example is in the figure below: Line 1: Indicates that the floating point value of label 0 is assigned to 69905.14159 Line 3: Indicates converting the floating point value of label 0 into an int32 integer value And there is a position of DR10, and the decimal point will be removed.
  • Page 63 Line 2: DR14 (INT32) is converted into a floating-point data type and stored in the label 0 (The digital representation of observable floating point numbers is different from that of integers and can be used as Fun 200 I -> F) Structured Language ST Manual...
  • Page 64 3-7-4 Constant The table below shows the ST-supported constant types: Type Format andnd Sample Bool (Bit) 0, 1, TRUE, FALSE ------------------------------------------- M0:=1; M0:=TRUE; Integer Integer: R0:=1; R0:=-10; Binary: followed by the value of 0,1, underscores can be used to divide groups R0:=2#1111_0000;...
  • Page 65 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 ( "my_lab" Structured Language ST Manual...
  • Page 66: Using Plc Register And Memory

    3-8 Using PLC Register and Memory In addition to using the created Tag to call 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 67: Calling System Built-In Functions

    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 68 Most functions are executed as soon as they are called. If you want to execute the action only once after the condition is met, please refer to the writing method. IF R_TRIG( S:="condition" ) then "Function" END_IF !Note! The "Motion Basic"."Motion Mode1". "Motion Mode2". "Motion Mode3" functions in the toolbox are only executed once unless the conditional state changes.
  • Page 69 3-9-2 Counter / Counter_L There are two groups of Counter functions here, so that users can easily distinguish whether they are currently calling the counter of single word (Counter) or the version of double words (Counter_L) Prototype: Counter( Pulse:= (* Pulse Signal *), Clr:= (* CLR Signal *), C:= (* counter number (0~1023) *), PV:= (* Preset value (Single Word 0~65535) *),...
  • Page 70 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) : Rising / Falling Edge Detecting source (bool) Detecting result Example:...
  • Page 71: Functions With Multiple Calling Modes

    3-10 Functions with multiple calling modes Such as the trigger detection instructions in the previous chapter 3-9-3. These instructions support two types, one is a direct complete call, and the other is to omit the register location (D) where the result is stored.
  • Page 72: Multi-Cycle Instruction

    3-11 Multi-cycle instruction 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. As the example shown below: Because these instruction classes are called, the execution time usually exceeds one scan cycle.
  • Page 73 ModBUS CLINK 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 Structured Language ST Manual...
  • Page 74 ME_RCPR ME_RCPW 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 Structured Language ST Manual...
  • Page 75: Enable/Disable Interrupt And Special Instructions

    3-12 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. Interrupt Interrupt INT No.
  • Page 76 X0 negative X0−I (INT0-) edge trigger X1 positive X1+I (INT1+) edge trigger X1 negative X1−I (INT1-) edge trigger X2 positive X2+I (INT2+) edge trigger X2 negative X2−I (INT2-) edge trigger X3 positive X3+I (INT3+) edge trigger X3 negative X3−I (INT3-) edge trigger X4 positive X4+I (INT4+)
  • Page 77 X5 positive X5+I (INT5+) edge trigger X5 negative X5−I (INT5-) edge trigger X6 positive X6+I (INT6+) edge trigger X6 negative X6−I (INT6-) edge trigger X7 positive X7+I (INT7+) edge trigger X7 negative X7−I (INT7-) edge trigger Tick unit 1ms, Interval from Hardware STM0I 1ms~60000ms...
  • Page 78 Interval from STM3I 1ms~60000ms Tick unit 10ms, Interval from LTM0I 10ms~60000ms Value=1~6000 Interval from LTM1I 10ms~60000ms Interval from LTM2I 10ms~60000ms Interval from LTM3I 10ms~60000ms Interval from Tick uint 100us, HST0I 0.1ms to Value=1~60000 6000ms Interval HST1I from 0.1ms to 6000ms Interval HST2I from 0.1ms to...
  • Page 79 Interval from HSC0I HSC0 to (CV=PV) Interval from HSC1I HSC1 to (CV=PV) Interval from HSC2I HSC2 to (CV=PV) Interval from HSC3I HSC3 to (CV=PV) Interval from HSC4I HSC4 to (CV=PV) Interval from HSC5I HSC5 to (CV=PV) Interval from HSC6I HSC6 to (CV=PV) Interval from HSC7I...
  • Page 80 X8 positive The software high speed X8+I (INT8+) edge trigger Build-in counter HSC4~HSC7 can Digital be assigned as the Inputs (MA trigger source of any Series) interrupt X0~X15. Therefore, the interrupt priority of the software high speed counter depends on the priority of X0~X15.
  • Page 81 X11+I X11 positive (INT11+) edge trigger X11 negative X11−I (INT11-) edge trigger X12+I X12 positive (INT12+) edge trigger X12 negative X12−I (INT12-) edge trigger X13+I X13 positive (INT13+) edge trigger X13 negative X13−I (INT13-) edge trigger X14+I X14 positive (INT14+) edge trigger X14 negative X14−I (INT14-)
  • Page 82 X15 negative X15−I (INT15-) edge trigger X16+I X16 上沿觸發 (INT15+) X16−I (INT15-) X16 下沿觸發 X17+I X17 上沿觸發 (INT15+) X17−I (INT15-) X17 下沿觸發 MQ model DI Plug-in X18+I X18 上沿觸發 (INT15+) X18−I (INT15-) X18 下沿觸發 X19+I X19 上沿觸發 (INT15+) X19−I (INT15-) X19 下沿觸發 Structured Language ST Manual...
  • Page 83 X20+I X20 上沿觸發 (INT15+) X20−I (INT15-) X20 下沿觸發 X21+I X21 上沿觸發 (INT15+) X21−I (INT15-) X21 下沿觸發 X22+I X22 上沿觸發 (INT15+) X22−I (INT15-) X22 下沿觸發 X23+I X23 上沿觸發 (INT15+) X23−I (INT15-) X23 下沿觸發 Structured Language ST Manual...
  • Page 84: Variable Names With Special Meanings

    3-13 Variable names with special meanings A. Timer, Counter T0~TN, C0~CN In the ST environment, these two variables are given the characteristics of Bool and the characteristics of Integer. R0:=T1; //The currently calculated value of Timer1 will be stored in R0(Integer) M0:=T1;...
  • Page 85 B. Interrupt (Enum) Originally, only constants could be input for Enable/Disable interrupts. In order to improve the readability of the program, it was modified to allow the input of system default Enum parameters. If you type INT_, the corresponding series of available Enums will be displayed. IF M2 THEN INTEnable( LB:= INT_STM1I);...
  • Page 86 C. High-speed counting Enum “HSC_” Prefix Call related high-speed instructions such as HSCTR( CN:= (* 0~7 *)); HSCTW( S:= , CN:= , D:= );; Among them, the parameter expressions of CN, and D support constant integers. For the convenience of reading, Enum starting with HSC_ is also imported. Make programs more readable HSCTR( CN:= HSC_HSC0(* 0~7 *));...
  • Page 87 D. File Register Enum F0~F32767 For the Sb parameter of FUN 160, in addition to using 0~32767, you can use the Enum of F0~F32767 to represent the corresponding position. Structured Language ST Manual...
  • Page 88: Calling Fcm Function

    3-14 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. FCM can specify a Return Value, which can be call directly when programming.
  • Page 89 Calling side: In this way, some temporarily unnecessary variable declarations can be reduced in a timely manner. Structured Language ST Manual...
  • Page 90: Function Notes

    3-15 Function notes Whether it is built-in call system or FCM, they all have the following common characteristics: A. Calling method: 1. Enter the complete parameter name 2. Omit parameter names 3. Output parameters (=>) can be directly ignored and not passed. example: Take the R_TRIG function as an example Complete performance: R_TRIG( S:= M0, D=>M1);...
  • Page 91: St Editing Environment Support Function List

    ST Editing Environment Support Function List Name comparison between Ladder and ST editing environment instructions... 90 Functions with multiple calling modes ..................96 Structured Language ST Manual...
  • Page 92: Name Comparison Between Ladder And St Editing Environment Instructions

    Name comparison between Ladder and ST editing environment instructions ST function name Parameter Instruction manual Remark corresponding information Number Name ToBCD Fun20 ToBCD_D ToBIN Fun21 ToBIN_D F_TRIG Fun4 DIFU R_TRIG Fun5 DIFD Timer EN,T,PV,IsTimeout TIMER Counter Pulse,clr,C,PV,IsUp COUNTER Counter_L Fun28 ABS_D CRC16 S,N,D...
  • Page 93 LCNV_D MEAN S,N,D Fun25 MEAN MEAN_D EN,XY,Rs,Sl,Tx,Ty,Tl Fun34 ,D,OVR Sa,Sb,D Fun13 MULTIPLICATI S,N,D Fun24 SUM_D BITRD S,N,OTB,ERR Fun40 BITRD BITRD_D BITWR INB,D,N,ERR Fun41 BITWR BITWR_D DBUF EN,ID,CH,D,DN Fun115 DBUF ReadSDMem EN,INC,Bk,Os,Pr,L, Fun162 RD-MP D,ERR ReadWriteFileReg EN,R_W,INC,Sa,Sb, Fun160 RW-FR ReadWriteFileReg_D Pr,L SWAP Fun46 SWAP...
  • Page 94 PID_D SR,O_R,PR,WR,CC ERR,HAL,LAL PID2 EN,UPD,AM,D_R, Fun38 PID2 ID,CH,SR,OutR,PR, WR,ERR TPCTL2 EN,UPD,A_M,D_R, Fun99 TPCTL2 ID,CH,SR,PR,OriR, WR,ERR,ALM IMDIO Fun74 IMDIO EN,S,TI,D,OVF Fun83 ACTimer_10MS TIM,EN,CV,PV,TUP, Fun87 T.01S ACTimer_10MS_D ACTimer_100MS TIM,EN,CV,PV,TUP, Fun88 T.1S ACTimer_100MS_D ACTimer_1S TIM,EN,CV,PV,TUP, Fun89 ACTimer_1S_D RSWDT Fun91 RSWDTF Fun90 HSCTR Fun92 HSCTR HSCTW S,CN,D...
  • Page 95 T_Search_D ND,END,ERR SORT AD,S,D,L Fun113 SORT SORT_D STACK InOut,IW,ST,L,Pr, Fun111 STACK STACK_D OW,EPT,FUL T_Compare FHD,DS,Ta,Tb,L,Pr, Fun106 T-T_C T_Compare_D FND,END,ERR T_Fill Rs,Td,L Fun107 T_FIL T_Fill_D ZoneWR Val,D,N Fun114 Z-WR MAND Ma,Mb,Md,L Fun120 MAND MBCNT OnOff,Ms,L,D Fun130 MBCNT MBRD EN,INC,CLR,Ms,L, Fun126 MBRD Pr,OTB,END,ERR MBROT L_R,Ms,Md,L,OTB...
  • Page 96 PSOFF EN,Ps Fun142 PSOFF INTDisable Fun146 INTEnable Fun145 TARESUB EN,RST,ID,CH,SB, Fun258 MODCONF TAREZEOFFSET EN,MD,ID,CH,WR, Fun258 MFSysCAMR EN,Md,D,ID,L,ACT, Fun191 MFSysCAMR ERR,DN MFSysCAMW EN,Md,D,ID,L,ACT, Fun192 MFSysCAMW ERR,DN MFSysInit EN,ACT,ERR,DN Fun187 MFSysInit MFSysRCPR EN,Md,D,Gp,ACT,E Fun188 MFSysRCPR RR,DN MFSysRCPW EN,MD,D,GP,ACT, Fun189 MFSysRCPW ERR,DN MFSysRstAlm EN,ACT,ERR,DN Fun185 MFSysRstAlm...
  • Page 97 MFAxLMov EN,UPD,TAX,MD, Fun238 MFAxLMov DR,BF,D,EC,ACT, ERR,DN,UPD MFAxMov EN,UPD_in,AX,MD Fun197 MFAxMov MFAxMov_D ,Ps,V_n,A,D,SA,SD, DR,BF,ACT,ERR,DN ,UPD_out MFGearMPG EN,UPD_in,M,S,N, Fun193 MFGearMPG MFGearMPG_D D,T,ACT,ERR,DN,U PD_out MFPathMov EN,ACT,UPD,AX1, Fun240 MFPathMov AX2,AX3,PT,V,TA,T D,SA,SD,EC,ACT,ER R,DN,UPD MFTorqCtl EN,UPD_in,AX,T,M Fun195 MFTorqCtl MFTorqCtl_D X,ACT,ERR,DN, UPD_out MFVelCtl EN,UPD_in,AX,T,M Fun194 MFVelCtl MFVelCtl_D X,ACT,ERR,DN, UPD_out Structured Language ST Manual...
  • Page 98: Functions With Multiple Calling Modes

    Functions with multiple calling modes ST function Parameter Parameter description name ToBCD S: The data being converted or its register number. ToBCD_D D: The register number that stores the conversion result (BCD code) ToBIN S: The data being converted or its register number. ToBIN_D D: The scratchpad number where the conversion result (BIN code) is stored.
  • Page 99 and the register D stores the Upper Byte register D of the CRC calculation result +1 Lower Byte S,N,D of the stored CRC resultThe operator can be combined with V, Z, P0~P9 indicators for indirect addressing applications Sa,Sb,D Sa: The dividend number or its scratchpad number. SB: The divisor or its register number.
  • Page 100 value. D : The number of the scratchpad where the result is stored. /b12> The register used by the operator must be an even address, e.g. R8 is valid and R7 is not. The S and D operators can be combined with V, Z, P0~P9 indicators for indirect addressing applications FDIV...
  • Page 101 FSQR S: Find the source value or scratchpad number of the square root. D : The register number that holds the result (square root value) /b15> The register used by the operator must be an even address, e.g. R8 is valid and R7 is not. The S and D operators can be combined with V, Z, P0~P9 indicators for indirect addressing applications...
  • Page 102 LCNV EN,Md,S,Ts, Md: operation mode selection, 0~3 S: the start number of LCNV_D the source register to be converted TS: the start number of the start register of the conversion table D: The starting register number where the conversion result is stored L: The length to be converted, 1~64 MEAN S,N,D...
  • Page 103 S,N can be combined with V, Z, P0~P9 for indirect addressing applications BITWR INB,D,N,ERR D: The register number of the bit to be written BITWR_D N: Specifies that the state of the write bit INB is written to the Nth bit D in D, and N can be combined V, Z, P0~P9 for indirect addressing applications DBUF EN,ID,CH,D,...
  • Page 104 applications ToASCII S,N,D S : The starting number of the source register N: The number of ASCII codes to be converted into hexadecimal values D: The start number of the register where the result (ASCII code) is stored S,N,D can be combined with V,Z,P0~P9 for indirect addressing applications ToBCD S: The data being converted or its register number.
  • Page 105 BintoGray_D D: The start number of the scratchpad where the result (Gray code) is stored The S,D operators can be combined with V, Z, P0~P9 indicators for indirect addressing applications DECOD S,Ns,Nl,D,D,E S: The decoded source data register number (16 bits). NS: The start bit to be decoded in S NL: The length of the decoded value (1~8 bits) D : The starting number of the register (2~256 points=1~16 words) where the decoding result...
  • Page 106 R,PR,WR,ERR CH : The channel number used as the input signal SR : Programmable setpoint start register number, occupies a total of 8 registers OR: PID output register number PR: Parameter setpoint start register number, 7 registers occupied in total WR: The working instantial memory start number required for this instruction occupies a total of 5 scratchpads, and cannot be reused elsewhere.
  • Page 107 is, 0.5 seconds ~ 1.2 seconds HSCTR CN: Hardware high-speed counter number 0: HSC0 1: HSC1 2: HSC2 3: HSC3 4:HSC4 5:HSC5 6:HSC6 7:HSC7 HSCTW S,CN,D CN: Hardware high-speed counter number 0: HSC0 1: HSC1 2: HSC2 3: HSC3 4:HST4 2:HSC2 3:HSC3 4:HST4 D: Write object (0: for CV, 1: for PV) RAMP2 EN,Om,Ta,Td,...
  • Page 108 ModBUS EN,A_R,ABT, PT: 1, 2, through this port,, the MODBUS PT,SRWR,AC RTU communication protocol is used for data T,ERR,DN, transmission SR: Communicator start register (see example). WR: The instruction operation start register (see example), which occupies a total of 8 registers, and cannot be reused by other programs NE,SR,MD,W SR: Table start register address.
  • Page 109 D,ERR TS: The register number at the beginning of the searched list L: the length of the list PR: Indicator, which is used to record the value of the location of the target Rs,Ts can be combined with V, Z, P0~P9 for indirect addressing applications SORT AD,S,D,L...
  • Page 110 ZoneWR Val,D,N D: The starting address of the region to be written or cleared N: The length of the area to be written or cleared: 1~511 D, N can be combined with V, Z, P0~P9 for indirect addressing applications MAND Ma,Mb,Md,L MA: The starting register number of Source Matrix A MB: The register number at the beginning of...
  • Page 111 Md,L,OTB matrix MD: The register number at the beginning of the destination matrix L: Matrix (Ms and Md) length Ms, Md can be combined with V, Z, P0~P9 for indirect addressing applications MINV Ms,Md,L Ms : The register number at the beginning of the source matrix MD: The number of the scratchpad at the beginning of the matrix for which the result is stored...
  • Page 112 Source Matrix B MD: The number of the scratchpad at the beginning of the matrix for which the result is stored L : the length of the matrix (Ma, Mb, Md). Ma, Mb, Md can be combined with V, Z, P0~P9 for indirect Addressing applications HSPSO EN,PAU,ABT,...
  • Page 113 Read E-Cam data ,ACT,ERR,DN Route 1: From PLC Md: 0 D: The initial address of the PLC register after the E-Cam data is read ID: E-Cam number L: E-Cam resolution Route 2: From FATEK SD card Structured Language ST Manual...
  • Page 114 Md: 1 D: FATEK SD card E-Cam data's file number ID: E-Cam number L: E-Cam resolution MFSysCAMW EN,Md,D,ID,L Write E-Cam data ,ACT,ERR,DN Route 1: From PLC Md: 0 D: The initial address of the written E-Cam data in the PLC...
  • Page 115 Route 2: From FATEK SD card Md: 1 D: FATEK SD card recipe file number Gp: Write all set recipes = 0, write first set recipe = 1, and so on MFSysRstAlm EN,ACT,ERR, Remade motion control bug MFSysSetVirt EN,AX,ACT,E Translate Real axis to virtual axis...
  • Page 116 Positive direction (ON) / Negative direction (OFF) MFPointMov EN,PT,AX,AC Execution point table positioning mode T,ERR,DN Pt: point number AX: Axis number MFAxCirMov EN,UPD,TAX, Total number of axes (TAX): Mode (MD): DR,BF,D,EC,A 0: absolute, 1: relative CT,ERR,DN,U Direction (DR): 1: Forward, 2: Reverse Continuous mode (BF): MFAxLMov EN,UPD,TAX,...
  • Page 117 N: (conversion numerator) Integer, including decimal point from axis D: (conversion denominator) Positive integer including main axis decimal point T: (smoothing time) positive integer Unit: ms MFPathMov EN,ACT,UPD, AX1: Axis 1 AX1,AX2,AX AX2: Axis 2 3,PT,V,TA,TD, AX3: Axis 3 SA,SD,EC,AC PT: path number T,ERR,DN,UP V: Vel...

Table of Contents