[go: up one dir, main page]

JP5790128B2 - Programmable controller system and its support device - Google Patents

Programmable controller system and its support device Download PDF

Info

Publication number
JP5790128B2
JP5790128B2 JP2011100991A JP2011100991A JP5790128B2 JP 5790128 B2 JP5790128 B2 JP 5790128B2 JP 2011100991 A JP2011100991 A JP 2011100991A JP 2011100991 A JP2011100991 A JP 2011100991A JP 5790128 B2 JP5790128 B2 JP 5790128B2
Authority
JP
Japan
Prior art keywords
variable
additional
instance
address
pou
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2011100991A
Other languages
Japanese (ja)
Other versions
JP2012234272A (en
Inventor
吉原 大助
大助 吉原
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fuji Electric Co Ltd
Original Assignee
Fuji Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fuji Electric Co Ltd filed Critical Fuji Electric Co Ltd
Priority to JP2011100991A priority Critical patent/JP5790128B2/en
Publication of JP2012234272A publication Critical patent/JP2012234272A/en
Application granted granted Critical
Publication of JP5790128B2 publication Critical patent/JP5790128B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Programmable Controllers (AREA)

Description

本発明は、プログラマブルコントローラ・システムに係わり、特にその支援装置に関する。   The present invention relates to a programmable controller system, and more particularly to a support device therefor.

PLC(プログラマブルコントローラ)の支援ツールは、ユーザが記述したプログラム(ソースコード;変数含む)をコンパイルして、PLCで動作する機械語オブジェクトを生成し、その際、PLC上の有限なメモリに(その任意のアドレスに)各変数を割り付ける。そして、機械語オブジェクトをPLCにダウンロードして記憶させる。これより、PLCは、このプログラムを実行することで各種処理を実行し、各変数の値のリード/ライト等の処理の際には、その変数に割り付けられたアドレス(割当位置)にアクセスすることになる。   The PLC (programmable controller) support tool compiles a program written by the user (source code; including variables) to generate a machine language object that operates on the PLC. Assign each variable (to any address). Then, the machine language object is downloaded and stored in the PLC. As a result, the PLC executes various processes by executing this program, and accesses the address (allocation position) assigned to the variable in the process of reading / writing the value of each variable. become.

PLCが稼動中にそのプログラムを変更する場合は(プログラムのバージョンアップ等)、既に割り付けた変数(既存の変数というものとする)のアドレスを変更することができない(変数の割当位置が変化すると、変更前と変更後とで変数の値がプログラムで正常に扱えないため、誤動作する。;変数のアドレスが変更されることにより、アドレスの変更前と変更後とでデータを引き継ぐことができない)。   If the program is changed while the PLC is running (program version upgrade, etc.), the address of a variable that has already been assigned (referred to as an existing variable) cannot be changed (if the variable assignment position changes, (Because the variable value cannot be handled normally by the program before and after the change, it malfunctions.) By changing the address of the variable, data cannot be transferred before and after the change of the address).

そのため、従来は、変数を追加しても既存の変数のアドレスが変更されないようにするために予備領域を設けて、追加した変数(追加変数というものとする)をこの予備領域に割り付けるようにしている。予備領域に追加変数を割り付けることにより、既に割り付けた変数(既存の変数)の割当位置を変更しないで、変数の追加が可能になる。予備領域は、プログラム構成単位(以下POUと示す)単位で持つため、予備領域のサイズは、大抵、数W(WORD)から数10Wである。   Therefore, conventionally, a spare area is provided to prevent the address of an existing variable from being changed even if a variable is added, and the added variable (referred to as an additional variable) is assigned to this spare area. Yes. By assigning the additional variable to the spare area, it is possible to add the variable without changing the assignment position of the already assigned variable (existing variable). Since the spare area has a program configuration unit (hereinafter referred to as POU), the size of the spare area is usually from several W (WORD) to several tens of W.

予備領域は、変数を追加しなければ無駄な領域となる。PLCのメモリは有限であり、且つ、大規模なシステムではPOUの数も多いため、予備領域を大きく(幾つも)確保することができない。   The spare area is a useless area unless a variable is added. Since the PLC memory is finite and the number of POUs is large in a large scale system, a large (several) spare area cannot be secured.

ユーザが、予備領域の数を越える変数の追加を伴うプログラムの変更を実施すると、既存の変数の割当位置を維持できなくなるため、PLCの動作を継続しながらプログラムを変更すること(オンライン変更)はできなくなる。   If the user changes the program with the addition of variables exceeding the number of spare areas, the allocation position of the existing variables cannot be maintained, so changing the program while continuing the PLC operation (online change) become unable.

予備領域を大きく確保し、オンライン変更の制限を緩和する方法として、例えば特許文献1に開示されている従来技術が存在するが、予備領域をPOU単位ではなくタスク単位にまとめて大きめに予備領域を確保する方式のため、予備領域の数を超えるような変数を追加できない課題がある。   As a method for reserving a large spare area and relaxing the restriction on online change, for example, there is a conventional technique disclosed in Patent Document 1, but the spare area is grouped into task units instead of POU units so that the spare area is made larger. There is a problem that a variable exceeding the number of spare areas cannot be added because of the method of securing.

特開2008−269449号公報JP 2008-269449 A

ここで、上記POUには、PG(プログラム)、FB(ファンクションブロック)、FCT(ファンクション)等の種類がある。基本的には、PGがメインプログラムでFBやFCTがサブプログラムと見做してよく、PGが、その処理実行中にFBやFCT等を呼び出す。また、FBが、その処理実行中に他のFBやFCTを呼び出す場合もある。   Here, the POU includes types such as PG (program), FB (function block), and FCT (function). Basically, PG may be regarded as a main program and FB or FCT as a subprogram, and PG calls FB, FCT, or the like during execution of the processing. In addition, the FB may call another FB or FCT during execution of the process.

PGを例にすると、PGのソースコードを作成するユーザが、PG中に任意のFB等の呼び出しを記述するものであり、基本的に何種類でも何回でも呼び出すように記述できる。例えば、FB1、FB2の2種類のFBがあるものとし、ユーザが作成した任意のPGでは、FB1を3回呼び出し、FB2は2回呼び出すものとする。   Taking PG as an example, a user who creates a source code of PG describes a call such as an arbitrary FB in the PG, and can be described so that it can be called any number of times regardless of the type. For example, it is assumed that there are two types of FBs, FB1 and FB2, and an arbitrary PG created by the user calls FB1 three times and FB2 calls twice.

あるいは、呼び出されたFB1が、その処理実行中にFB2を呼び出すように、FB1のソースコードを記述することもできる。
このように、ファンクションブロックFB1のロジック自体は1つでも、ユーザは、複数回利用することができる。同様にファンクションブロックFB2のロジック自体は1つでも、ユーザは、複数回利用することができる。
Alternatively, the source code of FB1 can be written so that the called FB1 calls FB2 during the execution of the process.
Thus, even if the logic of the function block FB1 is only one, the user can use it multiple times. Similarly, even if there is only one logic of the function block FB2, the user can use it multiple times.

ここで、上記PG(プログラム)、FB(ファンクションブロック)、FCT(ファンクション)等の各種POUのソースコードには、通常、任意の変数が記述されている。そして、各種POUを有するプログラムをコンパイルする際には、コンパイラ機能により各POUのインスタンス化(各POUの各変数をメモリに割り付ける)を実施する。   Here, in the source code of various POUs such as PG (program), FB (function block), and FCT (function), an arbitrary variable is usually described. When compiling a program having various POUs, instantiating each POU (assigning each variable of each POU to a memory) is performed by a compiler function.

これは、例えば上記のようにFB1が3回呼び出される例では、FB1に関しては3回のインスタンス化が行われる。例えば、FB1が温度計による計測温度と湿度計による計測湿度とを取得・記憶するロジックであった場合、例えば温度計Aの計測値を1000番地、湿度計aの計測値を1001番地に記憶するインスタンス、温度計Bの計測値を1010番地、湿度計bの計測値を1011番地に記憶するインスタンス、温度計Cの計測値を1020番地、湿度計cの計測値を1021番地に記憶するインスタンスの3つのインスタンスが生成されることになる。   For example, in the example in which FB1 is called three times as described above, instantiation is performed three times for FB1. For example, when FB1 is a logic for acquiring and storing the temperature measured by the thermometer and the humidity measured by the hygrometer, for example, the measured value of the thermometer A is stored at address 1000 and the measured value of the hygrometer a is stored at address 1001. An instance that stores the measured value of thermometer B at address 1010, the measured value of hygrometer b at address 1011, the measured value of thermometer C at address 1020, and the measured value of hygrometer c at address 1021 Three instances will be created.

コンパイラ機能は、各POUをインスタンス化する場合、予備領域も含めて1つの塊としてメモリを割り付ける。上記のようにFBを複数回利用する場合にはそれぞれについてインスタンス化が行われる。上記のようにFB1の例の場合には3つのインスタンスが生成され、それぞれについて1つの塊としてメモリを割り付けることになる。上記の例では、各インスタンス毎に、温度計と湿度計それぞれに1ワード(1番地)ずつ計2ワードと、更に予備領域を1ワードの計3ワード分を、1つの塊としてメモリを割り付けることになる。   When instantiating each POU, the compiler function allocates memory as one lump including a spare area. When the FB is used a plurality of times as described above, instantiation is performed for each. As described above, in the case of the example of FB1, three instances are generated, and the memory is allocated as one lump for each instance. In the above example, for each instance, the memory is allocated as a lump with a total of 3 words, 1 word (1 address) for each thermometer and hygrometer, and 1 word for the spare area. become.

そして、後にプログラムを修正(バージョンアップ)する等して、任意のPOUにおける変数に追加があった場合、この追加変数を上記予備領域に割り付けることになる。追加変数が多い為に予備領域が不足しても、通常、PLCのメモリには未だ十分な余裕(空き領域)が残っているため、他のメモリ領域に変数を割り付けることは可能である。   If a variable is added to an arbitrary POU, for example, by correcting (upgrading) the program later, this additional variable is allocated to the spare area. Even if the spare area is insufficient due to the large number of additional variables, usually a sufficient margin (empty area) still remains in the PLC memory, so it is possible to allocate variables to other memory areas.

しかし、従来の方式では、予備領域を超えて変数を追加した場合、既存の変数のアドレス(割当位置)を変更する必要があり、既存変数のアドレスが変更されると上記の通り正常なデータ引き継ぎができない為、PLCを停止し、データの初期化を行い、プログラムをすべてPLCに転送してから、PLCを起動する必要がある。PLCが停止すると、システムも停止するため、システムの稼働率、保守性、拡張性の低下や、プラントなどシステムを停止できない場合に問題になる。   However, in the conventional method, when a variable is added beyond the spare area, it is necessary to change the address (allocation position) of the existing variable. If the address of the existing variable is changed, normal data transfer is performed as described above. Therefore, it is necessary to stop the PLC, initialize data, transfer all the programs to the PLC, and then start the PLC. When the PLC stops, the system also stops, which causes a problem when the system operation rate, maintainability, expandability is deteriorated, or when the system cannot be stopped such as a plant.

本発明の課題は、PLCシステムに係わりそのPLC支援装置におけるPLCのプログラムの更新/修正に伴い、既存の変数のアドレス(割当位置)を変更することなく、予備領域では対応できないような変数追加があった場合でもPLCのメモリの空き領域に追加変数を割り付けることで、PLCを停止しないでプログラム更新を可能とするPLC(プログラマブルコントローラ)システム、その支援装置を提供することである。   An object of the present invention is to add a variable that cannot be dealt with in a spare area without changing an address (allocation position) of an existing variable in accordance with the PLC system in the PLC support apparatus associated with the PLC system update / correction. Even when there is a PLC, a PLC (programmable controller) system that can update a program without suspending the PLC by allocating an additional variable to an empty area of the PLC memory, and its support device.

本発明のプログラマブルコントローラ・システムは、プログラマブルコントローラ用の任意のプログラムのソースコードをコンパイルして機械語オブジェクトを生成する支援装置と、プログラマブルコントローラとから成るプログラマブルコントローラ・システムであって、前記支援装置は、前記プログラマブルコントローラが稼働中にそのプログラムを変更する場合、前記ソースコードのコンパイルの際に、前記ソースコードに含まれる各POU毎に、そのPOUに係わる各変数の格納領域と予備領域と追加変数格納先記憶領域の各領域を相対アドレスで示す領域情報を保持する変数情報記憶手段と、前記ソースコードのコンパイルの際に、前記各POUの各インスタンス毎に、そのインスタンスに関して確保された一塊のメモリ領域であるブロックに関する情報として少なくともその先頭アドレスを記憶するインスタンス情報記憶手段と、前記変数情報記憶手段と前記インスタンス情報記憶手段とを参照して、前記各変数を前記各インスタンス毎にメモリ割当てを行いながら、前記任意のプログラムのソースコードを前記機械語オブジェクトに変換するコンパイル手段と、前記プログラムの修正版/更新版である修正/更新プログラムのソースコードをコンパイルする際に、該ソースコードに含まれる各POU毎に、前記変数情報記憶手段を参照して追加変数の有無をチェックし、追加変数がある場合には前記予備領域で対応可能か否かを判定し、対応できる場合には該予備領域に追加変数を割当て、対応できない場合には、該POUの各インスタンス毎に追加のブロックを確保すると共に、既存のブロックの前記追加変数格納先記憶領域に該追加ブロックの先頭アドレスを格納させる為の情報を生成・記憶する追加変数対応手段とを有する。

The programmable controller system of the present invention is a programmable controller system including a support device that compiles a source code of an arbitrary program for a programmable controller and generates a machine language object, and a programmable controller. When changing the program while the programmable controller is operating, for each POU included in the source code when the source code is compiled, a storage area, a spare area, and an additional variable for each variable related to the POU Variable information storage means for holding area information indicating each area of the storage destination storage area by a relative address, and a lump of memory reserved for each instance of each POU at the time of compiling the source code In the area With reference to the instance information storage means for storing at least the head address as information about the block, the variable information storage means and the instance information storage means, while performing memory allocation for each instance, the variables, Compile means for converting source code of an arbitrary program into the machine language object, and each POU included in the source code when compiling the source code of the correction / update program that is a correction / update version of the program Then, referring to the variable information storage means, the presence or absence of an additional variable is checked, and if there is an additional variable, it is determined whether or not it can be handled in the spare area. If this cannot be handled, an additional block is confirmed for each instance of the POU. While, and an additional variable corresponding means for generating and storing information for and stores the head address of the additional blocks in the additional variable storage destination memory area of the existing block.

上記プログラマブルコントローラ・システムにおいて、例えば、前記コンパイル手段は、前記修正/更新プログラムの前記機械語オブジェクトへの変換に関しては、前記追加変数の有無に係らず、既存の変数に関しては前記変数情報記憶手段の前記領域情報に基づいて前回コンパイル時と同じアドレスを割り当てる。   In the programmable controller system, for example, the compiling unit may convert the correction / update program into the machine language object regardless of the presence or absence of the additional variable and the variable information storage unit for the existing variable. Based on the area information, the same address as the previous compilation is assigned.

また、上記プログラマブルコントローラ・システムにおいて、例えば、前記コンパイル手段は、前記修正/更新プログラムの前記機械語オブジェクトへの変換に関しては、前記追加変数格納先記憶領域経由で前記追加変数にアクセスする機械語オブジェクトを生成する。   In the programmable controller system, for example, the compiling means accesses the additional variable via the additional variable storage destination storage area regarding the conversion of the correction / update program into the machine language object. Is generated.

上記プログラマブルコントローラ・システムでは、例えばその支援装置において、修正/更新プログラムにおいて追加変数がある場合、予備領域で対応できる場合には予備領域を割当て、予備領域では対応できない場合であっても追加ブロックを確保することで対応できる。また、既存の変数に関しては、変数情報記憶手段の領域情報に基づいて前回コンパイル時と同じアドレスを割り当てることができる。   In the programmable controller system, for example, in the support device, if there is an additional variable in the correction / update program, a spare area is allocated if it can be handled in the spare area, and an additional block is assigned even if it cannot be handled in the spare area. It can respond by securing. For existing variables, the same address as that at the previous compilation can be assigned based on the area information in the variable information storage means.

本発明のPLC(プログラマブルコントローラ)システム、その支援装置等によれば、PLCシステムに係わりそのPLC支援装置におけるPLCのプログラムの更新/修正に伴い、既存の変数のアドレス(割当位置)を変更することなく、予備領域では対応できないような変数追加があった場合でもPLCのメモリの空き領域に追加変数を割り付けることで、PLCを停止しないでプログラム更新を可能とする。   According to the PLC (programmable controller) system of the present invention, its support device, etc., the address (allocation position) of an existing variable is changed as the PLC program in the PLC support device is updated / modified. In addition, even when there is a variable addition that cannot be dealt with in the spare area, the program can be updated without stopping the PLC by allocating the additional variable to the empty area of the PLC memory.

本例のPLCシステムの全体構成図である。It is a whole block diagram of the PLC system of this example. 変数のメモリ割付けの一例を示す図である。It is a figure which shows an example of the memory allocation of a variable. (a),(b)は、追加変数格納領域の割当てを示す図である。(A), (b) is a figure which shows allocation of the additional variable storage area. (a)〜(c)は変数情報管理表の具体例を示す図である。(A)-(c) is a figure which shows the specific example of a variable information management table | surface. (a)、(b)は、POUインスタンスアドレス割付対応表の具体例を示す図である。(A), (b) is a figure which shows the specific example of a POU instance address allocation correspondence table. コンパイル処理を説明する為のフローチャート図である。It is a flowchart figure for demonstrating a compilation process. ソースコード識別番号対応表の具体例を示す図である。It is a figure which shows the specific example of a source code identification number corresponding table. 修正版プログラムのコンパイル処理を説明する為のフローチャート図である。It is a flowchart for demonstrating the compilation process of a correction version program. POUインスタンスアドレス情報の具体例を示す図である。It is a figure which shows the specific example of POU instance address information.

以下、図面を参照して本発明の実施の形態について説明する。
尚、本説明では「割当て」と「割付け」はほぼ同義であると見做すものとする。
図1は、本例のプログラマブルコントローラ(PLC)システムの全体構成を示す図である。
Embodiments of the present invention will be described below with reference to the drawings.
In this description, it is assumed that “assignment” and “assignment” are almost synonymous.
FIG. 1 is a diagram showing an overall configuration of a programmable controller (PLC) system of this example.

本例のPLCシステムは、PLC(プログラマブルコントローラ)30と、このPLC30用のプログラム(制御プログラム等;以下、制御プログラムを例にして説明する)をユーザが任意に作成できるように支援する機能等を有する開発支援装置(ローダ)10を有する。   The PLC system of this example includes a PLC (programmable controller) 30 and a function for supporting a user to arbitrarily create a program for the PLC 30 (a control program or the like; the control program will be described below as an example). A development support apparatus (loader) 10 is provided.

開発支援装置10は、上記作成された制御プログラムを、コンパイルして機械語に変換した後、不図示の通信線を介してPLC30にダウンロードする機能等も備えている。PLC30は、この機械語プログラムを記憶する(後述する機械語オブジェクト41に相当)。また、PLC30は、制御プログラムの更新/修正等に伴い更新/修正版等の機械語プログラムがダウンロードされた場合には、記憶してあった旧プログラムを削除して新プログラムを記憶する。そして、PLC30は、現在記憶している機械語プログラムを実行することで、制御対象の各種機器を制御する。   The development support device 10 also has a function of compiling the created control program and converting it into a machine language, and then downloading it to the PLC 30 via a communication line (not shown). The PLC 30 stores this machine language program (corresponding to a machine language object 41 described later). Further, when a machine language program such as an update / correction version is downloaded in accordance with the update / correction of the control program, the PLC 30 deletes the stored old program and stores the new program. Then, the PLC 30 controls various devices to be controlled by executing the machine language program currently stored.

尚、特に図示しないが、PLC30は、上記制御対象である何らかの機器または当該機器を接続しているI/Oユニットと、通信線を介して接続している。
開発支援装置(ローダ)10は、コンパイラ機能部11、インタフェース機能部12、通信機能部13等の各種機能部と記憶部20等を有する。また、ユーザに上記制御プログラム等を作成させるための画面等を表示するディスプレイ14と、キーボード/マウス等の入力装置15等も有する。また、特に図示しないが、開発支援装置(ローダ)10は、CPU/MPU等の演算処理プロセッサも有している。
Although not particularly illustrated, the PLC 30 is connected via a communication line to some device to be controlled or an I / O unit to which the device is connected.
The development support apparatus (loader) 10 includes various function units such as a compiler function unit 11, an interface function unit 12, a communication function unit 13, and a storage unit 20. In addition, it includes a display 14 for displaying a screen for allowing the user to create the control program and the like, an input device 15 such as a keyboard / mouse, and the like. Although not particularly shown, the development support apparatus (loader) 10 also has an arithmetic processing processor such as a CPU / MPU.

記憶部20には、予め不図示のアプリケーションプログラムが記憶されている。上記CPU/MPU等が、このアプリケーションプログラムを読み出し・実行することにより、上記各種機能部11,12、13の機能(特に後述する図6や図8に示す処理)が実現される。   The storage unit 20 stores an application program (not shown) in advance. When the CPU / MPU or the like reads and executes the application program, the functions of the various functional units 11, 12, and 13 (particularly, the processes shown in FIGS. 6 and 8 described later) are realized.

また、記憶部20には、図示の各種データ/プログラム等が記憶される。
すなわち、記憶部20には、上記ユーザによって作成された制御プログラムのソースコード21、このソースコード21をコンパイラ機能部11によってコンパイルした結果である機械語オブジェクト23等が格納される。
The storage unit 20 stores various data / programs shown in the figure.
That is, the storage unit 20 stores the source code 21 of the control program created by the user, the machine language object 23 that is the result of compiling the source code 21 by the compiler function unit 11, and the like.

更に、記憶部20には、図示の各種データ、すなわちソースコード識別番号対応表22、変数情報管理表24、POUインスタンスアドレス情報25、POUインスタンスアドレス割付対応表26等が、記憶される。尚、これら各種データについては、後に具体例を参照して説明する。   Further, the various types of data shown in the figure, that is, the source code identification number correspondence table 22, the variable information management table 24, the POU instance address information 25, the POU instance address assignment correspondence table 26, and the like are stored in the storage unit 20. These various data will be described later with reference to specific examples.

上記各種機能部のうち、まず、インタフェース機能部12は、ユーザが任意の制御プログラム(ソースコード21)を作成する際に作成作業が行い易いように支援する、既存の一般的な機能を有する処理機能部である。例えば上記ディスプレイ14上に所定の入力画面を表示し、ユーザは上記入力装置15を操作してこの入力画面上で任意の制御プログラムを記述する。   Of the various functional units described above, first, the interface functional unit 12 is a process having an existing general function that assists the user in facilitating creation work when creating an arbitrary control program (source code 21). It is a functional part. For example, a predetermined input screen is displayed on the display 14, and the user operates the input device 15 to write an arbitrary control program on the input screen.

コンパイラ機能部11は、ユーザによって作成されたソースコード21を、ターゲット(PLC30)上で動作する機械語オブジェクト23に変換する(コンパイルを実行する)。通信機能部13は、生成された機械語オブジェクト23を、不図示の通信線を介してターゲット(PLC30)に送信する(ダウンロードする)。   The compiler function unit 11 converts the source code 21 created by the user into a machine language object 23 that operates on the target (PLC 30) (performs compilation). The communication function unit 13 transmits (downloads) the generated machine language object 23 to the target (PLC 30) via a communication line (not shown).

PLC(プログラマブルコントローラ)30は、プログラム実行管理機能部31、通信機能部32等の各種機能部と記憶部40を有する。また、特に図示しないが、PLC30は、CPU/MPU等の演算処理プロセッサも有している。   The PLC (programmable controller) 30 includes various function units such as a program execution management function unit 31 and a communication function unit 32 and a storage unit 40. Although not particularly shown, the PLC 30 also has an arithmetic processing processor such as a CPU / MPU.

記憶部40には、予め不図示のアプリケーションプログラムが記憶されている。上記CPU/MPU等が、このアプリケーションプログラムを読み出し・実行することにより、上記各種機能部31,32の機能(処理)が実現される。   An application program (not shown) is stored in the storage unit 40 in advance. The functions (processes) of the various functional units 31 and 32 are realized by the CPU / MPU and the like reading and executing the application program.

通信機能部32は、上記開発支援装置10(その通信機能部13)との通信を行って、例えば上記ダウンロードされる機械語オブジェクト23の受信を行い、これを記憶部40に記憶する(これが図示の機械語オブジェクト41である)。また、POUインスタンスアドレス情報25がダウンロードされた場合には、これを記憶部40に記憶する(これが図示のPOUインスタンスアドレス情報42である)。   The communication function unit 32 communicates with the development support apparatus 10 (its communication function unit 13), for example, receives the downloaded machine language object 23 and stores it in the storage unit 40 (this is illustrated). Machine language object 41). When the POU instance address information 25 is downloaded, it is stored in the storage unit 40 (this is the POU instance address information 42 shown in the figure).

