JP2012128743A - Detection method of stack overflow - Google Patents

Detection method of stack overflow Download PDF

Info

Publication number
JP2012128743A
JP2012128743A JP2010280986A JP2010280986A JP2012128743A JP 2012128743 A JP2012128743 A JP 2012128743A JP 2010280986 A JP2010280986 A JP 2010280986A JP 2010280986 A JP2010280986 A JP 2010280986A JP 2012128743 A JP2012128743 A JP 2012128743A
Authority
JP
Japan
Prior art keywords
area
watchdog
key
stack
watchdog timer
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.)
Granted
Application number
JP2010280986A
Other languages
Japanese (ja)
Other versions
JP5636943B2 (en
Inventor
Yoshihiro Aosaki
義宏 青崎
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.)
NSK Ltd
Original Assignee
NSK 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 NSK Ltd filed Critical NSK Ltd
Priority to JP2010280986A priority Critical patent/JP5636943B2/en
Publication of JP2012128743A publication Critical patent/JP2012128743A/en
Application granted granted Critical
Publication of JP5636943B2 publication Critical patent/JP5636943B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

PROBLEM TO BE SOLVED: To surely detect stack overflow.SOLUTION: At a start-up, watchdog keys KY1 and KY2 are stored in a watchdog key area a11 which is a boundary area between a stack area a1 and a work area a2, and each time when performing a reset operation of a watchdog timer 105, the watchdog keys KY1 and KY2 are read out from the watchdog key area a11 to be utilized for the reset operation. When stack overflow occurs, the watchdog keys KY1 and KY2 in the watchdog key area a11 are written over and the predetermined reset operation cannot be performed, so a reset signal is output to a CPU main body 101 and a micro computer is stopped. Thus, by using a function of the watchdog timer 105, stack overflow detection and corresponding processing at detection of stack overflow are performed.

Description

本発明は、スタックオーバーフローの検出方法に関する。   The present invention relates to a stack overflow detection method.

従来、例えば、メガトルクモータ(登録商標)等のモータを駆動するドライブユニットにおいては、マイクロコンピュータ上でソフトウェアを動作させてモータの駆動制御を行っている。このとき、マイクロコンピュータでは、内蔵されているRAM(Random Access Memory)に各制御変数等を格納するが、このRAMの残りの一部分をスタック領域として使用している。このスタック領域は、ソフトウェア実行中の一時的なデータ格納領域、またはサブルーチンや割込み処理に際して戻り番地を格納する領域などとしても使用される。   Conventionally, for example, in a drive unit that drives a motor such as a Megatorque Motor (registered trademark), the drive of the motor is controlled by operating software on a microcomputer. At this time, the microcomputer stores each control variable or the like in a built-in RAM (Random Access Memory), but uses the remaining part of the RAM as a stack area. This stack area is also used as a temporary data storage area during software execution or an area for storing a return address in a subroutine or interrupt process.

ここで、スタック領域は通常ワーク用メモリ領域と隣接して配置される。このとき、これらスタック領域に空き領域が十分あれば問題はないが、スタック領域の空き領域が不足してしまうとスタック領域に隣接するワーク用メモリ領域もスタック領域として利用してしまい、その結果、ワーク用メモリ領域に格納されているデータが破壊されてしまう可能性がある。   Here, the stack area is arranged adjacent to the normal work memory area. At this time, there is no problem if there is enough free space in these stack areas, but if there is insufficient free space in the stack area, the work memory area adjacent to the stack area is also used as the stack area. Data stored in the work memory area may be destroyed.

また、コード不具合あるいはコンパイラ不具合などによってもスタック領域として確保されたメモリ領域を超えてデータの書き込みが行われてワーク用メモリ領域のデータが破壊されてしまう可能性がある。このようにワーク用メモリ領域のデータが破壊されると、このワーク用メモリ領域のデータを利用して処理を行うソフトウェアプログラムが予期せぬ動作を行う等、不具合が生じる可能性がある。   Further, due to a code defect or a compiler defect, data may be written beyond the memory area secured as the stack area, and the data in the work memory area may be destroyed. When the data in the work memory area is destroyed in this way, there is a possibility that a malfunction may occur such as an unexpected operation of a software program that performs processing using the data in the work memory area.

そのため、このスタック領域のオーバーフローを検出する方法が従来から提案されており、例えば、スタック領域の終端に既知の値を書き込んでおき、周期的にこの既知の値が変化していないことを確認することでスタックオーバーフローを検出する方法(例えば、特許文献1参照)、或いは、タスクディスパッチャの先頭にてスタックサイズ(予め設定されているスタックの使用量)を監視することによって、スタックオーバーフローを検出する方法(例えば、特許文献2参照)などが提案されている。   Therefore, a method for detecting the overflow of the stack area has been proposed in the past. For example, a known value is written at the end of the stack area, and it is confirmed that the known value does not change periodically. A method of detecting a stack overflow (see, for example, Patent Document 1) or a method of detecting a stack overflow by monitoring a stack size (a preset stack usage amount) at the head of a task dispatcher (For example, refer patent document 2) etc. are proposed.

特開2003−22181号公報JP 2003-22181 A 特開平2−293939号公報JP-A-2-293939

しかしながら、上述のように、スタック領域の終端に既知の値を書き込んでおきこの既知の値を周期的に監視する方法にあっては、既知の値を周期的に監視する処理及び異常を検出したときの対応処理をソフトウェアで実行している。同様に、タスクディスパッチャの先頭にてスタックサイズを監視する方法にあっても、スタックサイズを監視する処理及び異常を検出したときにウォッチドッグタイマリセット処理部の動作を禁止する処理をソフトウェアで実行している。   However, as described above, in the method in which a known value is written at the end of the stack area and this known value is periodically monitored, the process of periodically monitoring the known value and an abnormality are detected. The corresponding process is executed by software. Similarly, even in the method of monitoring the stack size at the head of the task dispatcher, the processing for monitoring the stack size and the processing for prohibiting the operation of the watchdog timer reset processing unit when an abnormality is detected are executed by software. ing.

このようにスタック領域のオーバーフローの検出及び異常時の停止動作にソフトウェアを介在させる方法にあっては、例えばスタックオーバーフローによりマイクロコンピュータが無限ループに入ってしまいオーバーフローの検出のための処理を実行することができない場合には、結果的にスタックオーバーフローを検出することができない可能性がある。そのため、より確実性の高いスタックオーバーフローの検出方法が望まれていた。
そこで、この発明は、上記従来の未解決の問題点に着目してなされたものであり、スタックオーバーフローの検出の確実性をより向上させることの可能なスタックオーバーフローの検出方法を提供することを目的としている。
As described above, in the method of interposing software in the detection of the stack area overflow and the stop operation at the time of abnormality, for example, the microcomputer enters an infinite loop due to the stack overflow and executes the process for detecting the overflow. As a result, there is a possibility that stack overflow cannot be detected. Therefore, a more reliable stack overflow detection method has been desired.
Accordingly, the present invention has been made paying attention to the above-mentioned conventional unsolved problems, and an object thereof is to provide a stack overflow detection method capable of further improving the reliability of detection of stack overflow. It is said.

