JP4978373B2 - Programmable controller and its CPU module - Google Patents
Programmable controller and its CPU module Download PDFInfo
- Publication number
- JP4978373B2 JP4978373B2 JP2007220439A JP2007220439A JP4978373B2 JP 4978373 B2 JP4978373 B2 JP 4978373B2 JP 2007220439 A JP2007220439 A JP 2007220439A JP 2007220439 A JP2007220439 A JP 2007220439A JP 4978373 B2 JP4978373 B2 JP 4978373B2
- Authority
- JP
- Japan
- Prior art keywords
- access
- request
- task
- processing
- low
- 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.)
- Expired - Fee Related
Links
Images
Landscapes
- Programmable Controllers (AREA)
Description
本発明は、プログラマブルコントローラ、そのCPUモジュール等に関する。 The present invention relates to a programmable controller and its CPU module.
従来の技術を図18〜図21を参照して説明する。
プログラマブルコントローラ(以下 PLC)は、例えばIEC61131-3で規格化されたプログラム言語によって記述されたアプリケーションを実行するものである。アプリケーションは実行優先度によって複数レベルのタスク(マルチタスク)をもつことができることが一般に知られている。図18に、このマルチタスク実行の様子を示している。
Prior art will be described with reference to FIGS.
A programmable controller (hereinafter referred to as a PLC) executes an application described in a program language standardized by, for example, IEC61131-3. It is generally known that an application can have multiple levels of tasks (multitask) depending on execution priority. FIG. 18 shows the state of this multitask execution.
図18に示す例では、0レベルタスク、1レベルタスク、デフォルトタスクの3種類あり、“0レベルタスク>1レベルタスク>デフォルトタスク”の関係にある(つまり、0レベルタスクが最も実行優先度が高い)。 In the example shown in FIG. 18, there are three types, a 0-level task, a 1-level task, and a default task, which have a relationship of “0-level task> 1-level task> default task” (that is, the 0-level task has the highest execution priority). high).
図示の例では、通常はデフォルトタスクを実行しているが、0レベルタスクの実行タイミング(2ms周期)又は1レベルタスクの実行タイミング(5ms周期)になる毎に、デフォルトタスクの実行を中断し、0レベルタスク又は1レベルタスクを実行する。また、図には示されていないが、1レベルタスク実行中に0レベルタスクの実行タイミングとなった場合には、1レベルタスクの実行を中断し、0レベルタスクを実行する。 In the illustrated example, the default task is normally executed, but the execution of the default task is interrupted every time the execution timing of the 0 level task (2 ms cycle) or the execution timing of the 1 level task (5 ms cycle) A 0 level task or a 1 level task is executed. Although not shown in the figure, when the execution timing of the 0 level task is reached during the execution of the 1 level task, the execution of the 1 level task is interrupted and the 0 level task is executed.
また、図19に、従来のPLCの内部および外部構成例を示す。
図19に示すPLC構成例では、複数のI/Oモジュール104と複数のCPUモジュール110が、I/Oバス103に接続しており、モジュール相互に通信を行う。また、複数のCPUモジュール110は、共有メモリバス102にも接続しており、各CPUモジュール110各々が、共有メモリバス102を介して共有メモリ101にアクセスする。
FIG. 19 shows an example of the internal and external configurations of a conventional PLC.
In the PLC configuration example shown in FIG. 19, a plurality of I /
各CPUモジュール110は、マイコン111、ROM112、RAM113、バスインタフェース114、I/Oインタフェース115、RDY制御部116を有する。
I/Oインタフェース115は、I/Oバス103に接続しており、他のモジュールとの通信制御を行う。バスインタフェース114は、共有メモリバス102に接続しており、共有メモリ101に対するアクセス制御を行う。
Each
The I /
マイコン111は、RAM113またはROM112に格納されているアプリケーションプログラムを読み出しては命令の実行を行う。このアプリケーションプログラム実行中に、共有メモリアクセス処理が発生した場合には、アプリケーションはシステムソフトを呼び出す。このシステムソフトはPLCメーカ側で予め作成しておくファームウェアであり、共有メモリアクセス処理を実行する。一方、アプリケーションプログラムは顧客側で作成する。顧客側では、新たなアプリケーションプログラムを作成する際、例えば上記共有メモリへアクセスする処理を逐一記述する必要はなく、上記予め用意されているシステムソフトを呼び出せばよいので、手間が軽減される。つまり、システムソフトは、アプリケーションが呼び出すサブルーチンの様なものである。
The microcomputer 111 reads an application program stored in the
システムソフトは、バスインタフェース114を介して、共有メモリアクセス処理を実行するが、処理が完了するまで、後述するRDY信号のためにWAIT状態となり、アプリケーションに戻らない。この為、上位レベルのタスクの実行タイミングになっても実行できないという問題が生じる。詳しくは後述する。
The system software executes the shared memory access process via the
以下に共有メモリアクセス処理の実行について説明する。
マイコン111の上記システムソフトは、バスインタフェース114を介して共有メモリバス102上の共有メモリ101へアクセスする。
The execution of the shared memory access process will be described below.
The system software of the microcomputer 111 accesses the shared
共有メモリ101は、共有メモリバス102に接続されている全CPUモジュール110からアクセス可能であり、複数アクセス者を調停機能により排他してアクセス者を決定する。このように、共有メモリアクセスには、マイコン111から見て、バスインタフェース114へのアクセスタイム、バスインタフェース114によるバス調停及び共有メモリ101へのアクセスタイムというように、内部のROM112、RAM113等へのアクセスタイムと比較して長い時間が掛かる。更に、仮に、調停で負けた場合は、他のCPUモジュール110による共有メモリアクセス完了まで待たされた後、ようやく共有メモリアクセス権が回ってくるため、さらに時間が掛かることになる。
The shared
図20に、従来のバスインタフェース114の構成例を示す。また、図21に、従来のバスインタフェース114による共有メモリアクセスタイミングチャート(リード処理の場合)例を示す。
FIG. 20 shows a configuration example of the
バスインタフェース114とマイコン111とは、データバス、アドレスバス、セレクト(*CS)、リード/ライト(RD/*WT)、レディ(RDY)の各信号線が接続される。バスインタフェース114内の「内部制御信号とRDYの生成部」131は、マイコン111から送信されるセレクト*CS信号、アドレス信号により共有メモリ101へのアクセス要求を認識すると、レディ(RDY)信号をWAIT状態“L”(Low)にしてマイコン111をWAIT状態にさせておいて、バスアクセス制御部132に対してアクセス要求を出す。尚、図21に示す通り、レディ(RDY)信号は‘L’でWAIT、‘H’でRDY(WAIT解除)を意味する。
The
バスアクセス制御部132は、このアクセス要求に応じて共有メモリ101へのアクセスを行う。尚、バスアクセス制御部132には、データバス、アドレスバスが接続しており、アドレスバスを介して共有メモリ101へのアクセスアドレスが入力される。そして、リード/ライト(RD/*WT)信号がライト要求*WTであれば、データバスを介して共有メモリ101への書き込みデータが入力され、バスアクセス制御部132は、このデータを共有メモリ101の上記アクセスアドレスの領域に書き込む。一方、リード/ライト(RD/*WT)信号がリード要求RDであれば、バスアクセス制御部132は、共有メモリ101の上記アクセスアドレスの領域からデータを読み出して、このリードデータをデータバスに出力する。これらの入力/出力の相手先は、当然、マイコン111である。
The bus
図21はリードの場合の例なので、ここではリード要求RDに応じて、共有メモリ101へのリードアクセスを行うものとする。
バスアクセス制御部132は、共有メモリバス102上でのリードアクセスが完了すると、上記の通りデータバス上に読出しデータを出力すると共に、「内部制御信号とRDYの生成部」131に対してアクセス完了を通知する。この通知を受けた「内部制御信号とRDYの生成部」131は、図21に示す通り、レディ(RDY)信号をWAIT状態“L”からRDY状態“H”にする。これによって、マイコン111はリードデータを取得する。
Since FIG. 21 is an example in the case of read, it is assumed here that read access to the shared
When the read access on the shared memory bus 102 is completed, the bus
これにより、マイコン111としては、共有メモリアクセス命令の実行を完了し、アプリケーションプログラム上の次の命令実行に移ることになる。しかし、図21に示す通り、バスインタフェース114による共有メモリ101へのリードアクセスが完了するまでの間、レディ(RDY)信号はWAIT状態となっており、マイコン111は、この間ずっと待たされることになる。そして、上述してある通り、この待ち時間は長く、更に調停で負
けた場合には非常に長くなる。
As a result, the microcomputer 111 completes the execution of the shared memory access instruction and proceeds to the next instruction execution on the application program. However, as shown in FIG. 21, until the read access to the shared
低速デバイスへアクセスに行った時に待ち時間を短縮する方法として、例えば特許文献1に記載の手法が知られている。
この手法は、マスタからスレーブにアクセスする際、コマンドをスレーブ内に設けたバッファに一旦受けた時点で、マスタのウエイト解除をするというものである。
In this method, when the master accesses the slave, the master is released from the wait when the command is once received in the buffer provided in the slave.
上述した従来技術の問題点について、以下、説明する。
(課題1)
PLCにおいては、各CPUモジュール110毎に1つのマイコン111によって、アプリケーションの実行、ローダとの通信など複数の処理を実行させている。PLCではI/Oモジュール104とのアクセス、複数のCPUモジュール110とのメモリ共有が相変わらず存在しているが、この共有メモリ等のような低速デバイスへのアクセスタイムは、マイコン111の動作スピード、RAM113、ROM112へのアクセスタイム等と比較して圧倒的に長いため、マイコン111が行なわなければならない処理が低速デバイスアクセスによって阻害、滞ることが深刻化してきている。特に、マイコン111の動作スピードに比較して、共有メモリへのアクセスタイムは非常に長いため、従来技術で述べたように、共有メモリアクセスが完了するまでの間、CPUがWAIT状態になり続けるのは、マイコンが行なわなければならない処理が非常に阻害されることになる。
The problems of the prior art described above will be described below.
(Problem 1)
In the PLC, a plurality of processes such as application execution and communication with a loader are executed by one microcomputer 111 for each
また近年、より高速なネットワークとの接続もPLCに求められてくると考えられ、ますますマイコン111の処理性能劣化への対策が重要となってくる。
このような共有メモリ等の低速デバイスへのアクセスに伴うマイコン111の処理性能劣化の問題を解決することが求められている。
In recent years, it is thought that PLCs are also required to connect to higher-speed networks, and countermeasures against deterioration in processing performance of the microcomputer 111 are becoming increasingly important.
It is required to solve the problem of deterioration in processing performance of the microcomputer 111 accompanying access to such a low-speed device such as a shared memory.
ここで、特に、マイコン111が上記図18に示すようなマルチタスク実行を行うものである場合、例えば図22に示すように、低いレベルのタスク(デフォルトタスク等)を実行中に共有メモリアクセスがあった場合、上記WAIT中に高レベルのタスク(例えば0レベルタスク)の実行タイミングになっても、マイコン111がWAIT状態なので、割り込みが受け付けられず、高レベルのタスク(例えば0レベルタスク)の実行に移れない。勿論、図示の通り、WAIT状態が解除されれば、高レベルのタスクを実行できるようになるが、WAIT状態が解除されるまで待たなければならない。このため、応答性能が要求される場合(高レベルタスクは、通常、決められた実行タイミングで実行されることが要求されている)は深刻な問題となる。 Here, in particular, when the microcomputer 111 performs multitask execution as shown in FIG. 18, for example, as shown in FIG. 22, shared memory access is performed while a low level task (default task or the like) is being executed. If there is a high-level task (for example, 0-level task) during the WAIT, the microcomputer 111 is in the WAIT state, so an interrupt is not accepted and a high-level task (for example, 0-level task) Can't move on. Of course, as shown in the figure, when the WAIT state is released, a high-level task can be executed, but it is necessary to wait until the WAIT state is released. For this reason, when response performance is required (a high-level task is usually required to be executed at a predetermined execution timing), it becomes a serious problem.
また、PLCがネットワーク接続されているなどにより通信処理が頻繁に行われる状況にあって(特に図示しないが、例えばCPUモジュールがLANに接続しており、LANを介して外部の情報処理装置等と頻繁にやりとりする必要がある場合等)、長期間のWAIT状態が発生することは、スループットの低下、バッファアンダーランなどの発生を招く。 In addition, there is a situation where communication processing is frequently performed because the PLC is connected to the network (not particularly shown, for example, the CPU module is connected to the LAN, and with the external information processing apparatus etc. via the LAN. For example, when it is necessary to communicate frequently), a long-term WAIT state causes a decrease in throughput and a buffer underrun.
以上述べたように、マイコンがアプリケーションプログラム実行上、アクセスタイムの長い低速デバイスへアクセスする場合であっても、マイコンのWAIT状態を解除して他の処理(特に上位レベルのタスクの処理)が行えたり、割込み受付可能な状態にすることが本課題である。 As described above, even when the microcomputer accesses a low-speed device with a long access time during execution of an application program, the microcomputer can be released from the WAIT state to perform other processing (especially high-level task processing). It is this issue to make it possible to accept interrupts.
尚、PLCにおけるアプリケーションプログラムには、例えば図23に示すようにラダー図のような、順次命令実行を行い、直前の命令実行結果を得て次の命令実行へ移るとい
った“シーケンシャル処理”がある。また、例えば、IEC61131-3で規定されているFBD(Function Block Diagram)やST(Structured Text)言語で表現されるような、ある条件が満足されたらある実行を行うといった“判断処理”もある。
Note that the application program in the PLC includes “sequential processing” in which, for example, as shown in a ladder diagram in FIG. 23, sequential instruction execution is performed and the immediately preceding instruction execution result is obtained and the next instruction execution is started. Also, for example, there is a “determination process” in which a certain execution is performed when a certain condition is satisfied, as expressed in an FBD (Function Block Diagram) or ST (Structured Text) language defined in IEC61131-3.
このようにプログラム言語としては、アクセス関数が用途に応じた最適インタフェースを備えていることが望まれる。すなわち、メモリアクセス命令で当てはめると、ラダー図であればメモリアクセスが完了してから、次の命令に実行が移ってほしい。一方、FBDであればメモリアクセスが完了していなくても、とりあえずメモリアクセス要求だけ発しておいて次の命令実行に移り、次のスキャンでメモリアクセスが完了しているかいないか判別して相応の処理が行えればよい。 As described above, as a programming language, it is desirable that the access function has an optimum interface corresponding to the application. In other words, if it is applied with a memory access instruction, if it is a ladder diagram, I want the execution to move to the next instruction after the memory access is completed. On the other hand, even if the memory access is not completed with FBD, only the memory access request is issued for the time being and the next instruction is executed, and it is determined whether the memory access is completed in the next scan. It only needs to be able to process.
(課題2)
上記FBDやST言語の場合、アプリケーションプログラムには、メモリアクセス命令が、1つだけでなく複数含まれる。それぞれのアクセス命令が実行されるタイミングはプログラム処理の流れによって決定するため、1スキャンで複数の共有メモリアクセス要求が発生し得る。例えば、図25に示すように、1タスク内に多数のFB(ファンクションブロック)が存在し、図示の1スキャンでFB1〜FB100の100個のFBの命令が実行される場合であって、このFB1〜FB100全てが共有メモリアクセス要求を発生するものである場合、1スキャンで100個の共有メモリアクセス要求が発生し得る。このような場合であっても、アクセス要求発生順に順次アクセスを実行させることが本課題である。尚、1タスク内の複数の命令を、始めから終わりまで全て実行することを1スキャンと呼んでいる。
(Problem 2)
In the case of the FBD or ST language, the application program includes a plurality of memory access instructions instead of only one. Since the timing at which each access instruction is executed is determined by the flow of program processing, a plurality of shared memory access requests can be generated in one scan. For example, as shown in FIG. 25, there are many FBs (function blocks) in one task, and instructions of 100 FBs FB1 to FB100 are executed in one scan shown in the figure, and this FB1 When all of the
(課題3)
図19に示したように、PLCにはローダ120が接続される場合がある。ローダ120は、一般的に、アプリケーションの変数モニタや変数の書換え、プログラムダウンロード等を行うために接続される。
(Problem 3)
As shown in FIG. 19, a
アプリケーション実行中に共有メモリ上の変数をモニタしたいといった場合に、ローダ120からモニタコマンドが発行され、マイコン111がモニタコマンドを受けて、アプリケーションを中断するか又はスキャンエンド(アプリケーションを実行していない状態)で、システムソフトが共有メモリアクセスを行う。
When it is desired to monitor a variable in the shared memory during execution of the application, a monitor command is issued from the
既に述べたように、共有メモリアクセス中にはマイコン111にはWAITが掛かるので、図24に示すように、ローダ120からのモニタコマンドに応じた共有メモリアクセス中には、アプリケーションは一切実行されない。すなわち、デフォルトタスクは中断されるし、0レベルタスク、1レベルタスクのような定周期タスクの実行タイミングになっても、割込みが受け付けられないため、実行されない。
As already described, since WAIT is applied to the microcomputer 111 during the shared memory access, no application is executed during the shared memory access according to the monitor command from the
この様に、ローダ120からモニタ要求があると、アプリケーション実行がされない又は実行が遅れるという問題点があり、この様なローダ120からの要求に影響されずにアプリケーションを実行できるようにすることが本課題である。
As described above, when there is a monitor request from the
また、上記特許文献1に記載の従来技術は、本例に当て嵌めれば、上記図19におけるCPUモジュール110(マスタに相当)とI/Oモジュール104(スレーブに相当)との間の話であり、I/Oモジュール104が、自己に接続している周辺メモリに対する書き込みを行う前に、直ちに、CPUモジュール110へウェイト信号を返信することに相当する技術であり、共有メモリアクセスの話ではない。すなわち、特許文献1では、複数のスレーブが接続されたバスである為、直ちにバスを解放することに意味があるが、共有メモリの場合、アクセスが完了していないのにバスを解放しても意味がない。
Further, the conventional technique described in
更に、特許文献1では、結局、バスを介して、マスタ−スレーブ間でデータ送受信する為の時間が掛かる。また、特許文献1では、上記課題1で述べたようなマルチタスクにおける問題には対応できないし、課題2のような1スキャンで多数のアクセス命令が生じる場合にも対応できない。課題3についても同様である。
Furthermore, in
本発明の課題は、マイコンが共有メモリ等のアクセスタイムの長いデバイス(低速デバイス)をアクセスする場合に、アクセス実行完了を待たずに、他の処理を実行可能にしたり割込み受付可能な状態にすることであり、特にマイコンが複数レベルのタスクを実行可能な場合にも対応可能とすることであり、又はタスク内で複数FBがアクセス要求を発生させても要求発生順に順次要求が処理されるようにでき、あるいはモニタ要求等のようなCPUモジュール外部(又PLC外部)からの要求に起因する低速デバイスアクセスを行っても影響されずにアプリケーションを実行可能にするプログラマブルコントローラのCPUモジュール、当該プログラマブルコントローラ等を提供することである。 The problem of the present invention is that when a microcomputer accesses a device (low speed device) having a long access time such as a shared memory, other processing can be executed or an interrupt can be accepted without waiting for completion of access execution. In particular, it is possible to cope with a case where the microcomputer can execute a task of a plurality of levels, or even if a plurality of FBs generate an access request in the task, the requests are sequentially processed in the order in which the requests are generated. Or a programmable controller CPU module that enables an application to be executed without being affected by a low-speed device access caused by a request from the outside of the CPU module (or outside the PLC) such as a monitor request, and the like Etc. is to provide.
本発明のプログラマブルコントローラのCPUモジュールは、複数レベルのタスクを実行する処理ユニットと、該処理ユニットからの要求に応じて低速デバイスにアクセスするインタフェースユニットとを有するCPUモジュールであって、該インタフェースユニットは、前記複数のレベル各々に応じた複数のアクセスチャネルを有し、前記処理ユニットは、前記何れかのレベルのタスクを実行中に前記低速デバイスへのアクセス要求が発生した場合、該タスクのレベルに応じた前記アクセスチャネルに対して低速デバイスアクセス処理の実行を依頼するアクセス処理手段を有し、前記インタフェースユニットは、該アクセス処理手段からの依頼の受付完了した時点で、前記低速デバイスアクセス処理の実行の依頼に伴ってWAIT状態となっていた前記処理ユニットの該WAIT状態を解除し、その後に、該依頼に基づく前記低速デバイスへのアクセスを実行する。
The CPU module of the programmable controller of the present invention is a CPU module having a processing unit for executing a task at a plurality of levels and an interface unit for accessing a low-speed device in response to a request from the processing unit. A plurality of access channels corresponding to each of the plurality of levels, and when the access request to the low-speed device is generated while executing the task at any level, the processing unit is set to the level of the task. An access processing unit that requests execution of the low-speed device access process for the corresponding access channel, and the interface unit executes the low-speed device access process when reception of the request from the access processing unit is completed. WAIT state with the request of Releasing the said WAIT state of the processing unit, thereafter, it executes the access to the low-speed device based on the request.
上記CPUモジュールにおいては、当該CPUモジュール外の任意の低速デバイスにアクセスする場合、インタフェースユニットが処理ユニットからの依頼に応じて低速デバイスアクセス処理を実行するが、その際、依頼受付完了した時点で、処理ユニットのWAIT状態を解除する。よって、処理ユニットは他の処理を実行可能となり、割り込みも受付可能となる。 In the CPU module, when accessing any low-speed device outside the CPU module, the interface unit executes low-speed device access processing in response to a request from the processing unit. Release the WAIT status of the processing unit. Therefore, the processing unit can execute other processes and can accept interrupts.
特に、上記構成では、インタフェースユニットは、複数のレベル各々に応じた複数のアクセスチャネルを有している。
これによって、例えば、前記処理ユニットは、前記WAIT状態の解除によって、前記アクセス要求が発生したタスクより上位レベルのタスクの実行が可能となり、前記アクセス処理手段は、該上位レベルのタスクを実行中に前記低速デバイスへのアクセス要求が発生した場合、該タスクのレベルに応じた前記アクセスチャネルに対して低速デバイスアクセス処理の実行を依頼することができる。
In particular, in the above configuration, the interface unit has a plurality of access channels corresponding to each of a plurality of levels.
Thereby, for example, the processing unit can execute a task at a higher level than the task for which the access request has been generated by releasing the WAIT state, and the access processing means can execute the task at the higher level. When an access request to the low-speed device is generated, it is possible to request the access channel corresponding to the task level to execute low-speed device access processing.
また、例えば、前記タスクのアプリケーションがシーケンシャル処理を実行するものである場合、前記アクセス処理手段は、該アプリケーションにおける任意の命令実行に伴い前記アクセスチャネルに対する低速デバイスアクセス処理の実行依頼後、該依頼先のアクセスチャネルに対する定期的なポーリングを行って低速デバイスアクセス処理の実行完了を待つ。 Also, for example, when the application of the task executes sequential processing, the access processing means may request the execution of the low-speed device access processing for the access channel in response to execution of an arbitrary instruction in the application. The access channel is periodically polled and the completion of the low-speed device access processing is awaited.
上記シーケンシャル処理を実行するアプリケーションとは、例えばラダー図のように、順次命令実行を行い、直前の命令実行結果を得て次の命令実行へ移るといった処理を行うものである。この場合、直前の命令実行完了しなければ次の命令実行に移れないので、上記ポーリングを行って実行完了を待つことになる。但し、上位レベルのタスクの割り込み
があった場合、当該上位レベルのタスクを実行することはできる。
The application that executes the sequential process is a process that sequentially executes instructions, obtains the previous instruction execution result, and shifts to the next instruction execution as shown in a ladder diagram, for example. In this case, since the next instruction cannot be executed unless the immediately preceding instruction execution is completed, the polling is performed and the completion of the execution is awaited. However, when an upper level task is interrupted, the upper level task can be executed.
また、例えば、前記タスクのアプリケーションが判断処理を実行するものである場合、前記アクセス処理手段は、該アプリケーションにおける任意の命令実行に伴い前記アクセスチャネルに対する低速デバイスアクセス処理の実行依頼後、次の命令実行に移る。 Also, for example, when the application of the task is to execute a determination process, the access processing means, after executing an arbitrary instruction in the application, requests execution of a low-speed device access process for the access channel, Move on to execution.
上記判断処理を実行するアプリケーションとは、例えばFBDで表現されるアプリケーションのように、前の命令の実行完了を待たずに次の命令に移れるものである。この為、ポーリングを行うことなく、直ちに、アプリケーションに戻り、次の命令を実行可能としている。 An application that executes the above determination processing is an application that can move to the next instruction without waiting for completion of execution of the previous instruction, such as an application expressed in FBD. For this reason, it is possible to immediately return to the application without executing polling and execute the next instruction.
但し、判断処理を実行するものである場合、1スキャンで複数の共有メモリアクセス要求が発生し得る。これに対応する為に、例えば以下の構成を追加する。すなわち、例えば、
前記タスクのアプリケーションが判断処理を実行するものである場合、前記処理ユニットは、各レベルに応じた記憶手段を更に有し、前記アクセス処理手段は、該アプリケーションにおける任意の命令実行に伴い低速デバイスアクセス要求が発生する毎に、該要求を該アプリケーションのレベルに対応する前記記憶手段に格納し、前記インタフェースユニット側で低速デバイスアクセス処理が完了する毎に、該記憶手段に記憶されている要求の中で最も古い要求を取り出して、前記インタフェースユニットに対して低速デバイスアクセス処理を依頼する。
However, when the determination process is executed, a plurality of shared memory access requests can be generated in one scan. In order to deal with this, for example, the following configuration is added. That is, for example,
When the application of the task is to execute a determination process, the processing unit further includes a storage unit corresponding to each level, and the access processing unit accesses a low-speed device according to execution of an arbitrary instruction in the application. Each time a request occurs, the request is stored in the storage means corresponding to the level of the application, and each time the low-speed device access processing is completed on the interface unit side, the request stored in the storage means The oldest request is taken out, and the interface unit is requested to perform low-speed device access processing.
また、例えば、前記インタフェースユニットは、システム用アクセスチャネルを更に備え、前記アクセス処理手段は、前記タスクのアプリケーション以外による低速デバイスアクセス要求が発生すると、前記システム用アクセスチャネルに対して低速デバイスアクセス処理を依頼し、前記インタフェースユニットは、該アクセスチャネルへの依頼が完了すると、前記処理ユニットのWAIT状態を解除し、該システム用アクセスチャネルは、低速デバイスアクセス処理が完了すると、前記処理ユニットに対して、アクセス完了割込みを出力する。 In addition, for example, the interface unit further includes a system access channel, and the access processing means performs a low-speed device access process on the system access channel when a low-speed device access request is generated by an application other than the task application. The interface unit releases the WAIT state of the processing unit when the request to the access channel is completed, and the system access channel sends the processing unit to the processing unit when the low-speed device access processing is completed. An access completion interrupt is output.
上記構成によってタスクのアプリケーション以外に起因するバスアクセス要求の場合にも対応可能となる。更に、依頼後、ポーリングを行う必要が無く、完了割込みで例えばリードデータの取り込み等を行えるので、処理ユニットの処理能力を無駄なく使用できる。 With the above configuration, it is possible to cope with a bus access request caused by other than the task application. Furthermore, there is no need to perform polling after the request, and for example, read data can be fetched by a completion interrupt, so that the processing capability of the processing unit can be used without waste.
本発明のプログラマブルコントローラのCPUモジュール、当該プログラマブルコントローラ等によれば、マイコンが共有メモリ等のアクセスタイムの長いデバイス(低速デバイス)をアクセスする場合に、アクセス実行完了を待たずに、他の処理を実行可能にしたり割込み受付可能な状態にすることができ、特にマイコンが複数レベルのタスクを実行可能な場合にも対応できる。また、ラダー図用、FBD用等、用途に応じたインタフェース、仕様のアクセス手段の提供を実現できる。更に、タスク内で複数FBがアクセス要求を発生させても要求発生順に順次要求が処理されるようにできる。あるいは、モニタ要求等のようなCPUモジュール外部(又PLC外部)からの要求に起因する低速デバイスアクセスを行っても影響されずにアプリケーションを実行可能にできる。 According to the CPU module of the programmable controller of the present invention, the programmable controller, etc., when the microcomputer accesses a device (low speed device) having a long access time such as a shared memory, other processing is performed without waiting for completion of access execution. It can be executed or can accept interrupts, especially when the microcomputer can execute multiple levels of tasks. Also, it is possible to provide access means for interfaces and specifications according to applications, such as for ladder diagrams and FBDs. Furthermore, even if multiple FBs generate access requests within a task, the requests can be processed sequentially in the order of request generation. Alternatively, the application can be executed without being affected even when a low-speed device access caused by a request from the outside of the CPU module (or outside the PLC) such as a monitor request is performed.
以下、図面を参照して、本発明の実施の形態について説明する。
本例では、例えば一例として、0レベル、1レベル、デフォルトタスクの3レベルのタスクを実行可能なPLCを想定する。
Embodiments of the present invention will be described below with reference to the drawings.
In this example, for example, a PLC capable of executing tasks of three levels of 0 level, 1 level, and default task is assumed.
図1に、実施例1、2におけるバスインタフェースの構成例を示す。
また、図2に、本例のプログラマブルコントローラ全体の構成を示しておく。この全体構成自体は従来と同じである。すなわち、複数のI/Oモジュール4と複数のCPUモジュール10が、I/Oバス3に接続しており、モジュール相互に通信を行う。また、複数のCPUモジュール10は、共有メモリバス2にも接続しており、各CPUモジュール10各々が、共有メモリバス2を介して共有メモリ1にアクセスする。
FIG. 1 shows a configuration example of the bus interface in the first and second embodiments.
FIG. 2 shows the overall configuration of the programmable controller of this example. The overall configuration itself is the same as the conventional one. That is, a plurality of I /
また、各CPUモジュール10は、マイコン21、ROM22、RAM23、バスインタフェース10、I/Oインタフェース25、RDY制御部26を有する。
I/Oインタフェース25は、I/Oバス3に接続しており、他のモジュールとの通信制御を行う。バスインタフェース10は、共有メモリバス2に接続しており、共有メモリ1に対するアクセス制御を行う。
Each
The I /
但し、バスインタフェース10の構成・動作は従来とは異なり、マイコン21の動作も従来とは異なる。すなわち、簡単に説明するならば、共有メモリ1へのアクセス要求を受け付ける為の、各タスクレベルに対応する複数のアクセスチャネルを、バスインタフェース10内に備えている。一方、マイコン21に実装されるシステムソフトは、従来のバスアクセス手順とは違うバスアクセス手順を実行する。本例のバスアクセス手順は、従来のように直接共有メモリ1にアクセスする為の手順ではなく、アクセスチャネルに対するリード/ライトを行う手順であり、一例は図5に示し、後に説明する。
However, the configuration / operation of the
図2に示すように、マイコン21を中心としてRAM23、ROM22、バスインタフェース10、I/Oインタフェース25、RDY制御部26の各ブロックでCPUモジュール20が構成される。複数のCPUモジュール20からアクセスが可能な共有メモリ1が共有メモリバス2上に存在し、共有メモリ1を本実施例における低速デバイスと位置付ける。
As shown in FIG. 2, the CPU module 20 is configured by blocks of a
尚、RDY制御部26は、図示していないが、バスインタフェース10だけでなく他の構成(I/Oインタフェース25等)からのRDY信号を集中管理制御する構成であるが、本説明では特に関係ないので、RDY制御部26については特に触れずに、マイコン21−バスインタフェース10間で直接RDY信号をやりとりするものと見做して説明するものとする。
Although not shown, the
ここで、図1に示すバスインタフェース10について説明する。バスインタフェース10は、アクセスチャネルを、PLCで実行可能なアプリケーションタスクレベル数分備えるようにする。本例では、上記の通り、3レベルのタスクを実行可能なPLCを例にしているので、図1に示すように、バスインタフェース10は、レベル0用、レベル1用、デフォルトタスク用の3つのアクセスチャネル11、12,13を備える。これら各アクセスチャネルは、マイコン21から読み書きできるレジスタ群を備える。1つのアクセスチャネルは1度に1つのアクセス要求のみ受け付けられるものとする。よって、同レベルのタスクの要求は、前の要求が完了するまで受け付けられない。
Here, the
図示の例では、各アクセスチャネルは、各々、5つのレジスタを有する。ここではレベル0用アクセスチャネル11を例にすると、コマンドレジスタa、アクセスアドレスレジスタb、ライトデータレジスタc、リードデータレジスタd、及びステータスレジスタeの5本のレジスタを備える。他のアクセスチャネル12,13も同じ構成である。よって、バスインタフェース10は、3チャネル分合計15本のレジスタを持つ。
In the example shown, each access channel has 5 registers each. Here, taking the
マイコン21が上記アクセスチャネルにアクセス要求を書き込むと、以後、バスインタフェース10側が、マイコン21とは独立してバスアクセス(共有メモリアクセス)を実
行する。すなわち、アクセス要求が書き込まれたアクセスチャネルは、その要求コマンド等をアクセス要求キュー14に積む。バスアクセス制御部15は、アクセス要求キュー14から要求コマンドを取り出して共有メモリ1へのアクセス実行を開始する。このアクセス実行が完了したら、要求発行元のアクセスチャネル内のステータスレジスタeの完了ビットがセットされる。
When the microcomputer 21 writes an access request to the access channel, the
アクセス実行中に新たに別なアクセスチャネルへアクセス要求が書き込まれた場合、その要求コマンド等はアクセス要求キュー14に積まれる。前のアクセス完了後、順次キュー14に積まれている次のアクセス要求が実行される。このようにして共有メモリへのアクセスが間断なく行われる。
When an access request is newly written to another access channel during access execution, the request command or the like is loaded in the
アクセスチャネルは、具体的には、例えば、ゲートアレイ、PLD(Programmable Logic Device)等で実現されるディジタル回路である。
以下、更に詳しく説明する。
Specifically, the access channel is a digital circuit realized by, for example, a gate array, a PLD (Programmable Logic Device), or the like.
This will be described in more detail below.
低いレベルのアプリケーションタスクからの要求に応じた共有メモリアクセス中に、マイコン21側で上位レベルタスクによる割り込みが発生し、この上位レベルのアプリケーションタスクを実行中に共有メモリアクセス要求が発生する場合に備えて、上記の通りバスインタフェース10内に、アプリケーションタスクのレベル数と同じ数(ここでは3つ)のアクセスチャネルを用意している。但し、上位レベルのタスクの要求を優先的に処理するわけではない。しかし、例えば、デフォルトタスクがアクセス要求を出し、その後に実行されたレベル1タスクもアクセス要求を出した後、レベル0タスクが実行される場合、レベル0タスクは待たされることなく直ちに実行される。レベルが高いタスクほど、定周期性を崩さずに決められたタイミングで実行することが要求されるので、この点で効果がある。
In preparation for a case where an interrupt by a higher-level task occurs on the microcomputer 21 side during a shared memory access in response to a request from a lower-level application task, and a shared-memory access request is generated while this higher-level application task is being executed. As described above, the same number (three in this case) of access channels as the number of application task levels are prepared in the
マイコン21は、例えば、レベル0のタスクからの共有メモリアクセス要求は、レベル0用アクセスチャネル11にアクセスを依頼し、レベル1のタスクからの共有メモリアクセス要求は、レベル1用アクセスチャネル12にアクセスを依頼する。
For example, the microcomputer 21 requests access to the
このようにアクセスチャネルを介して共有メモリアクセスを行った場合には、ダイレクトに共有メモリアクセスをする場合に比較して、アクセスチャネルへの要求書き込み等に余計な時間が掛かるが、もともとバスアクセス制御部15による共有メモリアクセスの時間が長いため、全体としてアクセス完了までに掛かる時間は、若干増加するに過ぎない。その引き換えに、アクセス完了までの長い時間、マイコン21は別の処理(例えば上位のタスク。あるいは同タスクにおける他の命令)を実行することができる。割り込みも問題なく受け付けられる。
When shared memory access is performed via an access channel in this way, it takes extra time to write a request to the access channel compared to direct shared memory access. Since the shared memory access time by the
図3にこれら各種レジスタのレジスタマップを示す。図3に示す通り、バスインタフェース10が有する不図示のメモリ内の各アドレスが、上記各種レジスタとして割り当てられている。マイコン21は、このレジスタマップを記憶している。そして、例えばレベル1のタスク実行で共有メモリ1へのリード/ライト要求が発生した場合には、例えばアドレスバスには図示のアドレス“+6”を出力し、データバスには共有メモリ1へのアクセスアドレスを出力することで、アクセスチャネル12のアクセスアドレスレジスタbに、共有メモリ1へのアクセスアドレスをセットする。
FIG. 3 shows a register map of these various registers. As shown in FIG. 3, each address in a memory (not shown) of the
図4に上記各種レジスタの構成例を示す。
図4に示す通り、コマンドレジスタaは、リードアクセス要求ビット、ライトアクセス要求ビットの2ビットのみ使用する。例えば、リードアクセス要求があった場合にはリードアクセス要求ビットが‘1’となり、ライトアクセス要求があった場合にはライトアク
セス要求ビットが‘1’となる。
FIG. 4 shows a configuration example of the various registers.
As shown in FIG. 4, the command register a uses only two bits, a read access request bit and a write access request bit. For example, when there is a read access request, the read access request bit is “1”, and when there is a write access request, the write access request bit is “1”.
アクセスアドレスレジスタbには、上記の通り、マイコン21が指定した共有メモリ1へのアクセスアドレスがセットされる。リードデータレジスタcには、リードアクセス要求に対して共有メモリ1から読み出されたリードデータが格納される。ライトデータレジスタdには、ライトアクセス要求に伴いマイコン21が出力した、共有メモリ1への書き込みデータが格納される。
As described above, the access address to the shared
ステータスレジスタeは、アクセス完了/未完了を表す1ビット(完了ビット)のみ使用する。ここでは、この完了ビットが‘0’の場合はアクセス未完了、完了ビットが‘1’の場合はアクセス完了を示すものとする。マイコン21から任意のアクセス要求を受けると完了ビットを‘0’にリセットし、この要求に対する応答をバスアクセス制御部15から受けると、完了ビットを‘1’にセットする。
The status register e uses only one bit (completion bit) indicating access completion / non-completion. Here, it is assumed that when the completion bit is “0”, access is not completed, and when the completion bit is “1”, access is completed. When an arbitrary access request is received from the microcomputer 21, the completion bit is reset to "0". When a response to this request is received from the bus
ここで、図1の構成の動作について説明する。
上記各アクセスチャネル11〜13は、上記の通り、アクセス要求が書き込まれると、その要求コマンド等をアクセス要求キュー14に積む。ここで、マイコン21が書き込む上記アクセス要求には、リードアクセス要求かライトアクセス要求かを示す上記要求コマンド、共有メモリ1へのアクセスアドレスが含まれ、更にライトアクセス要求である場合には共有メモリ1への書き込みデータも含まれる。上記要求コマンドはコマンドレジスタaにセットされ、アクセスアドレスはアクセスアドレスレジスタbに格納され、書き込みデータはライトデータレジスタcに格納される。
Here, the operation of the configuration of FIG. 1 will be described.
As described above, when an access request is written, each of the
そして、上記アクセス要求が書き込まれたアクセスチャネルは、上記要求コマンドと自己の識別情報(レベル0、レベル1、デフォルトの何れであるかを示す情報。予め各アクセスチャネル内に記憶されている)とを(以下、これらをまとめてアクセス要求データと呼ぶ)、アクセス要求キュー14に格納する。アクセス要求キュー14は、FIFO(Fast In
Fast Out)構造となっている。よって、要求発生順にアクセスの実行がなされる。
The access channel in which the access request is written is the request command and its own identification information (information indicating whether it is
Fast Out) structure. Therefore, access is executed in the order of request generation.
バスアクセス制御部15は、任意のアクセス要求に応じた共有メモリ1へのリードアクセス処理又はライトアクセス処理を完了する毎に、アクセス要求キュー14から新たなアクセス要求データを取り出す。その際、上記識別情報は、そのまま、アドレスセレクタ17、ライトデータセレクタ18、及びチャネルセレクタ19に入力され、これらセレクタの選択信号となる。つまり、これら各セレクタは、この識別情報に対応するアクセスチャネルを選択する。よって、バスアクセス制御部15は、これらセレクタを介して、要求元のアクセスチャネルのレジスタからのデータ取得又レジスタへのデータ書き込みを行うことになる。
The bus
すなわち、バスアクセス制御部15は、リード/ライト要求何れの場合でも、アドレスセレクタ17を介して、要求元のアクセスチャネルのアクセスアドレスレジスタbに格納されているデータを読み出す。ライト要求である場合には、更に、ライトデータセレクタ18を介して、要求元のアクセスチャネルのライトデータレジスタcに格納されているデータを読み出す。そして、これら取り出した要求コマンド、読み出したデータに基づいて、共有メモリ1に対するアクセス処理を実行する。そして、アクセス処理完了したら、チャネルセレクタ19を介して、要求元のアクセスチャネルに処理結果を書き込む。リード要求の場合は、処理結果として得られたリードデータをリードデータレジスタdに格納すると共に、ステータスレジスタeの上記完了ビットを‘1’にセットする。ライト要求の場合は、ステータスレジスタeの上記完了ビットを‘1’にセットする。
That is, the bus
そして、バスアクセス制御部15は、アクセス要求キュー14から次のアクセス要求デ
ータを取り出して、上記と同様の処理を実行する。
尚、上記処理は一例を示しているに過ぎない。例えば、バスアクセス制御部15は、アクセス要求キュー14からアクセス要求データを取り出して、コマンドと識別情報の両方を取得し、識別情報に基づいて上記各セレクタを制御するようにしてもよい。
Then, the bus
Note that the above processing is merely an example. For example, the bus
上記の通り、マイコン21が、アクセスチャネルの各レジスタにデータを格納させるが、これについて図5を参照して説明する。図5は、リード要求の場合のアクセスタイミングチャートである。 As described above, the microcomputer 21 stores data in each register of the access channel. This will be described with reference to FIG. FIG. 5 is an access timing chart in the case of a read request.
まず、図1に示す通り、“内部制御信号とRDY生成部”16は、アドレスバスに接続しており、マイコン21から出力される任意のアドレスを入力している。このアドレスは、上述してある通り、任意のアクセスチャネルの任意のレジスタのアドレスであり、共有メモリ1へのアクセスアドレスとは異なるものである。また、“内部制御信号とRDY生成部”16には、マイコン21から出力されるセレクト信号(*CS)とリード/ライト信号(RD/*WT)が入力している。
First, as shown in FIG. 1, the “internal control signal and RDY generator” 16 is connected to the address bus and receives an arbitrary address output from the microcomputer 21. As described above, this address is an address of an arbitrary register of an arbitrary access channel, and is different from an access address to the shared
“内部制御信号とRDY生成部”16は、セレクト信号(*CS)が有効(‘L’)且つリード/ライト信号(RD/*WT)が‘0’のときには、上記アドレスのレジスタに、データバスを介して入力されるデータを書き込む。“内部制御信号とRDY生成部”16は、セレクト信号(*CS)が有効(‘L’)且つリード/ライト信号(RD/*WT)が‘1’のときには、上記アドレスのレジスタに格納されているデータを、データバスを介してマイコン21に出力する。つまり、リード/ライト信号(RD/*WT)が‘0’はライト、‘1’はリードを意味する。尚、マイコン21側は、アドレスバスに出力するアドレスが、上記レジスタa〜dの何れかのアドレスであるときには、セレクト信号(*CS)を有効(‘L’)にする。 The “internal control signal and RDY generator” 16 stores the data in the register at the address when the select signal (* CS) is valid (“L”) and the read / write signal (RD / * WT) is “0”. Write data that is input via the bus. The “internal control signal and RDY generator” 16 is stored in the address register when the select signal (* CS) is valid (“L”) and the read / write signal (RD / * WT) is “1”. The output data is output to the microcomputer 21 via the data bus. That is, in the read / write signal (RD / * WT), “0” means write and “1” means read. The microcomputer 21 makes the select signal (* CS) valid ('L') when the address output to the address bus is one of the addresses in the registers a to d.
また、“内部制御信号とRDY生成部”16は、マイコン21からの指示に応じた上記レジスタへのアクセスが完了する毎に、マイコン21に対してRDY信号“H”を送信する。レジスタへのリード/ライトだけなので、RDY信号“H”は短時間でマイコンに返信されることになる。 The “internal control signal and RDY generation unit” 16 transmits an RDY signal “H” to the microcomputer 21 every time access to the register according to an instruction from the microcomputer 21 is completed. Since only reading / writing to the register is performed, the RDY signal “H” is returned to the microcomputer in a short time.
図5に示す例は上記の通りリード要求の場合なので、マイコン21において図6の処理を実行するシステムソフトは、まず、アクセスアドレスレジスタbのアドレスをアドレスバスに出力すると共に、データバスには共有メモリ1に対するアクセスアドレスを出力する。勿論、その際、マイコン21は、セレクト信号(*CS)を有効(‘L’)にし且つリード/ライト信号(RD/*WT)を‘0’にする。これより、“内部制御信号とRDY生成部”16は、アクセスアドレスレジスタへの書き込み制御を行う。そして、RDY信号‘H’を返す。
Since the example shown in FIG. 5 is a read request as described above, the system software that executes the processing of FIG. 6 in the microcomputer 21 first outputs the address of the access address register b to the address bus and shares it to the data bus. The access address for the
更に続いて、マイコン21は、コマンドレジスタaのアドレスをアドレスバスに出力すると共に、データバスにはリードアクセス要求であることを示す要求コマンドを出力する。リード/ライト信号(RD/*WT)が‘0’なので、“内部制御信号とRDY生成部”16は、コマンドレジスタaへの書き込み制御を行う。そして、RDY信号‘H’を返す。 Subsequently, the microcomputer 21 outputs the address of the command register a to the address bus and also outputs a request command indicating that it is a read access request to the data bus. Since the read / write signal (RD / * WT) is “0”, the “internal control signal and RDY generator” 16 controls the writing to the command register a. Then, the RDY signal 'H' is returned.
その後は、アクセス要求キュー14に従って、順番が来れば、バスアクセス制御部15は、共有メモリ1に対するリード動作制御を行う。そしてリード完了したら、要求発行元のアクセスチャネルのリードデータレジスタdに、共有メモリ1から読み出したリードデータを格納すると共に、ステータスレジスタに“アクセス完了”をセットする(上記“完了ビット”が‘1’となる)。
After that, if the order comes according to the
システムソフトは、コマンドレジスタaへの要求コマンド書込み後は、ステータスレジスタeの“完了ビット”をポーリングしている。すなわち、図5に示す通り、定期的に、アドレスバスにステータスレジスタeのアドレスを出力し、リード/ライト信号(RD/*WT)は‘1’(リード要求)とすることで、ステータスレジスタeのデータを読み出す。当然、共有メモリ1へのアクセスが完了するまでは、完了ビットは‘0’(未完了)となっている。勿論、その都度、直ちにRDY信号‘H’を返すので(WAIT状態を解除するので)、マイコン21の待ち時間は非常に短くて済む。そして、図5の図上右側に示すように、ステータスレジスタeの完了ビットが‘1’にセットされた後にこれを読み出したら、マイコン21はアクセス完了を知るので、図5には示していないが、アドレスバスにリードデータレジスタdのアドレスを出力し、リード/ライト信号(RD/*WT)は‘1’(リード要求)とすることで、共有メモリ1からのリードデータを取得する。以上により共有メモリリードシーケンスが完了する。
The system software polls the “complete bit” of the status register e after writing the request command to the command register a. That is, as shown in FIG. 5, by periodically outputting the address of the status register e to the address bus and setting the read / write signal (RD / * WT) to “1” (read request), the status register e Read the data. Naturally, the completion bit is “0” (incomplete) until the access to the shared
共有メモリ1へのライト要求の場合は、上記アクセスアドレスライト後にライトデータレジスタcに共有メモリ1への書き込みデータをセットし、コマンドレジスタaにはライト要求を示す要求コマンドを書き込む。
In the case of a write request to the shared
マイコン21は、その後、リード要求の場合と同様に、アクセス完了までステータスレジスタeをポーリングしながら待つ。勿論、その間、上位タスクの割り込みが入った場合には、上位タスクの処理が実行されるので、ポーリングは中断される。上位タスクの処理が完了したら、ポーリングを再開することになる。 The microcomputer 21 then waits while polling the status register e until the access is completed, as in the case of the read request. Of course, if an upper-task interrupt occurs during that time, the upper-task processing is executed, so polling is interrupted. When the processing of the upper task is completed, polling is resumed.
ここで、PLCにおけるアプリケーションプログラム例としては、図23に示すラダー図のような、順次命令実行を行い、直前の命令実行結果を得て次の命令実行へ移るといったシーケンシャル処理がある。あるいは、図8に示すようなFBDでのアプリケーション命令もある。 Here, as an example of an application program in the PLC, there is a sequential process as shown in a ladder diagram shown in FIG. 23, in which sequential instruction execution is performed, the immediately preceding instruction execution result is obtained, and the next instruction execution is started. Alternatively, there is an application command in the FBD as shown in FIG.
まず、以下、ラダー図の場合における上記システムソフトの処理について説明する。ここでは、図23に示す例を用いて、まず接点命令を実行し、次にコイル命令を実行する場合の処理について説明する。 First, the processing of the system software in the case of a ladder diagram will be described below. Here, using the example shown in FIG. 23, a process when a contact instruction is first executed and then a coil instruction is executed will be described.
マイコン21においてアプリケーションは、図示の各命令を実行し共有メモリ1へのアクセスが必要になると、上記システムソフトを呼び出す。
システムソフトは、共有メモリ1に対するリード処理の場合には図6の処理を実行し、ライト処理の場合には図7の処理を実行する。すなわち、従来で説明したように、システムソフトは、アプリケーションが呼び出すサブルーチンのような存在であるが、このサブルーチンは複数種類存在し、リード処理の場合は図6の処理を実行するサブルーチンが呼び出され、ライト処理の場合は図7の処理を実行するサブルーチンが呼び出されることになる。これは後述する他の処理フローチャート図の処理についても同様である。
In the microcomputer 21, the application calls the system software when it executes each instruction shown in the drawing and needs to access the shared
The system software executes the process of FIG. 6 in the case of a read process for the shared
ここでは、接点命令に係る処理がリード処理、コイル命令に係る処理がライト処理であるものとする。
図6、図7に示す処理は、既に図5の説明で触れているので、ここでは簡単に説明する。
Here, it is assumed that the process related to the contact command is a read process, and the process related to the coil command is a write process.
The processing shown in FIGS. 6 and 7 has already been described in the description of FIG. 5 and will be briefly described here.
図6に示す処理は、共有メモリからのデータリード要求の処理であり、図7に示す処理は、共有メモリへのデータライト要求の処理である。
図6に示す処理おいて、まず、接点命令のレベルに応じたアクセスチャネルのアクセスアドレスレジスタbに、共有メモリ1へのアクセスアドレスを書き込む処理(ステップS
11)、及びコマンドレジスタaのリードアクセス要求ビットを‘1’にセットする処理(ステップS12)を実行する。そして、その後は、上記ポーリングを行う。すなわち、定期的に上記要求を書き込んだアクセスチャネルのステータスレジスタeをリードし(ステップS13)、完了ビットが‘1’(完了)であれば(ステップS14,YES)、このアクセスチャネルのリードデータレジスタdからデータを読出し、これをアプリケーションに渡す(ステップS15)。これを受けたアプリケーションは、続いてコイル命令を実行する。これによって、図7の処理が実行される。尚、共有メモリからのリードデータは、コイル命令の入力値となる。従って、接点命令の実行が完了するまでは、コイル命令は実行できない。
The process shown in FIG. 6 is a process of a data read request from the shared memory, and the process shown in FIG. 7 is a process of a data write request to the shared memory.
In the process shown in FIG. 6, first, a process of writing an access address to the shared
11) and a process of setting the read access request bit of the command register a to “1” (step S12). Thereafter, the polling is performed. That is, the status register e of the access channel to which the above request has been written is periodically read (step S13), and if the completion bit is '1' (completed) (step S14, YES), the read data register of this access channel Data is read out from d and transferred to the application (step S15). Upon receiving this, the application subsequently executes a coil command. Thereby, the process of FIG. 7 is executed. Note that the read data from the shared memory is the input value of the coil command. Therefore, the coil command cannot be executed until the contact command execution is completed.
図7の処理では、まず、コイル命令のレベルに応じたアクセスチャネルに対して、そのアクセスアドレスレジスタbに共有メモリへのアクセスアドレスを書き込む処理(ステップS21)、そのライトデータレジスタcに共有メモリへの書き込みデータを格納する処理(ステップS22)、及びそのコマンドレジスタのライトアクセス要求ビットを‘1’にセットする処理(ステップS23)を実行する。 In the process of FIG. 7, first, a process of writing an access address to the shared memory in the access address register b for the access channel corresponding to the level of the coil instruction (step S21), and the write data register c to the shared memory Is executed (step S22), and the command register write access request bit is set to '1' (step S23).
そして、その後は、上記ポーリングを行う。すなわち、定期的に上記アクセスチャネルのステータスレジスタeをリードし(ステップS24)、完了ビットが‘1’(完了)であれば(ステップS25,YES)、アプリケーションに完了を知らせ、アプリケーションに戻る。 Thereafter, the polling is performed. That is, the status register e of the access channel is periodically read (step S24), and if the completion bit is ‘1’ (completion) (step S25, YES), the application is notified of completion and the process returns to the application.
尚、上記説明では、「接点命令のレベルに応じた」、「コイル命令のレベルに応じた」と記したが、図23に示す例において接点命令とコイル命令とでレベルが異なるわけではない。同一タスク内の一連の命令全てが、同じレベルである。これは、FBDの場合も同じであり、例えば図25に示す1タスク内の全ての命令(FB)は、同じレベルである(このタスクのレベルである)。 In the above description, “according to the level of the contact command” and “according to the level of the coil command” are described, but in the example shown in FIG. 23, the level is not different between the contact command and the coil command. All of the series of instructions in the same task are at the same level. This is the same in the case of FBD. For example, all instructions (FB) in one task shown in FIG. 25 are at the same level (the level of this task).
上記図6、図7で説明した処理では、アクセスチャネルに対して要求を出した後、アプリケーションに戻らずにシステムソフトの処理を続行する(ポーリングを繰返す)。よって、リード要求であればリードデータを共有メモリ1から得るまで、ライト要求であれば共有メモリ1へのデータライト完了までは、ラダー図の後続命令の実行には移らない。上記の通り、ラダー図は、順次命令実行を行い、直前の命令実行結果を得て次の命令実行へ移るといったシーケンシャル処理であるからである。よって、コイル命令、接点命令ともにシステムソフト層でポーリングを行い、アクセス完了でアプリケーションに戻るようにしている。但し、割込みは受付可能なので、上記のように、より高いレベルのタスクへの遷移は可能である。
In the processing described with reference to FIGS. 6 and 7, after issuing a request to the access channel, the processing of the system software is continued without returning to the application (polling is repeated). Therefore, execution of subsequent instructions in the ladder diagram does not proceed until read data is obtained from the shared
図8(a)、(b)に、FBDで表現されるアプリケーション命令の具体例を示す。
尚、FBの基本概念は国際規格IEC61131-3で規定、説明されている。
図8(a)にはREAD_WORD(リード用FB)、図8(b)にはWRITE_WORD(ライト用FB)の例を示す。尚、図8に示す表記は単にIEC61131-3によるものであり、この例に限るわけではない。
FIGS. 8A and 8B show specific examples of application instructions expressed in FBD.
The basic concept of FB is defined and explained in the international standard IEC61131-3.
FIG. 8A shows an example of READ_WORD (read FB), and FIG. 8B shows WRITE_WORD (write FB). Note that the notation shown in FIG. 8 is simply according to IEC61131-3, and is not limited to this example.
図8(a)に示す命令(READ_WORD)は、入力端子にRQ(アクセス要求)、AD(アクセスアドレス)を備え、出力端子にDONE(完了)、RD(読出しデータ)を備える。DONEが‘1’になると、後段の命令は、本命令(READ_WORD)の実行完了を知り、新たに取得してデータ(共有メモリリードデータ)を用いて命令実行する。 The instruction (READ_WORD) shown in FIG. 8A includes RQ (access request) and AD (access address) at the input terminal, and DONE (complete) and RD (read data) at the output terminal. When DONE becomes “1”, the subsequent instruction knows the completion of execution of this instruction (READ_WORD), and newly executes the instruction using data (shared memory read data).
また入力端子から入力されるデータ、出力端子からの出力データ情報、内部状態情報(EXビット、XRQビット、E_DONEビット)は、1つのFBに1つ割り付けられるインスタンスと
呼ばれるメモリ領域に、格納・保持される。
Data input from the input terminal, output data information from the output terminal, and internal state information (EX bit, XRQ bit, E_DONE bit) are stored and held in a memory area called an instance that is assigned to one FB. Is done.
また、図8(b)に示す命令(WRITE_WORD)は、入力端子にRQ(アクセス要求)、AD(アクセスアドレス)、WD(ライトデータ)、出力端子にDONE(完了)を備える。
図8(a)、(b)において、AD(アクセスアドレス)に共有メモリへのアクセスアドレスが入力された場合に、本処理が実行されることになる。
The command (WRITE_WORD) shown in FIG. 8B includes RQ (access request), AD (access address), WD (write data) at the input terminal, and DONE (complete) at the output terminal.
8A and 8B, this processing is executed when an access address to the shared memory is input to AD (access address).
図9(a)に、実施例1におけるREAD_WORDのインスタンスのデータ構造を示す。
図示のインスタンス80において、EXビット81はアクセス実行中を示すビットである。XRQビット82はRQ端子に前スキャン時に入力された値、RQビット83はRQ端子に今回スキャン時に入力された値であり、XRQビット82が‘0’で且つRQビット83が‘1’の場合、「新要求あり」と判定される(後述するステップS97の判定がYESとなる)。DONEビット84は上記DONE端子の出力データであり、‘1’が完了、‘0’が未完了を意味する。
FIG. 9A shows the data structure of the READ_WORD instance in the first embodiment.
In the illustrated instance 80, the
また、アドレス下位85及びアドレス上位86には、共有メモリ1へのアクセスアドレスが格納される。リードデータ下位87及びリードデータ上位88には、共有メモリ1から読み出されたデータが格納される。図示の通り、当該インスタンス80の先頭アドレスから、それぞれ、+2、+3、+4、+5のアドレスに、上記アドレス下位85、アドレス上位86、リードデータ下位87、リードデータ上位88が格納される。
Further, the address
図9(b)に、上記READ_WORDが呼び出すシステムソフトの処理フローチャート図を示す。
図9において、まず、DONEビットをクリアする(未完了とする)(ステップS91)。そして、アクセス実行中であるか否かを判定する(ステップS92)。これは、上記呼び出し元のREAD_WORDのインスタンス80を参照し、EXビット81=‘1’であればアクセス実行中と判定する。
FIG. 9B shows a process flowchart of the system software called by the READ_WORD.
In FIG. 9, first, the DONE bit is cleared (not completed) (step S91). Then, it is determined whether or not access is being executed (step S92). This refers to the READ_WORD instance 80 of the caller, and if the
もし、アクセス実行中であれば(ステップS92,YES)、当該READ_WORDのレベルに対応するアクセスチャネルのステータスレジスタeをリードし(ステップS93)、その完了ビットが‘1’(完了)であれば(ステップS94,YES)、上記アクセスチャネルのリードデータレジスタdからデータを読出し、これをインスタンス80の上記+4、+5のアドレス(リードデータ下位87、リードデータ上位88)に格納する(ステップS95)。
If the access is being executed (step S92, YES), the status register e of the access channel corresponding to the READ_WORD level is read (step S93), and if the completion bit is “1” (completed) ( In step S94, YES), data is read from the read data register d of the access channel, and stored in the +4 and +5 addresses of the instance 80 (
そして、EXビット81をクリアし(1→0)、DONEビット84をセット(0→1)する(ステップS96)。そして、ステップS101へ進む。アクセス実行中で且つ未完了であれば(ステップS94,NO)、そのままステップS101へ進む。
Then, the
ステップS101では、RQビット83の値をXRQビット82にコピーする。これで本処理は終了し、アプリケーションに戻る
一方、EXビット=‘0’である場合には(アクセス実行なし)(ステップS92,NO)、このREAD_WORDに新たなアクセス要求が発生しているか否かを判定する。これは、上記の通り、XRQビット82が‘0’で且つRQビット83が‘1’の場合、すなわちRQが0から1へと立ち上がった場合に、「新要求あり」と判定される(ステップS97,YES)。「新要求あり」の場合には、まず、インスタンス80の上記+2、+3のアドレスに格納されているデータ(アドレス下位85、アドレス上位86)と要求コマンド(リードorライト)を、それぞれ、当該READ_WORDのレベルに対応するアクセスチャネルのアクセスアドレスレジスタbとコマンドレジスタaにセットする(ステップS98,S99)。そして、EXビット81をセット(0→1)し(ステップS100)、ステップ
S101へ進む。尚、アクセスチャネルは、コマンドレジスタaに要求コマンドがセットされたことをトリガとして、上記要求コマンドと識別情報をアクセス要求キュー14に格納する動作を行う回路構成となっている。
In step S101, the value of the
新要求がない場合には(ステップS97,NO)、そのままステップS101へ進む。
図10に、上記図9の処理のアクセスタイミングチャートを示す。
尚、図10において図上縦の点線は、処理の実行周期を示す。すなわち、縦の点線で示すタイミング毎に、図9の処理が実行される。
When there is no new request (step S97, NO), the process proceeds to step S101 as it is.
FIG. 10 shows an access timing chart of the processing of FIG.
In FIG. 10, the vertical dotted line in the figure indicates the processing execution cycle. That is, the process of FIG. 9 is executed at each timing indicated by a vertical dotted line.
ここでは、アクセス実行中ではないものとし、図上左側に示すように、RQの立ち上がり(0→1)を検出することによって(ステップS97,YES)、アクセスチャネルに対して新規要求を出すことになる。すなわち、上記ステップS98,S99の処理により、アクセスチャネルのレジスタに、アドレスと要求コマンドを書き込む。更に、ステップS100によって、EXビット(EXフラグ)がセットされる。 Here, it is assumed that access is not being executed, and as shown on the left side of the figure, by detecting the rising edge of RQ (0 → 1) (YES in step S97), a new request is issued to the access channel. Become. That is, the address and the request command are written in the access channel register by the processing in steps S98 and S99. Further, the EX bit (EX flag) is set in step S100.
アクセスチャネルは、コマンドレジスタaに要求コマンドがセットされると、上記の通り、この要求コマンド等をアクセス要求キュー14に格納し、これによってその後、共有メモリ1へのアクセス動作(ここではリード)が開始されることになる。そして、アクセス完了すると、アクセスチャネルの上記完了ビットを‘1’にする。これによって、図10の図上右側に示す通り、次の図9の処理実行時に、リードデータの読出し、EXフラグのクリア、DONEビットのセット(ステップS95,S96)が行われる。図10に示す通り、DONEビットは、更に次の図9の処理実行により(そのステップS91の処理により)クリアされるまでの間、セットされており、その間に、アプリケーションは、DONEビット=1であることからリード完了を認識し、リードデータ(87,88)を使用する。
When a request command is set in the command register a, the access channel stores the request command and the like in the
尚、図8(b)に示すWRITE_WORDが呼び出すシステムソフトの処理は、特に図示しないが、図9(a)に示すインスタンスにおいて、アドレス+4、+5の位置に、リードデータ下位87及びリードデータ上位88に代えて、ライトデータ下位、上位が格納されることになり、更に、図9(b)に示すフローチャートにおいてステップS98の処理の後に「インスタンスの+4、+5に格納されているライトデータ(下位と上位)を、アクセスチャネルのライトデータレジスタへセットする」という処理が追加される。更に、ステップS95の処理は必要ないので削除される。 Note that the processing of the system software called by WRITE_WORD shown in FIG. 8B is not particularly shown, but in the instance shown in FIG. 9A, the read data lower 87 and the read data upper 88 are located at addresses +4 and +5. Instead, the lower and upper write data are stored. Further, in the flowchart shown in FIG. 9B, after the processing of step S98, “write data stored in +4 and +5 of the instance (lower and higher) are stored. Is added to the write data register of the access channel. Furthermore, since the process of step S95 is not necessary, it is deleted.
上記図9等の処理では、図6、図7の処理とは異なり、要求を出した後、ポーリングは行わずに、直ちにアプリケーションに戻る。これは、上述してある通り、FBDやST言語で表現されるプログラムでは、メモリアクセスが完了していなくても、とりあえずメモリアクセス要求だけ発しておいて次の命令実行に移り、次のスキャン以降の各スキャンでメモリアクセスが完了しているかいないか判別すればよいからである。接点命令、コイル命令が共有メモリアクセス中は同レベル以下のタスクの命令実行ができなかったのに比べ、アクセス完了までの時間も余すことなく全レベルのタスク実行が可能である。 In the processing of FIG. 9 and the like, unlike the processing of FIG. 6 and FIG. 7, after issuing a request, polling is not performed, and the processing immediately returns to the application. This is because, as described above, in a program expressed in FBD or ST language, even if the memory access is not completed, only the memory access request is issued and the next instruction is executed. This is because it is sufficient to determine whether or not the memory access is completed in each of the scans. Compared to the case where contact instructions and coil instructions cannot execute instructions for tasks at the same level or lower while the shared memory is being accessed, all levels of tasks can be executed without leaving the time until access completion.
尚、“次の命令実行”とは、例えば図25においてFB1がメモリアクセス要求を発したなら、メモリアクセスが完了していなくても、FB2を実行することを意味している。但し、FB1の後段の命令であるFB101も、メモリアクセスが完了しなくてもFB1のアクセス前の出力を用いて命令実行してよい仕様となっている場合には、メモリアクセスが完了していなくても、FB101を実行できる。
Note that “next instruction execution” means that, for example, if FB1 issues a memory access request in FIG. 25, FB2 is executed even if the memory access is not completed. However, even if FB101, which is a subsequent instruction of FB1, has a specification that can be executed using the output before accessing FB1 even if the memory access is not completed, the memory access is not completed. However, the
また、図25に示すタスクの各命令(FB)を実行中に、不図示の上位タスクの割り込みが入った場合には、この上位タスクを実行することになるので、その間、図25に示す
タスクの命令実行は中断される。
In addition, when an upper-level task (not shown) is interrupted during execution of each instruction (FB) of the task shown in FIG. 25, this higher-level task is executed. The command execution is interrupted.
ところで、ここで、上記一例のようにFB1に関してメモリアクセスが完了していない状態でFB2を実行した場合において、FB2でもメモリアクセス要求が発生する可能性はある。FB1とFB2は同一タスクなので、当然、レベルは同じであり、要求先のアクセスチャネルは同じであるので、FB2の要求を受けられないことになる。特に、1タスク内で実行される順番は、FB1→FB2→・・・FB100というように決まっている為、FB1の要求が最優先で受け付けられてしまう為、FB2以降の他のFBはなかなか要求が受け付けられず、特に最後のFB100は、殆ど要求が受け付けられないという事態に成り得る。これが上記課題2に係る問題点となる。従って、要求発生順に、順番に、要求が受け付けられるようにする必要がある。
By the way, when FB2 is executed in a state where memory access is not completed for FB1 as in the above example, there is a possibility that a memory access request may be generated in FB2. Since FB1 and FB2 are the same task, the level is naturally the same and the access channel of the request destination is the same, so that the request of FB2 cannot be received. In particular, since the order of execution within one task is determined as FB1 → FB2 →... FB100, the request of FB1 is accepted with the highest priority, so it is quite a request for other FBs after FB2. Cannot be accepted, and in particular, the
この問題に対して、実施例2を提案する。
以下、実施例2について説明する。実施例2は、上記課題2を解決するものである。
課題2で述べたように(及び上記の通り)、FBDやST言語で表現されるプログラムでは、1タスク内で複数個のアクセス要求発生が起こり得るため、実施例2では、これに対応して、マイコン側21側に、共有メモリアクセス要求を格納するための要求バッファを備えている。要求バッファは、アプリケーションのタスクレベル数分用意する。
Example 2 is proposed for this problem.
Example 2 will be described below. The second embodiment solves the
As described in Problem 2 (and as described above), in a program expressed in FBD or ST language, a plurality of access requests may occur within one task. The microcomputer side 21 has a request buffer for storing a shared memory access request. Prepare as many request buffers as there are application task levels.
図12(a)に、実施例2におけるREAD_WORDのインスタンスのデータ構造を示す。図示のインスタンス40において、EXビット41はアクセス実行中を示すビット、XRQビット42はRQ端子に前スキャン時に入力された値、E_DONE44はアクセスチャネルのアクセス完了/未完了を示すビットである(ON(‘1’)で完了)。また、DONEビット45は上記DONE端子の出力データである。RQビット43はRQ端子に今回スキャン時に入力された値であり、XRQビット42が‘0’で且つRQビット43が‘1’の場合、「新規要求あり」と判定される。
FIG. 12A shows the data structure of an instance of READ_WORD in the second embodiment. In the illustrated instance 40, the
また、アドレス下位46及びアドレス上位47には、共有メモリへのアクセスアドレスが格納される。リードデータ下位48及びリードデータ上位49には、共有メモリから読み出されたデータが格納される。
Further, in the
また、図15(a)に、実施例2におけるWRITE_WORDのインスタンス60のデータ構造を示す。図示の通り、EXビット41〜アドレス上位47までは上記READ_WORDのインスタンス40と同じであるので、同一符号を付してある。インスタンス60には、上記リードデータ下位48及びリードデータ上位49の代わりに、ライトデータ下位61及びライトデータ上位62がある。
FIG. 15A shows the data structure of the
図12(b)に、要求バッファの一例を示す。
図12(b)に示す要求バッファ50は、1タスク内のインスタンスの数(つまり、FBの数;尚、要求バッファ50は、リード、ライト共通で使用される)の分だけ要求キューを格納できる記憶容量を持ち(図示の例では、N個のFBがあり、要求キュー1〜要求キューNまでのN個の要求キューを格納可能)、リングバッファ状に使用される。各要求キューは、要求元FBのインスタンスの先頭アドレス51と要求コマンドデータ52から成る。要求コマンドデータ52のデータフォーマットは、上記アクセスチャネル内のコマンドレジスタaと同じである(要求キューから読み出して、そのまま、コマンドレジスタaに書き込めるようにする為)。
FIG. 12B shows an example of the request buffer.
The
図示のリードポインタRp又はライトポインタWpによって、現在の処理対象である要求キューが指定される。リードポインタRpはアクセスチャネルへの要求を発行するためのポインタ、ライトポインタWpはFBの内部処理でアクセス要求を積むときに使用する。 The request queue that is the current processing target is designated by the illustrated read pointer Rp or write pointer Wp. The read pointer Rp is a pointer for issuing a request to the access channel, and the write pointer Wp is used when an access request is accumulated in the internal processing of the FB.
ソフトウェア処理として、共有メモリアクセスするFBの内部処理(このFBが呼び出すシステムソフト)によって、アクセスチャネルの完了/未完了処理、新たなアクセス要求のキューへの積み上げ、アクセスチャネルへの要求発行を行わせるようにする。 As software processing, the internal processing of the FB that accesses the shared memory (system software called by the FB) performs completion / incomplete processing of the access channel, stacking of new access requests in a queue, and issuing requests to the access channel. Like that.
図11に、上記FB(READ_WORD)が呼び出すシステムソフトの処理フローチャートを示す。また、図11に示すステップS32の詳細フローを図13に示し、ステップS36の詳細フローを図14に示す。 FIG. 11 shows a process flowchart of the system software called by the FB (READ_WORD). Further, a detailed flow of step S32 shown in FIG. 11 is shown in FIG. 13, and a detailed flow of step S36 is shown in FIG.
以下、図11の処理について、その詳細フローも参照して説明する。
尚、以下の説明におけるアクセスチャネルは、当然、上記FB(READ_WORD)のレベルに応じたアクセスチャネルである。但し、上記の通り、同一タスク内の全てのFBのレベルは同じである。
The process of FIG. 11 will be described below with reference to the detailed flow.
The access channel in the following description is naturally an access channel according to the level of the FB (READ_WORD). However, as described above, the levels of all FBs in the same task are the same.
図11において、まず、DONEビットをクリアする(未完了とする)(ステップS31)。そして、アクセスチャネルに対して、現在の状況を確認する処理を行う(ステップS32)。ステップS32の詳細フローは図13に示す。 In FIG. 11, first, the DONE bit is cleared (not completed) (step S31). And the process which confirms the present condition is performed with respect to an access channel (step S32). The detailed flow of step S32 is shown in FIG.
図13において、まず、アクセスチャネルのステータスレジスタeをリードし(ステップS51)、現在の完了ビットの状態が“未完了”である場合には(ステップS52,NO)、現在、全く要求が無い状態であるか、又は何等かの要求に対する処理を実行中であることになるので、アクセスチャネルのコマンドレジスタaをリードして確認する(ステップS60)。その結果、もし、上記リードアクセス要求ビット、ライトアクセス要求ビットの何等かが‘1’であれば(ステップS61,YES)、変数BUSYに‘1’をセットする(ステップS62)。一方、アクセスチャネルが現在何も要求を受け付けていない状態であれば(ステップS61,NO)、そのままステップS59に進み、変数BUSYに‘0’をセットする。 In FIG. 13, first, the status register e of the access channel is read (step S51). If the current completion bit state is “incomplete” (step S52, NO), there is no request at present. Or processing for any request is being executed, the command register a of the access channel is read and confirmed (step S60). As a result, if any of the read access request bit and the write access request bit is “1” (step S61, YES), “1” is set to the variable BUSY (step S62). On the other hand, if the access channel is currently not accepting any request (step S61, NO), the process proceeds to step S59, and '0' is set to the variable BUSY.
一方、ステータスレジスタeの完了ビットが示す状態が“完了”である場合には(ステップS52,YES)、上記リードポインタRpが現在指している位置の要求キューから、要求元のインスタンスの先頭アドレス51と要求コマンドデータ52とを読出す(ステップS53,S54)。つまり、現在アクセスチャネルに依頼しているアクセス要求の要求元FBのインスタンスの特定と、要求コマンドが”リード”なのか”ライト”なのか判別する。尚、本処理の呼び出し元FB(以下、自FB又は自インスタンスと呼ぶ)がアクセス要求元FBとは限らない。例えば、上記例において、仮に、FB1の実行に伴って本処理が呼び出され、現在の要求元がFB2であった場合、ステップS56,S57の処理は、FB2のインスタンスに対して行われることになる。
On the other hand, when the status indicated by the completion bit of the status register e is “completed” (YES in step S52), the
要求コマンドがリードであれば(ステップS55,YES)、アクセスチャネルのリードデータレジスタdからデータを読出し、これを要求元FBのインスタンスの先頭アドレスから+4、+5の領域(リードデータ下位48、リードデータ上位49)に格納する(ステップS56)。そして、ステップS57に進む。一方、要求コマンドがライトであれば(ステップS55,NO)、そのままステップS57に進む。 If the request command is read (step S55, YES), data is read from the read data register d of the access channel, and this is read from the start address of the instance of the request source FB in +4 and +5 areas (read data lower 48, read data). It is stored in the upper 49) (step S56). Then, the process proceeds to step S57. On the other hand, if the request command is write (step S55, NO), the process proceeds to step S57 as it is.
ステップS57では、要求元FBのインスタンス40のE_DONEビット44をONする。更に、アクセスチャネルの完了ビットをクリアする(ステップS58)。そして、変数BUSYに‘0’をセットし(ステップS59)、本処理は終了し、図11のステップS33の処理に進む。
In step S57, the
ステップS33では、アクセス実行中であるか否かを判定する。これは、上記自インス
タンスのEXビット41を参照し、EXビット=‘1’であればアクセス実行中と判定する。アクセス実行中の場合(ステップS33,YES)、続いて、自インスタンスのE_DONEビット44が‘1’(ON)であるか否かを判定する(ステップS34)。上記の通り、ステップS57の処理でE_DONEビット44がONされるが、上述してある通り、これは自FBによる処理でONされるとは限らず、他FBによる処理でONされる場合もあり得る。
In step S33, it is determined whether access is being executed. This refers to the
E_DONEビット44=‘1’であれば(ステップS34,YES)、自インスタンスのEXビット41をクリアし(1→0)、DONEビット45をセットし(0→1)、E_DONEビット44はクリアする(1→0)(ステップS35)。そして、ステップS36へ進む。自FBが要求したアクセス実行中で且つ未完了であれば(ステップS34,NO)、そのままステップS36へ進む。
If the
一方、自インスタンスのEXビット=‘0’であれば(アクセス実行なし)(ステップS33,NO)、この自FBのインスタンスに新たなアクセス要求が発生していれば、要求を出してよい状態である。よって、自インスタンスのXRQビット42とRQビット43をチェックし、新要求がある場合には(ステップS38,YES)、当該インスタンスの先頭アドレスと要求コマンドデータ(リード)とを、上記ライトポインタWpが示す位置の要求キューにセットする(ステップS39,S40)。自インスタンスの先頭アドレスを積むのは、インスタンスが個々のFBに与えられた一意なものだからである。但し、先頭アドレスを用いるのは一例であり、例えば、PLCシステムによりIDが別途存在するならばそれを使用してもかまわない。
On the other hand, if the EX bit of the own instance is “0” (no access execution) (NO in step S33), if a new access request is generated in the instance of the own FB, the request can be issued. is there. Therefore, the
そして、ライトポインタWpの位置を1つ進める(ステップS41)。最後に、自インスタンスのEXビット41をセットし(0→1)(ステップS42)、ステップS36へ進む。新要求がない場合には(ステップS38,NO)、そのままステップS36へ進む。
Then, the position of the write pointer Wp is advanced by one (step S41). Finally, the
ステップS36の処理の詳細フローを図14に示す。
まず、リードポインタRpとライトポインタWpを参照し(ステップS71)、リードポインタRpの位置とライトポインタWpの位置が同じであれば(ステップS72,YES)、未処理の要求は無いことになるので(当然、RpとWpの初期位置は同じにしてある)、アクセスチャネルに対する新規要求発行は行わずに、本処理を終了する。これは、変数BUSYが‘1’である場合(Rpが指す位置の要求キューに対する処理をバスインタフェース側で実行中である場合)(ステップS73,YES)も同様である。
A detailed flow of the process in step S36 is shown in FIG.
First, the read pointer Rp and the write pointer Wp are referred to (step S71). If the position of the read pointer Rp and the position of the write pointer Wp are the same (step S72, YES), there is no unprocessed request. (Of course, the initial positions of Rp and Wp are the same), and this process is terminated without issuing a new request for the access channel. The same applies to the case where the variable BUSY is “1” (when processing for the request queue at the position indicated by Rp is being executed on the bus interface side) (step S73, YES).
要求バッファ50に未処理の要求があり(ステップS72、NO)且つ変数BUSYが‘0’である場合(ステップS73,NO)には、バスインタフェースへの新規要求発行処理を行う。すなわち、まず、Rpが指す位置の要求キューから、要求元のインスタンス(自インスタンスとは限らない)の先頭アドレス51と要求コマンドデータ52を取得する(ステップS74)。そして、取得した要求元インスタンスの先頭アドレスから+2、+3の領域(アドレス下位46、アドレス上位47)から、共有メモリ1へのアクセスアドレスを取得して、これをバスインタフェースのアクセスチャネルのアクセスアドレスレジスタbへセットする(ステップS75)。更に、取得した要求コマンドデータ52がライト要求であれば(ステップS76,YES)、要求元インスタンスの先頭アドレスから+4、+5の領域(この場合は、ライトデータ下位61、ライトデータ上位62となる)から共有メモリ1へのライトデータを取得して、これをバスインタフェースのアクセスチャネル内のライトデータレジスタcへセットする(ステップS77)。そして、取得した要求コマンドデータ52をアクセスチャネル内のコマンドレジスタaへセットする(ステップS78)ことで、バスインタフェースへの新規要求発行処理は完了し、最後に、Rpを1つ進
める(ステップS79)。
When there is an unprocessed request in the request buffer 50 (step S72, NO) and the variable BUSY is “0” (step S73, NO), a new request issue process to the bus interface is performed. That is, first, the
以上説明したステップS36の処理が終了したら、最後にRQビット43の値をXRQビット42にコピーして(ステップS37)、図11に示す処理は終了する。
図15(b)に、上記FB(WRITE_WORD)が呼び出すシステムソフトの処理フローチャートを示す。
When the process of step S36 described above is completed, the value of the
FIG. 15B shows a process flowchart of the system software called by the FB (WRITE_WORD).
図15(b)の処理において、図11と同じ処理は、同一のステップ番号を付してあり、その説明は省略する。図15(b)の処理が図11と異なる点は、図11のステップS40の処理に代えて、図示のステップS81の処理を実行している点のみである。すなわち、要求バッファへのセットにおいて、要求コマンドデータがライト要求であることのみである。 In the processing of FIG. 15B, the same processing as that of FIG. 11 is given the same step number, and the description thereof is omitted. The process of FIG. 15B is different from that of FIG. 11 only in that the process of step S81 shown in the figure is executed instead of the process of step S40 of FIG. In other words, in the setting to the request buffer, the request command data is only a write request.
次に、実施例3について説明する。実施例3は上記課題3を解決するものである。
図16に、実施例3におけるバスインタフェース70の構成図を示す。
図16に示す構成において、図1に示す構成と同一の構成には同一の参照符号を付しており、その説明は省略する。すなわち、図1の構成に加えて、システム用アクセスチャネル71を設けている。
Next, Example 3 will be described. The third embodiment solves the above-mentioned
FIG. 16 shows a configuration diagram of the bus interface 70 in the third embodiment.
In the configuration illustrated in FIG. 16, the same configuration as the configuration illustrated in FIG. 1 is denoted by the same reference numeral, and the description thereof is omitted. That is, a
各アクセスチャネル11〜13が定周期タスクに対応するものであるのに対して、システム用アクセスチャネル71は、例えばローダ30のモニタ要求や、CPUモジュール間のメッセージ通信に対応する。具体的にはローダ30からのモニタコマンドによる低速デバイス(ここでは、共有メモリ1等を指す)へのアクセス要求や、アプリケーション実行サポートの為のCPUモジュール20間のメッセージの遣り取り(ここでは、共有メモリ1を等を利用)等があげられる。これらは、任意のCPUモジュールの外部からの割り込み等に起因し、上記タスクのアプリケーションによって発生したアクセス要求以外の共有メモリアクセス要求に対応するものである。
While each of the
システム用アクセスチャネル71は、割込みによるアクセス完了通知機能を備える。すなわち、バスアクセス(共有メモリアクセス)の完了を、図2に示す割込み信号INTによって、マイコン21に通知する。システム用アクセスチャネル71は、自己のステータスレジスタ内の上記“完了ビット”が‘1’になったら、INT信号を活性化(ON)する。これによって、マイコン21に完了割込みが入り、システムソフトは不図示の割り込み処理を実行する。仮にリード要求を出した場合であれば、システムソフトは当該割込み処理において、リードデータをリードデータレジスタから取り出したのち、図17に示すステータスレジスタ内の完了ビットを0クリアして、割込み処理を終了し、中断していた処理を続行する。システム用アクセスチャネル71は、この0クリアにより、INT信号はOFFする。
The
以上述べたように、実施例3では、マイコン21は、モニタ要求等のようなCPUモジュール外部(又PLC外部)からの要求に起因するバスアクセス要求の発行後、実施例1等の場合と同様に直ちに定周期タスクのアプリケーションに戻ることができるだけでなく、その後のポーリングを行う必要が無く、完了割込みでリードデータの取り込みを行えるので、マイコンの処理能力を無駄なく使用できる。 As described above, in the third embodiment, the microcomputer 21 is the same as in the first embodiment after issuing a bus access request caused by a request from the outside of the CPU module (or outside the PLC) such as a monitor request. In addition to being able to return to the periodic task application immediately, there is no need to perform subsequent polling, and read data can be fetched by a completion interrupt, so that the processing power of the microcomputer can be used without waste.
尚、ここでいう“ポーリング”は、上述したラダー図の場合のようにそのままシステムソフト層に留まって行うポーリングとは異なる。本例の場合、アクセス要求を依頼完了したら、直ちに、定周期タスクアプリケーションに戻ってよいが、当然、アクセス完了したらアクセス結果をローダ等に返信する必要がある為、本来であれば定期的に定周期タスクアプリケーションを中断して、アクセス完了したか否かを確認する必要が生じる。これが
本例におけるポーリングの意味である。しかし、上記本手法では、上記の通り、ポーリングを行う必要がないようにしている。
The “polling” here is different from the polling that is performed as it is in the system software layer as in the ladder diagram described above. In this example, when the access request is completed, you can return to the scheduled task application immediately, but of course, you need to return the access result to the loader when the access is completed. It becomes necessary to interrupt the periodic task application and check whether the access is completed. This is the meaning of polling in this example. However, in this method, as described above, it is not necessary to perform polling.
尚、本実施形態では、アクセス対象は共有メモリとしたが、この例に限らず、アプリケーションがRS232やシリアルEEPROMなど応答の遅いデバイス(これらを総称して低速デバイスと呼ぶものとする)を使う場合にも本発明が適用できる。 In this embodiment, the access target is a shared memory. However, the present invention is not limited to this example, and the application uses devices with slow responses such as RS232 and serial EEPROM (collectively referred to as low-speed devices). The present invention can also be applied to.
1 共有メモリ
2 共有メモリバス
3 I/Oバス
4 I/Oモジュール
10 バスインタフェース
11 アクセスチャネル(レベル0用)
12 アクセスチャネル(レベル1用)
13 アクセスチャネル(デフォルト用)
a コマンドレジスタ
b アクセスアドレスレジスタ
c ライトデータレジスタ
d リードデータレジスタ
e ステータスレジスタ
14 アクセス要求キュー
15 バスアクセス制御部
16 内部制御信号とRDY生成部
17 アドレスセレクタ
18 ライトデータセレクタ
19 チャネルセレクタ
20 CPUモジュール
21 マイコン
22 ROM
23 RAM
25 I/Oインタフェース
26 RDY制御部
30 ローダ
40 インスタンス
41 EXビット
42 XRQビット
43 RQビット
44 E_DONE
45 DONEビット
46 アドレス下位
47 アドレス上位
48 リードデータ下位
49 リードデータ上位
50 要求バッファ
51 要求元のインスタンスの先頭アドレス
52 要求コマンドデータ
60 インスタンス
61 ライトデータ下位
62 ライトデータ上位
70 バスインタフェース
71 システム用アクセスチャネル
80 インスタンス
81 EXビット
82 XRQビット
83 RQビット
84 DONEビット
85 アドレス下位
86 アドレス上位
87 リードデータ下位
88 リードデータ上位
1
12 Access channel (for level 1)
13 Access channel (for default)
a command register b access address register c write data register d read data register
23 RAM
25 I /
45 DONE
Claims (8)
該インタフェースユニットは、前記複数のレベル各々に応じた複数のアクセスチャネルを有し、
前記処理ユニットは、前記何れかのレベルのタスクを実行中に前記低速デバイスへのアクセス要求が発生した場合、該タスクのレベルに応じた前記アクセスチャネルに対して低速デバイスアクセス処理の実行を依頼するアクセス処理手段を有し、
前記インタフェースユニットは、該アクセス処理手段からの依頼の受付完了した時点で、前記低速デバイスアクセス処理の実行の依頼に伴ってWAIT状態となっていた前記処理ユニットの該WAIT状態を解除し、その後に、該依頼に基づく前記低速デバイスへのアクセスを実行することを特徴とするプログラマブルコントローラのCPUモジュール。 A CPU module having a processing unit for executing a multi-level task and an interface unit for accessing a low-speed device in response to a request from the processing unit;
The interface unit has a plurality of access channels corresponding to each of the plurality of levels,
When an access request to the low-speed device is generated during execution of the task at any level, the processing unit requests the access channel according to the task level to execute low-speed device access processing. Having access processing means;
Wherein the interface unit is at the time of the reception completion of the request from the access processing means, said releasing the WAIT state of the processing unit and WAIT state with the request for execution of the low-speed device access process, the subsequent A CPU module of a programmable controller that executes access to the low-speed device based on the request.
前記アクセス処理手段は、該アプリケーションにおける任意の命令実行に伴い低速デバイスアクセス要求が発生する毎に、該要求を該アプリケーションのレベルに対応する前記記憶手段に格納し、前記インタフェースユニット側で低速デバイスアクセス処理が完了する毎に、該記憶手段に記憶されている要求の中で最も古い要求を取り出して、前記インタフェースユニットに対して低速デバイスアクセス処理を依頼することを特徴とする請求項1に記載のプログラマブルコントローラのCPUモジュール。 When the application of the task is to execute a determination process, the processing unit further includes storage means corresponding to each level,
The access processing means stores the request in the storage means corresponding to the level of the application every time a low-speed device access request is generated as a result of execution of an arbitrary instruction in the application, and the low-speed device access is performed on the interface unit side. 2. The method according to claim 1, wherein each time processing is completed, the oldest request among the requests stored in the storage unit is extracted, and the interface unit is requested to perform low-speed device access processing. Programmable controller CPU module.
前記アクセス処理手段は、前記タスクのアプリケーション以外による低速デバイスアクセス要求が発生すると、前記システム用アクセスチャネルに対して低速デバイスアクセス処理を依頼し、
前記インタフェースユニットは、該アクセスチャネルへの依頼が完了すると、前記処理ユニットのWAIT状態を解除し、
該システム用アクセスチャネルは、低速デバイスアクセス処理が完了すると、前記処理ユニットに対して、アクセス完了割込みを出力することを特徴とする請求項1に記載のプログラマブルコントローラのCPUモジュール。 The interface unit further comprises a system access channel;
The access processing means requests a low-speed device access process to the access channel for the system when a low-speed device access request other than the application of the task occurs,
When the interface unit completes the request to the access channel, it releases the WAIT state of the processing unit,
The CPU module of the programmable controller according to claim 1, wherein the system access channel outputs an access completion interrupt to the processing unit when the low-speed device access processing is completed.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2007220439A JP4978373B2 (en) | 2007-08-27 | 2007-08-27 | Programmable controller and its CPU module |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2007220439A JP4978373B2 (en) | 2007-08-27 | 2007-08-27 | Programmable controller and its CPU module |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JP2009053963A JP2009053963A (en) | 2009-03-12 |
| JP4978373B2 true JP4978373B2 (en) | 2012-07-18 |
Family
ID=40504985
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2007220439A Expired - Fee Related JP4978373B2 (en) | 2007-08-27 | 2007-08-27 | Programmable controller and its CPU module |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP4978373B2 (en) |
Families Citing this family (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP5473817B2 (en) * | 2010-07-23 | 2014-04-16 | 三菱電機株式会社 | Programmable controller and bus converter |
| KR101786277B1 (en) | 2011-10-26 | 2017-10-17 | 인텔 코포레이션 | Multi-touch interface schemes |
| EP2975474B1 (en) * | 2014-07-17 | 2018-12-26 | Wago Verwaltungsgesellschaft mbH | Industrial control system and method for transferring data |
| JP7675607B2 (en) * | 2021-09-21 | 2025-05-13 | 株式会社東芝 | Plant Control Device |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP3432728B2 (en) * | 1997-12-12 | 2003-08-04 | 株式会社日立産機システム | Programmable controller |
| JPH11296210A (en) * | 1998-04-07 | 1999-10-29 | Omron Corp | Programmable controller |
| JP2006309579A (en) * | 2005-04-28 | 2006-11-09 | Hitachi Ltd | Storage control device and storage system |
-
2007
- 2007-08-27 JP JP2007220439A patent/JP4978373B2/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| JP2009053963A (en) | 2009-03-12 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| KR100762388B1 (en) | Low-overhead processor interfacing | |
| JP4978373B2 (en) | Programmable controller and its CPU module | |
| KR100708096B1 (en) | How to adjust the bus system and its execution order | |
| US20050188137A1 (en) | Matrix type bus connection system and power reduction method therefor | |
| JP2010176442A (en) | Descriptor transfer device, i/o controller and descriptor transfer method | |
| JP4193746B2 (en) | Matrix bus connection system | |
| WO2013062109A1 (en) | I/o device control system and method for controlling i/o device | |
| CN104077080A (en) | Memory access method, memory access control method, SPI flash memory device and controller thereof | |
| JP2011090485A (en) | Circuit and method for pipe arbitration | |
| JP7294912B2 (en) | control system | |
| JP4649257B2 (en) | Multi CPU system | |
| JP2007172254A (en) | Memory control circuit | |
| JP2018106583A (en) | Semiconductor device | |
| WO2022185581A1 (en) | Control device and data transfer method | |
| WO2018003244A1 (en) | Memory controller, memory system, and information processing system | |
| JP2007506174A (en) | Integrated circuit having a plurality of communication digital signal processors | |
| JP2008146541A (en) | DMA transfer system, DMA controller, and DMA transfer method | |
| WO2020209016A1 (en) | Semiconductor device and debug system | |
| CN120179592B (en) | Multi-slave control system, method, device, program product and storage medium | |
| CN111124987B (en) | PCIE-based data transmission control system and method | |
| JPH11110342A (en) | Bus connection method and device | |
| JPH08249269A (en) | Method and device for controlling dma transfer | |
| JPH11252150A (en) | Network connection device and network connection control method | |
| JP4862593B2 (en) | Data transfer apparatus and image forming apparatus | |
| JP6631370B2 (en) | Microcomputer and electronic control unit |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A625 | Written request for application examination (by other person) |
Free format text: JAPANESE INTERMEDIATE CODE: A625 Effective date: 20100615 |
|
| A711 | Notification of change in applicant |
Free format text: JAPANESE INTERMEDIATE CODE: A712 Effective date: 20110422 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20110906 |
|
| A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20110907 |
|
| RD12 | Notification of acceptance of power of sub attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7432 Effective date: 20111026 |
|
| A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20111102 |
|
| RD14 | Notification of resignation of power of sub attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7434 Effective date: 20111108 |
|
| A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A821 Effective date: 20111026 |
|
| 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: 20120321 |
|
| A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20120403 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20150427 Year of fee payment: 3 |
|
| R150 | Certificate of patent or registration of utility model |
Ref document number: 4978373 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 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 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
| LAPS | Cancellation because of no payment of annual fees |