プログラム実行管理機能部31は、上記のように開発支援装置10からダウンロードされて記憶部40に記憶された機械語オブジェクト41等の実行を管理する。詳しくは後述する。   The program execution management function unit 31 manages the execution of the machine language object 41 and the like downloaded from the development support apparatus 10 and stored in the storage unit 40 as described above. Details will be described later.

また、記憶部40(メモリ)の記憶領域の一部は、POUインスタンスメモリ領域43となっている。この領域43内に各変数を割当てる(各変数に係るデータ格納領域を割付ける)。これらについても詳しくは後述する。   A part of the storage area of the storage unit 40 (memory) is a POU instance memory area 43. Each variable is assigned in this area 43 (a data storage area related to each variable is assigned). Details of these will also be described later.

ここで、PLCのプログラミングには、プログラム(PG)、ファンクションブロック(FB)、ファンクション(FCT)の3つのPOU要素がある。通常、各POUには
1以上の変数が含まれている。上記制御プログラム等をPLC30上で動作させる為には、開発支援装置10でコンパイルする際に、その各POUの各変数をPLC30のメモリ(領域43内)に割り付けてから(アドレスを割り当てる)、機械語オブジェクト23を生成する必要がある。コンパイラ機能部11が、上記コンパイルの際にPOU毎に(インスタンス毎に)その各変数のメモリ割付けを実施している。
Here, the PLC programming includes three POU elements: a program (PG), a function block (FB), and a function (FCT). Usually, each POU contains one or more variables. In order to operate the control program or the like on the PLC 30, when the development support apparatus 10 compiles, each variable of each POU is assigned to the memory (in the area 43) of the PLC 30 (address is assigned), and then the machine The word object 23 needs to be generated. The compiler function unit 11 performs memory allocation of each variable for each POU (for each instance) during the above compilation.

コンパイラ機能部11は、上記POU毎に各変数をメモリに割付ける際に、各インスタンス毎に、上記のように一塊の領域(ブロック;変数割当領域というものとする)を確保する。これには、既に説明したように、予備領域も含まれる。つまり、各POUの各インスタンス毎に、各変数の割付領域と予備領域等から成る変数割当領域を割り当てることになる(例えば後述する図2参照)。そして、本手法では、更に「追加変数格納先アドレス」領域も確保する(これも上記変数割当領域(ブロック)に含まれる)。   When allocating each variable to the memory for each POU, the compiler function unit 11 secures a block area (block; variable allocation area) as described above for each instance. This includes the spare area as described above. That is, for each instance of each POU, a variable allocation area including a variable allocation area and a spare area is allocated (for example, see FIG. 2 described later). In this method, an “additional variable storage destination address” area is also secured (this is also included in the variable allocation area (block)).

例えば、任意の制御プログラムの新規作成時に、そのコンパイルの際に上記メモリ割付けを行うことで、その後にこの制御プログラムの修正/更新時には、そのコンパイルの際に、追加変数があった場合には上記変数割当領域内の予備領域に割り当てるようにする。   For example, when an arbitrary control program is newly created, the above memory allocation is performed at the time of compilation, and when this control program is subsequently modified / updated, if there are additional variables at the time of compilation, the above-mentioned Allocate to the spare area in the variable allocation area.

しかし、追加変数が多い場合等には、上記予備領域では足りない場合がある。つまり、上記確保してあった変数割当領域内に追加変数全てを割当てることが出来ない場合がある。   However, when there are many additional variables, the spare area may not be sufficient. That is, it may not be possible to allocate all the additional variables in the reserved variable allocation area.

本手法では、この様な場合に備えて上記のように上記変数割当領域内に上記「追加変数格納先アドレス」領域も確保している。また、各POUの各インスタンス毎に、上記変数割当領域の先頭アドレスやサイズ、その変数等のメモリ割り当て状況を、上記変数情報管理表24、POUインスタンスアドレス割付対応表26に記憶している。   In this method, the “additional variable storage destination address” area is also secured in the variable allocation area as described above in preparation for such a case. Further, for each instance of each POU, the variable address management table 24 and the POU instance address allocation correspondence table 26 store the start address and size of the variable allocation area, and the memory allocation status of the variable.

尚、上記制御プログラムの修正/更新版のコンパイルの際には、これら管理表24や対応表26を参照することで、既にメモリ割当て済みの変数(上述した既存の変数)に関しては同じアドレスを割当てることができる。   When compiling a modified / updated version of the control program, the same address is assigned to variables already allocated to memory (the above-mentioned existing variables) by referring to the management table 24 and the correspondence table 26. be able to.

そして、上記予備領域では足りない様な(対応できないような)変数追加があった場合、PLC30のメモリ(領域43内)の空き領域に新たな変数割当領域(ブロック)を確保して、この変数割当領域内に追加変数を割り付けると共に、この追加した変数割当領域の先頭アドレスを「追加変数格納先アドレス」に書き込ませる。これより、追加変数は「追加変数格納先アドレス」経由でアクセスすることができる(例えば後述する図3参照)。   If there is a variable addition that is not sufficient (cannot be handled) in the spare area, a new variable allocation area (block) is secured in a free area of the memory (in the area 43) of the PLC 30, and this variable An additional variable is allocated in the allocation area, and the start address of the added variable allocation area is written in the “additional variable storage destination address”. Thus, the additional variable can be accessed via the “additional variable storage destination address” (see, for example, FIG. 3 described later).

ここで、上記コンパイラ機能部11が上記コンパイルの際にPOU毎に(各インスタンス毎に)その各変数のメモリ割付を行うのは、上記の通りPOUインスタンスメモリ領域43内の任意の記憶領域である。図2に、この様なメモリ割付けの一例を示す。   Here, it is an arbitrary storage area in the POU instance memory area 43 as described above that the compiler function unit 11 performs memory allocation of each variable for each POU (for each instance) during the compilation. . FIG. 2 shows an example of such memory allocation.

図2に示すように、POUインスタンスメモリ領域43に対してPOU毎(インスタンス毎に)の変数のメモリ割付けが行われる。
図2の例は、2つのファンクションブロック(FB1、FB2)に関して、FB1は2つ、FB2は1つ、インスタンス化した場合のメモリ割付例である。
As shown in FIG. 2, memory allocation of variables for each POU (for each instance) is performed on the POU instance memory area 43.
The example of FIG. 2 is an example of memory allocation when two function blocks (FB1, FB2) are instantiated with two FB1 and one FB2.

既に従来等で説明したように、ファンクションブロック(FB)に関しては、ユーザは、複数回利用することができる。複数回利用する場合は、コンパイラ機能により利用毎のインスタンス化(ファンクションブロックの変数をメモリに割り付ける)を実施する。従って、上記の例ではFB1は2度利用され、FB2は一度だけ利用されていることになる。   As already described in the related art, the user can use the function block (FB) a plurality of times. When using multiple times, the compiler function instantiates (assigns function block variables to memory) for each use. Therefore, in the above example, FB1 is used twice and FB2 is used only once.

そして、変数のメモリ割付けは、各インスタンス毎に行われる。よって、上記の例では、FB2に関してはFB2のインスタンス2、FB1に関してはインスタンス1、インスタンス3のインスタンス化が行われ、これら各インスタンス毎に図示のように変数のメモリ割付けが行われる。   Variable memory allocation is performed for each instance. Therefore, in the above example, the instance 2 of FB2 is instantiated for FB2, the instance 1 and instance 3 are instantiated for FB1, and memory allocation of variables is performed for each of these instances as shown in the figure.

コンパイラ機能部11は、ファンクションブロックをインスタンス化する場合、1つの塊(ブロック;上記変数割当領域)としてメモリを割り付ける。すなわち、例えば図2に示す例のように、各ファンクションブロックをインスタンス化してなる各インスタンス毎に、1つの塊(ブロック)としてメモリ領域を割り付ける。   When instantiating a function block, the compiler function unit 11 allocates memory as one block (block; the variable allocation area). That is, for example, as in the example shown in FIG. 2, a memory area is allocated as one block (block) for each instance obtained by instantiating each function block.

図2の例では、インスタンス1、インスタンス2、インスタンス3の3つのインスタンス化が行われるものとし、インスタンス1とインスタンス3はファンクションブロックFB1に係るインスタンス、インスタンス2はファンクションブロックFB2に係るインスタンスである。   In the example of FIG. 2, three instantiations of instance 1, instance 2, and instance 3 are performed. Instance 1 and instance 3 are instances related to function block FB1, and instance 2 is an instance related to function block FB2.