上記目的を達成するために、本発明の請求項1にかかるスタックオーバーフローの検出方法は、スタック領域と当該スタック領域に隣接したワーク領域とを備えた記憶手段を有し、前記スタック領域へのデータの書き込みを行い所定の処理を実行するマイクロコンピュータにおける、スタックオーバーフローの検出方法であって、前記マイクロコンピュータは、予め設定されたウォッチドッグタイマキーを用いてリセット操作が行われるとともにタイムアウトしたときまたは前記ウォッチドッグタイマキーを用いた所定のリセット操作が行われないときに前記マイクロコンピュータに対して所定の異常時の処理を実行するウォッチドッグタイマを有し、起動時に、前記スタック領域と前記ワーク領域との境界領域に前記ウォッチドッグタイマキーを格納し、前記リセット操作を行うときにはその都度、前記境界領域から前記ウォッチドッグタイマキーを読み出して前記リセット操作を行うことを特徴としている。   In order to achieve the above object, a stack overflow detection method according to claim 1 of the present invention comprises a storage means having a stack area and a work area adjacent to the stack area, and data to the stack area is provided. A stack overflow detection method in a microcomputer that performs a predetermined process by writing and when the microcomputer performs a reset operation using a preset watchdog timer key and times out or A watchdog timer for executing a predetermined abnormal process for the microcomputer when a predetermined reset operation using a watchdog timer key is not performed, and at startup, the stack area and the work area; The watchdog timer in the boundary area Stores over, each time when performing the reset operation, is characterized by performing the reset operation from the boundary area by reading the watchdog timer key.

なお、前記ウォッチドッグタイマキーを用いた所定のリセット操作が行われないときとは、例えば、前記ウォッチドッグタイマキーではないキーを用いた操作や、予め設定した所定の手順ではなく異なる手順で操作が行われたときなど、前記所定のリセット操作とは異なる操作が行われたときをいう。
また、請求項2にかかるスタックオーバーフローの検出方法は、ウォッチドッグタイマキーを、前記ワーク領域の1または複数の領域にも格納し、前記境界領域および前記1または複数の領域のうち前記ウォッチドッグタイマキーを読み出す領域を順次切り替え、当該領域から前記ウォッチドッグタイマキーを読み出して前記リセット操作を行うことを特徴としている。
Note that when the predetermined reset operation using the watchdog timer key is not performed, for example, an operation using a key other than the watchdog timer key or a different procedure instead of a predetermined procedure set in advance. The time when an operation different from the predetermined reset operation is performed, such as when the operation is performed.
The stack overflow detection method according to claim 2 also stores a watchdog timer key in one or more areas of the work area, and the watchdog timer of the boundary area and the one or more areas. A key reading area is sequentially switched, and the watchdog timer key is read from the area to perform the reset operation.

また、請求項3にかかるスタックオーバーフローの検出方法は、前記ウォッチドッグタイマキーとして第1および第2のウォッチドッグタイマキーが設定され、前記リセット操作は、前記第1のウォッチドッグタイマキーを所定の書き込み領域に書き込んだ後、前記第2のウォッチドッグタイマキーを前記書き込み領域に書き込む操作であることを特徴としている。
さらに、請求項4にかかるスタックオーバーフローの検出方法は、前記マイクロコンピュータは、アクチュエータ駆動制御用のマイクロコンピュータであることを特徴としている。
さらにまた、請求項5にかかるスタックオーバーフローの検出方法は、前記マイクロコンピュータは、モータ駆動制御用のマイクロコンピュータであることを特徴としている。
According to a third aspect of the present invention, there is provided a stack overflow detection method in which first and second watchdog timer keys are set as the watchdog timer key, and the reset operation is performed by setting the first watchdog timer key to a predetermined value. It is an operation to write the second watchdog timer key to the write area after writing to the write area.
Furthermore, the stack overflow detection method according to claim 4 is characterized in that the microcomputer is a microcomputer for actuator drive control.
Furthermore, the stack overflow detection method according to claim 5 is characterized in that the microcomputer is a microcomputer for motor drive control.

本発明によれば、スタック領域と、ワーク領域との境界領域にウォッチドッグタイマキーを格納し、ウォッチドッグタイマのリセット操作を行うときには、その都度前記境界領域に格納されたウォッチドッグタイマキーを読み出しこれを利用してリセット操作を行い、スタックオーバーフローが生じている場合にはウォッチドッグタイマキーが書き換えられてしまうためリセット操作が正常に行われずに、前記マイクロコンピュータに対して所定の異常時の処理が行われることを利用して、マイクロコンピュータに対する異常時の処理を実行するため、スタックオーバーフローの検出およびスタックオーバーフロー検出時の対応を、ソフトウェア処理のみにより行う場合に比較して、より確実に行うことができる。   According to the present invention, the watchdog timer key is stored in the boundary area between the stack area and the work area, and the watchdog timer key stored in the boundary area is read each time the watchdog timer is reset. Using this, a reset operation is performed, and if a stack overflow occurs, the watchdog timer key is rewritten, so the reset operation is not performed normally, and the microcomputer performs a predetermined abnormality process. In order to execute the processing at the time of abnormality for the microcomputer by using the fact that it is performed, the detection of stack overflow and the response at the time of detection of stack overflow should be performed more reliably than when performing only by software processing Can do.

モータシステムの一例を示すブロック図である。It is a block diagram which shows an example of a motor system. 図1中のDSPの構成を示すブロック図である。It is a block diagram which shows the structure of DSP in FIG. 図2中のRAMの領域図の一例である。It is an example of the area | region figure of RAM in FIG. CPUの処理手順の一例を示すフローチャートである。It is a flowchart which shows an example of the process sequence of CPU. 本発明のその他の実施形態におけるRAMの領域図の一例である。It is an example of the area | region figure of RAM in other embodiment of this invention. 本発明のその他の実施形態におけるRAMの領域図の一例である。It is an example of the area | region figure of RAM in other embodiment of this invention.

以下、本発明の実施の形態を説明する。
図1は、本発明によるスタックオーバーフローの検出方法をメガトルクモータなどのダイレクトドライブモータを用いて、例えば搬送装置などを駆動するモータシステムに適用したものである。
図1において、1はモータコアにレゾルバが組み込まれたメガトルクモータなどのモータ、2はモータ1を駆動制御するドライブユニット、3はドライブユニット2へモータ回転指令などの指令信号を出力するプログラマブルコントローラ等の上位装置である。
Embodiments of the present invention will be described below.
FIG. 1 shows an application of the stack overflow detection method according to the present invention to a motor system that drives, for example, a transport device using a direct drive motor such as a mega torque motor.
In FIG. 1, 1 is a motor such as a megatorque motor in which a resolver is incorporated in a motor core, 2 is a drive unit that drives and controls the motor 1, and 3 is a host device such as a programmable controller that outputs a command signal such as a motor rotation command to the drive unit 2. It is.

