【0001】
【発明の属する技術分野】
本発明は、ユーザプログラムに従って演算する機能を有するプログラマブルコントローラなどにおいて、ユーザプログラムの実行時間を測定する方法に関する。
【0002】
【従来の技術】
一般に、プログラマブルコントローラは図3のような構成になっている。図3において、1はユーザプログラムを作成する機能を有し、作成したユーザプログラムをプログラマブルコントローラ2に送信する手段を有しているプログラム入力装置である。2はプログラマブルコントローラで、ユーザプログラムを記憶しているプログラムメモリ部20と、データメモリ部21と、前記プログラムメモリ部に格納されたユーザプログラムに従って演算する演算部(CPU)22と、外部の信号を取り込むための入力部23と、外部へ信号を出力するための出力部24から構成される。
従来のプログラマブルコントローラ制御装置においてのユーザプログラムの実行時間を測定する方法を図4に示す。図4において3はユーザプログラムで、図3の出力部24より出力信号1を出力するよう命令する外部信号1出力命令30と前記出力部24より出力信号2を出力するよう命令する外部信号2出力命令31が用意されている。4はオシロスコープ等の信号測定機器である。この信号測定機器4に図3の出力部24より出力信号1・出力信号2を測定するようにプログラマブルコントローラ2と接続する。ユーザプログラム3において実行時間を測定したい部分(ユーザプログラム実行時間測定部32)の開始直前に前記外部信号1出力命令30を、終了直後に外部信号2出力命令31を記述しておく。ユーザプログラムを実行すると、外部信号1出力命令30より、図3の出力部24の出力信号1がOFF→ONとなり図4の測定機器4においてプログラム開始パルス40が測定され、ユーザプログラム実行時間測定部32を経て、外部信号2出力命令31より、図3の出力部24の出力信号2がOFF→ONし図4の測定機器4においてプログラム終了パルス41を測定する。プログラム開始パルス40とプログラム終了パルス41の間隔を計測することでユーザプログラムの実行時間を測定することが出来る(例えば、特許文献1参照)。
【0003】
【特許文献1】特開平05−165655号公報
【0004】
【発明が解決しようとする課題】
しかしながら、上記従来のユーザプログラムの実行時間の測定方式においては、プログラマブルコントローラの他に別途信号測定機器を用意しなければならず、更にプログラマブルコントローラから出力信号を取り出して信号測定機器に接続する為に、プログラマブルコントローラの出力端子に出力信号を取り出す為のリード線のはんだ付け等の加工が必要であり、面倒であった。
そこで本発明は、別途信号測定機器を必要とせず、はんだ付け等の加工の必要の無いユーザプログラムの実行時間の測定を可能にすることを目的とする。
【0005】
【課題を解決するための手段】
上記問題を解決するため本発明では、外部の信号を取り込むための入力部と、外部へ信号を出力するための出力部と、クロックパルスをカウントするタイマ部と、データメモリ部と、ユーザプログラムを記憶しているプログラムメモリ部と、プログラムメモリ部に記憶されたユーザプログラムに従って演算する演算部(CPU)を有するプログラマブルコントローラなどの装置において、前記タイマ部のタイマ値をデータメモリ部に記憶する実行時間測定開始命令と、前記タイマ部のタイマ値をデータメモリ部に格納し前記実行時間測定開始命令により格納されたタイマ値との差分から実行時間を計算する実行時間測定終了命令を用意することにより、前記ユーザプログラムの実行時間を測定することを特徴とするプログラム実行時間測定方法である。
【0006】
【発明の実施の形態】
以下この発明の実施例を図1及び図2に基づいて説明する。
図1において、1はユーザプログラムを作成する機能を有し、作成したユーザプログラムをプログラマブルコントローラ2に送信する手段を有しているプログラム入力装置である。2はプログラマブルコントローラで、ユーザプログラムを記憶しているプログラムメモリ部20と、データメモリ部21と、前記プログラムメモリ部に格納されたユーザプログラムに従って演算する演算部(CPU)22と、クロックパルスをカウントするタイマ部25と、外部の信号を取り込むための入力部23と、外部へ信号を出力するための出力部24から構成される。
図2は本発明におけるプログラマブルコントローラ制御装置においてのユーザプログラムの実行時間を測定する方法である。ユーザプログラム3には、前記タイマ部のタイマ値をデータメモリ部に記憶する実行時間測定開始命令33と、前記タイマ部のタイマ値をデータメモリ部に格納し前記実行時間測定開始命令33により格納されたタイマ値との差分から実行時間を計算する実行時間測定終了命令34を用意し、ユーザプログラム3において実行時間を測定したい部分(ユーザプログラム実行時間測定部32)の開始直前に前記実行時間測定開始命令33を、終了直後に前記実行時間測定終了命令34を記述しておく。ユーザプログラム3を実行すると、実行時間測定開始命令33が実行され、タイマ25でカウントされているタイマ値をメモリ21に格納し、実行時間測定開始時のタイマ値D1として保持する。実行時間測定開始命令33実行後、ユーザプログラム実行時間測定部32を経て、実行時間測定終了命令34が実行される。この実行時間測定終了命令34により、タイマ25から実行時間測定部終了時のタイマ値D2を参照メモリ21に格納し、前記実行時間測定開始時のタイマ値D1との差分から実行時間を計算することにより、ユーザプログラムの実行時間が測定される。
【0007】
【発明の効果】
以上述べたように本発明によれば、ユーザプログラムの実行時間を測定する為に、プログラマブルコントローラの他に別途信号測定機器を用意する必要が無く、更にプログラマブルコントローラから出力信号を取り出して信号測定機器に接続する為に、プログラマブルコントローラの出力端子に出力信号を取り出す為のリード線のはんだ付け等の加工を必要としないため、ユーザプログラムの実行時間を容易に測定することが可能となる。
【図面の簡単な説明】
【図1】本発明において用いるプログラム入力装置とプログラマブルコントローラの概念図。
【図2】本発明の説明図。
【図3】従来技術において用いるプログラム入力装置とプログラマブルコントローラの概念図。
【図4】従来技術の説明図。
【符号の説明】
1 プログラム入力装置
2 プログラマブルコントローラ
20 プログラムメモリ部
21 データメモリ部
22 演算部(CPU)
23 入力部
24 出力部
25 タイマ部
3 ユーザプログラム
30 外部信号1出力命令
31 外部信号2出力命令
32 ユーザプログラム実行時間測定部
33 実行時間測定開始命令
34 実行時間測定終了命令
S1 出力信号1
S2 出力信号2
D1 実行時間測定開始時のタイマ値
D2 実行時間測定終了時のタイマ値[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a method for measuring the execution time of a user program in a programmable controller having a function of calculating according to the user program.
[0002]
[Prior art]
In general, the programmable controller has a configuration as shown in FIG. In FIG. 3, reference numeral 1 denotes a program input device having a function of creating a user program and having means for transmitting the created user program to the programmable controller 2. Reference numeral 2 denotes a programmable controller, which includes a program memory unit 20 storing a user program, a data memory unit 21, a calculation unit (CPU) 22 that operates according to the user program stored in the program memory unit, and an external signal. It comprises an input unit 23 for capturing and an output unit 24 for outputting a signal to the outside.
FIG. 4 shows a method for measuring the execution time of a user program in a conventional programmable controller control device. In FIG. 4, 3 is a user program, an external signal 1 output command 30 for instructing to output the output signal 1 from the output unit 24 of FIG. 3, and an external signal 2 output for instructing to output the output signal 2 from the output unit 24 Instruction 31 is prepared. Reference numeral 4 denotes a signal measuring device such as an oscilloscope. The signal measuring device 4 is connected to the programmable controller 2 so as to measure the output signal 1 and the output signal 2 from the output unit 24 of FIG. In the user program 3, the external signal 1 output command 30 is described immediately before the start of the portion (user program execution time measuring unit 32) whose execution time is to be measured, and the external signal 2 output command 31 is described immediately after the end. When the user program is executed, the external signal 1 output command 30 causes the output signal 1 of the output unit 24 in FIG. 3 to be turned from OFF to ON, and the program start pulse 40 is measured in the measuring device 4 in FIG. After 32, the external signal 2 output command 31 causes the output signal 2 of the output unit 24 of FIG. By measuring the interval between the program start pulse 40 and the program end pulse 41, the execution time of the user program can be measured (see, for example, Patent Document 1).
[0003]
[Patent Document 1] Japanese Patent Application Laid-Open No. 05-165655
[Problems to be solved by the invention]
However, in the conventional method for measuring the execution time of the user program, a separate signal measuring device must be prepared in addition to the programmable controller, and the output signal is extracted from the programmable controller and connected to the signal measuring device. Processing such as soldering of lead wires for taking out an output signal to the output terminal of the programmable controller is necessary, which is troublesome.
Therefore, an object of the present invention is to enable measurement of the execution time of a user program that does not require a separate signal measuring device and does not require processing such as soldering.
[0005]
[Means for Solving the Problems]
In order to solve the above problems, in the present invention, an input unit for capturing an external signal, an output unit for outputting a signal to the outside, a timer unit for counting clock pulses, a data memory unit, and a user program are provided. In a device such as a programmable controller having a stored program memory unit and a calculation unit (CPU) that performs calculations according to a user program stored in the program memory unit, an execution time for storing the timer value of the timer unit in the data memory unit By preparing an execution time measurement end instruction that calculates the execution time from the difference between the measurement start instruction and the timer value of the timer unit stored in the data memory unit and the timer value stored by the execution time measurement start instruction, Measuring the execution time of the user program It is.
[0006]
DETAILED DESCRIPTION OF THE INVENTION
An embodiment of the present invention will be described below with reference to FIGS.
In FIG. 1, reference numeral 1 denotes a program input device having a function of creating a user program and having means for transmitting the created user program to the programmable controller 2. Reference numeral 2 denotes a programmable controller, which includes a program memory unit 20 storing a user program, a data memory unit 21, a calculation unit (CPU) 22 that operates according to the user program stored in the program memory unit, and counts clock pulses. Timer section 25, an input section 23 for capturing external signals, and an output section 24 for outputting signals to the outside.
FIG. 2 shows a method for measuring the execution time of a user program in the programmable controller control apparatus according to the present invention. The user program 3 stores an execution time measurement start command 33 for storing the timer value of the timer unit in the data memory unit, and stores the timer value of the timer unit in the data memory unit and stored by the execution time measurement start command 33. The execution time measurement end command 34 for calculating the execution time from the difference from the timer value is prepared, and the execution time measurement starts immediately before the start of the portion (user program execution time measurement unit 32) where the user program 3 wants to measure the execution time. The execution time measurement end instruction 34 is described immediately after the instruction 33 is ended. When the user program 3 is executed, an execution time measurement start instruction 33 is executed, and the timer value counted by the timer 25 is stored in the memory 21 and held as the timer value D1 at the start of execution time measurement. After the execution time measurement start command 33 is executed, the execution time measurement end command 34 is executed via the user program execution time measurement unit 32. In response to the execution time measurement end command 34, the timer 25 stores the timer value D2 at the end of the execution time measurement unit in the reference memory 21, and calculates the execution time from the difference from the timer value D1 at the start of the execution time measurement. Thus, the execution time of the user program is measured.
[0007]
【The invention's effect】
As described above, according to the present invention, it is not necessary to prepare a separate signal measuring device in addition to the programmable controller in order to measure the execution time of the user program. Therefore, it is possible to easily measure the execution time of the user program because it is not necessary to perform processing such as soldering of the lead wire for extracting the output signal to the output terminal of the programmable controller.
[Brief description of the drawings]
FIG. 1 is a conceptual diagram of a program input device and a programmable controller used in the present invention.
FIG. 2 is an explanatory diagram of the present invention.
FIG. 3 is a conceptual diagram of a program input device and a programmable controller used in the prior art.
FIG. 4 is an explanatory diagram of a conventional technique.
[Explanation of symbols]
1 Program Input Device 2 Programmable Controller 20 Program Memory Unit 21 Data Memory Unit 22 Arithmetic Unit (CPU)
23 Input unit 24 Output unit 25 Timer unit 3 User program 30 External signal 1 output command 31 External signal 2 output command 32 User program execution time measurement unit 33 Execution time measurement start command 34 Execution time measurement end command S1 Output signal 1
S2 Output signal 2
D1 Timer value at the start of execution time measurement D2 Timer value at the end of execution time measurement