各インスタンス毎の変数割当領域は、その各変数に対するメモリ割当て領域と予備用領域から成る。図2の例では、予備1と予備2の2つの予備領域が加わる。そして、図示の例ではファンクションブロックFB1に係る変数は変数1と変数2であり、ファンクションブロックFB2に係る変数は変数3と変数4と変数5であるものとしている。これより、図示の通り、インスタンス1とインスタンス3に関しては、変数1と変数2と予備1と予備2とを含む1つの塊(ブロック)として図示のようにメモリを割付ける。インスタンス2に関しては、変数3と変数4と変数5と予備1と予備2とを含む1つの塊(ブロック)として図示のようにメモリを割付ける。   The variable allocation area for each instance includes a memory allocation area and a spare area for each variable. In the example of FIG. 2, two spare areas, spare 1 and spare 2, are added. In the illustrated example, the variables related to the function block FB1 are the variables 1 and 2, and the variables related to the function block FB2 are the variables 3, 4 and 5. Thus, as shown in the figure, for instance 1 and instance 3, memory is allocated as shown in the figure as one block (block) including variable 1, variable 2, spare 1 and spare 2. For instance 2, the memory is allocated as shown in the figure as one block (block) including variable 3, variable 4, variable 5, spare 1 and spare 2.

図2に示す例に対して、本手法の場合にはブロック内に更に図3に示すように「追加変数格納先アドレス」が加わる。すなわち、本手法では、上記図1のPOUインスタンスメモリ領域43に対する各インスタンス毎のメモリ割当ては、例えば図3に示すようになる。   In contrast to the example shown in FIG. 2, in the case of this method, an “additional variable storage destination address” is further added to the block as shown in FIG. That is, in this method, the memory allocation for each instance in the POU instance memory area 43 in FIG. 1 is as shown in FIG. 3, for example.

本手法では、図3(a)に示すように、各変数1,2,3,4,5に関するメモリ割当ては、上記図2の例と同様である。一方、2つの予備領域に関しては、予備1のみとなっており、上記予備2の割当て領域には図示のように「追加変数格納先アドレス」が割当てられている。但し、この例に限らず、予備領域は予備1、予備2の2つのままで更に「追加変数格納先アドレス」が加わるようにしてもよい。   In this method, as shown in FIG. 3A, the memory allocation for each of the variables 1, 2, 3, 4, and 5 is the same as in the example of FIG. On the other hand, regarding the two spare areas, only spare 1 is provided, and an “additional variable storage destination address” is assigned to the spare 2 allocation area as shown in the figure. However, the present invention is not limited to this example, and two additional areas, spare 1 and spare 2, may be used, and an “additional variable storage destination address” may be added.

ここで、PLC30の稼働中に、ユーザが開発支援装置10上で変数の追加を伴うプログラム修正(例えばバージョンアップしたソースコード21の作成等)を行った場合であって、特にPLC30を止めないでPLC30のプログラムの変更を実施するためには、既にメモリに割付けた変数(既存の変数)のメモリ割付け位置を変更しないようにする必要がある。   Here, when the PLC 30 is in operation, the user makes a program correction (for example, creation of the upgraded source code 21) accompanied by addition of a variable on the development support apparatus 10, and the PLC 30 is not particularly stopped. In order to change the program of the PLC 30, it is necessary not to change the memory allocation position of a variable (existing variable) that has already been allocated to the memory.

そこで、本手法では、コンパイラ機能部11は、ソースコード21のコンパイル実行の際に行う上記各インスタンス毎のメモリ割当ての際に、上記管理表24や対応表26に各変数のメモリ割当て状況を登録しておくと共に、予備領域だけでなく上記「追加変数格納先アドレス」を格納する領域を確保する。新規プログラム(新規ソースコード21)のコンパイルの際には、基本的には、この「追加変数格納先アドレス」領域には何もデータは格納されない(後述するNULLとなる)。   Therefore, in this method, the compiler function unit 11 registers the memory allocation status of each variable in the management table 24 and the correspondence table 26 when the memory allocation for each instance is performed when the source code 21 is compiled. In addition, an area for storing the above “additional variable storage destination address” is secured in addition to the spare area. When compiling a new program (new source code 21), basically, no data is stored in this “additional variable storage destination address” area (the NULL will be described later).

そして、後にこの新規プログラムを修正/更新(バージョンアップ等)したときに、修正/更新版プログラムをコンパイルする際に、追加変数があり且つ予備領域だけでは対応できない場合には、例えば図3(b)に示す「追加変数格納領域」(追加ブロック)を新たに確保すると共に、この「追加変数格納領域」の先頭アドレスを上記「追加変数格納先アドレス」が示す領域に格納させる。これについては、詳しくは後に図9を参照して説明するが、PLC30側において、「POUインスタンスアドレス情報」42(開発支援装置10側で生成した「POUインスタンスアドレス情報」25をダウンロードしたもの)を用いて「追加変数格納先アドレス」が示す領域に、「追加変数格納領域」の先頭アドレスを格納する。これより、その後は、PLC30では、「追加変数格納先アドレス」経由で「追加変数格納領域」の各追加変数にアクセスすることになる。   Then, when this new program is later corrected / updated (version upgrade, etc.), when the corrected / updated version program is compiled, if there are additional variables and only the spare area cannot be handled, for example, FIG. The “additional variable storage area” (additional block) shown in FIG. 6 is newly secured, and the start address of the “additional variable storage area” is stored in the area indicated by the “additional variable storage destination address”. This will be described in detail later with reference to FIG. 9. On the PLC 30 side, “POU instance address information” 42 (downloaded “POU instance address information” 25 generated on the development support apparatus 10 side) is stored. And the head address of the “additional variable storage area” is stored in the area indicated by the “additional variable storage destination address”. Thus, after that, the PLC 30 accesses each additional variable in the “additional variable storage area” via the “additional variable storage destination address”.

尚、本手法では、予備領域は確保せずに「追加変数格納先アドレス」領域だけを確保するようにしてもよい。尚、逐一述べないが、各変数に関する領域割当ては、当然、図2の場合と同様に行っている。   In this method, only the “additional variable storage destination address” area may be secured without securing the spare area. Although not described one by one, the area allocation for each variable is naturally performed in the same manner as in FIG.

また、コンパイラ機能部11は、どの変数をどの記憶領域(アドレス)に割当てたのかを示す情報を、テーブル(上記管理表24等)に記憶しておく。
コンパイラ機能部11は、上記修正版(バージョンアップ版等)プログラムをコンパイルする際には、特に変数の追加があったPOUのインスタンスに係るメモリ割当てに関しては、既存の変数に関しては上記テーブルを参照することで既に割当てられている記憶領域を変更しないようにする(前回コンパイル時と同じアドレスが割当てられるようにする)。一方、新たに追加された変数(追加変数)に関しては、まず上記予備領域への割当てを試みて、割当て可能であれば予備領域を割当てる。
The compiler function unit 11 stores information indicating which variable is assigned to which storage area (address) in a table (the management table 24 or the like).
When compiling the modified version (upgraded version, etc.) program, the compiler function unit 11 refers to the table for the existing variables, particularly regarding the memory allocation related to the instance of the POU in which the variables have been added. This prevents the storage area that has already been allocated from being changed (so that the same address as the previous compilation is allocated). On the other hand, for a newly added variable (additional variable), first, the allocation to the spare area is attempted, and if the allocation is possible, the spare area is allocated.

図3(b)に示す例では、ソースコード21において上記ファンクションブロックFB1に関して3つの変数が追加されたものとしている。これら追加された3つの変数を、追加変数1、追加変数2、追加変数3と呼ぶものとする。よって、新たなファンクションブロックFB1に関しては、上記既存の変数である変数1、変数2と、これら追加変数1、追加変数2、追加変数3との合計5つの変数が存在する状態となっている。   In the example shown in FIG. 3B, it is assumed that three variables are added to the function block FB1 in the source code 21. These three added variables are referred to as additional variable 1, additional variable 2, and additional variable 3. Therefore, regarding the new function block FB1, there are a total of five variables, namely the variable 1 and the variable 2, which are the existing variables, and the additional variable 1, the additional variable 2, and the additional variable 3.

よって、上記コンパイルの際、新たなファンクションブロックFB1に係るインスタンス1、インスタンス3に関しては、両方とも、5つの変数のメモリ割り当てを行うことになる。   Therefore, at the time of the above compilation, regarding the instance 1 and the instance 3 related to the new function block FB1, both of the variables are allocated to the memory.

そして、上記の通り(そして図3(b)に示す通り)、既存の変数1、変数2に関しては図示の通り割当位置は図3(a)の状態と同じである(変わらない)。一方、追加変数に関しては、上記3つの追加変数のうちの1つ(ここでは追加変数1とする)は予備領域への割当てが可能であるが、他の2つの追加変数(ここでは追加変数2,3)を割当てることはできない。   Then, as described above (and as shown in FIG. 3B), with respect to the existing variables 1 and 2, the allocation position is the same as that shown in FIG. On the other hand, regarding the additional variable, one of the three additional variables (here, referred to as additional variable 1) can be allocated to the spare area, but the other two additional variables (here, additional variable 2). , 3) cannot be assigned.

この様に予備領域では対応できないような変数の追加が行われた場合には、POUインスタンスメモリ領域43内の空き領域に、当該インスタンス用の新たな変数記憶領域(追加変数格納領域/追加ブロックという)を確保し、当該追加ブロックのアドレス(先頭アドレス等)を上記「追加変数格納先アドレス」が示す領域に格納させる。   In this way, when a variable that cannot be handled by the spare area is added, a new variable storage area for the instance (additional variable storage area / additional block) is added to the free area in the POU instance memory area 43. ) And the address (head address, etc.) of the additional block is stored in the area indicated by the “additional variable storage destination address”.

そして、当該追加ブロック内に上記他の2つの追加変数(ここでは追加変数2,3)を割当てる。これより、例えば図3(b)に示す状態となる。ここで、既に述べた通り、各インスタンス毎に1つの塊(ブロック)としてメモリ領域を割付けるものである為、上記新たな変数記憶領域(追加ブロック)においても、追加変数2,3だけでなく、予備領域(予備1)及び「追加変数格納先アドレス」領域も確保されることになる。   Then, the other two additional variables (here, additional variables 2 and 3) are allocated in the additional block. Thus, for example, the state shown in FIG. Here, as already described, since the memory area is allocated as one block (block) for each instance, not only the additional variables 2 and 3 but also in the new variable storage area (additional block). The spare area (spare 1) and the “additional variable storage destination address” area are also secured.

また、本例ではFB1は2つインスタンス化されているため、インスタンス毎に、(予備領域では対応できない)追加変数の格納領域を確保する必要がある。この為、図3(b)に示す通り、FB1のインスタンス1の追加変数格納領域と、FB1のインスタンス3の追加変数格納領域とが、新たに確保されることになる。   In this example, since two FB1s are instantiated, it is necessary to secure a storage area for additional variables (which cannot be handled by a spare area) for each instance. For this reason, as shown in FIG. 3B, an additional variable storage area of instance 1 of FB1 and an additional variable storage area of instance 3 of FB1 are newly secured.

このようにすることで、最初に各インスタンス毎に1つの塊として割付けられるメモリ領域(初期ブロックという)では、全ての追加変数を割当てることができない場合でも、POUインスタンスメモリ領域43内に空き領域が存在する限りは、追加変数格納領域(追加ブロック)を確保することで、追加変数のメモリ割当てが可能となる。これは、既に存在する変数の割り当て位置は、変更しないで、追加変数のメモリ割当てを殆ど制限なしに(勿論、領域43の空き領域が無くなれば駄目であるが)行うものとなる。変数の追加の制限を撤廃し、PLCを停止しないでプログラムの変更が実施できる。   In this way, in the memory area (called initial block) that is initially allocated as one lump for each instance, even if all the additional variables cannot be allocated, there is an empty area in the POU instance memory area 43. As long as it exists, an additional variable memory area (additional block) can be secured to allocate memory for the additional variable. This does not change the allocation position of variables that already exist, and performs memory allocation of additional variables almost without restriction (of course, if there is no free space in the area 43). It is possible to change the program without removing the restriction of adding variables and stopping the PLC.

コンパイラ機能部11は、ユーザが記述したプログラム(ソースコード21)をコンパイルする際に、当該プログラムにおける各POU毎に、そのPOUが使用している変数の情報管理のため、「変数情報管理表」24を作成する。「変数情報管理表」24には、各変数毎に、変数の名前、型(サイズ)、割当位置を示す相対位置などの情報が存在する。   When compiling a program (source code 21) written by a user, the compiler function unit 11 uses a “variable information management table” for information management of variables used by the POU for each POU in the program. 24 is created. In the “variable information management table” 24, information such as a variable name, a type (size), and a relative position indicating an allocation position exists for each variable.

図4(a)〜(c)に、「変数情報管理表」24の具体例を示す。
図4(a)、(b)は、上記ファンクションブロックFB1に関する「変数情報管理表」24の具体例であって、図4(a)は図6の新規コンパイル後、図4(b)は図8の修正版等コンパイル後の状態を示す。このようなデータ例については、後に図6や図8の説明の際に説明するものとし、ここでは「変数情報管理表」24のフォーマットについてのみ説明するものとする。尚、図4(c)は後述するファンクションブロックFBCALLに関する「変数情報管理表」24の具体例である。
4A to 4C show specific examples of the “variable information management table” 24. FIG.
4A and 4B are specific examples of the “variable information management table” 24 related to the function block FB1. FIG. 4A is a diagram after the new compilation of FIG. 6, and FIG. 8 shows the state after compilation of the revised version. Such data examples will be described later in the description of FIGS. 6 and 8, and only the format of the “variable information management table” 24 will be described here. FIG. 4C is a specific example of a “variable information management table” 24 related to a function block FBCALL described later.

図4(a)〜(c)に示すように、「変数情報管理表」24のフォーマットは、変数名51、型52、相対位置53、及び格納先ブロック54の各データ項目より成るものである。尚、特に図示・説明しないが、各「変数情報管理表」24には、どのPOUの変数情報管理表であるのかを示す情報も含まれている。   As shown in FIGS. 4A to 4C, the format of the “variable information management table” 24 is composed of data items of a variable name 51, a type 52, a relative position 53, and a storage block 54. . Although not shown or described in particular, each “variable information management table” 24 includes information indicating which POU is the variable information management table.

変数名51には、図示の変数1、変数2等の変数名等(名前に限らず、識別番号等であってもよい)が格納される。図4(a),(b)の例の場合はファンクションブロックFB1で使用する各変数の変数名が、変数名51に格納されることになる。   The variable name 51 stores variable names such as the illustrated variable 1 and variable 2 (not limited to names, but may be identification numbers or the like). 4A and 4B, the variable name of each variable used in the function block FB1 is stored in the variable name 51.

但し、変数名51には、変数名等に限らず、図示のように「予備領域」、「追加変数格納先アドレス」等も格納される。これら名称やサイズは予め決められているものであり、上記各変数名等の格納が完了したら、続いてこれらの所定の名称や使用領域サイズを変数名51や型52に格納する。詳しくは後述する。   However, the variable name 51 is not limited to the variable name or the like, but also stores a “reserved area”, an “additional variable storage destination address”, and the like as illustrated. These names and sizes are determined in advance, and when the above variable names and the like are stored, the predetermined names and use area sizes are subsequently stored in the variable names 51 and the mold 52. Details will be described later.

型52には、変数名51に変数名等が格納されている場合には、当該変数名の変数の型と使用する記憶容量(使用領域のサイズ)とが格納される。例えば、変数1は、INT型であって使用領域サイズが1W(ワード)であることになる。変数2は、WORD型であって使用領域サイズが1W(ワード)であることになる。また、型52には、変数名51に変数名以外が格納されている場合には、使用領域サイズのみが格納される。図示の例では、「予備領域」に関しては使用領域サイズが2W(ワード)となっており、「追加変数格納先アドレス」に関しても使用領域サイズが2W(ワード)となっている。   In the type 52, when a variable name or the like is stored in the variable name 51, the variable type of the variable name and the storage capacity (the size of the used area) to be used are stored. For example, the variable 1 is an INT type and the use area size is 1 W (word). The variable 2 is WORD type, and the use area size is 1 W (word). Further, in the type 52, when a variable name 51 other than the variable name is stored, only the used area size is stored. In the illustrated example, the used area size is 2 W (words) for the “reserve area”, and the used area size is 2 W (words) for the “additional variable storage destination address”.

相対位置53には、上記各使用領域の相対アドレスが格納されている。これは、後述する先頭アドレス63からの相対位置を意味する。つまり、各インスタンス毎に、そのインスタンスに係るブロックの先頭アドレス63と上記各変数の相対位置53とによって、そのインスタンスで使用する各変数の割当位置を示す実アドレスが、分かることになる。   The relative position 53 stores the relative address of each used area. This means a relative position from the head address 63 described later. That is, for each instance, the real address indicating the allocation position of each variable used in the instance can be known from the head address 63 of the block related to that instance and the relative position 53 of each variable.