ドライブユニット2は、制御部21とパワーアンプ部22とから構成される。制御部21は、マイクロコンピュータ等で構成されるDSP21aと上位装置3との間の入出力処理を行うI/O部21bとを有し、DSP21aは、I/O部21bを介して上位装置3とデータの入出力を行って上位装置3からモータ回転指令を入力し、図示しないレゾルバからの3相のレゾルバ位置検出信号φABCを入力してこれに基づきモータ1の回転角度位置検出を行うとともに、この位置検出結果と上位装置3からのモータ回転指令とに応じて、モータ1を回転駆動させるためのモータ電流指令値を生成する。パワーアンプ部22では制御部21からのモータ駆動電流指令値に応じた3相のUVWモータ駆動電流を生成しこれをモータ1に出力する。
ここで、前記モータ1としてのメガトルクモータは、高分解能の検出器を内蔵し高速高精度の位置決めが可能なダイレクトドライブモータであって、例えば日本精工株式会社製のメガトルクモータ PSシリーズ/PNシリーズ等を適用することができる。
The drive unit 2 includes a control unit 21 and a power amplifier unit 22. The control unit 21 includes a DSP 21a configured by a microcomputer or the like and an I / O unit 21b that performs input / output processing between the host device 3 and the DSP 21a passes through the I / O unit 21b. And a data input / output, a motor rotation command is input from the host device 3, a three-phase resolver position detection signal φABC from a resolver (not shown) is input, and based on this, the rotational angle position of the motor 1 is detected, A motor current command value for rotating the motor 1 is generated according to the position detection result and the motor rotation command from the host device 3. The power amplifier unit 22 generates a three-phase UVW motor drive current corresponding to the motor drive current command value from the control unit 21 and outputs it to the motor 1.
Here, the megatorque motor as the motor 1 is a direct drive motor with a built-in high-resolution detector and capable of high-speed and high-accuracy positioning. For example, Megatorque Motor PS Series / PN series manufactured by NSK Ltd. Can be applied.

前記DSP21aは、図2に示すように、CPU本体101、カウンタ102、RAM(記憶手段)103、ROM104、ウォッチドッグタイマ(WDT)105を備える。このDSP21aとして、例えば、Texas Instruments社のDSP(Digital Signal Processors)であるTMS320F2812を適用することができる。
ウォッチドッグタイマ105は図示しないウォッチドッグカウンタを有し、リセット操作が行われたときにはウォッチドッグカウンタをリセットし、ウォッチドッグカウンタがその最大値を超えてタイムアウトしたときには、CPU本体101をリセットするためのリセット信号をCPU本体101に出力し、CPU本体101の動作を停止させる。
As shown in FIG. 2, the DSP 21 a includes a CPU main body 101, a counter 102, a RAM (storage means) 103, a ROM 104, and a watch dog timer (WDT) 105. As this DSP 21a, for example, TMS320F2812 which is a DSP (Digital Signal Processors) of Texas Instruments can be applied.
The watchdog timer 105 has a watchdog counter (not shown). When the reset operation is performed, the watchdog counter is reset, and when the watchdog counter exceeds its maximum value, the CPU body 101 is reset. A reset signal is output to the CPU main body 101 to stop the operation of the CPU main body 101.

前記ウォッチドッグタイマのリセット操作は、予め設定されたキーコードからなる第1のウォッチドッグキー(ウォッチドッグタイマキー)KY1がレジスタなどで構成される所定のウォッチドッグキー書き込み領域105aに書き込まれた後、予め設定されたキーコードからなる第2のウォッチドッグキー(ウォッチドッグタイマキー)KY2が前記ウォッチドッグキー書き込み領域105aに書き込まれたとき、すなわち、第1のウォッチドッグキーKY1、第2のウォッチドッグキーKY2がこの順に書き込まれたときに、ウォッチドッグタイマ105のリセット操作が行われたと判断し、ウォッチドッグカウンタをリセットする。   The reset operation of the watchdog timer is performed after the first watchdog key (watchdog timer key) KY1 having a preset key code is written in a predetermined watchdog key write area 105a composed of a register or the like. When a second watchdog key (watchdog timer key) KY2 having a preset key code is written in the watchdog key write area 105a, that is, the first watchdog key KY1 and the second watchdog When the dog key KY2 is written in this order, it is determined that the reset operation of the watch dog timer 105 has been performed, and the watch dog counter is reset.

なお、前記ウォッチドッグキー書き込み領域105aに第1のウォッチドッグキーKY1または第2のウォッチドッグキーKY2とは異なる、誤ったキーが書き込まれたとき、また、第1のウォッチドッグキーKY1、或いは、第2のウォッチドッグキーKY2が書き込まれたとしても、これらが、第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2の順に書き込まれない場合には、即時に、CPU本体101をリセットするためのリセット信号をCPU本体101に出力し、CPU本体101の動作を停止させる。   When an incorrect key different from the first watchdog key KY1 or the second watchdog key KY2 is written in the watchdog key writing area 105a, the first watchdog key KY1, or Even if the second watchdog key KY2 is written, if these are not written in the order of the first watchdog key KY1 and the second watchdog key KY2, the CPU body 101 is immediately reset. Reset signal is output to the CPU main body 101 to stop the operation of the CPU main body 101.

前記ROM104には、前記モータ1を駆動制御するための処理プログラムや各種制御定数など各種の情報が格納されるとともに、前記ウォッチドッグタイマ105をリセットするための第1のウォッチドッグキーKY1と第2のウォッチドッグキーKY2とが格納されている。前記RAM103には、図3に示すように、ソフトウェア実行中の一時的なデータ格納領域、またはサブルーチンや割込み処理に際して戻り番地を格納する領域などとして使用されるスタック領域a1と、ソフトウェアにおいて一時的に利用するワーク領域a2とが形成され、スタック領域a1とワーク領域a2とは隣接して設けられている。   The ROM 104 stores various information such as a processing program for controlling the drive of the motor 1 and various control constants, and also includes a first watchdog key KY1 and a second watchdog key KY1 for resetting the watchdog timer 105. The watchdog key KY2 is stored. In the RAM 103, as shown in FIG. 3, a temporary data storage area during software execution, or a stack area a1 used as an area for storing a return address in a subroutine or interrupt processing, and the software temporarily A work area a2 to be used is formed, and the stack area a1 and the work area a2 are provided adjacent to each other.

前記スタック領域a1のサイズは、プログラマーがスタックサイズを見積もることにより予め決定される。さらに、本発明におけるRAM103には、スタック領域a1の、ワーク領域a2との境界にウォッチドッグキー領域a11が形成されている。このウォッチドッグキー領域a11には、前記第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2が書き込まれる。   The size of the stack area a1 is determined in advance by the programmer estimating the stack size. Further, in the RAM 103 according to the present invention, a watchdog key area a11 is formed at the boundary between the stack area a1 and the work area a2. In the watchdog key area a11, the first watchdog key KY1 and the second watchdog key KY2 are written.

そして、CPU本体101は、起動時に、前記ROM104に格納されている処理プログラムや各種制御定数などを読み出しこれをワーク領域a2に書き込むとともに、第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2を、スタック領域a1の、ワーク領域a2との境界に形成されたウォッチドッグキー領域a11に書き込む。なお、ウォッチドッグキー領域a11は、スタック領域a1とワーク領域a2との境界に設けてもよく、またワーク領域a2の、スタック領域a1との境界に設けてもよい。   The CPU main body 101 reads out the processing program and various control constants stored in the ROM 104 and writes them in the work area a2 at the time of activation, and the first watchdog key KY1 and the second watchdog key KY2. Is written in the watch dog key area a11 formed at the boundary between the stack area a1 and the work area a2. Note that the watchdog key area a11 may be provided at the boundary between the stack area a1 and the work area a2, or may be provided at the boundary between the work area a2 and the stack area a1.

そして、以後、ウォッチドッグキー領域a11に格納された第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2を読み出し、これを前記ウォッチドッグタイマがタイムアウトしないタイミングで周期的に前記ウォッチドッグキー書き込み領域105aに第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2の順に書き込んでリセット操作を行う。   Thereafter, the first watchdog key KY1 and the second watchdog key KY2 stored in the watchdog key area a11 are read, and the watchdog key is written periodically at a timing when the watchdog timer does not time out. The first watchdog key KY1 and the second watchdog key KY2 are written in the area 105a in this order to perform a reset operation.

