f1336852 九、發明說明: 【發明所屬之技術領域】 本發明係有關於—種可程式控制器(PLC) #呈式編輯方 法,更有關於-種可由游標拖拉及判斷拖拉來源方式,自 動產生IEC61131程式片爲·夕济& a t 八月奴之可私式控制器(PLC)程式編輯 方法。 【先前技術】 早期PLC控制程式發展軟體大多使用階梯圖程式 (LadderDiagram,LD)語言,其語法簡單易學,因此被廣泛 使用於PLC制程式之開發^但階梯圖程式欠缺許多高階 語:之特色,例如變數資料結構、數值運算能力、物件導 向。又。十方式及程式執行控Μ等。此夕卜’階梯圖程式之語法 及語意亦隨其PLC硬體平台之不同而異。因此國際電:聯F1336852 IX. Description of the invention: [Technical field of the invention] The present invention relates to a programmable controller (PLC) #presentation editing method, and more related to - a type of cursor can be dragged and judged to drag the source mode, automatically generating IEC61131 The program is the Xiji & at August slave private controller (PLC) program editing method. [Prior Art] Most of the early PLC control program development software used LadderDiagram (LD) language, which has a simple and easy to learn syntax. Therefore, it is widely used in the development of PLC programs. However, the ladder program lacks many high-level languages: For example, variable data structure, numerical computing capability, object orientation. also. Ten ways and program execution control. The syntax and semantics of the ladder program are also different depending on the PLC hardware platform. Therefore, International Power: Union
jl (International Electrotechnical Commission,IEC)制訂出 IEC 61131-3之國際標準編程語言,該標準除具備前揭高階語言 之特色外,更定義一組完整的程式發展工具。 IEC 61131-3定義了下列五種不同的程式語言 1.階梯圖程式(LD) 階梯圖須熟悉機械的動作順序並先行畫出控制迴路 後,再將繼電器控制電路中的a接點、b接點、電路串並 聯及線圈予以符號化而成。 2·功能方塊(Functional Block Diagram,FBD) 程式語言係由一些事先定義好的功能方塊組成,並經 由適當連接以構成一完整電路,因此功能方塊程式特別適 [1336852 合於說明控制元件中資料或是數據的流程。 3. 指令(Instructional List, IL,或是 Statement List, SL) 指令為一種低階語言,由布林代數(Boolean Algebra)及 *' 其基本邏輯演變而來,主要是由一些助憶符號(Memonics) 所組成。例如及(AND)、與(OR)、反相(NOT)等符號。 4. 結構式文件編程語言(Structure Text, ST) 一些高階之P L C具有高階程式語言,例如數學運 | 算、副程式、迴圈及條件判斷式,以透過通訊網路與電腦 (PC)連線操作。 5·順序功能流程圖(Sequential Function Chart, SFC) 順序功能流程圖係將機械動作或步驟一步步分解成順 序功能流程圖的組成元素,再依其動作順序連接起來,以 完成整體之機械動作。 IEC 61131-3的程式語言可以用PLC本身配置的程式書 寫器輸入,或是藉由電腦連線編程軟體,前者僅適於指令 _ 碼之輸入,而後者則可輸入所有類型之程式語言。習知之 電腦連線編程軟體,例如CoDesys的編程軟體或是 InfoTeam編程軟體在撰寫程式時,使用者須熟記語法 (Syntax),若要進行函式呼叫,更須查明該函式有哪些參 數,在使用上對於使用者相當不便。 正C61131對於結構式文件編程語言(ST)與指令(IL)兩 種文字語言的編輯器,在其使用上其語法有特定規範。因 此如能提供函式庫拖拉,讓使用者可以不用記住IEC61131 所制訂的特殊語法,直接用拖拉方式完成函式呼叫;或利 7Jl (International Electrotechnical Commission, IEC) has developed an international standard programming language of IEC 61131-3, which defines a complete set of program development tools in addition to the features of the previous high-level languages. IEC 61131-3 defines the following five different programming languages. 1. Ladder diagram program (LD) The ladder diagram must be familiar with the mechanical sequence of motion and draw the control loop first, then connect the a contact and b in the relay control circuit. Points, circuit strings are connected in parallel and coils are symbolized. 2·Functional Block Diagram (FBD) The programming language consists of pre-defined function blocks and is connected to form a complete circuit. Therefore, the function block program is particularly suitable [1336852 to explain the data in the control element or It is the flow of data. 3. Instruction (Instructional List, IL, or Statement List, SL) The instruction is a low-level language evolved from Boolean Algebra and *' its basic logic, mainly by some memory symbols (Memonics). Composed of. For example, symbols such as (AND), AND (OR), and inversion (NOT). 4. Structured Text Programming Language (Structure Text, ST) Some high-end PLCs have high-level programming languages, such as mathematics, calculations, subroutines, loops, and conditional judgments, to connect to a computer (PC) via a communication network. . 5. Sequential Function Chart (SFC) The Sequential Function Chart (SFC) is a step-by-step decomposition of mechanical actions or steps into constituent elements of a sequential functional flow diagram, which are then connected in order of motion to complete the overall mechanical action. The programming language of IEC 61131-3 can be input by the program writer of the PLC itself, or by the computer programming software. The former is only suitable for the input of the command _ code, while the latter can input all kinds of programming languages. Conventional computer programming software, such as CoDesys programming software or InfoTeam programming software, users must memorize the syntax (Syntax) when writing a program. To make a function call, it is necessary to find out which parameters of the function. It is quite inconvenient for the user in use. The C61131 editor for the two-language language of the Structured Document Programming Language (ST) and Instruction (IL) has specific specifications for its syntax. Therefore, if the library drag and drop can be provided, the user can directly complete the function call by dragging without having to remember the special grammar formulated by IEC61131;
Si::有广語法範列導出’再由範例修改成自 ^式,即可大幅改善程式撰寫效率。 【發明内容】 斷掩=Γ::广提供-種可以游標掩拉及判 制器程式法自動產生咖⑶程式片段之可程式控 上述目的’本發明提供一種咖程式編輯方 '、 電腦上使用一游標工具編輯PLC程式。在電腦 來源轉換成二:::==定是否將拖拉物件 源是專案中 L並真入編輯區。若拖拉物件來 Λ,、主式',且織單元(P0U),則依據來源POIJ形 =編輯中的咖形態及禁止遞迴呼叫原則,決定是否將 轉換成IEC61131語法,並填入編輯區。在判 ==树明之方法,可讓使用者用游標二使 式撰寫。xpou轉換成程式碼貼在編輯區,以利虹程 【實施方式】 電腦作X月本:明,程式編輯方法於- 木作不思圖,在視窗上側部份為一功能選單 (_enu)、左下側為一程式檔案總管(program flIe mamger)、右下側為一編輯區(Editarea),但是須知 置oay⑽)僅為說明方便,並不是對於本發明之限制。此配 8 1336852 在視窗左下侧程式檔案總管所顯示的專案樹(project tree)主要具有兩個樓案夾,亦即函式庫(Libraries)及程式組 織單元(Programming Organization Unit,POU Pool)樓案夾。函式 庫中的函式共分兩種型態,即函式(Function, FC)與功能方 塊(Function Block, FB);而專案中的POU共分三種型態1.程 式(Program, PG)、 2.函式FC 、3.功能方塊FB。其中函 式庫中的函式跟POU都是一樣供使用者呼叫使用的;差別 在於函式是有經包裝過,因此不可再進行編輯。 如此圖所示,目前編輯中的POU型態為程式(Program) 而POU名稱為ST。依IEC61131規定,有下列的呼叫規則: 1. 程式PG能呼叫函式FC及功能方塊FB ; 2. 功能方塊FB能呼叫函式FC及功能方塊FB ,但 不能呼叫程式PG ; 3. 函式FC只能呼叫函式FC ,不能呼叫程式PG及 功能方塊FB ; 4. 不允許遞迴呼叫,所以POU不能呼叫自已。 因此可以看出在上述的規則中,呼叫的優先次序是程 式(Program)—功能方塊(Function Block)—函式(Function),且 不容許遞迴呼叫。 參見第二圖,為說明依據本發明第一實施例的方法流 程圖。在IEC61131編輯器(Text editor )作業時(步驟 10),若在一游標工具(如滑鼠)偵測到一個拖放動作 (drag and drop)(步驟12),則此電腦系統會判斷在拖拉 (drag)作業時的内容是否可以丟放(drop)到編輯器區域 Ί336852 (步驟14),若否則回到步驟10 ;若可以丟放,則進―步 判斷拖拉内容是功能方塊FB或是函式FC(步驟16)。若 拖拉内容是函式FC ,則進行轉換成IEC61131語法程式片 段(步驟16A),再將轉換IEC61131語法程式片段貼到 IEC61131編輯器區域(步驟18)。若拖拉内容是功能方塊 FB ’則進行轉換成IEC61131語法程式片段(步驟ι6Β), 再將轉換IEC61131語法程式片段貼到IEC61131編輯器區域 (步驟18)。因此使用者可以直接將函式庫中的函式fc •與功能方塊FB對應的IEC61131語法程式片段,用游標拖 拉的方式,貼到IEC61131編輯器區域。 參見第三圖及第三圖A,為說明依據本發明第二實施 例的方法流程圖,此流程更具體說明依據在拖拉(drag)作 業時的内容,而判斷是否可拖放的作業。 在IEC61131編輯器區域作業時(步驟20),若一游標 工具(如滑鼠)彳貞測到一個拖放動作(drag and drop)(步驟 22),則此電腦系統會判斷拖拉(drag)作業時的物件來源 ® (步驟22) ’並分成拖拉作業時的物件來源為函式庫(步 驟30)、拖拉作業時的物件來源為專案中的p〇U(步驟50) 及其他來源(步驟70)處理。 若拖拉作業時的物件來源為函式庫(步驟30),則判 斷函式形態(步驟300)。若函式形態為函式FC ,則可進 行轉換成IEC61131語法程式片段(步驟302)、將滑鼠游標 改成可接受丟放(drop)的圖像(icon)(步驟314)、找到游標 位置(步驟318)、再將轉換IEC61131語法程式片段貼到 1336852 IEC61131編輯器區域(步驟320)。 若函式形態為功能方塊FB ,則判斷編輯中的POU形 態(步驟310)。若編輯中的POU形態為函式FC ,則將滑 鼠游標改成禁止接受丟放(drop)的圖像(icon)(步驟312), 因為函式FC不能呼叫功能方塊FB 。若編輯中的POU形 態為功能方塊FB或是程式PG ,則可以呼叫功能方塊 FB ,因此將滑鼠游標改成可接受丢放(drop)的圖像 (icon)(步驟314)、進行轉換成IEC61131之功能方塊FB語 法程式片段(步驟316)、找到游標位置(步驟318)、再將 轉換IEC61131語法程式片段貼到IEC61131編輯器區域(步 驟 320)。 若拖拉作業時的物件來源為專案中的POU(步驟50), 則判斷拖拉物件的POU形態(步驟52),並分成型態為函 式FC(步驟54)、功能方塊FB(步驟56)及程式PG(步驟 58)三種情形來考量。 若拖拉物件的POU形態為函式FC ,則判斷拖拉來源 是否與編輯中的POU同名(步驟54),若同名表示不能遞 廻呼叫(POU不能呼叫自已),則將滑鼠游標改成禁止接受 丟放(drop)的圖像(步驟540)。若不同名,則進行步驟 542-548以指示使用者可接受拖放並將來源POU轉換 IEC61131語法程式片段貼到IEC61131編輯區。 若拖拉物件的POU形態為功能方塊FB ,則判斷編輯 中的POU型態(步驟56),並依據編輯中的POU型態,分 別進行步驟560(對應POU型態為函式FC),步驟562(對應 rI336852 p〇u型態為功能方塊FB),步驟566(對應p〇u型態為程式 G) /如果對應POU型怨為函式Fc,將滑鼠游標改成禁 止接受丟放(drop)的圖傻卩半跡ςΛΛ、 ^ ^ ' y 口1豕(步驟560),因為函式FC不能 呼叫功能方塊FB。如果對應P〇U型態為功能方塊FB, 則判斷拖拉來源是否為編輯中的p〇u(步驟562);若是 將滑鼠游標改成禁止接受丢放(dr〇p)的圖像(步驟撕卜 因為禁止遞迴呼叫。如果來源不是為編輯中的㈣,則進 行步驟566-572 ’以指示使用者可接受拖放、並將由來源 P〇U轉換IEC61131語法程式片段貼到ffiC61l3i編輯區。若 ^拉物件的刚形態為程式阳,則進行步驟566·572,以 指不使用者可接受拖放、並將來源舰轉換脇語法 程式片段貼到IEC61131編輯區。 在步驟52中,若拖拉物件的P〇U形態為程式PG 將滑氣游標改成禁止接受丟放(dr〇p)的圖像(步驟 因為程式PG不能被守叫。 故占ί步驟24中’若拖拉物件來源為其他,則將滑氣游標 /成示止接受丟放(dr〇p)的圖像,以提醒使用者作業錯 誤。 、曰 參^第四圖、第五A圖及第五㈣’為說明依據上述 ::白在况明當一個程& (Pro—㈣的P〇U編輯器接收 的:放二一功能方塊FB型態的函式形態所觸發Si:: has a wide grammar list to export' and then modified from the example to self-style, which can greatly improve the efficiency of programming. [Summary of the Invention] 断 Γ : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : A cursor tool to edit the PLC program. Convert the computer source to two:::== to determine whether the object will be dragged and the source is in the project L and actually enter the editing area. If the object is dragged, the main type, and the weaving unit (P0U), it is determined according to the source POIJ shape = the coffee form in the edit and the principle of prohibiting the recursive call, whether it will be converted into the IEC61131 syntax and filled in the editing area. In the method of == Shuming, the user can use the cursor two to write. Xpou is converted into a code to be posted in the editing area, to facilitate the process [implementation] computer X-moon: Ming, program editing method in - wood does not think, in the upper part of the window is a function menu (_enu), The lower left side is a program file manager (program flIe mamger), and the lower right side is an edit area (Editarea), but it should be noted that setting oay (10) is merely for convenience of explanation and is not intended to limit the present invention. The project tree displayed on the left and right side of the window is mainly composed of two building folders, namely Libraries and Programming Organization Unit (POU Pool). folder. The functions in the library are divided into two types, namely, Function (FC) and Function Block (FB). The POU in the project is divided into three types. 1. Program (PG) , 2. Function FC, 3. Function block FB. The function in the library is the same as the POU for the user to call; the difference is that the function is packaged, so it can't be edited. As shown in the figure, the POU type in the current editing is Program and the POU name is ST. According to IEC61131, the following calling rules are available: 1. The program PG can call the function FC and the function block FB; 2. The function block FB can call the function FC and the function block FB, but cannot call the program PG; 3. Function FC You can only call the function FC, you cannot call the program PG and the function block FB; 4. The call cannot be returned, so the POU cannot call itself. Therefore, it can be seen that in the above rules, the priority of the call is Program - Function Block - Function, and the call is not allowed to be reciprocated. Referring to the second figure, a flow chart of a method in accordance with a first embodiment of the present invention is illustrated. In the IEC61131 Text Editor (step 10), if a cursor (such as a mouse) detects a drag and drop (step 12), the computer system will judge the drag (drag) whether the content of the job can be dropped to the editor area Ί 336852 (step 14), otherwise return to step 10; if it can be thrown, then step by step to determine the drag content is the function block FB or letter Formula FC (step 16). If the drag content is a function FC, it is converted into an IEC61131 grammar fragment (step 16A), and the converted IEC61131 grammar fragment is pasted into the IEC61131 editor area (step 18). If the dragged content is the function block FB', it is converted into an IEC61131 grammar program fragment (step ι6Β), and the converted IEC61131 grammar program fragment is pasted into the IEC61131 editor area (step 18). Therefore, the user can directly paste the function fc in the library and the IEC61131 grammar fragment corresponding to the function block FB by the cursor to the IEC61131 editor area. Referring to the third and third figures A, in order to illustrate a flow chart of a method according to a second embodiment of the present invention, this flow more specifically explains whether or not a job that can be dragged and dropped is determined based on the content at the time of drag operation. When working in the IEC61131 editor area (step 20), if a cursor tool (such as a mouse) detects a drag and drop (step 22), the computer system will determine the drag operation. Source of Objects® (Step 22) 'The source of the object when it is divided into dragging operations is the library (Step 30), the source of the object when dragging the job is p〇U (Step 50) and other sources (Step 70) )deal with. If the object source at the time of the drag operation is a library (step 30), the function form is judged (step 300). If the function form is a function FC, it can be converted into an IEC61131 grammar program fragment (step 302), the mouse cursor is changed to an acceptable drop image (step 314), and the cursor position is found. (Step 318), the converted IEC 61131 grammar program fragment is then pasted into the 1363852 IEC 61131 editor area (step 320). If the function form is the function block FB, the POU state in the editing is judged (step 310). If the POU in the edit mode is the function FC, the mouse cursor is changed to an image (icon) that is prohibited from accepting the drop (step 312) because the function FC cannot call the function block FB. If the POU in the edit mode is the function block FB or the program PG, the function block FB can be called, so the mouse cursor is changed to an image that can accept the drop (step) (step 314), and converted into The function block FB syntax program fragment of IEC 61131 (step 316), finds the cursor position (step 318), and then converts the converted IEC 61131 grammar program fragment to the IEC 61131 editor area (step 320). If the object source during the drag operation is the POU in the project (step 50), determine the POU form of the dragged object (step 52), and divide the formed state into a function FC (step 54), a function block FB (step 56), and The program PG (step 58) considers three situations. If the POU form of the dragged object is the function FC, it is judged whether the drag source has the same name as the POU in the edit (step 54), and if the same name indicates that the call cannot be made (the POU cannot call the self), the mouse cursor is changed to prohibit the acceptance. An image of the drop (step 540). If the name is different, steps 542-548 are performed to indicate that the user can accept the drag and drop and paste the source POU conversion IEC61131 grammar program into the IEC61131 editing area. If the POU form of the dragged object is the function block FB, the POU type in the editing is judged (step 56), and according to the POU type in the editing, step 560 is performed respectively (corresponding to the POU type is the function FC), step 562 (corresponding to rI336852 p〇u type is function block FB), step 566 (corresponding to p〇u type is program G) / If the corresponding POU type is function Fc, change the mouse cursor to prohibit accepting drop (drop The figure is silly and half traced, ^ ^ ' y port 1豕 (step 560), because the function FC cannot call the function block FB. If the corresponding P〇U type is the function block FB, it is determined whether the drag source is the edited p〇u (step 562); if the mouse cursor is changed to the image that is forbidden to accept the drop (dr〇p) (step If the source is not in the edit (4), then steps 566-572' are performed to indicate that the user can accept the drag and drop, and the IEC61131 grammar fragment converted by the source P〇U is posted to the ffiC61l3i editing area. If the shape of the object is programmed, then step 566·572 is performed to indicate that the user can accept the drag and drop and paste the source ship conversion grammar fragment into the IEC61131 editing area. In step 52, if the drag is pulled The P〇U form of the object is the program PG that changes the slippery cursor to an image that is forbidden to accept the drop (dr〇p) (step because the program PG cannot be called.) Therefore, in step 24, if the source of the dragged object is other , the image of the slippery vernier/shower accepts the drop (dr〇p) to remind the user of the wrong operation. 曰 ^ ^ 4th, 5th and 5th (4)' ::White in the case of a course & (Pro-(four) P〇U Editor receiving: a functional block FB put twenty-one form patterns function triggered
之流裎路徑。 W 當文字編輯器接受一個拖放作業時,由於目前編輯的 12 [Ϊ336852 POU型態為程式PG ,而拖拉來源為函式庫中的功能方塊 FB ,因此流程會走如第四圖所示的路徑:步驟2〇:步驟 22—步驟24—步驟30—步驟310〜步驟314〜步驟 ^驟步驟320。依據本發明之方法可判斷為fb : 態的函式庫,故游標會變成接受圖像以顯示允許丟放狀 態、就呼叫對制FB㉟態函式解析程式將函式自動轉換 成脇㈣# FB呼叫(CALL)語法、找到目前游標指到的 位置、將轉換後的程式片段填入游標指到的位置。 因IEC61131夫見範的函式或功能方塊呼叫較為特殊,跟 一般程式語言不太一樣。利用此拖拉技巧,可讓使用者不 需記憶呼叫方歧料叫的函式有何參數。因為依據 明之方法,拖拉到文字編輯器後,會自動產 : 段及内部參數。 八月 再者,因EEC61131規範的基本程式語法盘The rogue path. W When the text editor accepts a drag-and-drop job, since the currently edited 12 [Ϊ336852 POU type is the program PG, and the drag source is the function block FB in the library, the flow will go as shown in the fourth figure. Path: Step 2: Step 22 - Step 24 - Step 30 - Step 310 ~ Step 314 ~ Step Step 320. According to the method of the present invention, the library of the fb: state can be judged, so the cursor becomes an accepted image to display the allowable drop state, and the call-to-system FB35 state parsing program automatically converts the function into a threat (four) # FB Call (CALL) syntax, find the current cursor position, fill the converted program fragment into the position pointed by the cursor. The function of the function or function block of IEC61131 is quite special, which is different from the general programming language. With this dragging technique, the user does not need to remember the parameters of the caller's function. Because it is dragged to the text editor according to the method, it will automatically generate: segment and internal parameters. August, the basic program syntax disk for the EEC61131 specification
……等語言不太-樣,利用本發明之拖::::: 式,導出語法範例,可讓使用者不需記憶IEC6lm 基本程式香法,提升裎式編輯效率。 、 上述僅為本發明之較佳實_而已,並非用來 發明實施範圍。即凡依本發明申請專利範圍所做的 化與修飾,皆為本發明專利範圍所涵蓋。 艾 【圖式簡單說明】 第一圖為說明本發明之ΡΙΧ程式編輯方法 窗上之操作示意圖。 包驷視 第二圖為說明依據本發明苐—實施例的方法流程圖。 13 弟一圖4說明依據本發电 圖 第三圖第―只轭例的方法流程圓 為說明依據本發明第二實施例的方法流程 第四圖為說明本發明之一範例操作。 第五A圖及第五B圖說明依據第四圖的範例操作結 【主要元件符號說明】 【本發明】 步驟 10-18 步驟20-72......etc. The language is not very similar, using the drag::::: formula of the present invention, the grammar example is exported, so that the user does not need to memorize the IEC6lm basic program scent method, and improves the editing efficiency of the 裎. The above is only the preferred embodiment of the present invention and is not intended to be used in the scope of the invention. That is, the modifications and modifications made to the scope of the patent application of the present invention are covered by the scope of the invention. Ai [Simplified Schematic Description] The first figure is a schematic diagram showing the operation on the window of the editing method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS The second drawing is a flow chart illustrating a method in accordance with the present invention. 13 shows a flow of a method according to a second embodiment of the present invention. The fourth figure illustrates an exemplary operation of the present invention. 5A and 5B illustrate an example operation junction according to the fourth figure. [Main component symbol description] [Invention] Step 10-18 Step 20-72