例えば、変数2の相対位置53は‘1’であり、図4(a)はファンクションブロックFB1の例であるので、仮にインスタンス3であった場合には先頭アドレス63は‘1018’番地であることから、変数2の割当位置の実アドレスは、‘1018’番地+1=‘1019’番地であることになる。また、この例の場合、予備領域の使用領域の実アドレスは、‘1018’番地+2=‘1020’番地であることになる。ここで、予備領域の型51(使用領域サイズ)は上記の通り2W(ワード)であるので、予備領域の使用領域は、‘1020’番地〜‘1021’番地ということになる。   For example, since the relative position 53 of the variable 2 is “1” and FIG. 4A is an example of the function block FB1, if it is the instance 3, the start address 63 is “1018”. Therefore, the real address of the allocation position of variable 2 is “1018” address + 1 = “1019” address. In the case of this example, the real address of the use area of the spare area is “1018” address + 2 = “1020” address. Here, since the spare area type 51 (use area size) is 2 W (words) as described above, the use area of the spare area is from “1020” to “1021”.

格納先ブロック54は、変数名51の変数等を格納するブロックを示すものである。すなわち、上記の通り、各インスタンス毎に、最初に1つのブロック(初期ブロック)を確保し、その後、修正版プログラム等のコンパイルの際に場合によっては追加ブロックを確保することになるが、変数名51の変数の割当位置が、初期ブロック内であるのか追加ブロック内であるのかを示す情報が、格納先ブロック54に格納されている。   The storage block 54 indicates a block that stores a variable or the like of the variable name 51. That is, as described above, for each instance, one block (initial block) is secured first, and then an additional block is secured in some cases when a modified version program is compiled. Information indicating whether the allocation position of the variable 51 is in the initial block or in the additional block is stored in the storage block 54.

図3(a)に示す例では、インスタンス1,2,3の全てが初期ブロックのみである。一方、図3(b)に示す状態では、インスタンス2は初期ブロックのみであるが、インスタンス1,3は各々追加ブロックが新たに確保される為、2つのブロックを有するものとなっている。この例の場合、格納先ブロック54は、変数名51の変数等の割当位置が、これら2つのブロックのうちのどちらのブロック内であるのかを示すものとなる。本例では、格納先ブロック54が‘0’の場合は初期ブロック、格納先ブロック54が‘1’の場合は追加ブロックであることを示すものとする。尚、この例に限らず、例えば1つの追加ブロックだけでは足りずに2つ目の追加ブロックが確保された場合には、例えば格納先ブロック54が‘2’の場合には2つ目の追加ブロックを示すものとしてもよい。   In the example shown in FIG. 3A, all of the instances 1, 2, and 3 are only initial blocks. On the other hand, in the state shown in FIG. 3B, the instance 2 is only the initial block, but the instances 1 and 3 each have two blocks because an additional block is newly secured. In the case of this example, the storage block 54 indicates which of the two blocks the allocation position of the variable of the variable name 51 is in. In this example, when the storage destination block 54 is “0”, it indicates an initial block, and when the storage destination block 54 is “1”, it indicates an additional block. Note that the present invention is not limited to this example. For example, when the second additional block is secured without only one additional block, for example, when the storage block 54 is “2”, the second additional block is added. It may be a block.

尚、特に詳細には説明しないが、後述する変数宣言部分には、図4(c)に示すように変数名として「FB1インスタンス」、型として「FB1(2)」等といった情報も含まれていてもよい。尚、これはFB呼出しに係る情報であり、この例ではFBCALLがFB1を呼び出すことになるが、ここでは特に関係ないので、これ以上詳細には説明しない。   Although not described in detail, the variable declaration part to be described later includes information such as “FB1 instance” as the variable name and “FB1 (2)” as the type as shown in FIG. May be. This is information related to the FB call. In this example, FBCALL calls FB1, but since it is not particularly relevant here, it will not be described in further detail.

また、コンパイラ機能部11は、コンパイル時に変数をPLC30のメモリに割り付ける際、「変数情報管理表」24を元に、「POUインスタンスアドレス割付対応表」26を作成する。   Further, the compiler function unit 11 creates a “POU instance address assignment correspondence table” 26 based on the “variable information management table” 24 when assigning variables to the memory of the PLC 30 at the time of compilation.

当該対応テーブル26の一例を図5(a)、(b)に示す。図5(a)は図6の処理後、図5(b)は図8の処理後の状態を示す。ここでは、「POUインスタンスアドレス割付対応表」26のフォーマットのみについて説明するものとし、内容等の説明は図6、図8の説明の際に説明する。   An example of the correspondence table 26 is shown in FIGS. FIG. 5A shows a state after the processing in FIG. 6, and FIG. 5B shows a state after the processing in FIG. Here, only the format of the “POU instance address allocation correspondence table” 26 will be described, and the contents will be described in the description of FIGS. 6 and 8.

図5(a)、(b)に示すように、「POUインスタンスアドレス割付対応表」26は、インスタンス番号61、POU名62、先頭アドレス63、インスタンスサイズ64、追加変数格納先アドレス65、追加変数格納先サイズ66の各データ項目より成る。   As shown in FIGS. 5A and 5B, the “POU instance address assignment correspondence table” 26 includes an instance number 61, a POU name 62, a head address 63, an instance size 64, an additional variable storage destination address 65, and an additional variable. Each data item has a storage destination size 66.

まず、上記の通り、各POU毎に1以上のインスタンスが生成されるものであり、インスタンス生成毎にそのインスタンスに識別番号を割付ける。ここでは、インスタンス番号は、インスタンス生成毎に‘1’から順にシリアルに番号が付されるものとする(+1インクリメントされる)。ここでは上記インスタンス1,2,3の識別番号が、‘1’、‘2’、‘3’であるものとする。よって、図示のインスタンス番号61=‘1’、‘3’のレコードは、上記インスタンス1、3に関する情報であり、従ってそのPOU名62は両方とも図示の通り“FB1”となっている。   First, as described above, one or more instances are generated for each POU, and an identification number is assigned to the instance for each instance generation. Here, the instance number is serially numbered from “1” every time an instance is generated (incremented by +1). Here, it is assumed that the identification numbers of the instances 1, 2, and 3 are ‘1’, ‘2’, and ‘3’. Therefore, the record of the instance number 61 = “1”, “3” shown in the figure is information regarding the instances 1 and 3, and therefore, the POU name 62 is “FB1” as shown in the figure.

先頭アドレス63及びインスタンスサイズ64には、インスタンス番号61のインスタンスに割当てられた上記初期ブロックの先頭アドレス(実アドレス)とサイズが格納される。ここで、例えば、最初に生成されたインスタンスである上記インスタンス1に関しては、その先頭アドレスには予め決められたデフォルト値(=1000番地)が割り当てられるものとする。また、FB1に関しては、図4(b)に示す例ではそのブロック全体のサイズは6W(ワード)であるので、インスタンスサイズ64=‘6’となっている。つまり、インスタンス1に割当てられる初期ブロックの領域は、1000番地〜1005番地となっている。   The start address 63 and the instance size 64 store the start address (real address) and size of the initial block allocated to the instance with the instance number 61. Here, for example, regarding the instance 1 that is the first generated instance, a predetermined default value (= 1000 addresses) is assigned to the head address. For FB1, in the example shown in FIG. 4B, the size of the entire block is 6W (words), so the instance size 64 = '6'. That is, the area of the initial block allocated to the instance 1 is from address 1000 to address 1005.

これより、次に生成されたインスタンス2に関しては、その先頭アドレス63は1006番地(1005番地+1あるいは1000番地+6)となる。
また、追加変数格納先アドレス65及び追加変数格納先サイズ66には、上記追加変数格納領域(追加ブロック)の先頭アドレス(実アドレス)とサイズが格納される。尚、追加変数格納先アドレス65及び追加変数格納先サイズ66は、上記追加ブロックの数の分だけ存在する。ここでは、未だ追加ブロックは存在しないので、追加変数格納先アドレス65及び追加変数格納先サイズ66には図5(a)に示すように“NULL”及び‘0’が格納される。
As a result, for the instance 2 generated next, the head address 63 is addressed 1006 (address 1005 + 1 or address 1000 + 6).
The additional variable storage destination address 65 and the additional variable storage destination size 66 store the start address (real address) and size of the additional variable storage area (additional block). Note that there are as many additional variable storage destination addresses 65 and additional variable storage destination sizes 66 as the number of additional blocks. Here, since there are no additional blocks, “NULL” and “0” are stored in the additional variable storage destination address 65 and the additional variable storage destination size 66 as shown in FIG.

図2の例では、FB1についてはインスタンス1,3、FB2についてはインスタンス2の合計3つのインスタンス化が成されている。
インスタンス1のメモリ割付けを実施する時、POUがFB1なので、FB1の「変数情報管理表」24から、インスタンス化に必要なサイズ(ブロックのサイズ)を算出する(本例では6W(ワード))。このサイズを元に、PLC30のメモリ(そのPOUインスタンスメモリ領域43)にインスタンス1のブロックの領域を確保する。
In the example of FIG. 2, a total of three instantiations of instances 1 and 3 for FB1 and instance 2 for FB2 are made.
When the memory allocation of the instance 1 is performed, since the POU is FB1, the size (block size) necessary for instantiation is calculated from the “variable information management table” 24 of the FB1 (in this example, 6 W (word)). Based on this size, the block area of the instance 1 is secured in the memory of the PLC 30 (its POU instance memory area 43).

同様にして、インスタンス2のPOUはFB2なので、FB2の「変数情報管理表」24から、インスタンス化に必要なサイズ(ブロックのサイズ)を算出し、このサイズを元に上記インスタンス2のブロックの領域を確保する。   Similarly, since the POU of the instance 2 is FB2, the size (block size) required for instantiation is calculated from the “variable information management table” 24 of the FB2, and the block area of the instance 2 is based on this size. Secure.

上記の処理を、インスタンスの数分繰り返し実施する。
「POUインスタンスアドレス割付対応表」26には、各インスタンスの割当て領域(ブロック)の先頭アドレスとサイズが設定される。図5(a)の段階では、初期ブロックの先頭アドレス63とサイズ64が設定される一方で、追加ブロックは未だ存在しないので、追加変数格納先アドレス65には無効を示すNULL情報が設定されると共に、追加変数格納先サイズ66には‘0’が設定される。
The above process is repeated for the number of instances.
In the “POU instance address allocation correspondence table” 26, the start address and size of the allocation area (block) of each instance are set. At the stage of FIG. 5A, the initial block start address 63 and size 64 are set, but no additional block yet exists, so the additional variable storage destination address 65 is set to NULL information indicating invalidity. At the same time, “0” is set in the additional variable storage destination size 66.

ユーザが、変数の追加を伴う修正版/更新版の(バージョンアップ版等の)ソースコード21を作成してコンパイルの実施を指示・操作した時、コンパイラ機能部11は、各POU毎に、追加変数がある場合にはまず当該追加変数を予備領域に割付けるようにする。予備領域で収まる場合は、「変数情報管理表」24を更新し(追加変数のメモリ割当て情報を追加し)、予備領域のサイズ(型52)を減らすと共に予備領域の相対位置53を変更する。予備領域では収まらないような変数の追加が行われていた場合、コンパイラ機能部11は、空き領域に追加ブロックの領域を確保すると共に、この追加ブロック領域内に追加変数を割当てる。また、確保した追加ブロックの領域の先頭アドレスとサイズを、追加変数格納先アドレス65、追加変数格納先サイズ66に格納する。   When the user creates a modified / updated source code 21 (added version, etc.) with addition of a variable and instructs / operates to execute the compilation, the compiler function unit 11 adds for each POU. If there is a variable, the additional variable is first assigned to the spare area. If it falls within the spare area, the “variable information management table” 24 is updated (additional variable memory allocation information is added) to reduce the spare area size (type 52) and change the relative position 53 of the spare area. If a variable that does not fit in the spare area has been added, the compiler function unit 11 secures an additional block area in the free area and allocates the additional variable in the additional block area. Further, the start address and size of the reserved additional block area are stored in the additional variable storage destination address 65 and the additional variable storage destination size 66.

これによって、例えば、図5(a)の状態から図5(b)の状態へと移行することになる。図5(b)の例では、FB1に関しては予備領域では対応できないような変数の追加が行われた為に、FB1の各インスタンス1,3に関しては追加ブロックが新たに確保され、各追加ブロックの先頭アドレスとサイズが、図示のように格納される(図示の例ではアドレス65が‘1034’と‘1044’)。   As a result, for example, the state shown in FIG. 5A is shifted to the state shown in FIG. In the example of FIG. 5B, since a variable that cannot be handled in the spare area is added for FB1, an additional block is newly secured for each instance 1 and 3 of FB1, and The head address and size are stored as shown (in the example shown, addresses 65 are '1034' and '1044').

尚、この追加ブロックについても、初期ブロックと同様に、変数の格納領域だけでなく、予備領域や上記「追加変数格納先アドレス」の領域が含まれるようにしてもよい。
以下、図6、図8のフローチャート図を参照して、上述したコンパイラ機能部11の処理についてより詳細に説明する。
The additional block may include not only the variable storage area but also the spare area and the area of the “additional variable storage destination address”, as in the initial block.
Hereinafter, the processing of the compiler function unit 11 described above will be described in more detail with reference to the flowcharts of FIGS.

図6は、新規作成されたソースコード21のコンパイル時の処理を示す。
図8は、既存のソースコード21の一部を修正/更新等(特に変数の追加を伴う修正/更新)して成る修正版(バージョンアップ版)のソースコード21のコンパイル時の処理を示す。
FIG. 6 shows processing at the time of compiling the newly created source code 21.
FIG. 8 shows a process at the time of compiling a modified version (upgraded version) of source code 21 obtained by modifying / updating a part of existing source code 21 (particularly, modifying / updating with addition of a variable).

まず、図6の処理について説明する。
図6において、まず、コンパイル対象のソースコード21に記述されている各POU毎に、そのソースコードに基づいて「コンパイル(変数宣言)」処理を行うことになる。すなわち、各POUのソースコードは、大別して、変数宣言部分と本文部分とから成るものであり、当該「コンパイル(変数宣言)」処理では、この変数宣言部分を参照してステップS12〜S15の処理を行うものである。尚、特に図示しないが、変数宣言部分には、各変数の名称と型が宣言されており、更にそのPOUの名称(POU名;プログラム作成者が任意に決めている)も記述されている。
First, the process of FIG. 6 will be described.
In FIG. 6, first, for each POU described in the source code 21 to be compiled, a “compile (variable declaration)” process is performed based on the source code. That is, the source code of each POU is roughly divided into a variable declaration part and a body part. In the “compile (variable declaration)” process, the process of steps S12 to S15 is performed with reference to this variable declaration part. Is to do. Although not particularly illustrated, the variable declaration portion declares the name and type of each variable, and further describes the name of the POU (POU name; arbitrarily determined by the program creator).

図6の処理では、全POUについて「コンパイル(変数宣言)」処理済みであるか否かを判定し(ステップS11)、未だ「コンパイル(変数宣言)」処理を行っていないPOUがある場合には(ステップS11,NO)、当該未処理のPOUのうちの1つを処理対象として、「コンパイル(変数宣言)」処理(ステップS12〜S15の処理)を実行する。   In the processing of FIG. 6, it is determined whether or not “compilation (variable declaration)” processing has been completed for all POUs (step S11), and if there is a POU that has not yet undergone “compilation (variable declaration)” processing. (Step S11, NO), one of the unprocessed POUs is processed, and the “compile (variable declaration)” process (the processes of Steps S12 to S15) is executed.

すなわち、処理対象POUのソースコードの上記変数宣言部分を読み込み(ステップS12)、これに基づいて「ソースコード識別番号対応表」22と「変数情報管理表」24を作成する(ステップS13〜S15)。   That is, the variable declaration part of the source code of the processing target POU is read (step S12), and based on this, a "source code identification number correspondence table" 22 and a "variable information management table" 24 are created (steps S13 to S15). .

すなわち、まず、上記ステップS12で読み込んだPOUのソースコードの上記変数宣言部分に基づいて、「ソースコード識別番号対応表」22にPOU名と識別番号を登録する(ステップS13)。そして識別番号を更新する(ステップS14)。   That is, first, based on the variable declaration part of the POU source code read in step S12, the POU name and identification number are registered in the “source code identification number correspondence table” 22 (step S13). Then, the identification number is updated (step S14).

ここで、図7に、「ソースコード識別番号対応表」22の具体例を示す。
図示の例の「ソースコード識別番号対応表」22は、POU名71、識別番号72の各データ項目より成る。POU名71には、上記処理対象POUのソースコードの上記変数宣言部分から得られるPOU名等(そのPOUの識別情報)が格納される。識別番号72には、POU名71のPOUに対して任意に割り当てた識別番号が格納される。ここでは識別番号の初期値を‘1’とし、上記ステップS14の処理で+1インクリメントする更新を行うものとし、それによって図7に示すように識別番号72は1,2,3,4等となっている。
Here, FIG. 7 shows a specific example of the “source code identification number correspondence table” 22.
The “source code identification number correspondence table” 22 in the illustrated example includes data items of a POU name 71 and an identification number 72. The POU name 71 stores a POU name and the like (identification information of the POU) obtained from the variable declaration part of the source code of the processing target POU. In the identification number 72, an identification number arbitrarily assigned to the POU of the POU name 71 is stored. Here, it is assumed that the initial value of the identification number is “1”, and updating is performed by incrementing by +1 in the process of step S14, so that the identification number 72 becomes 1, 2, 3, 4, etc. as shown in FIG. ing.