本実施形態では、前記ドライブユニット2により定周期で実行されるモータ1の駆動制御処理の実行周期に同期して行い、前記駆動制御処理を開始する前のタイミングで第1のウォッチドッグキーKY1の書き込みを行って、続いて前記駆動制御処理を実行し、この駆動制御の終了後、この駆動制御に続いて第2のウォッチドッグキーKY2の書き込みを行う。   In the present embodiment, the writing of the first watchdog key KY1 is performed in synchronization with the execution cycle of the drive control process of the motor 1 executed at a fixed cycle by the drive unit 2, and at the timing before the drive control process is started. Then, the drive control process is executed. After the end of the drive control, the second watchdog key KY2 is written following the drive control.

次に、上記実施形態の動作を説明する。
DSP21aは、起動されると、まず初期処理を実行し、ROM104からモータ1の駆動制御処理プログラムやこの駆動制御処理プログラムで必要な各種制御定数などを読み出しRAM103のワーク領域a2に書き込む。また、ROM104に格納されている第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2をRAM103のウォッチドッグキー領域a11に書き込む。
Next, the operation of the above embodiment will be described.
When activated, the DSP 21 a first executes initial processing, reads out the drive control processing program of the motor 1 and various control constants necessary for this drive control processing program from the ROM 104, and writes them in the work area a 2 of the RAM 103. Further, the first watchdog key KY1 and the second watchdog key KY2 stored in the ROM 104 are written in the watchdog key area a11 of the RAM 103.

そして、以後、図4に示すフローチャートにしたがって、モータ1に対する駆動制御処理を定周期で実行する。このとき、まず、ステップS1で、RAM103のウォッチドッグキー領域a11に格納されている第1のウォッチドッグキーKY1を読み出し、これをウォッチドッグタイマ105のウォッチドッグキー書き込み領域105aに書き込む。次に、所定のモータ1の駆動制御処理を実行する(ステップS2)。   Thereafter, the drive control process for the motor 1 is executed at regular intervals according to the flowchart shown in FIG. At this time, first, in step S 1, the first watch dog key KY 1 stored in the watch dog key area a 11 of the RAM 103 is read and written into the watch dog key write area 105 a of the watch dog timer 105. Next, a predetermined motor 1 drive control process is executed (step S2).

次いで、ステップS3に移行し、RAM103のウォッチドッグキー領域a11に格納されている第2のウォッチドッグキーKY2を読み出し、これをウォッチドッグタイマ105のウォッチドッグキー書き込み領域105aに書き込む。以後、この処理を定周期で実行する。
これによって、モータ1の駆動制御が定周期で実行されるとともに、この定周期と同期して、第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2がウォッチドッグタイマ105のウォッチドッグキー書き込み領域105aにこの順に書き込まれる。これら第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2の書き込みは、ウォッチドッグタイマ105のカウンタがタイムアウトしないタイミングである。このため、ウォッチドッグタイマ105は、モータ1の駆動制御処理が実行される定周期のタイミングでリセット操作が行われることになる。
Next, the process proceeds to step S 3, where the second watch dog key KY 2 stored in the watch dog key area a 11 of the RAM 103 is read and written into the watch dog key write area 105 a of the watch dog timer 105. Thereafter, this process is executed at regular intervals.
As a result, the drive control of the motor 1 is executed in a fixed cycle, and the first watchdog key KY1 and the second watchdog key KY2 write the watchdog key 105 to the watchdog timer 105 in synchronization with the fixed cycle. The data are written in the area 105a in this order. The writing of the first watchdog key KY1 and the second watchdog key KY2 is a timing at which the counter of the watchdog timer 105 does not time out. For this reason, the watchdog timer 105 is reset at a fixed cycle when the drive control process of the motor 1 is executed.

この状態で、スタック領域a1のスタックサイズの見積もり誤りなどによって、スタック領域a1がオーバーフローすると、スタック領域a1が満杯となった段階で、ウォッチドッグキー領域a11には別のデータがスタックされるため、ウォッチドッグキー領域a11のデータが書き換えられることになる。つまり、第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2が書き換えられてしまうことになる。   In this state, if the stack area a1 overflows due to an error in estimating the stack size of the stack area a1, etc., another data is stacked in the watchdog key area a11 when the stack area a1 is full. The data in the watchdog key area a11 is rewritten. That is, the first watchdog key KY1 and the second watchdog key KY2 are rewritten.

このため、次の、モータ1に対する駆動制御処理の実行タイミングでは、データの書き換えが行われたウォッチドッグキー領域a11から、第1のウォッチドッグキーKY1に相当するデ―タおよび第2のウォッチドッグキーKY2に相当するデータが読み出され、これが第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2としてウォッチドッグキー書き込み領域105aに書き込まれることになる。   Therefore, at the next execution timing of the drive control process for the motor 1, data corresponding to the first watchdog key KY1 and the second watchdog from the watchdog key area a11 where the data has been rewritten. Data corresponding to the key KY2 is read out and written into the watchdog key writing area 105a as the first watchdog key KY1 and the second watchdog key KY2.

ウォッチドッグタイマ105では、ウォッチドッグキー書き込み領域105aに書き込まれたデータが、真の第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2ではないため、ウォッチドッグタイマ105のリセット操作が行われたと判断せず、この時点で、CPU本体101に対してリセット信号を出力する。これによって、CPU101はリセットされ動作が停止する。
このため、スタック領域1aがオーバーフローすることによってデータの書き換えが行われたワーク領域2aの、誤ったデータに基づいてモータ1の駆動制御処理が実行されることが回避される。
In the watchdog timer 105, since the data written in the watchdog key write area 105a is not the true first watchdog key KY1 and the second watchdog key KY2, the reset operation of the watchdog timer 105 is performed. At this time, a reset signal is output to the CPU main body 101. As a result, the CPU 101 is reset and the operation stops.
For this reason, it is avoided that the drive control process of the motor 1 is executed based on erroneous data in the work area 2a in which the data is rewritten due to the overflow of the stack area 1a.

ここで、上述のように、スタックオーバーフローの検出に伴う処理としては、起動時にROM104の第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2をRAM103の所定のウォッチドッグキー領域a11に書き込む処理と、ウォッチドッグキー領域a11に格納された第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2をウォッチドッグタイマ105のウォッチドッグキー書き込み領域105aに定周期で書き込む処理とのみであり、スタックオーバーフローの検出およびスタックオーバーフローを検出したことに伴う対応は、ウォッチドッグタイマ105によりハードウェア的に行っている。そのため、スタックオーバーフローの検出およびスタックオーバーフローを検出したことに伴う対応をソフトウェア的に行う場合に比較して、より確実性を向上させることができる。   Here, as described above, the processing accompanying the detection of the stack overflow includes the processing of writing the first watchdog key KY1 and the second watchdog key KY2 of the ROM 104 into the predetermined watchdog key area a11 of the RAM 103 at the time of startup. And a process of writing the first watchdog key KY1 and the second watchdog key KY2 stored in the watchdog key area a11 into the watchdog key write area 105a of the watchdog timer 105 at a constant cycle, and the stack. The watchdog timer 105 is used in hardware to handle overflow detection and stack overflow detection. Therefore, the reliability can be further improved as compared with the case where the stack overflow detection and the action associated with the detection of the stack overflow are performed in software.

