



摘" 要: 為了設計一種PLC控制器,文中重點研究了PLC編程系統中由梯形圖到語句表編譯解算的實現過程,并提出一種應用于PLC開發的梯形圖轉換為語句表的新方法,即基于節點勢能的轉換方法。該方法將梯形圖類比電路圖,仿照電勢能,以節點勢能表示虛擬梯形圖中的能量流動,通過對梯形圖節點勢能的確定,將梯形圖各圖元之間的連接關系抽象為數值關系,并以此關系建立二叉樹,遍歷生成語句表。該方法簡單清晰,以一種復雜度較低的數據結構將梯形圖完整地描述出來,能夠準確快速地完成由梯形圖到語句表的編譯解算,并可適用于邏輯關系比較復雜的梯形圖程序的轉換。該轉換方法也能夠為其他類似圖形關系的解算提供參考,具有普遍適用性。
關鍵詞: PLC; 梯形圖; 語句表; 轉換方法; 節點勢能; 二叉樹
中圖分類號: TN709?34; TP273" " " " " " " " " " "文獻標識碼: A" " " " " " " " " " 文章編號: 1004?373X(2025)01?0168?05
A new method of converting ladder diagram into statement"list applied in PLC development
WEI Xiaoqing1, HAO Fang2, JIANG Tao1, KANG Bingbing1, ZHAO Nian1
(1. Institute of Aviation Basic, Naval Aviation University, Yantai 264001, China;
2. No. 1 Military Representative Office of Equipment Department of PLA Air Force in Shenyang, Shenyang 110034, China)
Abstract: In order to design a PLC controller, the realization process of compiling and calculating from ladder diagram to statement list is taken as the focus of the research, and a new method of converting ladder diagram into statement table applied in PLC development is proposed. It is a conversion method based on node potential energy. In this method, the ladder diagram is analogous to the circuit diagram. By imitating the electric potential energy, the energy flow in the virtual ladder diagram is represented by the node potential energy. The connection relationship between the primitives of the ladder diagram is abstracted into a numerical relationship by the determination of the node potential energy of the ladder diagram, and the binary tree is established based on this relationship, and the statement table is generated by traversing. This method is simple and clear, and can completely describe the ladder diagram with a low complexity data structure, and easily and accurately complete the compiling and calculating from the ladder diagram to the statement list. In addition, it can be applied to the conversion of ladder diagram programs with complex logical relationship. This conversion method can also provide a reference for the solution of other similar graph relationships, so it has universal applicability.
Keywords: PLC; ladder diagram; statement list; conversion method; node potential energy; binary tree
0" 引" 言
可編程邏輯控制器(PLC)在當今各行各業中的應用非常廣泛,是現代自動化行業的重要支柱[1?2],但目前國產PLC占市場份額[3]卻不足5%,發展空間非常大。為了設計一種PLC控制器,本文對PLC的編程系統進行了研究,研究重點是PLC編程系統中由梯形圖到語句表的編譯解算實現過程。
在IEC61131?3定義的5種PLC編程語言中,梯形圖和語句表的應用最為廣泛。梯形圖以常開元件、常閉元件、定時器等圖元的連接組合實現控制功能,作為一種圖形化編程語言易于工程人員使用。語句表是一種類匯編語言,易于處理器解析[4?5]。因此,在PLC開發中實現從梯形圖到語句表的轉換解算尤為重要,一直以來是PLC開發中的重點和難點[6?7]。……