上記ステップS14の処理に続いて、上記処理対象POUに関する「変数情報管理表」24を作成する(ステップS15)。すなわち、まず、予め設定されている「変数情報管理表」24の雛形(図4(a)は作成済みの状態を示すが、雛形では未だデータは何も格納されていない)を取得して、これに上記処理対象POUのPOU名/識別番号を付与すると共に、この処理対象POUのソースコードの上記変数宣言部分に記述されている各変数に関する情報(上記のように変数名や型など)を、上記取得した雛形に登録する。   Following the process of step S14, a “variable information management table” 24 relating to the processing target POU is created (step S15). That is, first, a template of the “variable information management table” 24 set in advance (FIG. 4A shows a created state, but no data is stored yet in the template), To this, the POU name / identification number of the processing target POU is given, and information (variable name, type, etc. as described above) regarding each variable described in the variable declaration part of the source code of the processing target POU is provided. And register it in the acquired template.

例えば図4(a)に示す例は、処理対象POUがFB1であり、そのソースコードの変数宣言部分に最初に記述されている変数の変数名は変数1であり、その型はINT型であり、そのサイズは1W(ワード)であったものとしている。それ故に図示のように変数名51と型52に、それぞれ、変数1、INT(1)が登録される。また、最初に登録される変数に関してはその相対位置53は必ず‘0’とする。   For example, in the example shown in FIG. 4A, the processing target POU is FB1, the variable name of the variable first described in the variable declaration part of the source code is variable 1, and the type is INT type. The size is assumed to be 1 W (word). Therefore, as shown in the figure, variable 1 and INT (1) are registered in variable name 51 and type 52, respectively. In addition, the relative position 53 of the first registered variable is always “0”.

尚、図6の処理では初期ブロックへの割当てになるので、逐一述べないが、格納先ブロック54は図4(a)に示すように全てのレコードで‘0’となる。
また、ここでは、変数宣言部分に2番目に記述されている変数の変数名は変数2であり、その型はWORD型であり、そのサイズは1W(ワード)であったものとしている。これより、図示のように変数2に関しては、変数名51と型52に、それぞれ、変数2、WORD(1)が登録される。そして、相対位置53に関しては、1つ前のレコードにおける型52(そのサイズ)に相対位置53を加算した値を登録する。ここでは、1つ前のレコードの型52はINT(1)、相対位置53は‘0’であるので、1+0=1が、図示の通り変数2のレコードの相対位置53に登録されることになる。
In the process of FIG. 6, since it is assigned to the initial block, the storage block 54 becomes “0” in all records as shown in FIG.
Here, it is assumed that the variable name of the second variable described in the variable declaration part is variable 2, its type is WORD type, and its size is 1W (word). Thus, as shown in the figure, for variable 2, variable 2 and WORD (1) are registered in variable name 51 and type 52, respectively. For the relative position 53, a value obtained by adding the relative position 53 to the pattern 52 (its size) in the previous record is registered. Here, since the type 52 of the previous record is INT (1) and the relative position 53 is “0”, 1 + 0 = 1 is registered in the relative position 53 of the record of the variable 2 as illustrated. Become.

そして、全ての変数の登録が完了したら、続いて、変数名51に所定の名称(「予備領域」と「追加変数格納先アドレス」)をそれぞれ登録すると共に、それぞれに対応する所定のサイズ(予め決められている)を型52に登録する。図示の例では両方ともサイズ=‘2’となっている。そして、上記変数2の場合と同様にして相対位置53を算出して登録する。これは「予備領域」に関してはWORD(1)+1=2が登録され、「追加変数格納先アドレス」に関しては2+2=4が登録されることになる。   When registration of all variables is completed, a predetermined name (“reserve area” and “additional variable storage destination address”) is registered in the variable name 51 and a predetermined size (preliminary size) corresponding to each is registered. Is registered in the mold 52. In the example shown in the figure, size = '2' in both cases. Then, the relative position 53 is calculated and registered in the same manner as in the case of the variable 2 described above. This means that WORD (1) + 1 = 2 is registered for the “reserved area” and 2 + 2 = 4 is registered for the “additional variable storage destination address”.

尚、上記処理の際に、更に、最後のレコード(「追加変数格納先アドレス」のレコード)における型52(そのサイズ)に相対位置53を加算した値を、当該対象POU(ここではFB1)に関する上記ブロックの全体サイズとして算出しておき、これを後述する「POUインスタンスアドレス割付対応表」26の作成の際にそのインスタンスサイズ64に登録するようにしてもよい。上記の例では、「追加変数格納先アドレス」のレコードおける型52(そのサイズ)は‘2’、相対位置53は‘4’であるので、このブロックの全体サイズ=2+4=6が求められ、これによって図5(a)の例ではFB1に関するインスタンスサイズ64は‘6’となっている。   In the above processing, the value obtained by adding the relative position 53 to the type 52 (its size) in the last record (record of “additional variable storage destination address”) is further related to the target POU (here, FB1). The total size of the block may be calculated and registered in the instance size 64 when a “POU instance address allocation correspondence table” 26 described later is created. In the above example, since the type 52 (its size) in the record of “additional variable storage destination address” is “2” and the relative position 53 is “4”, the total size of this block = 2 + 4 = 6 is obtained. As a result, in the example of FIG. 5A, the instance size 64 relating to FB1 is “6”.

コンパイル対象のソースコード21に記述されている全てのPOUに関して上記コンパイル(変数宣言)処理を実行したならば(ステップS11,YES)、続いて、当該全てのPOUについてステップS17〜S20によるインスタンス化処理を実行する。これは、ソースコード21(例えばPG)を先頭から順次参照していき、POU(FBやFCT)呼び出しの記述がある毎に(更に呼び出されたPOUに更に他のPOUの呼び出しの記述がある毎に)当該呼び出されるPOUのインスタンス化を実行する。   If the above compilation (variable declaration) process has been executed for all POUs described in the source code 21 to be compiled (step S11, YES), then the instantiation process in steps S17 to S20 for all the POUs Execute. This is because the source code 21 (for example, PG) is sequentially referred to from the top, and every time there is a description of a POU (FB or FCT) call (in addition, every time a call is made to another POU in the called POU). A) Instantiate the called POU.

例えば、上記の例では例えばPGにおいてFB1呼出し、FB2呼出し、FB1呼出しの記述があった場合、上記一例のようにFB1に関しては2回のインスタンス化でインスタンス1とインスタンス3が得られ、FB2に関しては1回のインスタンス化でインスタンス2が得られることになる。   For example, in the above example, for example, when there is a description of FB1, FB2, and FB1 calls in PG, instance 1 and instance 3 are obtained in two instantiations for FB1 as in the above example, and for FB2, Instance 2 is obtained by one instantiation.

ソースコード21に記述されている全てのPOUについてインスタンス化処理を実行したら(ステップS16,YES)、ステップS21以降の処理へと移行する。
以下、ステップS17〜S20の処理(インスタンス化処理)について説明する。このインスタンス化処理は、上記各POU毎のインスタンス毎に、その上記ブロックのメモリ領域を確保すると共に、このブロック領域の先頭アドレス(実アドレス)とサイズを「POUインスタンスアドレス割付対応表」26に登録する処理である。
When instantiation processing is executed for all POUs described in the source code 21 (YES in step S16), the processing proceeds to step S21 and subsequent steps.
Hereinafter, the process (instantiating process) of steps S17 to S20 will be described. This instantiation process secures the memory area of the block for each instance of each POU and registers the head address (real address) and size of this block area in the “POU instance address allocation correspondence table” 26. It is processing to do.

まず、処理対象POUに関する上記「変数情報管理表」24を読み込む(ステップS17)。そして、処理対象POUに関して確保すべきメモリ領域全体の(上記ブロックの)サイズを計算する(ステップS18)。この計算方法は既に述べた通りであり、上記の通り対象POUがFB1の場合には全体サイズ(ブロックサイズ)=‘6’が算出されることになる。   First, the “variable information management table” 24 related to the processing target POU is read (step S17). Then, the size (of the block) of the entire memory area to be secured for the processing target POU is calculated (step S18). This calculation method has already been described. When the target POU is FB1 as described above, the overall size (block size) = '6' is calculated.

続いて、「POUインスタンスアドレス割付対応表」26を参照して空きアドレスを検索する(ステップS19)。これは、例えば上記確保すべきブロックの先頭アドレスを求めるものである。   Subsequently, an empty address is searched with reference to the “POU instance address assignment correspondence table” 26 (step S19). This is to obtain the head address of the block to be secured, for example.

例えば、FB1に関する2回目のインスタンス化の場合、図5(b)の例では4つのレコードが登録されているが、ここではそのうちの最初の2つのレコードのみが「POUインスタンスアドレス割付対応表」26に登録されている状態となっていることになる。つまり、インスタンス番号61が‘1’である先頭レコードと‘2’である2番目のレコードとが登録されている状態である。   For example, in the case of the second instantiation related to FB1, four records are registered in the example of FIG. 5B, but only the first two records are “POU instance address allocation correspondence table” 26 here. It will be in the state registered in. That is, the first record whose instance number 61 is “1” and the second record whose instance number 61 is “2” are registered.

この状態で上記FB1に関する2回目のインスタンス化処理が行われる場合、POU名は当然「FB1」であり、またインスタンス番号=‘3’が割り当てられ、FB1に関する全体サイズは上記の通り‘6’が算出されているので、当該インスタンス3のブロックの領域の先頭アドレスが分かれば、「POUインスタンスアドレス割付対応表」26への新規登録が行える。この先頭アドレスは、現時点での最後のレコード(ここでは2番目のレコード)における先頭アドレス63にインスタンスサイズ64を加算することで求められる。2番目のレコードの先頭アドレス63は‘1006’、インスタンスサイズ64は‘12’であるので、1006+12=1018が算出される。   In this state, when the second instantiation process for the FB1 is performed, the POU name is naturally “FB1”, the instance number = “3” is assigned, and the overall size for the FB1 is “6” as described above. Since it is calculated, if the start address of the block area of the instance 3 is known, new registration to the “POU instance address allocation correspondence table” 26 can be performed. This head address is obtained by adding the instance size 64 to the head address 63 in the last record (here, the second record) at the present time. Since the start address 63 of the second record is “1006” and the instance size 64 is “12”, 1006 + 12 = 1018 is calculated.

以上得られた情報を、図示の通り、3番目のレコードにおけるインスタンス番号61、POU名62、先頭アドレス63、インスタンスサイズ64に格納する。更に、既に述べたように追加変数格納先アドレス65には“NULL”が格納され、追加変数格納先サイズ66には‘0’を格納する。このようにして「POUインスタンスアドレス割付対応表」26に新規レコードを登録したら(ステップS20)、ステップS16に戻り、全てのインスタンス化が行われたか否かを判定し、全インスタンス化が完了したならば(ステップS16,YES)、ステップS21の処理へ移行する。   The obtained information is stored in the instance number 61, the POU name 62, the head address 63, and the instance size 64 in the third record as shown. Furthermore, as already described, “NULL” is stored in the additional variable storage destination address 65, and “0” is stored in the additional variable storage destination size 66. When a new record is registered in the “POU instance address assignment correspondence table” 26 in this way (step S20), the process returns to step S16 to determine whether or not all instantiations have been performed. If (step S16, YES), the process proceeds to step S21.

上記インスタンス化処理が完了したら、最後に、コンパイル対象のソースコード21における各POU毎に「コンパイル(コード)」処理を行う。既に説明した「コンパイル(変数宣言)」処理は上記変数宣言部分に基づく処理であったが、「コンパイル(コード)」処理は上記本文部分を機械語に変換する処理である。   When the instantiation process is completed, finally, a “compile (code)” process is performed for each POU in the source code 21 to be compiled. The “compilation (variable declaration)” process already described is a process based on the variable declaration part. The “compile (code)” process is a process for converting the body part into a machine language.

特に例示はしないが、本文部分には、上記変数宣言部分で宣言された各種変数を用いた任意の処理が記述されており、これを機械語に変換する際にアドレス割り当てを行う必要がある。   Although not specifically illustrated, the text portion describes arbitrary processing using various variables declared in the variable declaration portion, and it is necessary to assign an address when converting this into machine language.

ステップS21では全てのPOUインスタンスについて「コンパイル(コード)」処理を実行したか否かを判定し、全POUインスタンスについて実行済みならば(ステップS21,YES)本処理を終了する。一方、未処理のPOUインスタンスがあるならば(ステップS21,NO)、そのうちの1つを処理対象として、基本的には、この処理対象POUのソースコード(本文部分)を読み込み(ステップS22)、このソースコードを機械語に変換するものである(ステップS26)。但し、ステップS26の処理の前に、「POUインスタンスアドレス割付対応表」26の読込み(ステップS24)、及び処理対象POUに関する「変数情報管理表」24の読込みを行ったうえで(ステップS25)、これらを参照して「変数のアドレス解決」処理を行い(ステップS23)、以って1POU分の機械語オブジェクト生成を行う(ステップS26)。   In step S21, it is determined whether or not “compile (code)” processing has been executed for all POU instances. If all POU instances have been executed (YES in step S21), the processing is terminated. On the other hand, if there is an unprocessed POU instance (step S21, NO), one of them is set as a processing target, and basically the source code (text part) of this processing target POU is read (step S22). This source code is converted into machine language (step S26). However, before the processing of step S26, after reading the “POU instance address assignment correspondence table” 26 (step S24) and reading the “variable information management table” 24 regarding the processing target POU (step S25), With reference to these, “variable address resolution” processing is performed (step S23), and machine language objects for one POU are generated (step S26).

すなわち、まず、処理対象POUのPOU名を用いて「POUインスタンスアドレス割付対応表」26を検索して、該当するレコードを見つける毎に、そのレコードの先頭アドレス63や追加変数格納先アドレス65等を用いて、更に「変数情報管理表」24も参照して、「変数のアドレス解決」処理を行う。尚、上記該当するレコードとは、そのPOU名62が、上記処理対象POUのPOU名と同一であるレコードである。   That is, first, the “POU instance address allocation correspondence table” 26 is searched using the POU name of the processing target POU, and each time a corresponding record is found, the start address 63 of the record, the additional variable storage destination address 65, etc. Further, referring to the “variable information management table” 24, “variable address resolution” processing is performed. The corresponding record is a record whose POU name 62 is the same as the POU name of the processing target POU.

基本的には、上記該当レコードの先頭アドレス63と、各変数毎の型52及び相対位置53とによって、各変数のアドレス解決が実現されるが、上記追加変数格納領域に格納される変数に関しては更に追加変数格納先アドレス65等を用いる処理が必要となる。詳しくは後述する。   Basically, the address resolution of each variable is realized by the start address 63 of the corresponding record, the type 52 and the relative position 53 for each variable, but regarding the variable stored in the additional variable storage area, Furthermore, processing using the additional variable storage destination address 65 or the like is required. Details will be described later.

上記「変数のアドレス解決」及び機械語への変換処理については、後に具体例を用いて説明するものとする。
次に、図8の処理について説明する。
The above-described “address resolution of variables” and the conversion process to machine language will be described later using specific examples.
Next, the process of FIG. 8 will be described.

尚、図8では省略しているが、図示のステップS31の判定がYESとなった場合には、更に続いて図6のステップS21〜S26の処理を実行する。
図8の処理の場合、既に述べた通り、コンパイル対象は上記修正版/更新版(バージョンアップ版等)のソースコード21である。これは例えば人間が判断して指定することで図6と図8の何れかの処理が実行されるようにしている。つまり、特に図示しないが、ユーザがコンパイル処理を指示する操作ボタンには、新規用と修正版用の2種類あり、ユーザが新規用を操作した場合には図6の処理が実行され、修正版用を操作した場合には図8の処理が実行される。
Although omitted in FIG. 8, if the determination in step S31 shown in the figure is YES, the processing in steps S21 to S26 in FIG. 6 is further executed.
In the case of the processing of FIG. 8, as already described, the compilation target is the source code 21 of the modified version / updated version (version-up version or the like). For example, one of the processes shown in FIGS. 6 and 8 is executed by a human being judging and specifying. That is, although not shown in particular, there are two types of operation buttons for the user to instruct compilation processing: new and modified versions. When the user operates the new version, the processing of FIG. 8 is executed.

あるいは、ユーザが特に指定しなくても開発支援装置(ローダ)10が自動的に図6、図8のどちらの処理を実行するのかを判断するようにしてもよい。これは、例えばオンラインの場合には図8の処理を実行し、オフラインのときには図6の処理を実行するようにしてもよい。尚、オンラインの場合とは、PLCを保守する為に開発支援装置(ローダ)10がPLC30に接続され且つ両者の通信が確立しているときである。   Alternatively, the development support apparatus (loader) 10 may automatically determine which process in FIGS. 6 and 8 is to be executed even if the user does not specify otherwise. For example, the processing of FIG. 8 may be executed when online, and the processing of FIG. 6 may be executed when offline. The online case is when the development support apparatus (loader) 10 is connected to the PLC 30 and communication between the two is established in order to maintain the PLC.