特に、モータ1としての、メガトルクモータなどのダイレクトドライブモータは、高精度な位置制御を行うことができる反面、ギアボックスなど間接的機構を介さずに直接駆動対象と接続されるため、回転数の変動は回転速度に直接影響することになり、高精度な位置制御が必要なシステムにおいては、多少の回転数の変動がシステムに大きく影響を与える可能性がある。そのため、上述のように、スタックオーバーフローの検出およびスタックオーバーフロー検出時の処理における確実性を向上させることができるということは有効である。   In particular, a direct drive motor such as a megatorque motor as the motor 1 can perform highly accurate position control, but is directly connected to an object to be driven without an indirect mechanism such as a gear box. The fluctuation directly affects the rotational speed, and in a system that requires highly accurate position control, a slight fluctuation in the rotational speed may greatly affect the system. Therefore, as described above, it is effective to improve the reliability in the detection of the stack overflow and the processing at the time of detecting the stack overflow.

また、第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2を、ウォッチドッグタイマ105のウォッチドッグキー書き込み領域105aに書き込む処理は従来から行われている処理であって、読み込み元が、ROM104からRAM103に切り替わっただけであり、スタックオーバーフローの検出およびスタックオーバーフロー検出時の処理はウォッチドッグタイマ105側で行っているため、スタックオーバーフローの検出およびその対応に伴うCPU101の負荷の増加分は、起動時に初期処理としてROM104に記憶された第1のウォッチドッグキーKY1および第2のウォッチドッグキーKY2を、RAM103の所定のウォッチドッグキー領域11aに書き込む処理だけである。したがって、CPU本体101の処理負荷の大幅な増加を伴うことなくスタックオーバーフローの検出の確実性を向上させることができる。   The process of writing the first watchdog key KY1 and the second watchdog key KY2 into the watchdog key write area 105a of the watchdog timer 105 is a conventional process, and the reading source is the ROM 104. Since the stack overflow detection and stack overflow detection processing are performed on the watchdog timer 105 side, the increase in the load on the CPU 101 due to the detection of the stack overflow and the response to it is activated. In some cases, the first watchdog key KY1 and the second watchdog key KY2 stored in the ROM 104 as initial processing are only written to a predetermined watchdog key area 11a of the RAM 103. Therefore, the reliability of detection of stack overflow can be improved without significantly increasing the processing load of the CPU main body 101.

なお、上記実施の形態においては、図4に示すように、第1ウォッチドッグキーKY1の書き込み処理および第2ウォッチドッグキーKY2の書き込み処理を、モータ1の駆動制御処理の前後に行う構成とした場合について説明したがこれに限るものではない。
ウォッチドッグタイマ105がタイムアウトするまでの所要時間に応じて、第1ウォッチドッグキーKY1の書き込み処理および第2ウォッチドッグキーKY2の書き込み処理を、モータ1の駆動制御処理とは独立に実行するように構成してもよい。
In the above embodiment, as shown in FIG. 4, the writing process of the first watchdog key KY1 and the writing process of the second watchdog key KY2 are performed before and after the drive control process of the motor 1. Although the case has been described, the present invention is not limited to this.
The writing process of the first watchdog key KY1 and the writing process of the second watchdog key KY2 are executed independently of the drive control process of the motor 1 according to the time required until the watchdog timer 105 times out. It may be configured.

また、上記実施の形態においては、第1ウォッチドッグキーKY1および第2ウォッチドッグキーKY2を用いてリセット操作を行う場合について説明したが、必ずしも2つのウォッチドッグキーを設ける必要はなく、例えば1つのウォッチドッグキーのみを用いてリセット操作を行うことも可能であり、逆に3以上のウォッチドッグキーを用いてリセット操作を行う構成とすることも可能である。   In the above embodiment, the case where the reset operation is performed using the first watchdog key KY1 and the second watchdog key KY2 is described. However, it is not always necessary to provide two watchdog keys. It is also possible to perform the reset operation using only the watchdog key, and conversely, the reset operation can be performed using three or more watchdog keys.

また、上記実施の形態では、第1ウォッチドッグキーKY1および第2ウォッチドッグキーKY2をこの順にウォッチドッグキー書き込み領域105aに書き込む場合について説明したが、これに限るものではなくウォッチドッグキーの書き込み順も、任意に設定することができる。
また、上記実施の形態においては、図3に示すように、スタック領域a1の、ワーク領域a2との境界部分に1つのウォッチドッグキー領域a11を設けた場合について説明したがこれに限るものではない。
In the above embodiment, the case where the first watchdog key KY1 and the second watchdog key KY2 are written to the watchdog key write area 105a in this order has been described. However, the present invention is not limited to this, and the write order of the watchdog keys is not limited thereto. Can also be set arbitrarily.
In the above embodiment, as shown in FIG. 3, the case where one watchdog key area a11 is provided at the boundary between the stack area a1 and the work area a2 has been described. However, the present invention is not limited to this. .

例えば、図5に示すように、さらにワーク領域a2にもウォッチドッグキー領域a12およびa13を設け、第1から第3のウォッチドッグキー領域a11〜a13のウォッチドッグキーを順番に読み出して、ウォッチドッグタイマ105のリセット操作を行うように構成してもよい。なお、図5では、3つのウォッチドッグキー領域a11〜a13を設けているが、2または4以上のウォッチドッグキー領域を設けることも可能である。
このように、複数のウォッチドッグキー領域を設けることにより、以下の効果を得ることができる。
For example, as shown in FIG. 5, watchdog key areas a12 and a13 are further provided in the work area a2, and the watchdog keys in the first to third watchdog key areas a11 to a13 are read in order, The timer 105 may be reset. In FIG. 5, three watchdog key areas a11 to a13 are provided. However, two or four or more watchdog key areas may be provided.
Thus, by providing a plurality of watchdog key regions, the following effects can be obtained.

すなわち、本モータシステムの動作環境が、電子機器などに囲まれた環境等、比較的ノイズが乗り易い環境にある場合には、ノイズによりスタックポインタの位置が変わる可能性があり、そのためスタック領域a1に設けたウォッチドッグキー領域a11を飛び越えてワーク領域a2へのスタックが行われる可能性がある。この場合、ウォッチドッグキー領域a11へのデータのスタックが行われないため、実際にはワーク領域a2へのスタックが行われているにも関わらず、第1ウォッチドッグキーKY1および第2ウォッチドッグキーKY2が書き換えられないため、スタックオーバーフローが検出されない可能性がある。   That is, when the operating environment of the motor system is an environment in which noise is relatively easy to ride, such as an environment surrounded by electronic devices, the position of the stack pointer may change due to the noise, and therefore the stack area a1. There is a possibility that stacking to the work area a2 is performed over the watchdog key area a11 provided in FIG. In this case, since the data is not stacked on the watchdog key area a11, the first watchdog key KY1 and the second watchdog key are actually stacked despite the fact that the work area a2 is stacked. Since KY2 is not rewritten, stack overflow may not be detected.

