結構式檔案程式語言(英語:Structured text)也稱為ST語言,是為可程式邏輯控制器(PLC)設計的程式語言,是相關的IEC 61131-3標準中支援幾種語言之一。
基本介紹
- 中文名:結構式檔案程式語言
- 外文名:Structured text
- 簡稱:ST語言
- 領域:計算機
簡介
- 循環(REPEAT-UNTIL; WHILE-DO)
- 條件式執行(IF-THEN-ELSE; CASE)
- 函式(SQRT(), SIN())
範例
簡單的程式
(* simple state machine *)TxtState := STATES[StateMachine];CASE StateMachine OF 1: ClosingValve();ELSE ;; BadCase();END_CASE;
另外一個結構式檔案的程式範例
// PLC configurationCONFIGURATION DefaultCfg VAR_GLOBAL b_Start_Stop : BOOL; // Global variable to represent a boolean. b_ON_OFF : BOOL; // Global variable to represent a boolean. Start_Stop AT %IX0.0:BOOL; // Digital input of the PLC (Address 0.0) ON_OFF AT %QX0.0:BOOL; // Digital output of the PLC (Address 0.0). (Coil) END_VAR // Schedule the main program to be executed every 20 ms TASK Tick(INTERVAL := t#20ms); PROGRAM Main WITH Tick : Monitor_Start_Stop;END_CONFIGURATIONPROGRAM Monitor_Start_Stop // Actual Program VAR_EXTERNAL Start_Stop : BOOL; ON_OFF : BOOL; END_VAR VAR // Temporary variables for logic handling ONS_Trig : BOOL; Rising_ONS : BOOL; END_VAR // Start of Logic // Catch the Rising Edge One Shot of the Start_Stop input ONS_Trig := Start_Stop AND NOT Rising_ONS; // Main Logic for Run_Contact -- Toggle ON / Toggle OFF --- ON_OFF := (ONS_Trig AND NOT ON_OFF) OR (ON_OFF AND NOT ONS_Trig); // Rising One Shot logic Rising_ONS := Start_Stop;END_PROGRAM