fbpx
维基百科

結構式文件編程語言

結構式文件編程語言(英語:Structured text)也稱為ST語言,是為可程式邏輯控制器(PLC)設計的程式語言,是相關的IEC 61131-3標準中支援幾種語言之一[1]。結構式文件編程語言是支援塊狀結構(block structured)的高階語言,以Pascal為基礎,語法也類似Pascal。所有IEC 61131-3的語言都支援IEC61131通用元素(IEC61131 Common Elements)。其變數及函式呼叫是由IEC61131通用元素所定,因此同一個程式中可以使用IEC 61131-3中的不同語言。

結構式文件編程語言類似於PASCAL及C語言,因此可利用與微電腦及個人電腦相同的程式設計技術,進行階梯圖所難以執行的複雜計算,完成程式的建立。常用的程式及迴路可透過FB(功能區塊)的建立輕易地重複利用。

結構式文件編程語言支援複雜的敘述及巢狀指令:

  • 迴圈(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 configuration CONFIGURATION 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_CONFIGURATION PROGRAM 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 

函式方塊範例 编辑

//======================================================================= // Function Block Timed Counter : Incremental count of the timed interval //======================================================================= FUNCTION_BLOCK FB_Timed_Counter  VAR_INPUT  Execute : BOOL := FALSE; // Trigger signal to begin Timed Counting  Time_Increment : REAL := 1.25; // Enter Cycle Time (Seconds) between counts  Count_Cycles : INT := 20; // Number of Desired Count Cycles  END_VAR    VAR_OUTPUT  Timer_Done_Bit : BOOL := FALSE; // One Shot Bit indicating Timer Cycle Done  Count_Complete : BOOL := FALSE; // Output Bit indicating the Count is complete   Current_Count : INT := 0; // Accumulating Value of Counter  END_VAR    VAR  CycleTimer : TON; // Timer FB from Command Library  CycleCounter : CTU; // Counter FB from Command Library  TimerPreset : TIME; // Converted Time_Increment in Seconds to MS  END_VAR    // Start of Function Block programming  TimerPreset := REAL_TO_TIME(in := Time_Increment) * 1000;   CycleTimer(  in := Execute AND NOT CycleTimer.Q,  pt := TimerPreset);  Timer_Done_Bit := CycleTimer.Q;    CycleCounter(  cu := CycleTimer.Qa,  r := NOT Execute,  pv := Count_Cycles);   Current_Count := CycleCounter.cv;  Count_Complete := CycleCounter.q;   END_FUNCTION_BLOCK 

参考文献 编辑

  1. ^ . [2015-03-19]. (原始内容存档于2015-04-02). 

結構式文件編程語言, 英語, structured, text, 也稱為st語言, 是為可程式邏輯控制器, 設計的程式語言, 是相關的iec, 61131, 3標準中支援幾種語言之一, 是支援塊狀結構, block, structured, 的高階語言, 以pascal為基礎, 語法也類似pascal, 所有iec, 61131, 3的語言都支援iec61131通用元素, iec61131, common, elements, 其變數及函式呼叫是由iec61131通用元素所定, 因此同一個程式中可以使用iec, 6. 結構式文件編程語言 英語 Structured text 也稱為ST語言 是為可程式邏輯控制器 PLC 設計的程式語言 是相關的IEC 61131 3標準中支援幾種語言之一 1 結構式文件編程語言是支援塊狀結構 block structured 的高階語言 以Pascal為基礎 語法也類似Pascal 所有IEC 61131 3的語言都支援IEC61131通用元素 IEC61131 Common Elements 其變數及函式呼叫是由IEC61131通用元素所定 因此同一個程式中可以使用IEC 61131 3中的不同語言 結構式文件編程語言類似於PASCAL及C語言 因此可利用與微電腦及個人電腦相同的程式設計技術 進行階梯圖所難以執行的複雜計算 完成程式的建立 常用的程式及迴路可透過FB 功能區塊 的建立輕易地重複利用 結構式文件編程語言支援複雜的敘述及巢狀指令 迴圈 REPEAT UNTIL WHILE DO 條件式執行 IF THEN ELSE CASE 函數 SQRT SIN 目录 1 範例 1 1 簡單的程式 1 2 另外一個結構式文件的程式範例 1 3 函式方塊範例 2 参考文献範例 编辑簡單的程式 编辑 simple state machine TxtState STATES StateMachine CASE StateMachine OF 1 ClosingValve ELSE BadCase END CASE 另外一個結構式文件的程式範例 编辑 PLC configuration CONFIGURATION 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 20 ms PROGRAM Main WITH Tick Monitor Start Stop END CONFIGURATION PROGRAM 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 函式方塊範例 编辑 Function Block Timed Counter Incremental count of the timed interval FUNCTION BLOCK FB Timed Counter VAR INPUT Execute BOOL FALSE Trigger signal to begin Timed Counting Time Increment REAL 1 25 Enter Cycle Time Seconds between counts Count Cycles INT 20 Number of Desired Count Cycles END VAR VAR OUTPUT Timer Done Bit BOOL FALSE One Shot Bit indicating Timer Cycle Done Count Complete BOOL FALSE Output Bit indicating the Count is complete Current Count INT 0 Accumulating Value of Counter END VAR VAR CycleTimer TON Timer FB from Command Library CycleCounter CTU Counter FB from Command Library TimerPreset TIME Converted Time Increment in Seconds to MS END VAR Start of Function Block programming TimerPreset REAL TO TIME in Time Increment 1000 CycleTimer in Execute AND NOT CycleTimer Q pt TimerPreset Timer Done Bit CycleTimer Q CycleCounter cu CycleTimer Qa r NOT Execute pv Count Cycles Current Count CycleCounter cv Count Complete CycleCounter q END FUNCTION BLOCK参考文献 编辑 IEC编程语言 2015 03 19 原始内容存档于2015 04 02 取自 https zh wikipedia org w index php title 結構式文件編程語言 amp oldid 58015611, 维基百科,wiki,书籍,书籍,图书馆,

文章

,阅读,下载,免费,免费下载,mp3,视频,mp4,3gp, jpg,jpeg,gif,png,图片,音乐,歌曲,电影,书籍,游戏,游戏。