しかしながら、ワーク領域a2にもウォッチドッグキー領域を設けているため、仮に、ウォッチドッグキー領域a11へのデータのスタックが行われないままスタックオーバーフローが生じている場合であっても、このスタックオーバーフローによりワーク領域a2に設けたウォッチドッグキー領域a12、或いはウォッチドッグキー領域a13へのデータのスタックが行われたときには、これらウォッチドッグキー領域a12またはa13の第1ウォッチドッグキーKY1或いは第2ウォッチドッグキーKY2が書き換えられた時点で、スタックオーバーフローを検出することができる。このため、より確実にスタックオーバーフローを検出することができる。   However, since the watchdog key area is also provided in the work area a2, even if a stack overflow occurs without stacking data in the watchdog key area a11, the stack overflow causes When data is stacked on the watchdog key area a12 or the watchdog key area a13 provided in the work area a2, the first watchdog key KY1 or the second watchdog key in the watchdog key area a12 or a13 When KY2 is rewritten, a stack overflow can be detected. For this reason, stack overflow can be detected more reliably.

このように複数のウォッチドッグキー領域を設けた場合には、これら領域から順番に、或いは任意の順番でウォッチドッグキーを読み出してウォッチドッグタイマ105のウォッチドッグキー書き込み領域105aに書き込む構成とすればよい。
なお、ワーク領域a2にウォッチドッグキー領域を設けた場合には、このウォッチドッグキー領域は、ワーク領域として利用しないように構成する必要がある。
When a plurality of watchdog key areas are provided as described above, the watchdog keys are read out from these areas or in an arbitrary order and written into the watchdog key writing area 105a of the watchdog timer 105. Good.
When a watchdog key area is provided in the work area a2, this watchdog key area needs to be configured not to be used as a work area.

また、このように、複数のウォッチドッグキー領域を設けた場合、全てのウォッチドッグキー領域に同一のウォッチドッグキーを格納してもよく、また、全てのウォッチドッグキー領域に互いに異なるウォッチドッグキーを格納してもよい。
全てのウォッチドッグキー領域に同一のウォッチドッグキーを格納した場合には、上記と同様に、ウォッチドッグタイマ105において、第1ウォッチドッグキーKY1、第2ウォッチドッグキーKY2の順に、所定のウォッチドッグキー書き込み領域105aに書き込まれたときにリセット操作が行われたと判断すればよい。
When a plurality of watchdog key areas are provided as described above, the same watchdog key may be stored in all watchdog key areas, and different watchdog keys may be stored in all watchdog key areas. May be stored.
When the same watchdog key is stored in all the watchdog key areas, in the same manner as described above, in the watchdog timer 105, in the order of the first watchdog key KY1 and the second watchdog key KY2, a predetermined watchdog key is stored. It may be determined that the reset operation has been performed when the key writing area 105a is written.

このとき、例えば、ウォッチドッグキーの書き込みを行ったにも関わらずCPU本体101に対してリセット信号が出力されたときには、このときの、第1ウォッチドッグキーKY1、および第2ウォッチドッグキーKY2としてのデータを読み出したウォッチドッグキー領域を記憶するように構成し、この記憶した情報を参照することによって、例えば第1ウォッチドッグキー領域a11から読み出したデータである場合には、スタックオーバーフローが生じたと判断し、ワーク領域a2に設定した第2ウォッチドッグキー領域a12または第3ウォッチドッグキー領域a13から読み出したウォッチドッグキーである場合には、ノイズによる影響を考慮する必要があると判断することも可能である。   At this time, for example, when a reset signal is output to the CPU main body 101 in spite of the writing of the watch dog key, as the first watch dog key KY1 and the second watch dog key KY2 at this time The watchdog key area from which the data is read is stored, and by referring to the stored information, for example, in the case of the data read from the first watchdog key area a11, a stack overflow has occurred. If it is a watchdog key read from the second watchdog key area a12 or the third watchdog key area a13 set in the work area a2, it may be determined that it is necessary to consider the influence of noise. Is possible.

一方、ウォッチドッグキー領域毎に異なるウォッチドッグキーを格納した場合には、全てのウォッチドッグキー領域に書き込まれたウォッチドッグキーをウォッチドッグタイマ105側で記憶しておき、ウォッチドッグキー書き込み領域105aにデータが書き込まれたとき、書き込まれたデータが、予め記憶しているウォッチドッグキーのうちの何れかと一致するときにリセット操作が行われたと判断する構成とすればよい。   On the other hand, when different watchdog keys are stored for each watchdog key area, the watchdog keys written in all the watchdog key areas are stored on the watchdog timer 105 side, and the watchdog key write area 105a is stored. When the data is written in, the configuration may be such that it is determined that the reset operation has been performed when the written data matches any of the watchdog keys stored in advance.

また、このとき例えば、ウォッチドッグキー書き込み領域105aに書き込まれたデータの履歴を、少なくともウォッチドッグキー領域の数相当だけ記憶する構成とし、ウォッチドッグキーの書き込みを行ったにも関わらずCPU本体101に対してリセット信号が出力されたときには、この記憶しておいた情報を参照することによって、例えば、ウォッチドッグキーの読み出しをアドレスの小さいもの順など各ウォッチドッグキー領域から順番に行う場合には、この読み出し順番に対応したウォッチドッグキーの並び順と、記憶しておいたウォッチドッグキー書き込み領域105aに書き込まれたデータの履歴とを比較して、どのウォッチドッグキー領域のデータが書き込まれた時点でCPU本体101に対してリセット信号が出力されたかを判断する。そして、これが第1ウォッチドッグキー領域a11から読み出したデータである場合にはスタックオーバーフローが生じたと判断し、第2ウォッチドッグキー領域a12または第3ウォッチドッグキー領域a13から読み出したウォッチドッグキーである場合にはノイズによる影響を考慮する必要があると判断することも可能である。   At this time, for example, the history of data written in the watchdog key writing area 105a is stored at least as much as the number of watchdog key areas, and the CPU body 101 is written despite the writing of the watchdog key. When a reset signal is output, the stored information is referred to, for example, when reading the watchdog key sequentially from each watchdog key area, such as in ascending order of address. By comparing the order of the watchdog keys corresponding to this reading order with the history of the data written in the stored watchdog key write area 105a, the data in which watchdog key area is written At that time, a reset signal was output to the CPU body 101 The judges. If this is data read from the first watchdog key area a11, it is determined that a stack overflow has occurred, and is a watchdog key read from the second watchdog key area a12 or the third watchdog key area a13. In some cases, it can be determined that the influence of noise needs to be taken into account.

さらに、このとき、ワーク領域a2に2つ以上のウォッチドッグキー領域を設けた場合には、少なくとも、ワーク領域a2に設けたウォッチドッグキー領域のうち、読み出し順が最後であるウォッチドッグキー領域についてはワーク領域a2の他のウォッチドッグキー領域および第1ウォッチドッグキー領域a11に格納されるウォッチドッグキーと異なる値に設定する。   Further, at this time, when two or more watchdog key areas are provided in the work area a2, at least the watchdog key area in the reading order among the watchdog key areas provided in the work area a2. Is set to a value different from the watchdog key stored in the other watchdog key area of the work area a2 and the first watchdog key area a11.