上記修正版のソースコード21のコンパイル時にその各POU毎に本処理(ステップS32〜S39の処理)を実行し、全てのPOUについて本処理を実行済みとなったら(ステップS31,YES)、本処理を終了する(上記ステップS21〜S26の処理に移行する)ものである。   When the modified version of the source code 21 is compiled, this processing (steps S32 to S39) is executed for each POU, and when this processing has been executed for all the POUs (step S31, YES), this processing is executed. Is terminated (the process proceeds to steps S21 to S26).

未処理のPOUがある場合、そのうちの1つを処理対象として、当該処理対象POUのソースコードを読み込み(ステップS32)、更に当該処理対象POUに関する上記「変数情報管理表」24を読み込み(ステップS33)、これらに基づいて追加変数があるか否かを判定する(ステップS34)。すなわち、ステップS32で読み込んだソースコードの変数宣言部分に記述されている全ての変数名を取得して、これらの変数名が全て上記「変数情報管理表」24の変数名51に登録されているか否かをチェックする。未登録の変数が1つも無い場合には、追加変数は存在しないと判定し(ステップS34,NO)、ステップS31に戻る。   If there is an unprocessed POU, one of them is set as a processing target, the source code of the processing target POU is read (step S32), and the “variable information management table” 24 related to the processing target POU is further read (step S33). Based on these, it is determined whether there is an additional variable (step S34). That is, all the variable names described in the variable declaration part of the source code read in step S32 are acquired, and all these variable names are registered in the variable name 51 of the “variable information management table” 24. Check whether or not. If there is no unregistered variable, it is determined that there is no additional variable (NO in step S34), and the process returns to step S31.

一方、未登録の変数がある場合には、当該未登録の変数が追加変数ということになり、ステップS34の判定はYESとなり、ステップS35へ移行する。
ステップS35では、全ての追加変数を予備領域に割付可能か否かを判定する。これは、まず、各追加変数の“型”を上記ソースコードから抽出する。“型”は上記INT、WORD等であり、“型”によってその変数のサイズ(占有領域)が決まるものである。上記の例では、INT、WORDは両方とも、サイズ(占有領域)が1W(ワード)となるものである。上記“型”によって、各追加変数のサイズが分かるので、これらの合計を求めることで追加変数全体のサイズが分かる。一方、ステップS33で読み込んだ「変数情報管理表」24において、変数名51が「予備領域」のレコードにおける型52を取得することで、予備領域のサイズが分かる。図4(a)の例では予備領域のサイズは‘2’であることになる。
On the other hand, if there is an unregistered variable, the unregistered variable is an additional variable, and the determination in step S34 is YES, and the process proceeds to step S35.
In step S35, it is determined whether or not all additional variables can be allocated to the spare area. First, the “type” of each additional variable is extracted from the source code. The “type” is INT, WORD, or the like, and the size (occupied area) of the variable is determined by the “type”. In the above example, both INT and WORD have a size (occupied area) of 1 W (word). Since the size of each additional variable is known from the “type”, the total size of the additional variables can be found by calculating the sum of these. On the other hand, in the “variable information management table” 24 read in step S33, the size of the spare area can be obtained by acquiring the type 52 in the record whose variable name 51 is “spare area”. In the example of FIG. 4A, the size of the spare area is “2”.

そして、上記追加変数全体のサイズが、予備領域のサイズ以下であるならば、ステップS35の判定はYESとなり、ステップS36の処理を実行する。
ステップS36では、追加変数のメモリ割当てを行い、それに伴って「変数情報管理表」24を更新する。
If the size of the additional variable as a whole is equal to or smaller than the size of the spare area, the determination in step S35 is YES, and the process of step S36 is executed.
In step S36, the memory of the additional variable is allocated, and the “variable information management table” 24 is updated accordingly.

例えば、図4(a)の例に対して、例えば追加変数が1つだけであり(仮に、変数名を“追加変数1”とする)、且つ、その型がINTであったとしたならば、追加変数全体のサイズ(占有領域)は1W(ワード)であり、予備領域のサイズは‘2’であることから、上記ステップS35の判定はYESとなる。   For example, in the example of FIG. 4A, for example, if there is only one additional variable (assuming the variable name is “additional variable 1”) and the type is INT, Since the size (occupied area) of the entire additional variable is 1W (word) and the size of the spare area is “2”, the determination in step S35 is YES.

そして、この例では、特に図示しないが、図4(a)に示す「変数2」のレコードの次のレコード(空きレコード)に、“追加変数1”に関する登録を行う。すなわち、特に図示しないがこのレコードでは、変数名51が“追加変数1”、型52がINT(1)、相対位置53が‘2’、格納先ブロック54が‘0’となる。尚、相対位置53の求め方は既に述べた通りである。   In this example, although not shown in particular, “additional variable 1” is registered in the record (empty record) next to the record of “variable 2” shown in FIG. That is, although not shown in particular, in this record, the variable name 51 is “additional variable 1”, the type 52 is INT (1), the relative position 53 is “2”, and the storage block 54 is “0”. The method for obtaining the relative position 53 is as described above.

これに伴って予備領域の確保分を削減しなければならないので、図4(a)に示す「予備領域」のレコードの型52と相対位置53を更新する。型52は‘2’であったが、上記追加変数のサイズである1W(ワード)を差し引くことで、‘1’に更新されることになる。また、相対位置53は‘3’となる。尚、相対位置53の求め方は既に述べた通りである。   Accordingly, the reserved area must be reduced, so the record type 52 and the relative position 53 of the “reserved area” shown in FIG. 4A are updated. Although the type 52 is “2”, it is updated to “1” by subtracting 1 W (word) which is the size of the additional variable. The relative position 53 is “3”. The method for obtaining the relative position 53 is as described above.

一方、例えば追加変数が2つあって(仮に“追加変数1”と“追加変数2”とする)、各サイズ(占有領域)が2W(ワード)であった場合、合計で4W(ワード)となる為、上記予備領域では対応できず、ステップS35の判定はNOとなる。尚、ここでは“型”がDINTである場合には、2W(ワード)必要であるものとする。   On the other hand, for example, if there are two additional variables (assuming “additional variable 1” and “additional variable 2”) and each size (occupied area) is 2W (word), the total is 4W (word). Therefore, it cannot be handled in the spare area, and the determination in step S35 is NO. Here, when the “type” is DINT, 2 W (words) is required.

ステップS35がNOの場合には、上記追加変数格納領域(追加ブロック)を確保すると共に、当該追加ブロック領域のアドレス情報や追加変数の割当て情報を、上記各種テーブル24、26(管理表24、対応表26)などに登録する。   When step S35 is NO, the additional variable storage area (additional block) is secured, and the address information and additional variable allocation information of the additional block area are stored in the various tables 24 and 26 (management table 24, corresponding Table 26) is registered.

まず、「変数情報管理表」24に拡張用の情報を追加する(ステップS37)と共に追加変数を登録する(ステップS38)。これによって、例えば図4(a)に示す例の「変数情報管理表」24は、図4(b)に示す状態になる。図示のように拡張用の情報(レコード)は、格納先ブロック54を全て‘1’とすることで、上記追加変数格納領域(追加ブロック)における割当て情報であることを示す。追加ブロックの場合も、初期ブロックに関する割当て情報(図4(a)に示すもの)と同様に、変数だけでなく、予備領域及び追加変数格納先アドレスの領域も確保して、図示のように相対位置53と型52(サイズ)を登録する。   First, information for expansion is added to the “variable information management table” 24 (step S37) and an additional variable is registered (step S38). Thereby, for example, the “variable information management table” 24 in the example shown in FIG. 4A becomes the state shown in FIG. As shown in the figure, the expansion information (record) indicates allocation information in the additional variable storage area (additional block) by setting all storage destination blocks 54 to “1”. In the case of an additional block, as in the allocation information related to the initial block (shown in FIG. 4 (a)), not only variables but also a spare area and an additional variable storage destination address area are secured and relative as shown. The position 53 and the mold 52 (size) are registered.

そして、追加変数を割当てるが、これはまず初期ブロックの予備領域への割当てを試みて、割当て可能であるならば初期ブロックの予備領域への割当てを行う。本例では、追加変数1,2の両方を初期ブロックの予備領域に割当てることは出来ないが、追加変数1のみは割当て可能なので、図4(b)に示すように追加変数1は初期ブロックの予備領域への割当てを行う。これによって初期ブロックでは予備領域は無くなることになる。尚、追加変数1の初期ブロックへの割当て処理は、上記ステップS36と略同様であってよい。但し、本例ではこれによって初期ブロックの予備領域の型52が‘0’になるので、この場合には初期ブロックの予備領域のレコードを削除する。   Then, an additional variable is allocated. This first tries to allocate the initial block to the spare area, and if possible, allocates the initial block to the spare area. In this example, both of the additional variables 1 and 2 cannot be assigned to the spare area of the initial block, but only the additional variable 1 can be assigned. Therefore, as shown in FIG. Allocate to spare area. As a result, there is no spare area in the initial block. Note that the process of assigning the additional variable 1 to the initial block may be substantially the same as step S36. However, in this example, the reserve area type 52 of the initial block is changed to ‘0’. In this case, the record of the reserve area of the initial block is deleted.

一方、この例では追加変数2は、初期ブロックに割当てることはできないので、追加ブロック内に割当てる。よって、図示の通り、追加変数2に関するレコードの格納先ブロック54は‘1’となっている。この点を除けば、追加変数2の追加ブロック内への割当て処理は、上記変数1、2の初期ブロックへの割当て処理と略同様であり、ここでは詳細には説明しないが、図示の通り、型52にはDINT(2)が登録されると共に、相対位置53には‘0’が登録されることになる。   On the other hand, in this example, since the additional variable 2 cannot be assigned to the initial block, it is assigned to the additional block. Therefore, as shown in the figure, the storage block 54 of the record related to the additional variable 2 is “1”. Except for this point, the process of assigning the additional variable 2 in the additional block is substantially the same as the process of assigning the variables 1 and 2 to the initial block, and will not be described in detail here. DINT (2) is registered in the mold 52, and '0' is registered in the relative position 53.

尚、予備領域や追加変数格納先アドレスのサイズは、予め任意に決められて設定されているものとし、ここでは予備領域のサイズは、初期ブロックに関しては‘2’であるが、追加ブロックに関しては‘8’が設定されているものとしている。追加変数格納先アドレスに関して、初期ブロック、追加ブロックどちらもサイズ=‘2’となっている。   The size of the spare area and additional variable storage destination address is arbitrarily determined and set in advance. Here, the size of the spare area is “2” for the initial block, but for the additional block, It is assumed that “8” is set. Regarding the additional variable storage destination address, both the initial block and the additional block have a size = “2”.

以上、「変数情報管理表」24の更新を行ったら、続いて、「POUインスタンスアドレス割付対応表」26の更新を行う(ステップS39)。すなわち、図5(a)ではNULLで‘0’としていた追加変数格納先アドレス65及び追加変数格納先サイズ66に、上記追加ブロックの領域の先頭アドレスとサイズを登録する。これによって例えば図5(b)に示す状態となる。   When the “variable information management table” 24 has been updated, the “POU instance address assignment correspondence table” 26 is updated (step S39). That is, in FIG. 5A, the top address and size of the area of the additional block are registered in the additional variable storage destination address 65 and the additional variable storage destination size 66 which are set to “0” in NULL. As a result, for example, the state shown in FIG.

尚、追加変数格納先サイズ66は、上記インスタンスサイズ64と同様に、「変数情報管理表」24に基づいて求めることができる。また、追加変数格納先アドレス65は、既に確保済みの領域のなかで最後のブロックの領域情報、すなわち図示の例ではPOU名が「PG1」のブロックの先頭アドレス63=1024とインスタンスサイズ64=10とに基づいて、1024+10=1034が求められることになる。   Note that the additional variable storage destination size 66 can be obtained based on the “variable information management table” 24, similarly to the instance size 64. Further, the additional variable storage destination address 65 is the area information of the last block among the areas already secured, that is, the head address 63 = 1024 and the instance size 64 = 10 of the block whose POU name is “PG1” in the illustrated example. Based on the above, 1024 + 10 = 1034 is obtained.

尚、上記ステップS36またはS39の処理後は、ステップS31に戻る。
上記図8の処理が完了したら、図6におけるステップS21〜S26の処理を実行することになる。当然、この場合には、例えば図4(b)と図5(b)に示す状態のテーブル24、26を参照して、処理実行することになる。
Note that after the processing in step S36 or S39, the process returns to step S31.
When the process in FIG. 8 is completed, the processes in steps S21 to S26 in FIG. 6 are executed. Naturally, in this case, the process is executed with reference to the tables 24 and 26 in the states shown in FIGS. 4B and 5B, for example.

以上、図8の処理について説明した。
ここで、上述してあった通り、上記ステップS23〜S26の処理について、以下、具体例を示して説明する。換言すれば、コンパイラの機械語コード生成例について以下に説明する。
The processing in FIG. 8 has been described above.
Here, as described above, the processing of steps S23 to S26 will be described below with a specific example. In other words, an example of compiler machine language code generation will be described below.

まず、以下の何れの例においても、本説明で用いるソースコードは、下記のような単純な例であるものとする。
ソースコード例; 変数2:=変数1;
すなわち、変数1の値を変数2に代入するという単純な処理である。
First, in any of the following examples, the source code used in this description is assumed to be a simple example as follows.
Source code example; variable 2: = variable 1;
That is, it is a simple process of substituting the value of variable 1 into variable 2.

まず最初は、上記ソースコード例がプログラムPG1に記述されたものであるとする。
この場合、まず「POUインスタンスアドレス割付対応表」26(図5(b))を参照することで、PG1の先頭アドレス(1024)が得られる。また、「変数情報管理表」24を参照することで、変数1、変数2それぞれのオフセットアドレス(相対位置)が得られる。図4等にはPG1に関する「変数情報管理表」24の具体例は図示していないが、仮に、変数1の相対位置53が‘0’、変数2の相対位置53が‘2’であったとするならば、上記PG1の先頭アドレス(1024)に、これら各変数のオフセット値を足した値が、各変数の実アドレスとなる。すなわち、1024+0=1024が変数1の格納アドレス(実アドレス)となる。同様に、1024+2=1026が変数2の格納アドレス(実アドレス)となる。
First, it is assumed that the source code example is described in the program PG1.
In this case, the head address (1024) of PG1 is obtained by referring to the “POU instance address assignment correspondence table” 26 (FIG. 5B) first. Further, by referring to the “variable information management table” 24, the offset addresses (relative positions) of the variables 1 and 2 can be obtained. Although a specific example of the “variable information management table” 24 related to PG1 is not shown in FIG. 4 and the like, it is assumed that the relative position 53 of the variable 1 is “0” and the relative position 53 of the variable 2 is “2”. In this case, a value obtained by adding the offset value of each of these variables to the top address (1024) of PG1 becomes the actual address of each variable. That is, 1024 + 0 = 1024 is the storage address (real address) of variable 1. Similarly, 1024 + 2 = 1026 is the storage address (real address) of variable 2.

以上のことからPG1の場合、上記ソースコード例に応じた機械語例は、以下のようになる。
LD B 1024
ST B 1026
尚、よく知られているように、LD命令は、指定したアドレスの内容を演算用メモリに読み込む命令である。ST命令は、演算用メモリの内容を指定したアドレスに書き込む命令である。更に、LD命令と指定アドレス(ここでは1024)との間の‘B’は、領域サイズを指定する為のオプションであり、‘B’は1バイト分を意味する。尚、同様にして、Wは2バイト分、Tは4バイト分を意味する。よって、上記「LD B 1024」は“1024番地から1バイト分の領域の内容を演算用メモリに読み込む”ことを意味する。これはST命令に関しても同様である。尚、例えば「LD W 1024」は“1024番地から2バイト分の領域(つまり1024番地〜1025番地)の格納データを演算用メモリに読み込む”ことになる。
From the above, in the case of PG1, a machine language example corresponding to the above source code example is as follows.
LD B 1024
ST B 1026
As is well known, the LD instruction is an instruction for reading the contents of a specified address into an arithmetic memory. The ST instruction is an instruction for writing the contents of the operation memory to a specified address. Furthermore, 'B' between the LD instruction and the specified address (1024 here) is an option for specifying the region size, and 'B' means 1 byte. Similarly, W means 2 bytes and T means 4 bytes. Therefore, the above-mentioned “LD B 1024” means “read the contents of an area of 1 byte from address 1024 into the arithmetic memory”. The same applies to the ST instruction. For example, “LD W 1024” means “reads stored data in an area corresponding to 2 bytes from address 1024 (that is, addresses 1024 to 1025) into the arithmetic memory”.

プログラム(PG)の場合は、1POUが1つだけインスタンス化されるため、変数にアクセスするコードを直接アドレス(実アドレス)で機械語を生成しても問題が無いが、FBの場合、1つのPOUが複数インスタンス化されるため問題が発生する。   In the case of a program (PG), since only one POU is instantiated, there is no problem even if a machine language is generated with a direct address (real address) as a code for accessing a variable. A problem occurs because multiple POUs are instantiated.