このようにすることによって、例えばアドレスの小さいものから順に各ウォッチドッグキー領域から順次ウォッチドッグキーを読み出す場合には、ウォッチドッグキーの書き込みを行ったにも関わらずCPU本体101に対してリセット信号が出力されたときの1周期前の時点でウォッチドッグキー書き込み領域105aに書き込まれたデータが、前記ワーク領域a2中の読み出し順が最後のウォッチドッグキー領域に格納されたウォッチドッグキーである場合には、第1ウォッチドッグキー領域a11のウォッチドッグキーが異常である可能性があると判断することができるため、スタックオーバーフローが生じたと判断することができる。また、前記ワーク領域a2中の読み出し順が最後のウォッチドッグキー領域を除くウォッチドッグキー領域のウォッチドッグキーまたは第1ウォッチドッグキー領域a11のウォッチドッグキーである場合には、ワーク領域a2の何れかのウォッチドッグキー領域のウォッチドッグキーが異常である可能性があると判断することができるため、ノイズによる影響を考慮する必要があると判断することができる。   In this way, for example, when reading the watchdog key sequentially from each watchdog key area in order from the smallest address, the reset signal is sent to the CPU main body 101 in spite of the writing of the watchdog key. When the data written in the watchdog key writing area 105a at the time one cycle before the output of the is the watchdog key stored in the last watchdog key area in the reading order in the work area a2 Since it can be determined that the watchdog key in the first watchdog key area a11 may be abnormal, it can be determined that a stack overflow has occurred. If the reading order in the work area a2 is the watchdog key in the watchdog key area excluding the last watchdog key area or the watchdog key in the first watchdog key area a11, any of the work areas a2 Since it can be determined that there is a possibility that the watchdog key in the watchdog key area is abnormal, it can be determined that it is necessary to consider the influence of noise.

また、ウォッチドッグキーを読み出すウォッチドッグキー領域は、前述のようにアドレスの若い順など順番に読み出す必要はなく、例えば、第1ウォッチドッグキー領域a11と、ワーク領域a2のウォッチドッグキー領域のうちの何れか1つとを交互に読み出し、且つワーク領域a2については読み出すウォッチドッグキー領域を順番に切り替えるなど、任意の順番で読み出すことも可能である。   Further, the watchdog key area for reading the watchdog key does not need to be read out in order of increasing address as described above. For example, the first watchdog key area a11 and the watchdog key area of the work area a2 It is also possible to read out in any order, such as alternately reading out any one of these and switching the watchdog key area to be read out in order for the work area a2.

この場合には、例えば、ウォッチドッグキー書き込み領域105aに書き込まれたデータの履歴を、少なくともウォッチドッグキー領域の数相当だけ記憶する構成とし、ウォッチドッグキーの書き込みを行ったにも関わらずCPU本体101に対してリセット信号が出力されたときには、この記憶しておいたウォッチドッグキー書き込み領域105aに書き込まれたデータの履歴と、予め設定された読み出し順に対応するウォッチドッグキー領域に格納されたウォッチドッグキーの並び順とを比較することで、どのウォッチドッグキー領域のデータが書き込まれた時点でタイムアウトが生じたかを判断するようにすればよい。   In this case, for example, the history of data written in the watchdog key writing area 105a is stored at least as much as the number of watchdog key areas, and the CPU main body is written despite the writing of the watchdog key. When a reset signal is output to 101, the stored history of data written in the watchdog key writing area 105a and the watchdog key area corresponding to the preset reading order are stored. By comparing the order of the dog keys, it is sufficient to determine which watch dog key area data is timed out when the data is written.

また、図6に示すように、スタック領域a1のワーク領域a2との境界にウォッチドッグキー領域a11を設けるだけでなく、さらに、スタック領域a1に、予め設定したキーコードからなる監視キーを格納する監視キー領域a21を設け、この監視キー領域a21に格納された監視キーが変化しないことを定期的に監視する構成としてもよい。なお、監視キー領域a21は、スタック領域a1の例えば、8割、或いは9割程度書き込みが行われたときの領域に相当する位置に設定される。   Further, as shown in FIG. 6, not only a watch dog key area a11 is provided at the boundary between the stack area a1 and the work area a2, but also a monitoring key composed of a preset key code is stored in the stack area a1. A monitoring key area a21 may be provided to periodically monitor that the monitoring key stored in the monitoring key area a21 does not change. The monitoring key area a21 is set at a position corresponding to, for example, an area when about 80% or 90% of the stack area a1 is written.

このように、監視キー領域a21を設けることによって、監視キー領域a21にスタックデータが書き込まれ監視キーが変更された時点で、監視キーが書き換えられたことが検出されることになるため、この時点でスタックオーバーフローが生じる可能性があることを検出することができる。したがって、例えば、監視キーでの監視の結果、監視キーの書き換えが検出されたときに監視キーの書き換えが行われたことを記憶しておく構成とすることによって、実際にはウォッチドッグキー領域a11の書き換えは行われなかったものの、スタック領域a1の8割或いは9割程度が利用されたことを認識することができる。そのため、この情報を収集することによって、例えば新たなモータシステムにおいてスタックサイズを決定する際の参考情報として活用することができる。
なお、この監視キー領域も、スタック領域に複数設けてもよい。
Thus, by providing the monitoring key area a21, it is detected that the monitoring key has been rewritten when the stack data is written to the monitoring key area a21 and the monitoring key is changed. It is possible to detect that a stack overflow may occur. Therefore, for example, when the monitoring key is rewritten as a result of monitoring with the monitoring key, the fact that the monitoring key has been rewritten is stored, so that the watchdog key area a11 is actually stored. However, it is possible to recognize that about 80% or 90% of the stack area a1 has been used. Therefore, by collecting this information, it can be used as reference information for determining the stack size in a new motor system, for example.
A plurality of monitoring key areas may be provided in the stack area.

また、上記実施の形態においては、モータ1としてメガトルクモータなどのダイレクトドライブモータを用いて、例えば搬送装置などを駆動するモータシステムに適用した場合について説明したが、搬送装置や、メガトルクモータなどのダイレクトドライブモータに限るものではなく、モータの回転力を、ギアボックスなど間接的機構を介して駆動対象に伝達するようにしたモータシステムであっても適用することができる。   In the above-described embodiment, the case where the motor 1 is applied to a motor system that drives a transport device using a direct drive motor such as a mega torque motor has been described. The present invention is not limited to a drive motor, and can be applied to a motor system that transmits the rotational force of a motor to an object to be driven via an indirect mechanism such as a gear box.

さらに、上記実施の形態においては、モータシステムのマイクロコンピュータに適用した場合について説明したが、これに限るものではなく、例えばアクチュエータを駆動制御する制御システムのマイクロコンピュータに適用することも可能であり、要は、スタック領域と当該スタック領域に隣接したワーク領域とを備えた記憶手段を有し、前記スタック領域へのデータの書き込みを行いつつ所定の処理を行うマイクロコンピュータであれば適用することができる。   Furthermore, in the above-described embodiment, the case where the present invention is applied to the microcomputer of the motor system has been described. However, the present invention is not limited to this. For example, the present invention can also be applied to the microcomputer of the control system that drives and controls the actuator. In short, it can be applied to any microcomputer that has a storage means having a stack area and a work area adjacent to the stack area and performs predetermined processing while writing data to the stack area. .

1 モータ
2 ドライブユニット
101 CPU本体
103 RAM(記憶手段)
104 ROM
105 ウォッチドッグタイマ
105a ウォッチドッグキー書き込み領域
KY1 第1ウォッチドッグキー(ウォッチドッグタイマキー)
KY2 第2ウォッチドッグキー(ウォッチドッグタイマキー)
DESCRIPTION OF SYMBOLS 1 Motor 2 Drive unit 101 CPU main body 103 RAM (memory | storage means)
104 ROM
105 Watchdog timer 105a Watchdog key write area KY1 First watchdog key (watchdog timer key)
KY2 Second watchdog key (watchdog timer key)