例えば上記の例でFB1の場合には、図4、図5に示す例より、上記ソースコード例に応じた機械語例は、以下のようになる。
LD B 1000
ST B 1001
FB1に関して1つだけインスタンス化されるならば、これでも問題はないが、上記の通り、複数インスタンス化された場合、全てのインスタンスが同じアドレスへアクセスするため(LDでは1000番地、STでは1001番地)、FB内の変数の独立性が保てない(FB内の内部変数は、独立していることが規約で定められている)。
For example, in the case of FB1 in the above example, machine language examples corresponding to the above source code examples are as follows from the examples shown in FIGS.
LD B 1000
ST B 1001
If only one instance of FB1 is instantiated, this is not a problem. However, as described above, when multiple instances are created, all instances access the same address (1000 addresses for LD, 1001 addresses for ST). ), The independence of the variables in the FB cannot be maintained (the internal variable in the FB is stipulated as being independent).

そこで、コンパイラ機能部11は、コンパイル対象POUがFB(ここではFB1)の場合には、例えば下記のようにベースポインタ(Base)経由で変数にアクセスする機械語を生成する。   Therefore, when the POU to be compiled is FB (here, FB1), the compiler function unit 11 generates a machine language for accessing a variable via a base pointer (Base) as follows, for example.

LD B Base+0
ST B Base+1
ここで、各FBの実行時には、上記Baseポインタにはインスタンスの先頭アドレスが入ることになり(図4、図5の例の場合、インスタンス1の場合にはBase=1000、インスタンス2の場合にはBase=1018が代入されることになる)、これはFBを呼び出すPOUが設定するものである。以下、まず、FB1を呼び出すPOUが、PGである場合について、具体的な機械語コードの生成例を示して説明する。
LD B Base + 0
ST B Base + 1
Here, at the time of execution of each FB, the start address of the instance is entered in the above Base pointer (in the example of FIGS. 4 and 5, Base = 1000 in the case of instance 1, and in the case of instance 2) Base = 1018 is substituted), which is set by the POU that calls the FB. In the following, a case where the POU that calls FB1 is PG will be described with reference to a specific machine language code generation example.

PGからFB1(ここではFB1のインスタンス1)を呼び出す場合の例を、以下に示す。この場合、コンパイラ機能部11はコンパイル時に、上記各種テーブル22、26等を参照して、上記PGからFB1を呼出すと共にその際に上記Baseポインタの設定を行う機械語コードを生成する。   An example of calling FB1 (here, instance 1 of FB1) from the PG is shown below. In this case, the compiler function unit 11 refers to the various tables 22 and 26 and the like at the time of compiling, and generates machine language code for calling the FB1 from the PG and setting the Base pointer at that time.

すなわち、基本的に、任意のFB(そのインスタンス)を呼び出す場合は、その識別番号(POUの識別番号)とインスタンスアドレス(先頭アドレス)が必要である。これより、まず、図7に示すソースコード識別番号対応表22を参照して、呼び出すFB(ここではFB1)の識別番号72(ここでは‘1’)を取得する。また、インスタンスアドレスは、上記「POUインスタンスアドレス割付対応表」26から取得する。図5の例では、FB1のインスタンス1の先頭アドレス63は‘1000’となっている。   That is, basically, when calling an arbitrary FB (its instance), its identification number (POU identification number) and instance address (head address) are required. Thus, first, the identification number 72 (here, “1”) of the FB to be called (here, FB1) is acquired with reference to the source code identification number correspondence table 22 shown in FIG. The instance address is acquired from the “POU instance address assignment correspondence table” 26. In the example of FIG. 5, the start address 63 of the instance 1 of FB1 is “1000”.

これより、PGにおけるFB1(インスタンス1)を呼び出しに係る機械語コードが、以下のように生成されることになる。
LD T1000
ST Base
CALL 1
尚、「LD 1000」は1000番地のデータを演算用メモリに読み込むものであるが、上記「LD T1000」は、Tの後の数値(ここでは1000)を演算用メモリに読み込むものである。従って、上記機械語は、‘1000’を取得して、これをBaseに代入した後、FB1を呼び出す処理となる。
As a result, the machine language code related to calling FB1 (instance 1) in the PG is generated as follows.
LD T1000
ST Base
CALL 1
Note that “LD 1000” is for reading data at address 1000 into the calculation memory, but “LD T1000” is for reading the numerical value after T (1000 here) into the calculation memory. Therefore, the above machine language is a process of calling FB1 after obtaining “1000” and substituting it into Base.

そして、この場合、呼び出されたFB1の上記機械語の処理は、実質的に以下の内容と同等となる。
LD B 1000+0
ST B 1000+1
尚、CALL命令は、識別番号(ここでは‘1’)によって指定されたPOUを呼び出す命令である。
In this case, the machine language processing of the called FB 1 is substantially equivalent to the following contents.
LD B 1000 + 0
ST B 1000 + 1
The CALL instruction is an instruction for calling a POU designated by an identification number (here, “1”).

尚、同じFB1を用いる場合でも、インスタンス3の場合には、以下の機械語が生成されることになる。
LD T1018
ST Base
CALL 1
この場合、呼び出されたFB1の上記機械語の処理は、実質的に以下の内容と同等となる。
Even when the same FB1 is used, in the case of instance 3, the following machine language is generated.
LD T1018
ST Base
CALL 1
In this case, the processing of the machine language of the called FB 1 is substantially equivalent to the following content.

LD B 1018+0
ST B 1018+1
PGの場合、上記「LD 1000」のように直接アドレス(実アドレス)をコード上に記述することができる。
LD B 1018 + 0
ST B 1018 + 1
In the case of PG, a direct address (real address) can be described on the code like “LD 1000”.

呼び出し元がFBの場合も、上記と略同様であってよいので、ここでの説明は省略する。
次に、以下、追加変数へのアクセスに係わる機械語コード生成例について説明する。
Also when the caller is FB, it may be substantially the same as described above, so the description here is omitted.
Next, an example of machine language code generation related to access to an additional variable will be described below.

例えば、下記のソースコードをコンパイルして機械語コードを生成する例を用いて説明する。
ソースコード例;
追加変数2:=変数2;
つまり、変数2の内容を追加変数2に代入する処理である。
For example, a description will be given using an example of compiling the following source code to generate a machine language code.
Source code example;
Additional variable 2: = variable 2;
That is, it is a process of substituting the contents of variable 2 for additional variable 2.

尚、特に説明しないが、本例においても当該FBの呼出元のPOUが、Baseの値を設定している。尚、本例のFBは、上記FB1であるものとする。そして、FB1に係る変数情報管理表24は、図4(b)に示す状態となっているものとする。   Although not specifically described, the POU of the FB caller also sets the Base value in this example. In addition, FB of this example shall be said FB1. And the variable information management table 24 concerning FB1 shall be in the state shown in FIG.4 (b).

この場合、図4(b)に示すFB1の「変数情報管理表」24を参照して、まず、変数2に関しては、格納先ブロック54が‘0’であるので、初期ブロックに格納されていると判定し、そのオフセット(相対位置53)が‘1’であることから、変数2に対応するアドレスは「Base+1」であると決定する。従って、上記ソースコード例ではまず変数2に対応するアドレスの格納データを読み出すことになるので機械語コード「LD Base+1」が生成される。   In this case, referring to the “variable information management table” 24 of FB1 shown in FIG. 4B, first, the variable 2 is stored in the initial block because the storage block 54 is “0”. Since the offset (relative position 53) is “1”, it is determined that the address corresponding to the variable 2 is “Base + 1”. Accordingly, in the above source code example, first, the stored data at the address corresponding to the variable 2 is read out, so that the machine language code “LD Base + 1” is generated.

続いて、追加変数2に関しては、図4(b)に示すFB1の「変数情報管理表」24の例では格納先ブロック54が‘1’であるので、「追加変数格納先アドレス1」経由でアクセスするものと判定すると共に、そのオフセット(相対位置53)=‘0’を取得して一時的に記憶する。そして、「変数情報管理表」24において変数名51が“追加変数格納先アドレス1”であるレコードを参照することで、そのオフセット(相対位置53)が‘4’であることから、対応するアドレスは「Base+4」であると判定する
以上の処理に基づいて、下記の機械語コードを生成することになる(尚、以下の例では上記BやW等は省略している)。
Subsequently, regarding the additional variable 2, since the storage destination block 54 is “1” in the example of the “variable information management table” 24 of FB1 shown in FIG. 4B, the “additional variable storage destination address 1” is passed. At the same time, it is determined to be accessed, and the offset (relative position 53) = “0” is acquired and temporarily stored. Then, by referring to the record in which the variable name 51 is “additional variable storage destination address 1” in the “variable information management table” 24, the offset (relative position 53) is “4”, so the corresponding address Is determined to be “Base + 4”. Based on the above processing, the following machine language code is generated (in the following example, B and W are omitted).

LD Base+1
LDAX Base+4
ADDAX 0
ST AX
尚、上記機械語コードにおいて、LDAX命令は、指定されたアドレスの格納データを、AXレジスタ(アドレス演算用の内部変数)にセットする命令である。上記の例の場合、アドレス“Base+4”の格納データを、AXレジスタにセットすることになる。
LD Base + 1
LDAX Base + 4
ADDAX 0
ST AX
In the machine language code, the LDAX instruction is an instruction for setting stored data at a specified address in the AX register (internal variable for address calculation). In the case of the above example, the stored data at the address “Base + 4” is set in the AX register.

FB1のインスタンス1の場合、Base=1000が設定されているはずであるので、アドレス“1004”の格納データを、AXレジスタにセットすることになる。尚、アドレス“1004”には予めインスタンス1に係わる追加ブロックの先頭アドレス(本例では‘1034’)が格納されている。これについては後に図9を参照して説明する。   In the case of instance 1 of FB1, since Base = 1000 is supposed to be set, the stored data at address “1004” is set in the AX register. Note that the head address (“1034” in this example) of the additional block related to the instance 1 is stored in advance at the address “1004”. This will be described later with reference to FIG.

なお、FB1のインスタンス3の場合、Base=1018が設定されているはずであるので、アドレス“1022”の格納データを、AXレジスタにセットすることになる。尚、アドレス“1022”には予めインスタンス3に係わる追加ブロックの先頭アドレス(本例では‘1044’)が格納されている。これについても後に図9を参照して説明する。   In the case of instance 3 of FB1, since Base = 1018 is supposed to be set, the stored data at address “1022” is set in the AX register. Note that the head address (“1044” in this example) of the additional block related to the instance 3 is stored in advance at the address “1022”. This will also be described later with reference to FIG.

また、ADDAX命令は、AXレジスタの格納内容に、指定した数字を加算する命令であり、上記機械語においては追加変数2の格納アドレスを演算している。インスタンス1の場合には、アドレス“1004”の格納データ(‘1034’)に‘0’が加算された値が、AXレジスタの新たな格納データとなる。インスタンス3の場合には、アドレス“1022”の格納データ(‘1044’)に‘0’が加算された値が、AXレジスタの新たな格納データとなる。   The ADDAX instruction is an instruction for adding a designated number to the stored contents of the AX register. In the machine language, the storage address of the additional variable 2 is calculated. In the case of instance 1, a value obtained by adding “0” to the stored data (“1034”) at the address “1004” becomes new stored data in the AX register. In the case of instance 3, a value obtained by adding “0” to the stored data (“1044”) at the address “1022” becomes new stored data in the AX register.

また、上記「ST AX」は、AXレジスタの格納データが示すアドレスに、上記1行目のLD命令でロードしたデータ(変数2のデータ)を格納する命令である。従って、本例では、インスタンス1の場合にはアドレス‘1034’に変数2のデータを格納することになり、インスタンス3の場合にはアドレス‘1044’に変数2のデータを格納することになる。   The “ST AX” is an instruction for storing the data loaded by the LD instruction in the first row (data of variable 2) at the address indicated by the storage data of the AX register. Therefore, in this example, the variable 2 data is stored in the address “1034” in the case of the instance 1, and the variable 2 data is stored in the address “1044” in the case of the instance 3.

ここで、上記アドレス“1004”や“1022”には、予めPLC30が、開発支援装置10から機械語オブジェクト23と共にダウンロードされたPOUインスタンスアドレス情報25に基づいて、該当データを設定しておく。   Here, in the addresses “1004” and “1022”, the PLC 30 sets the corresponding data based on the POU instance address information 25 downloaded together with the machine language object 23 from the development support apparatus 10 in advance.

図9に、上記図4(b)、図5(b)の例に応じたPOUインスタンスアドレス情報25の一例を示す。
図9の例のPOUインスタンスアドレス情報25は、アドレス81と値82から成る。
FIG. 9 shows an example of the POU instance address information 25 corresponding to the examples of FIGS. 4B and 5B.
The POU instance address information 25 in the example of FIG. 9 includes an address 81 and a value 82.

アドレス81には“追加変数格納先アドレス”のアドレスが格納され、値82には追加変数格納領域の先頭アドレスが格納される。
図4(b)に示すFB1の「変数情報管理表」24では“追加変数格納先アドレス”のオフセット(相対位置53)が‘4’である。また、図5(b)の「POUインスタンスアドレス割付対応表」26の例では、FB1によるインスタンス1の先頭アドレス63は‘1000’、追加変数格納先アドレス65は‘1034’となっており、FB1によるインスタンス3の先頭アドレス63は‘1018’、追加変数格納先アドレス65は‘1044’となっている。これより、図9に示すように、アドレス81が‘1004’(=1000+4)に対して値82が‘1034’となっており、アドレス81が‘1022’(=1018+4)に対して値82が‘1044’となっている。
The address 81 stores the address of “additional variable storage destination address”, and the value 82 stores the top address of the additional variable storage area.
In the “variable information management table” 24 of FB1 shown in FIG. 4B, the offset (relative position 53) of the “additional variable storage destination address” is “4”. In the example of the “POU instance address allocation correspondence table” 26 in FIG. 5B, the start address 63 of the instance 1 by FB1 is “1000”, and the additional variable storage destination address 65 is “1034”. The start address 63 of the instance 3 is “1018”, and the additional variable storage destination address 65 is “1044”. As a result, as shown in FIG. 9, the address 81 is “1004” (= 1000 + 4), the value 82 is “1034”, and the address 81 is “1022” (= 1018 + 4). The value 82 is '1044'.

以上のPOUインスタンスアドレス情報25生成処理は、例えばコンパイラ機能部11がコンパイルの際に行うものであり、その後、コンパイル結果として得られる機械語オブジェクト23と共にPOUインスタンスアドレス情報25がPLC30にダウンロードされる。これより、PLC30側では(例えばプログラム実行管理機能部31が)、当該新たな機械語オブジェクト23による運用を開始する前に、POUインスタンスアドレス情報25に基づく設定処理を行う。   The POU instance address information 25 generation process described above is performed, for example, by the compiler function unit 11 when compiling. Thereafter, the POU instance address information 25 is downloaded to the PLC 30 together with the machine language object 23 obtained as a compilation result. Thus, on the PLC 30 side (for example, the program execution management function unit 31), the setting process based on the POU instance address information 25 is performed before the operation using the new machine language object 23 is started.

図9に示す例では、アドレス‘1004’にデータ“1034”を格納し、アドレス‘1022’に対してデータ“1044”を格納することになる。この例の場合、上記「LDAX Base+4」は、インスタンス1の場合にはアドレス‘1004’の格納データすなわち“1034”を、AXレジスタに格納することになり、インスタンス3の場合にはアドレス‘1022’の格納データすなわち“1044”を、AXレジスタに格納することになる。   In the example shown in FIG. 9, data “1034” is stored at address “1004”, and data “1044” is stored at address “1022”. In this example, “LDAX Base + 4” stores the stored data of address “1004” in the case of instance 1, that is, “1034”, in the AX register, and in the case of instance 3, the address “1022”. The stored data of “1044” is stored in the AX register.

尚、POUインスタンスアドレス情報25の代わりに「POUインスタンスアドレス割付対応表」26をPLC30にダウンロードすることで、PLC30側で上記設定処理を行わせるようにしてもよい。但し、「POUインスタンスアドレス割付対応表」26は、
データ量が多い為、PLCでは扱いにくいので、該当アドレスとその内容(追加変数格納領域の先頭アドレス)を取り出した情報を格納したのが、上記「POUインスタンスアドレス情報」25である。PLC30は、この情報25を獲得し、PLC30内のメモリに、上記該当アドレスで指定された場所に値を展開する。
Note that the “POU instance address assignment correspondence table” 26 may be downloaded to the PLC 30 instead of the POU instance address information 25 so that the setting process is performed on the PLC 30 side. However, the “POU instance address assignment correspondence table” 26 is
Since the amount of data is large, it is difficult to handle in the PLC, and the “POU instance address information” 25 stores information obtained by extracting the corresponding address and its contents (the start address of the additional variable storage area). The PLC 30 acquires this information 25 and expands the value in the memory in the PLC 30 at the location specified by the corresponding address.

尚、上記のBaseポインタの設定例は、コンパイラ(コード生成)で実施しているが、PLC内のシステム(Call内)で同様な動作を実施することも可能である。
以上説明したように、本例のプログラマブルコントローラの支援装置によれば、ユーザが変数追加を伴うプログラムの更新を実施しても、既に割り付けた変数(既存の変数)のアドレス(割当位置)を変更することなく、追加した変数を新しいアドレスに割り付けることが可能になり、PLCを停止しないで(PLCを停止することは、システムを停止することになる)、プログラムを更新できるため、システムの稼動性、保守性、拡張性が向上する。特に既に確保済みのブロックのみでは全ての追加変数を割り当てられない場合であっても、追加ブロックを生成して追加変数を格納できるので、最初に確保したブロックのサイズ(予備領域のサイズ)によって制限を受けることなく、変数の追加を行うことができる。
The above example of setting the Base pointer is implemented by a compiler (code generation), but a similar operation can also be performed by a system in PLC (within Call).
As described above, according to the programmable controller support device of the present example, even if the user updates the program that accompanies variable addition, the address (allocation position) of the already allocated variable (existing variable) is changed. Without adding, it is possible to assign the added variable to a new address, and the program can be updated without stopping the PLC (stopping the PLC will stop the system). , Maintainability and expandability are improved. In particular, even if it is not possible to allocate all additional variables with only already secured blocks, additional variables can be generated and stored with additional variables, so it is limited by the size of the first secured block (the size of the spare area) You can add variables without receiving.

10 開発支援装置(ローダ)
11 コンパイラ機能部
12 インタフェース機能部
13 通信機能部
14 ディスプレイ
15 入力装置
20 記憶部
21 ソースコード
22 ソースコード識別番号対応表
23 機械語オブジェクト
24 変数情報管理表
25 POUインスタンスアドレス情報
26 POUインスタンスアドレス割付対応表
30 PLC(プログラマブルコントローラ)
31 プログラム実行管理機能部
32 通信機能部
40 記憶部
41 機械語オブジェクト
42 POUインスタンスアドレス情報
43 POUインスタンスメモリ領域
51 変数名
52 型
53 相対位置
54 格納先ブロック
61 インスタンス番号
62 POU名
63 先頭アドレス
64 インスタンスサイズ
65 追加変数格納先アドレス
66 追加変数格納先サイズ
71 POU名
72 識別番号
81 アドレス
82 値
10 Development support device (loader)
11 Compiler Function Unit 12 Interface Function Unit 13 Communication Function Unit 14 Display 15 Input Device 20 Storage Unit 21 Source Code 22 Source Code Identification Number Correspondence Table 23 Machine Language Object 24 Variable Information Management Table 25 POU Instance Address Information 26 POU Instance Address Assignment Correspondence Table 30 PLC (Programmable Controller)
31 Program execution management function unit 32 Communication function unit 40 Storage unit 41 Machine language object 42 POU instance address information 43 POU instance memory area 51 Variable name 52 Type 53 Relative position 54 Storage block 61 Instance number 62 POU name 63 First address 64 Instance Size 65 Additional variable storage destination address 66 Additional variable storage destination size 71 POU name 72 Identification number 81 Address 82 Value

Claims (8)

プログラマブルコントローラ用の任意のプログラムのソースコードをコンパイルして機械語オブジェクトを生成する支援装置と、プログラマブルコントローラとから成るプログラマブルコントローラ・システムであって、
前記支援装置は、前記プログラマブルコントローラが稼働中にそのプログラムを変更する場合、
前記ソースコードのコンパイルの際に、前記ソースコードに含まれるPOUに、そのPOUに係わる変数の格納領域と予備領域と追加変数格納先記憶領域を相対アドレスで示す領域情報を保持する変数情報記憶手段と、
前記ソースコードのコンパイルの際に、前記POUのインスタンスに、そのインスタンスに関して確保された一塊のメモリ領域であるブロックに関する情報として少なくともその先頭アドレスを記憶するインスタンス情報記憶手段と、
前記変数情報記憶手段と前記インスタンス情報記憶手段とを参照して、前記変数を前記インスタンスにメモリ割当てを行いながら、前記任意のプログラムのソースコードを前記機械語オブジェクトに変換するコンパイル手段と、
前記プログラムの修正版/更新版である修正/更新プログラムのソースコードをコンパイルする際に、該ソースコードに含まれるPOUに、前記変数情報記憶手段を参照して追加変数の有無をチェックし、追加変数がある場合には前記予備領域で対応可能か否かを判定し、対応できる場合には該予備領域に追加変数を割当て、対応できない場合には、該POUのインスタンスに追加のブロックを確保すると共に、既存のブロックの前記追加変数格納先記憶領域に該追加ブロックの先頭アドレスを格納させる為の情報を生成し記憶する追加変数対応手段と、
を有することを特徴とするプログラマブルコントローラ・システム。
A programmable controller system comprising a support device that compiles source code of an arbitrary program for a programmable controller and generates a machine language object, and a programmable controller,
When the support device changes the program while the programmable controller is operating,
When compiling the source code, the POU included in the source code includes variable information storage means for holding area information indicating relative storage addresses, spare areas, and additional variable storage destination storage areas related to the POU. When,
An instance information storage means for storing at least a head address as information on a block which is a block of memory area reserved for the instance in the POU instance when compiling the source code;
Compile means for converting the source code of the arbitrary program into the machine language object while allocating memory to the instance with reference to the variable information storage means and the instance information storage means;
When compiling the source code of a modified / updated program that is a modified / updated version of the program, the POU included in the source code is checked for the presence of additional variables by referring to the variable information storage means and added. If there is a variable, it is determined whether or not it can be handled in the spare area. If it can be dealt with, an additional variable is assigned to the spare area. If it cannot be dealt with, an additional block is secured in the instance of the POU. And an additional variable corresponding means for generating and storing information for storing the head address of the additional block in the additional variable storage destination storage area of the existing block;
A programmable controller system comprising:
前記コンパイル手段は、前記修正/更新プログラムの前記機械語オブジェクトへの変換に関しては、前記追加変数の有無に係らず、既存の変数に関しては前記変数情報記憶手段の前記領域情報に基づいて前回コンパイル時と同じアドレスを割り当てることを特徴とする請求項1記載のプログラマブルコントローラ・システム。   The compiling means converts the modified / updated program into the machine language object regardless of the presence of the additional variable, regardless of the existence of the additional variable, the existing compiling means based on the area information in the variable information storage means at the time of the previous compilation. The programmable controller system according to claim 1, wherein the same address is assigned. 前記コンパイル手段は、前記修正/更新プログラムの前記機械語オブジェクトへの変換に関しては、前記追加変数格納先記憶領域経由で前記追加変数にアクセスする機械語オブジェクトを生成することを特徴とする請求項1記載のプログラマブルコントローラ・システム。   The compiling means generates a machine language object that accesses the additional variable via the additional variable storage destination storage area with respect to conversion of the modification / update program into the machine language object. The programmable controller system described. 前記支援装置は、前記追加変数格納先記憶領域のアドレスと該追加変数格納先記憶領域に記憶される前記追加ブロックの先頭アドレスとの対応関係情報を、前記修正/更新プログラムの機械語オブジェクトと共に前記プログラマブルコントローラにダウンロードし、
前記プログラマブルコントローラは、該修正/更新プログラムの機械語オブジェクトを実行開始する前に、前記対応関係情報に基づいて、前記追加変数格納先記憶領域に前記追加ブロックの先頭アドレスを格納することを特徴とする請求項3記載のプログラマブルコントローラ・システム。
The support device displays correspondence information between the address of the additional variable storage destination storage area and the start address of the additional block stored in the additional variable storage destination storage area together with the machine language object of the correction / update program. Download to the programmable controller,
The programmable controller stores the start address of the additional block in the additional variable storage destination storage area based on the correspondence information before starting execution of the machine language object of the correction / update program. The programmable controller system according to claim 3.
前記コンパイル手段は、前記POUの一種であるPGに関しては、前記ブロックの先頭アドレスと前記変数の相対アドレスとによって変数の割当位置の実アドレスを求めて、該実アドレスを用いて前記機械語オブジェクトを生成することを特徴とする請求項1記載のプログラマブルコントローラ・システム。   For the PG which is a kind of the POU, the compiling unit obtains a real address of a variable allocation position from a head address of the block and a relative address of the variable, and uses the real address to determine the machine language object. The programmable controller system according to claim 1, wherein the programmable controller system is generated. 前記コンパイル手段は、前記POUの一種であるファンクションブロックに関しては、ベースポインタと前記変数の相対アドレスとによって変数の割当位置にアクセスさせる機械語オブジェクトを生成すると共に、該ファンクションブロックのインスタンスの呼び出し元POUが、該ファンクションブロックのインスタンスに対応する前記ブロックの先頭アドレスを前記ベースポインタにセットしてから該ファンクションブロックのインスタンスを呼び出す機械語オブジェクトを生成することを特徴とする請求項1記載のプログラマブルコントローラ・システム。   For the function block which is a kind of the POU, the compiling means generates a machine language object for accessing a variable allocation position based on a base pointer and a relative address of the variable, and also calls a POU that calls an instance of the function block. 2. The programmable controller according to claim 1, wherein a machine language object for calling an instance of the function block is generated after setting a head address of the block corresponding to the instance of the function block to the base pointer. system. 前記変数情報記憶手段には、前記変数に、その変数が前記既存のブロックと前記追加ブロックのどちらに割り当てられたかを示す情報も記憶されることを特徴とする請求項1記載のプログラマブルコントローラ・システム。   2. The programmable controller system according to claim 1, wherein the variable information storage means also stores information indicating whether the variable is assigned to the existing block or the additional block. . プログラマブルコントローラ用の任意のプログラムのソースコードをコンパイルして機械語オブジェクトを生成する支援装置であって、
プログラマブルコントローラが稼働中にそのプログラムを変更する場合、
前記ソースコードのコンパイルの際に、前記ソースコードに含まれるPOUに、そのPOUに係わる変数の格納領域と予備領域と追加変数格納先記憶領域を相対アドレスで示す領域情報を保持する変数情報記憶手段と、
前記ソースコードのコンパイルの際に、前記POUのインスタンスに、そのインスタンスに関して確保された一塊のメモリ領域であるブロックに関する情報として少なくともその先頭アドレスを記憶するインスタンス情報記憶手段と、
前記変数情報記憶手段と前記インスタンス情報記憶手段とを参照して、前記変数を前記インスタンスにメモリ割当てを行いながら、前記任意のプログラムのソースコードを前記機械語オブジェクトに変換するコンパイル手段と、
前記プログラムの修正版/更新版である修正/更新プログラムのソースコードをコンパイルする際に、該ソースコードに含まれるPOUに、前記変数情報記憶手段を参照して追加変数の有無をチェックし、追加変数がある場合には前記予備領域で対応可能か否かを判定し、対応できる場合には該予備領域に追加変数を割当て、対応できない場合には、該POUのインスタンスに追加のブロックを確保すると共に、既存のブロックの前記追加変数格納先記憶領域に該追加ブロックの先頭アドレスを格納させる為の情報を生成し記憶する追加変数対応手段と、
を有することを特徴とするプログラマブルコントローラの支援装置。
A support device for generating a machine language object by compiling a source code of an arbitrary program for a programmable controller,
When changing the program while the programmable controller is running,
When compiling the source code, the POU included in the source code includes variable information storage means for holding area information indicating relative storage addresses, spare areas, and additional variable storage destination storage areas related to the POU. When,
An instance information storage means for storing at least a head address as information on a block which is a block of memory area reserved for the instance in the POU instance when compiling the source code;
Compile means for converting the source code of the arbitrary program into the machine language object while allocating memory to the instance with reference to the variable information storage means and the instance information storage means;
When compiling the source code of a modified / updated program that is a modified / updated version of the program, the POU included in the source code is checked for the presence of additional variables by referring to the variable information storage means and added. If there is a variable, it is determined whether or not it can be handled in the spare area. If it can be dealt with, an additional variable is assigned to the spare area. If it cannot be dealt with, an additional block is secured in the instance of the POU. And an additional variable corresponding means for generating and storing information for storing the head address of the additional block in the additional variable storage destination storage area of the existing block;
A support device for a programmable controller, comprising:
JP2011100991A 2011-04-28 2011-04-28 Programmable controller system and its support device Active JP5790128B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2011100991A JP5790128B2 (en) 2011-04-28 2011-04-28 Programmable controller system and its support device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2011100991A JP5790128B2 (en) 2011-04-28 2011-04-28 Programmable controller system and its support device

Publications (2)

Publication Number Publication Date
JP2012234272A JP2012234272A (en) 2012-11-29
JP5790128B2 true JP5790128B2 (en) 2015-10-07

Family

ID=47434555

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2011100991A Active JP5790128B2 (en) 2011-04-28 2011-04-28 Programmable controller system and its support device

Country Status (1)

Country Link
JP (1) JP5790128B2 (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5957936B2 (en) * 2012-02-15 2016-07-27 富士電機株式会社 Programmable controller system, its support device, program
JP6124612B2 (en) * 2013-02-06 2017-05-10 アズビル株式会社 Engineering apparatus and engineering method
JP2015125713A (en) * 2013-12-27 2015-07-06 富士電機株式会社 Programmable controller system, supporting device, programmable controller, program
JP6295914B2 (en) * 2014-10-10 2018-03-20 富士電機株式会社 Programmable controller system, its support device, programmable controller
JP6790541B2 (en) * 2016-07-20 2020-11-25 株式会社Ihi Logic update device and logic update method
JP6950665B2 (en) * 2018-11-02 2021-10-13 横河電機株式会社 Engineering equipment, control methods and programs for engineering equipment
JP7622483B2 (en) 2021-03-11 2025-01-28 オムロン株式会社 Development support device, development support method, and development support program
JP7380635B2 (en) * 2021-04-09 2023-11-15 横河電機株式会社 Program modification support device and program modification support method
WO2023152890A1 (en) * 2022-02-10 2023-08-17 三菱電機株式会社 Programmable controller system, development support device, memory allocation method, and program

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05224707A (en) * 1992-02-13 1993-09-03 Yaskawa Electric Corp Program changing method for programmable controller
JP3207333B2 (en) * 1995-05-16 2001-09-10 東洋電機製造株式会社 Programmable controller
JP3389592B2 (en) * 1997-01-27 2003-03-24 オムロン株式会社 Programmable controller
JP2000020297A (en) * 1998-07-01 2000-01-21 Omron Corp Controller
JP2001142510A (en) * 1999-11-11 2001-05-25 Omron Corp Controller system, programming tool and controller
JP3844051B2 (en) * 2001-07-10 2006-11-08 オムロン株式会社 controller
JP4319082B2 (en) * 2004-04-08 2009-08-26 三菱電機株式会社 Programming system
JP5233544B2 (en) * 2008-09-18 2013-07-10 株式会社明電舎 POU mounting method

Also Published As

Publication number Publication date
JP2012234272A (en) 2012-11-29

Similar Documents

Publication Publication Date Title
JP5790128B2 (en) Programmable controller system and its support device
JP7090657B2 (en) Methods, devices, devices and storage media for upgrading applications
US9904539B2 (en) Generating and applying patches to computer program code concurrently with its execution
JP2015526821A5 (en)
JP6292096B2 (en) Programmable controller system and its support device
US7788661B2 (en) Method and system for applying patches to a computer program concurrently with its execution
JP2006092544A (en) Dynamic link of module in pre-operating system environment
JP6866663B2 (en) Programmable controller system, programmable controller, support device, HCI device, redundant programmable controller system
JP5757098B2 (en) Program creation support apparatus and program creation support method
JP4319082B2 (en) Programming system
JP2015125713A (en) Programmable controller system, supporting device, programmable controller, program
JP5849592B2 (en) Programmable controller system, programming device thereof, programmable controller, program, and debugging method
JP6205934B2 (en) Programmable controller system, its support device, program
JP5895616B2 (en) Information processing apparatus and program execution method
CN110720081B (en) Compiler and programming support device
KR101918430B1 (en) System design assistance tool
JP6071782B2 (en) PLANT CONTROL DEVICE, PLANT CONTROL METHOD, AND PLANT CONTROL PROGRAM
JP6455096B2 (en) Control system, its support device, programmable control device
JP6020071B2 (en) Programmable controller system, its support device, programmable controller
JP4760607B2 (en) Programmable controller
KR20070081868A (en) How to update software efficiently in mobile communication system
CN104106015A (en) Programmable controller system, programmable display therefor, assistance device, and program
CN108205462A (en) For the system and method for content-application separation
JP5978775B2 (en) PROGRAMMABLE CONTROLLER, ITS SUPPORT DEVICE, PROGRAM, PROGRAM TRANSFER METHOD
CN104199678B (en) The method for obtaining the type ID of board method and software release upgrade

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20140314

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20150120

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20150121

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20150304

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20150707

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20150720

R150 Certificate of patent or registration of utility model

Ref document number: 5790128

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250