Claims (5)

スタック領域と当該スタック領域に隣接したワーク領域とを備えた記憶手段を有し、前記スタック領域へのデータの書き込みを行い所定の処理を実行するマイクロコンピュータにおける、スタックオーバーフローの検出方法であって、
前記マイクロコンピュータは、予め設定されたウォッチドッグタイマキーを用いてリセット操作が行われるとともにタイムアウトしたときまたは前記ウォッチドッグタイマキーを用いた所定のリセット操作が行われないときに前記マイクロコンピュータに対して所定の異常時の処理を実行するウォッチドッグタイマを有し、
起動時に、前記スタック領域と前記ワーク領域との境界領域に前記ウォッチドッグタイマキーを格納し、
前記リセット操作を行うときにはその都度、前記境界領域から前記ウォッチドッグタイマキーを読み出して前記リセット操作を行うことを特徴とするスタックオーバーフローの検出方法。
A method for detecting a stack overflow in a microcomputer that has a storage means having a stack area and a work area adjacent to the stack area, writes data to the stack area and executes predetermined processing,
When the microcomputer is reset using a preset watchdog timer key and timed out or when a predetermined reset operation using the watchdog timer key is not performed, the microcomputer It has a watchdog timer that executes processing at a specified abnormality,
At startup, the watchdog timer key is stored in the boundary area between the stack area and the work area,
A method for detecting a stack overflow, comprising: reading the watchdog timer key from the boundary area and performing the reset operation each time the reset operation is performed.
ウォッチドッグタイマキーを、前記ワーク領域の1または複数の領域にも格納し、
前記境界領域および前記1または複数の領域のうち前記ウォッチドッグタイマキーを読み出す領域を順次切り替え、当該領域から前記ウォッチドッグタイマキーを読み出して前記リセット操作を行うことを特徴とする請求項1記載のスタックオーバーフローの検出方法。
The watchdog timer key is also stored in one or more areas of the work area,
The area for reading the watchdog timer key among the boundary area and the one or more areas is sequentially switched, and the reset operation is performed by reading the watchdog timer key from the area. How to detect stack overflow.
前記ウォッチドッグタイマキーとして第1および第2のウォッチドッグタイマキーが設定され、
前記リセット操作は、前記第1のウォッチドッグタイマキーを所定の書き込み領域に書き込んだ後、前記第2のウォッチドッグタイマキーを前記書き込み領域に書き込む操作であることを特徴とする請求項1または請求項2記載のスタックオーバーフローの検出方法。
First and second watchdog timer keys are set as the watchdog timer keys,
The reset operation is an operation of writing the second watchdog timer key to the writing area after writing the first watchdog timer key to a predetermined writing area. Item 3. A method for detecting a stack overflow according to Item 2.
前記マイクロコンピュータは、アクチュエータ駆動制御用のマイクロコンピュータであることを特徴とする請求項1から請求項3の何れか1項に記載のスタックオーバーフローの検出方法。   4. The stack overflow detection method according to claim 1, wherein the microcomputer is an actuator drive control microcomputer. 前記マイクロコンピュータは、モータ駆動制御用のマイクロコンピュータであることを特徴とする請求項1から請求項3の何れか1項に記載のスタックオーバーフローの検出方法。   4. The stack overflow detection method according to claim 1, wherein the microcomputer is a motor drive control microcomputer.
JP2010280986A 2010-12-16 2010-12-16 Stack overflow detection method, program, motor system, and transfer device Active JP5636943B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010280986A JP5636943B2 (en) 2010-12-16 2010-12-16 Stack overflow detection method, program, motor system, and transfer device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010280986A JP5636943B2 (en) 2010-12-16 2010-12-16 Stack overflow detection method, program, motor system, and transfer device

Publications (2)

Publication Number Publication Date
JP2012128743A true JP2012128743A (en) 2012-07-05
JP5636943B2 JP5636943B2 (en) 2014-12-10

Family

ID=46645666

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010280986A Active JP5636943B2 (en) 2010-12-16 2010-12-16 Stack overflow detection method, program, motor system, and transfer device

Country Status (1)

Country Link
JP (1) JP5636943B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107729240A (en) * 2017-09-30 2018-02-23 山东省科学院自动化研究所 Embedded software stack overflow detection method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06195476A (en) * 1992-07-21 1994-07-15 Advanced Micro Devicds Inc Integrated circuit for incorporation of microcontroller and method for reduction of power consumption by it
US5454767A (en) * 1993-12-30 1995-10-03 Agco Corporation Powershift transmission control system with turbo boost monitor
JPH07281912A (en) * 1994-04-07 1995-10-27 Nippondenso Co Ltd Stack abnormality detecting device
JP2008172896A (en) * 2007-01-10 2008-07-24 Nsk Ltd Controller of vehicular motor

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06195476A (en) * 1992-07-21 1994-07-15 Advanced Micro Devicds Inc Integrated circuit for incorporation of microcontroller and method for reduction of power consumption by it
US5454767A (en) * 1993-12-30 1995-10-03 Agco Corporation Powershift transmission control system with turbo boost monitor
JPH07281912A (en) * 1994-04-07 1995-10-27 Nippondenso Co Ltd Stack abnormality detecting device
JP2008172896A (en) * 2007-01-10 2008-07-24 Nsk Ltd Controller of vehicular motor

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107729240A (en) * 2017-09-30 2018-02-23 山东省科学院自动化研究所 Embedded software stack overflow detection method and device

Also Published As

Publication number Publication date
JP5636943B2 (en) 2014-12-10

Similar Documents

Publication Publication Date Title
JP5911922B2 (en) Safety-related control unit and control method for automated equipment
US9632860B2 (en) Multicore processor fault detection for safety critical software applications
CN100549986C (en) Signal conditioning package
RU2520399C2 (en) Microcomputer and operation method thereof
JP4917604B2 (en) Storage device configuration and driving method thereof
JP2017187992A (en) Control device, control method and program
JP5041290B2 (en) PROGRAMMABLE CONTROLLER AND ITS ERROR RECOVERY METHOD
CN1173264C (en) Protection of the core part of a computer against external manipulation
JP6007677B2 (en) Safety control system and processor of safety control system
KR20100010390A (en) Microcomputer and method for controlling thereof
JP5636943B2 (en) Stack overflow detection method, program, motor system, and transfer device
JP2009129463A (en) Processing method of temporary error in real time system of vehicle controller
JP2016066139A (en) Vehicle control unit
JP6502211B2 (en) Vehicle control device
JP5327105B2 (en) Backup system
JP5627414B2 (en) Action log collection system and program
JP2020016511A (en) Semiconductor integrated circuit and rotation detector
JP2009520290A (en) Fault-tolerant processor system
JP2011039667A (en) Numerical value controller
EP2615423B1 (en) Method for checking the operability of a digital signal processing unit of a position sensor and position encoder
JP2014225110A (en) Safety controller
CN116069442A (en) Information processing device, vehicle, and information processing method
JP2011108075A (en) Controller
WO2015147829A1 (en) System and method of run-time continuous memory check for embedded systems
JP2006011991A (en) Computer controller and software execution recording mode therefor

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20131003

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20140520

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20140603

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20140716

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: 20140924

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20141007

R150 Certificate of patent or registration of utility model

Ref document number: 5636943

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150