JP2020160704A - Integer division device and motor control device - Google Patents
Integer division device and motor control device Download PDFInfo
- Publication number
- JP2020160704A JP2020160704A JP2019058398A JP2019058398A JP2020160704A JP 2020160704 A JP2020160704 A JP 2020160704A JP 2019058398 A JP2019058398 A JP 2019058398A JP 2019058398 A JP2019058398 A JP 2019058398A JP 2020160704 A JP2020160704 A JP 2020160704A
- Authority
- JP
- Japan
- Prior art keywords
- value
- divisor
- output
- register
- bits
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F7/00—Methods or arrangements for processing data by operating upon the order or content of the data handled
- G06F7/38—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
- G06F7/48—Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
- G06F7/52—Multiplying; Dividing
- G06F7/535—Dividing only
-
- H—ELECTRICITY
- H02—GENERATION; CONVERSION OR DISTRIBUTION OF ELECTRIC POWER
- H02P—CONTROL OR REGULATION OF ELECTRIC MOTORS, ELECTRIC GENERATORS OR DYNAMO-ELECTRIC CONVERTERS; CONTROLLING TRANSFORMERS, REACTORS OR CHOKE COILS
- H02P23/00—Arrangements or methods for the control of AC motors characterised by a control method other than vector control
- H02P23/14—Estimation or adaptation of motor parameters, e.g. rotor time constant, flux, speed, current or voltage
Abstract
Description
本発明は、整数除算装置およびモータ制御装置に関する。 The present invention relates to an integer division device and a motor control device.
従来、整数除算機能を実現するハードウェアとしては、専用IC、または汎用MCUが用いられている。専用ICでは、ハードウェア除算命令が存在するため高速な除算処理を実現することができるが、コストが高いといった問題がある。そのため、コストの削減のためには、安価な汎用MCUを用い、汎用MCUにソフトウェア処理を加えることで整数除算機能を実現する必要がある。
例えば、特許文献1には、被除数から除数を減算したときに部分剰余と部分商とが同時に求められるように除算処理前に除数を変換し、被除数を1ビットずつ左シフトしながら被除数から除数を繰返し減算して各桁の商を求める整数除算方法が開示されている。
また、特許文献2には、整数の除算において、除数があらかじめ定まった定数のとき、被除数を補正することで、加減算とビットシフト操作だけで商を求める整数除算方式が開示されている。
Conventionally, a dedicated IC or a general-purpose MCU has been used as the hardware for realizing the integer division function. Since the dedicated IC has a hardware division instruction, high-speed division processing can be realized, but there is a problem that the cost is high. Therefore, in order to reduce costs, it is necessary to use an inexpensive general-purpose MCU and realize an integer division function by adding software processing to the general-purpose MCU.
For example, in Patent Document 1, the divisor is converted before the division process so that the partial remainder and the partial quotient can be obtained at the same time when the divisor is subtracted from the divisor, and the divisor is divided from the divisor while shifting the divisor to the left by one bit. An integer division method for repeatedly subtracting to obtain the quotient of each digit is disclosed.
Further, Patent Document 2 discloses an integer division method for obtaining a quotient only by addition / subtraction and bit shift operation by correcting a divisor when the divisor is a predetermined constant in integer division.
汎用MCU内で除算処理を行った場合、除算処理に時間がかかると、同一MCU内で行われる通信等の他の制御に支障をきたす。そのため、ハードウェアに対応するハードウェア除算命令が無い安価な汎用MCUでは、高速除算の実現が難しかった。
そこで、本発明は、ソフトウェアで高速除算機能を実現することができる整数除算装置およびモータ制御装置を提供することを目的とする。
When the division process is performed in the general-purpose MCU, if the division process takes a long time, other control such as communication performed in the same MCU will be hindered. Therefore, it has been difficult to realize high-speed division with an inexpensive general-purpose MCU that does not have a hardware division instruction corresponding to the hardware.
Therefore, an object of the present invention is to provide an integer division device and a motor control device that can realize a high-speed division function by software.
上記課題を解決するために、本発明の一つの態様の整数除算装置は、被除数および除数に基づいて、前記被除数を前記除数で除算して得られる商の値がレジスタの大きさのビット数で表せる値の範囲に収まるか否かを判定する判定部と、前記判定部により前記商の値が前記レジスタの大きさのビット数で表せる値の範囲に収まらないと判定された場合、予め定められた固定値を出力値として前記レジスタに出力する出力部と、を備える。 In order to solve the above problem, in the integer division apparatus of one aspect of the present invention, the quotient value obtained by dividing the division by the divisor based on the divisor and the divisor is the number of bits of the size of the register. A determination unit that determines whether or not the value is within the range of the value that can be expressed, and a determination unit that determines that the value of the quotient does not fall within the range of the value that can be expressed by the number of bits of the size of the register. It includes an output unit that outputs a fixed value as an output value to the register.
また、本発明の一つの態様のモータ制御装置は、入力信号を電子ギア比に基づいて調整する電子ギア部と、前記電子ギア部においてモータの位置指令値を前記入力信号として調整された前記位置指令値に基づいて、前記モータを制御する電力変換部と、を備え、前記電子ギア部は、被除数および除数に基づいて、前記被除数を前記除数で除算して得られる商の値がレジスタの大きさのビット数で表せる値の範囲に収まるか否かを判定する判定部と、前記判定部により前記商の値が前記レジスタの大きさのビット数で表せる値の範囲に収まらないと判定された場合、予め定められた固定値を出力値として前記レジスタに出力する出力部と、を備える。 Further, the motor control device according to one aspect of the present invention includes an electronic gear unit that adjusts an input signal based on an electronic gear ratio, and the position in which the position command value of the motor is adjusted as the input signal in the electronic gear unit. The electronic gear unit includes a power conversion unit that controls the motor based on a command value, and the electronic gear unit has a register value obtained by dividing the divisor by the divisor based on the divisor and the divisor. The determination unit that determines whether or not the value is within the range of values that can be represented by the number of bits, and the determination unit that determines that the value of the quotient does not fall within the range of values that can be represented by the number of bits of the size of the register. In this case, an output unit that outputs a predetermined fixed value as an output value to the register is provided.
さらに、本発明の一つの態様の整数除算方法は、被除数および除数に基づいて、前記被除数を前記除数で除算して得られる商の値がレジスタの大きさのビット数で表せる値の範囲に収まるか否かを判定するステップと、前記商の値が前記レジスタの大きさのビット数で表せる値の範囲に収まると判定された場合、予め定められた固定値を出力値として前記レジスタに出力するステップと、を含む。 Further, in the integer division method of one aspect of the present invention, the value of the quotient obtained by dividing the divisor by the divisor based on the divisor and the divisor falls within the range of values that can be represented by the number of bits of the size of the register. In the step of determining whether or not, and when it is determined that the value of the quotient falls within the range of values that can be represented by the number of bits of the size of the register, a predetermined fixed value is output to the register as an output value. Including steps.
本発明の一つの態様によれば、被除数を除数で除算して得られる商の値がレジスタの大きさのビット数で表せる値の範囲に収まるか否かを判定し、商の値がレジスタの大きさのビット数で表せる値の範囲に収まらないと判定された場合、除算処理を実行せず固定値を出力するため、除算の高速化を実現することができる。 According to one aspect of the present invention, it is determined whether or not the quotient value obtained by dividing the divisor by the divisor falls within the range of values that can be represented by the number of bits of the register size, and the quotient value is the register. If it is determined that the value does not fall within the range of values that can be represented by the number of bits of size, a fixed value is output without executing the division process, so that the division can be speeded up.
以下、図面を用いて本発明の実施の形態について説明する。
なお、本発明の範囲は、以下の実施の形態に限定されるものではなく、本発明の技術的思想の範囲内で任意に変更可能である。
Hereinafter, embodiments of the present invention will be described with reference to the drawings.
The scope of the present invention is not limited to the following embodiments, and can be arbitrarily changed within the scope of the technical idea of the present invention.
図1は、本実施形態におけるータ制御装置10の構成例を示す図である。
モータ制御装置10は、電子ギア部11〜13と、位置速度制御器14と、電力変換部15と、を備え、モータ21の回転を制御する。モータ21は、例えばACサーボモータであり、モータ21には、モータ軸の回転位置を検出する回転検出器としてのエンコーダ22が接続されている。
FIG. 1 is a diagram showing a configuration example of the
The
電子ギア部11〜13は、入力信号を電子ギア比に基づいて調整する。なお、電子ギア部11〜13は、分周逓倍を利用して電子ギア機能を実現する。したがって、図1では、電子ギア部11〜13を「分周逓倍」と表記している。
電子ギア部11は、モータ21の位置指令値を入力信号とし、位置指令値の分解能とモータ21に接続されたエンコーダ22の分解能との違いを調整する。ここで、モータ21の位置指令値は、モータ21の目標とする位置情報(角度情報)を示す値であり、整数の値である。当該位置指令値は、ユーザが指定した値であってもよいし、不図示の上位装置により生成された値であってもよい。
電子ギア部12は、エンコーダ22から出力されるモータ21の位置検出値を入力信号とし、位置指令値の分解能とエンコーダ22の分解能との違いを調整する。
電子ギア部13は、エンコーダ22から出力されるモータ21の位置検出値を入力信号とし、エンコーダ22の分解能とパルスの分解能との違いを調整する。
The
The
The
The
本実施形態では、電子ギア部11〜13における電子ギア機能は、汎用MCU(Micro Control Unit)のソフトウェア処理により実現される。電子ギア部11〜13の入力信号をinput、出力値をoutputとした場合、電子ギア機能は、次式の除算処理により表すことができる。
output=input×分解能A/分解能B ………(1)
ここで、電子ギア部11における処理の場合、入力信号inputは位置指令値、分解能Aはエンコーダ22の分解能、分解能Bは位置指令値の分解能である。
また、電子ギア部12における処理の場合、入力信号inputは位置検出値、分解能Aは位置指令値の分解能、分解能Bはエンコーダ22の分解能である。
さらに、電子ギア部13における処理の場合、入力信号inputは位置検出値、分解能Aはパルスの分解能、分解能Bはエンコーダ22の分解能である。
これらの電子ギア部11〜13は、それぞれ被除数を除数で整数除算した結果を出力する整数除算装置として動作することができる。
In the present embodiment, the electronic gear functions in the
output = input × resolution A / resolution B ……… (1)
Here, in the case of processing in the
Further, in the case of processing in the
Further, in the case of processing in the
Each of these
位置速度制御器14は、位置制御器や速度制御器、電流制御器といった制御器を備える。位置速度制御器14は、電子ギア部11において調整された位置指令値と、エンコーダ22から出力されるモータ21の位置検出値との偏差(差分)に基づいて、当該偏差を0とするべくフィードバック制御を行う。
電力変換部15は、位置速度制御器14により出力される制御信号に従って、モータ21の駆動電流を制御する。つまり、電力変換部15は、電子ギア部11においてモータ21の位置指令値を入力信号inputとして調整された位置指令値に基づいて、モータ21を制御する。
The position /
The
また、モータ制御装置10は、位置指令値と、電子ギア部12において調整された位置検出値との偏差をもとに、位置偏差の絶対値を出力するABS位置偏差の出力機能を有する。
さらに、モータ制御装置10は、電子ギア部13において調整された位置検出値をもとにパルス信号を出力するパルス出力機能を有する。
Further, the
Further, the
ところで、安価な汎用MCUはハードウェアに対応するハードウェア除算命令が無く、標準除算関数を用いて除算処理を行った場合、多くの処理時間がかかってしまう。開発環境によっては、ハードウェア除算命令が存在するMCUの場合と比較して、11倍もの処理時間がかかる場合もある。
そこで、本実施形態では、除算処理の高速化を実現するために、電子ギア部11〜13における出力値outputのビット数を制限する。
By the way, an inexpensive general-purpose MCU does not have a hardware division instruction corresponding to hardware, and when a division process is performed using a standard division function, a large amount of processing time is required. Depending on the development environment, the processing time may be 11 times longer than that of the MCU in which the hardware division instruction exists.
Therefore, in the present embodiment, the number of bits of the output value output in the
図2は、電子ギア部11の機能ブロック図である。なお、電子ギア部12および13についても、電子ギア部11と同様の構成を有するため、ここでは説明を省略する。
電子ギア部11は、取得部11aと、判定部11bと、除算部11cと、出力部11dと、異常判断部11eと、を備える。
取得部11aは、入力信号inputとして、位置指令値を取得する。取得部11aは、取得した入力信号inputを、判定部11bおよび除算部11cに出力する。
FIG. 2 is a functional block diagram of the
The
The
判定部11bは、被除数(input×エンコーダの分解能)および除数(位置指令値の分解能)に基づいて、被除数を除数で除算して得られる商の値がレジスタの大きさのビット数で表せる値の範囲に収まるか否かを判定する。ここで、上記レジスタは、MCUが有する内部レジスタであり、当該レジスタの大きさのビット数は予め分かっているものとする。
具体的には、判定部11bは、入力信号inputの値を取得し、入力信号inputの値が所定の値以上である場合に、商の値がレジスタの大きさのビット数で表せる値の範囲に収まらないと判定する。
In the
Specifically, the
位置指令値の分解能およびエンコーダの分解能の値は、プログラム(ソフトウェア)を実行する時点で分かっており、一度プログラムを実行した後は、ハードウェアが変わらない限り変わることはない。そのため、内部レジスタの大きさのビット数と、各分解能の値とに基づいて、入力信号inputの値がいくつ以下でないと商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まらないか(商がオーバーフローしてしまうか)が決まる。
そこで、判定部11bは、内部レジスタの大きさのビット数と、各分解能の値とに基づいて、商がオーバーフローしない入力信号inputの値を設定する。そして、判定部11bは、設定した値と入力信号inputの値とを比較し、商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まるか否かを判定する。
The resolution of the position command value and the resolution of the encoder are known at the time of executing the program (software), and once the program is executed, it does not change unless the hardware changes. Therefore, based on the number of bits of the size of the internal register and the value of each resolution, the value of the quotient must be within the range of the value that can be expressed by the number of bits of the size of the internal register unless the value of the input signal input is less than or equal to. Whether or not (whether the quotient overflows) is decided.
Therefore, the
除算部11cは、判定部11bの判定結果を入力し、判定部11bにより商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まると判定された場合に、取得部11aから取得された入力信号inputを用いて、被除数を除数で整数除算する除算処理を行う。このとき、除算部11cは、除数である位置指令値の分解能を定数として扱い、当該除数の逆数に対応する値を被除数に乗算することで除算処理を行う。
MCUにとっては、乗算の方が除算よりも処理時間が少なくてすむ。そのため、除数の逆数を被除数に乗算する手法を用いて除算処理を実現することで、演算処理時間を短縮することができる。また、電子ギア部11における除算処理の除数(分母)は、位置指令値の分解能であり、定数とみなせる。除数が定数である場合、除数の逆数は計算のたびに変化しないため、除算処理(除数の逆数を乗算する処理)のたびに当該逆数を計算する必要はない。したがって、除数を定数として扱い、当該除数の逆数に対応する値を被除数に乗算する除算処理を行うことで、高速演算が可能となる。
The
For the MCU, multiplication requires less processing time than division. Therefore, the calculation processing time can be shortened by realizing the division processing by using the method of multiplying the reciprocal of the divisor by the divisor. Further, the divisor (denominator) of the division process in the
なお、電子ギア部12および13における除算処理の場合にも、除数(分母)はエンコーダ22の分解能であり、定数とみなせる。したがって、同様に、除数であるエンコーダ22の分解能を定数として扱い、当該除数の逆数に対応する値を被除数に乗算することで除算処理の高速化が図れる。
Even in the case of division processing in the
出力部11dは、判定部11bの判定結果を入力し、判定部11bにより商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まると判定されている場合、除算部11cによる除算処理の結果である商を出力値outputとして出力する。一方、出力部11dは、判定部11bにより商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まらないと判定されている場合、予め定められた固定値を出力値outputとして内部レジスタに出力する。
The
ここで、上記固定値は、内部レジスタに収まる範囲の上限値または下限値とすることができる。例えば、内部レジスタの大きさのビット数がNビットであり、除算結果が負の値をとらない場合には、上限値は2N−1、下限値は0となる。一方、内部レジスタの大きさのビット数がNビットであり、除算結果が正負の値をとる場合には、符号ビット(最上位ビット)を考慮して、上限値は2N-1−1、下限値は−(2N-1−1)となる。
つまり、上記固定値は、内部レジスタの大きさのビット数で表せる最大値、内部レジスタの大きさのビット数で表せる最小値、もしくは零とすることができる。
なお、上記固定値は、内部レジスタの大きさのビット数で表せる値であれば、任意の値としてもよい。つまり、除算結果を内部レジスタの大きさ以下のビット数に制限して出力できればよい。
Here, the fixed value can be an upper limit value or a lower limit value in a range within the internal register. For example, if the number of bits of the size of the internal register is N bits and the division result does not take a negative value, the upper limit value is 2 N -1 and the lower limit value is 0. On the other hand, when the number of bits of the size of the internal register is N bits and the division result takes a positive or negative value, the upper limit is 2 N-1 -1, considering the sign bit (most significant bit). The lower limit is − (2 N-1 -1).
That is, the fixed value can be the maximum value that can be represented by the number of bits of the size of the internal register, the minimum value that can be represented by the number of bits of the size of the internal register, or zero.
The fixed value may be any value as long as it can be represented by the number of bits of the size of the internal register. That is, it is sufficient that the division result can be output by limiting the number of bits to the size of the internal register or less.
異常判定部11eは、出力部11dから出力される出力値outputを入力し、出力部11dにより出力値outputとして固定値が出力されている場合、整数除算の異常であると判断する。
The
図3は、電子ギア部11において実行される整数除算処理を示すフローチャートである。この図3に示す処理は、取得部11a、判定部11b、除算部11cおよび出力部11dの処理であり、MCUがプログラムを実行することにより実現される。なお、電子ギア部12および13においてそれぞれ実行される整数除算処理についても同様であるため、ここでは説明を省略する。
まずステップS1において、取得部11aは、被除数として、入力信号inputとエンコーダの分解能とを取得する。
FIG. 3 is a flowchart showing an integer division process executed by the
First, in step S1, the
次にステップS2において、判定部11bは、被除数および除数に基づいて、被除数を除数で除算して得られる商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まるか否かを判定する。具体的には、判定部11bは、ステップS1において取得された入力信号inputの値が所定の値以上であるか否かに基づいて、商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まるか否かを判定する。
そして、判定部11bは、商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まると判定した場合、ステップS3に移行する。一方、判定部11bは、商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まらないと判定した場合にはステップS4に移行する。
Next, in step S2, the
Then, when the
ステップS3では、除算部11cは、被除数を除数で整数除算する除算処理を行い、ステップS5に移行する。このとき、ステップS3において除算部11cは、除数である位置指令値の分解能を定数として扱い、当該除数の逆数に対応する値を被除数に乗算することで除算処理を行う。そして、出力部11dは、除算部11cによる除算処理の結果である商を出力値outputとして設定する。
また、ステップS4では、出力部11dは、予め定められた固定値を出力値outputとして設定し、ステップS5に移行する。
ステップS5では、出力部11dは、出力値outputを内部レジスタおよび異常判断部11eに出力し、図3の処理を終了する。
In step S3, the
Further, in step S4, the
In step S5, the
このように、本実施形態における電子ギア部11(整数除算装置)は、被除数および除数に基づいて、被除数を除数で除算して得られる商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まるか否かを判定する判定部11bと、商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まると判定された場合、予め定められた固定値を出力値outputとして内部レジスタに出力する出力部11dと、を備える。
さらに、電子ギア部11は、判定部11bにより商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まると判定された場合、被除数を除数で整数除算する除算処理を行う除算部11cをさらに備える。そして、電子ギア部11の出力部11dは、判定部11bにより商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まると判定された場合、除算部11cによる除算処理の結果である商を出力値outputとして出力する。
As described above, in the electronic gear unit 11 (integer division device) in the present embodiment, the quotient value obtained by dividing the divisor by the divisor based on the divisor and the divisor can be represented by the number of bits of the size of the internal register. The
Further, the
つまり、電子ギア部11は、除算処理を実行する前に、被除数を除数で除算した商の値を判定し、その判定結果に応じて、除算処理を実行した結果を出力したり、除算処理を実行せずに固定値を出力したりする。したがって、処理の高速化を実現することができる。
また、除算部11cは、除数を定数として扱い、当該除数の逆数に対応する値を被除数に乗算することで除算処理を行うことができる。電子ギアの場合、除数は位置指令値の分解能またはエンコーダの分解能であり、定数とみなすことができる。除数を定数として扱うことで、処理時間を要する除算に替えて乗算を行い、除算処理を実現することができるので、整数除算の高速演算が可能となる。また、分子の分解能Aと分母の分解能Bの両方を定数化するのではなく、分母の分解能Bのみを定数化するので、桁落ちの発生を防ぐことができ、精度良く除算処理を行うことができる。
That is, the
Further, the
さらに、出力値outputとして出力する上記固定値は、内部レジスタの大きさのビット数で表せる最大値、最小値もしくは零とすることができる。このように、商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まらない場合には、計算結果として想定されている商の上限値または下限値に張り付ける張り付け処理を行うようにしてもよい。
これにより、除算結果として出力する出力値outputを、内部レジスタの大きさ以下のビット数に制限することができる。また、出力値outputの張り付け処理を行うことで、商が内部レジスタからあふれたことを容易に判断することができる。
Further, the fixed value output as the output value output can be a maximum value, a minimum value, or zero that can be represented by the number of bits of the size of the internal register. In this way, if the quotient value does not fall within the range of values that can be expressed by the number of bits of the size of the internal register, paste processing is performed to paste it to the upper or lower limit value of the quotient assumed as the calculation result. It may be.
As a result, the output value output output as the division result can be limited to the number of bits equal to or less than the size of the internal register. Further, by pasting the output value output, it can be easily determined that the quotient has overflowed from the internal register.
さらにまた、電子ギア部11は、出力部11dにより出力値outputとして固定値が出力されている場合、整数除算の異常であると判断する異常判断部11eをさらに備えることができる。これにより、出力値outputの値から容易に異常判断を行うことができる。例えば、出力値outputが、内部レジスタの大きさのビット数で表せる最大値、最小値、もしくは零といった正常時には取り得ない値となっている場合には、整数除算の異常であると容易に判断することができる。
Furthermore, the
図4は、張り付け処理を行った場合の出力値outputを示す図である。この図4において、二点鎖線で示す直線Aは、除算処理の実際の計算結果である。なお、図4では、除算処理の計算結果が正負の値をとる場合の例を示している。除算処理の計算結果が負の値をとらない場合には、図4の最小値minが0となる。
本実施形態では、商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まると判定された場合、被除数を除数で整数除算する除算処理を行い、除算処理の結果である商を出力値outputとして出力する。したがって、この場合には、実際の計算結果が出力値outputとして出力される。
FIG. 4 is a diagram showing an output value output when the pasting process is performed. In FIG. 4, the straight line A indicated by the alternate long and short dash line is the actual calculation result of the division process. Note that FIG. 4 shows an example in which the calculation result of the division process takes a positive or negative value. If the calculation result of the division process does not take a negative value, the minimum value min in FIG. 4 becomes 0.
In the present embodiment, when it is determined that the value of the quotient falls within the range of the value that can be represented by the number of bits of the size of the internal register, the division process of dividing the divisor by an integer by the divisor is performed, and the quotient that is the result of the division process is obtained. Output as output value output. Therefore, in this case, the actual calculation result is output as an output value output.
一方、商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まらないと判定された場合には、出力値outputを最大値maxもしくは最小値minに張り付ける。具体的には、商の値が最大値max以上となる場合には、出力値outputを最大値maxに張り付け、商の値が最小値min以下となる場合には、出力値outputを最小値minに張り付ける。
したがって、出力値outputを見るだけで、商がオーバーフローする異常が発生したか否かを容易に判断することができる。例えば丸印Bで示すように、出力値outputが最大値maxである場合には、商が最大値max以上となるオーバーフローが発生したことを容易に把握することができる。
On the other hand, if it is determined that the quotient value does not fall within the range of values that can be represented by the number of bits of the size of the internal register, the output value output is pasted to the maximum value max or the minimum value min. Specifically, when the quotient value is greater than or equal to the maximum value max, the output value output is pasted to the maximum value max, and when the quotient value is less than or equal to the minimum value min, the output value output is set to the minimum value min. Stick to.
Therefore, it is possible to easily determine whether or not an abnormality in which the quotient overflows has occurred just by looking at the output value output. For example, as indicated by a circle B, when the output value output is the maximum value max, it can be easily grasped that an overflow has occurred in which the quotient is equal to or greater than the maximum value max.
一方、本実施形態のような出力値outputの張り付け処理を行わない場合、一般的には、実際の計算結果が内部レジスタに収まらない範囲の値であっても、内部レジスタの大きさのビット数で表すことができる範囲の数値のみが出力される。そのため、出力値outputは、図5に示すように内部レジスタに収まる範囲の値となる。例えば、商の値が最大値maxを超えた場合、出力値outputは最小値minから始まる値となる。このように、商がオーバーフローした場合、出力値outputは、内部レジスタに収まる範囲の値となって返ってくる。
したがって、出力値outputの張り付け処理を行わない場合には、出力値outputを見ただけでは、商がオーバーフローする異常が発生したか否かを判断することはできない。例えば丸印Cに示す出力値outputが得られた場合、実際の計算結果が内部レジスタに収まる範囲の値なのか、商がオーバーフローして内部レジスタに収まる範囲の値が返ってきたのかを判断できない。
本実施形態では、商がオーバーフローする異常を適切に判断し、電子ギアの異常を適切に判断することができる。
On the other hand, when the output value output is not pasted as in the present embodiment, in general, the number of bits of the size of the internal register is large even if the actual calculation result is a value in the range that does not fit in the internal register. Only the numerical values in the range that can be represented by are output. Therefore, the output value output is a value within the range within the internal register as shown in FIG. For example, when the quotient value exceeds the maximum value max, the output value output becomes a value starting from the minimum value min. In this way, when the quotient overflows, the output value output is returned as a value within the range within the internal register.
Therefore, when the output value output is not pasted, it is not possible to determine whether or not an abnormality in which the quotient overflows has occurred just by looking at the output value output. For example, when the output value output shown by the circle C is obtained, it cannot be determined whether the actual calculation result is the value in the range that fits in the internal register or the quotient overflows and the value in the range that fits in the internal register is returned. ..
In the present embodiment, the abnormality in which the quotient overflows can be appropriately determined, and the abnormality in the electronic gear can be appropriately determined.
なお、本実施形態では、実際の計算結果が最大値maxもしくは最小値minとなった場合であっても(商が内部レジスタに収まる場合であっても)、出力値outputが最大値maxもしくは最小値minであるために異常と判断する。内部レジスタの大きさは、正常な計算結果が最大値maxおよび最小値minに達しないように設計されるのが一般的であるため、実際の計算結果が最大値maxもしくは最小値minとなった場合には異常であると判断して問題はない。同様の理由により、商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まらないと判定された場合に張り付ける固定値は、最大値maxもしくは最小値minの近傍の値であってもよい。 In this embodiment, even if the actual calculation result is the maximum value max or the minimum value min (even if the quotient fits in the internal register), the output value output is the maximum value max or the minimum. Since the value is min, it is judged to be abnormal. Since the size of the internal register is generally designed so that the normal calculation result does not reach the maximum value max and the minimum value min, the actual calculation result becomes the maximum value max or the minimum value min. In some cases, it is judged to be abnormal and there is no problem. For the same reason, when it is determined that the quotient value does not fall within the range of values that can be represented by the number of bits of the size of the internal register, the fixed value to be pasted is a value near the maximum value max or the minimum value min. You may.
さらに、電子ギア部11は、内部レジスタの大きさのビット数が入力信号inputのビット数と同等であるとして、商の値が入力信号inputのビット数で表せる値の範囲に収まるか否かを判定するようにしてもよい。
電子ギアの場合、例えば位置指令値の分解能とエンコーダの分解能とは、同じくらいの桁数で表すことのできる値であり(位置指令値の分解能≒エンコーダの分解能)、上記(1)式の分解能A/分解能Bは1程度である。そのため、正常に計算が行われた場合、計算結果である商のビット数は、入力信号inputのビット数と同等となると考えることができる。
したがって、商の値が入力信号inputのビット数で表せる値の範囲に収まるか否かを判定することで、正常な計算結果の大きさに合わせて設計された内部レジスタに商が収まるか否かを適切に判定することができる。そして、その判定結果に応じて実際に除算処理を行うか固定値を出力するかを判断することで、正常な計算結果が出力されると予測される場合にのみ実際に除算処理を行うようにすることができ、適切に処理の高速化を実現することができる。
Further, the
In the case of electronic gears, for example, the resolution of the position command value and the resolution of the encoder are values that can be expressed by the same number of digits (resolution of the position command value ≒ resolution of the encoder), and the resolution of the above equation (1). A / resolution B is about 1. Therefore, when the calculation is performed normally, it can be considered that the number of bits of the quotient as the calculation result is equivalent to the number of bits of the input signal input.
Therefore, by determining whether or not the quotient value falls within the range of values that can be represented by the number of bits of the input signal input, whether or not the quotient fits in the internal register designed according to the size of the normal calculation result. Can be appropriately determined. Then, by determining whether to actually perform the division process or output a fixed value according to the determination result, the division process is actually performed only when it is predicted that a normal calculation result will be output. It is possible to appropriately speed up the processing.
以上説明したように、本実施形態における整数除算方法は、被除数および除数に基づいて、被除数を除数で除算して得られる商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まるか否かを判定するステップと、商の値が内部レジスタの大きさのビット数で表せる値の範囲に収まらないと判定された場合、予め定められた固定値を出力値としてレジスタに出力するステップと、を含む。
これにより、ハードウェアに対応するハードウェア除算命令が無い安価な汎用MCUであっても、ソフトウェアによる高速除算機能の実現を可能とすることができる。具体的には、汎用MCUにおいて標準除算関数を用いて除算処理を行った場合と比較して、6分の1まで処理時間を短縮することも可能である。また、本実施形態における整数除算方法では、処理時間が開発環境のバージョンに依存しない。
なお、本実施形態は、例えば、32bitの除算命令を備えるMCUにて、64bitの除算命令を実現する場合や、ハードウェア除算命令が存在しないMCUにて、32bitの除算命令を実現する場合など、対応するハードウェア除算命令が無い場合を想定している。
As described above, in the integer division method in the present embodiment, the quotient value obtained by dividing the divisor by the divisor based on the divisor and the divisor falls within the range of values that can be represented by the number of bits of the size of the internal register. A step to determine whether or not, and a step to output a predetermined fixed value to the register as an output value when it is determined that the quotient value does not fall within the range of values that can be expressed by the number of bits of the size of the internal register. And, including.
As a result, even an inexpensive general-purpose MCU that does not have a hardware division instruction corresponding to the hardware can realize a high-speed division function by software. Specifically, it is possible to reduce the processing time to one sixth of the case where the division processing is performed using the standard division function in the general-purpose MCU. Further, in the integer division method in the present embodiment, the processing time does not depend on the version of the development environment.
In the present embodiment, for example, a 64-bit division instruction is realized by an MCU provided with a 32-bit division instruction, or a 32-bit division instruction is realized by an MCU having no hardware division instruction. It is assumed that there is no corresponding hardware division instruction.
高応答および高精度な位置決めを実現するモータであるACサーボモータでは、ユーザから受信する位置指令値の分解能とモータに接続されたエンコーダの分解能との違いを調整するために、電子ギア機能が用いられている。この電子ギア機能を汎用MCUで実現する場合、ソフトウェアの処理として必ず除算処理が必要となる。ところが、除算処理に時間がかかると、同一MCU内で行われる他の制御(モータ制御や通信等)に支障をきたし、ACサーボモータの特徴である高応答が実現できなくなってしまう。そのため、ハードウェアに対応するハードウェア除算命令が無い安価な汎用MCUでの電子ギア機能の実現は難しかった。 In AC servo motors, which are motors that achieve high response and high-precision positioning, the electronic gear function is used to adjust the difference between the resolution of the position command value received from the user and the resolution of the encoder connected to the motor. Has been done. When this electronic gear function is realized by a general-purpose MCU, a division process is always required as a software process. However, if the division process takes a long time, other controls (motor control, communication, etc.) performed in the same MCU will be hindered, and the high response characteristic of the AC servomotor cannot be realized. Therefore, it has been difficult to realize the electronic gear function in an inexpensive general-purpose MCU that does not have a hardware division instruction corresponding to the hardware.
これに対して、本実施形態では、ハードウェアに対応するハードウェア除算命令が無い安価な汎用MCUで、高応答および高精度な位置決めを行うACサーボモータの電子ギア機能を適切に実現することができる。また、電子ギアの異常を除算の結果から容易に判断することができる。
なお、上記実施形態においては、整数除算装置が、ACサーボモータが有する電子ギア機能を実現する場合について説明したが、電子ギア機能以外の整数除算処理にも適用可能である。
On the other hand, in the present embodiment, it is possible to appropriately realize the electronic gear function of the AC servomotor that performs high response and high accuracy positioning with an inexpensive general-purpose MCU that does not have a hardware division instruction corresponding to the hardware. it can. In addition, the abnormality of the electronic gear can be easily determined from the result of division.
In the above embodiment, the case where the integer division device realizes the electronic gear function of the AC servomotor has been described, but it can also be applied to the integer division processing other than the electronic gear function.
10…モータ制御装置、11〜13…電子ギア部、14…位置速度制御器、15…電力変換部、11a…取得部、11b…判定部、11c…除算部、11d…出力部、11e…異常判断部、21…モータ、22…エンコーダ 10 ... Motor control device, 11-13 ... Electronic gear unit, 14 ... Position and speed controller, 15 ... Power conversion unit, 11a ... Acquisition unit, 11b ... Judgment unit, 11c ... Division unit, 11d ... Output unit, 11e ... Abnormality Judgment unit, 21 ... motor, 22 ... encoder
Claims (12)
前記判定部により前記商の値が前記レジスタの大きさのビット数で表せる値の範囲に収まらないと判定された場合、予め定められた固定値を出力値として前記レジスタに出力する出力部と、を備えることを特徴とする整数除算装置。 A determination unit that determines whether or not the value of the quotient obtained by dividing the divisor by the divisor based on the divisor and the divisor falls within the range of values that can be represented by the number of bits of the register size.
When the determination unit determines that the value of the quotient does not fall within the range of values that can be represented by the number of bits of the size of the register, an output unit that outputs a predetermined fixed value as an output value to the register. An integer divider characterized by comprising.
前記出力部は、
前記判定部により前記商の値が前記レジスタの大きさのビット数で表せる値の範囲に収まると判定された場合、前記除算部による前記除算処理の結果である商を前記出力値として出力し、
前記判定部により前記商の値が前記レジスタの大きさのビット数で表せる値の範囲に収まらないと判定された場合、前記固定値を前記出力値として出力することを特徴とする請求項1に記載の整数除算装置。 When the determination unit determines that the value of the quotient falls within the range of values that can be represented by the number of bits of the size of the register, the determination unit further includes a division unit that performs a division process of dividing the divisor by an integer by the divisor.
The output unit
When the determination unit determines that the value of the quotient falls within the range of values that can be represented by the number of bits of the size of the register, the quotient that is the result of the division processing by the division unit is output as the output value.
The first aspect of the present invention is to output the fixed value as the output value when the determination unit determines that the value of the quotient does not fall within the range of values that can be represented by the number of bits of the size of the register. The integer divider described.
前記除数を定数として扱い、当該除数の逆数に対応する値を前記被除数に乗算することで前記除算処理を行うことを特徴とする請求項2に記載の整数除算装置。 The division unit
The integer division apparatus according to claim 2, wherein the division is performed by treating the divisor as a constant and multiplying the divisor by a value corresponding to the reciprocal of the divisor.
前記電子ギア部においてモータの位置指令値を前記入力信号として調整された前記位置指令値に基づいて、前記モータを制御する電力変換部と、を備え、
前記電子ギア部は、
被除数および除数に基づいて、前記被除数を前記除数で除算して得られる商の値がレジスタの大きさのビット数で表せる値の範囲に収まるか否かを判定する判定部と、
前記判定部により前記商の値が前記レジスタの大きさのビット数で表せる値の範囲に収まらないと判定された場合、予め定められた固定値を出力値として前記レジスタに出力する出力部と、を備えることを特徴とするモータ制御装置。 An electronic gear section that adjusts the input signal based on the electronic gear ratio,
The electronic gear unit includes a power conversion unit that controls the motor based on the position command value adjusted by adjusting the position command value of the motor as the input signal.
The electronic gear unit
A determination unit that determines whether or not the value of the quotient obtained by dividing the divisor by the divisor based on the divisor and the divisor falls within the range of values that can be represented by the number of bits of the register size.
When the determination unit determines that the value of the quotient does not fall within the range of values that can be represented by the number of bits of the size of the register, an output unit that outputs a predetermined fixed value as an output value to the register. A motor control device characterized by comprising.
前記判定部により前記商の値が前記レジスタの大きさのビット数で表せる値の範囲に収まると判定された場合、前記被除数を前記除数で整数除算する除算処理を行う除算部をさらに備え、
前記出力部は、
前記判定部により前記商の値が前記レジスタの大きさのビット数で表せる値の範囲に収まると判定された場合、前記除算部による前記除算処理の結果である商を前記出力値として出力し、
前記判定部により前記商の値が前記レジスタの大きさのビット数で表せる値の範囲に収まらないと判定された場合、前記固定値を前記出力値として出力することを特徴とする請求項8に記載のモータ制御装置。 The electronic gear unit
When the determination unit determines that the value of the quotient falls within the range of values that can be represented by the number of bits of the size of the register, the determination unit further includes a division unit that performs a division process of dividing the divisor by an integer by the divisor.
The output unit
When the determination unit determines that the value of the quotient falls within the range of values that can be represented by the number of bits of the size of the register, the quotient that is the result of the division processing by the division unit is output as the output value.
The eighth aspect of the present invention is characterized in that when the determination unit determines that the value of the quotient does not fall within the range of values that can be represented by the number of bits of the size of the register, the fixed value is output as the output value. The motor control device described.
前記除算部は、
前記除数を定数として扱い、当該除数の逆数に対応する値を前記被除数に乗算することで前記除算処理を行うことを特徴とする請求項9に記載のモータ制御装置。 The divisor is either the resolution of the position command value or the resolution of the encoder connected to the motor.
The division unit
The motor control device according to claim 9, wherein the divisor is treated as a constant, and the division process is performed by multiplying the divisor by a value corresponding to the reciprocal of the divisor.
前記商の値が前記レジスタの大きさのビット数で表せる値の範囲に収まると判定された場合、予め定められた固定値を出力値として前記レジスタに出力するステップと、を含むことを特徴とする整数除算方法。 A step of determining whether or not the value of the quotient obtained by dividing the divisor by the divisor based on the divisor and the divisor falls within the range of values that can be represented by the number of bits of the register size.
When it is determined that the value of the quotient falls within the range of values that can be represented by the number of bits of the size of the register, it is characterized by including a step of outputting a predetermined fixed value as an output value to the register. Integer division method to do.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2019058398A JP7036075B2 (en) | 2019-03-26 | 2019-03-26 | Integer divider and motor controller |
CN202010099219.7A CN111752531B (en) | 2019-03-26 | 2020-02-18 | Integer division device and motor control device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2019058398A JP7036075B2 (en) | 2019-03-26 | 2019-03-26 | Integer divider and motor controller |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2020160704A true JP2020160704A (en) | 2020-10-01 |
JP7036075B2 JP7036075B2 (en) | 2022-03-15 |
Family
ID=72643400
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2019058398A Active JP7036075B2 (en) | 2019-03-26 | 2019-03-26 | Integer divider and motor controller |
Country Status (2)
Country | Link |
---|---|
JP (1) | JP7036075B2 (en) |
CN (1) | CN111752531B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2023272398A1 (en) | 2021-06-30 | 2023-01-05 | Leggett & Platt Canada Co. | Smart motor systems and methods using local intelligence |
CN114520613B (en) * | 2022-03-17 | 2022-11-15 | 哈尔滨理工大学 | Speed estimation method based on parameter-introduced asynchronous motor speed feedback observation algorithm |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS5741737A (en) * | 1980-08-22 | 1982-03-09 | Nec Corp | Dividing device |
JPH02242426A (en) * | 1989-03-16 | 1990-09-26 | Meidensha Corp | Division system for digital signal processor |
JPH06180640A (en) * | 1992-12-11 | 1994-06-28 | Canon Inc | Device and method for division |
JPH09222993A (en) * | 1996-02-14 | 1997-08-26 | Nec Corp | Divider |
JP2006023974A (en) * | 2004-07-08 | 2006-01-26 | Fujitsu Ltd | Remainder calculation processor and remainder calculation processing method |
JP2010033275A (en) * | 2008-07-28 | 2010-02-12 | Olympus Corp | Data processing method and data processor |
JP2015180983A (en) * | 2014-03-02 | 2015-10-15 | 裕 道脇 | Zero-division arithmetic processing program |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5426600A (en) * | 1993-09-27 | 1995-06-20 | Hitachi America, Ltd. | Double precision division circuit and method for digital signal processor |
CN100543666C (en) * | 2006-09-18 | 2009-09-23 | 华为技术有限公司 | The method of a kind of fixed-point divider and realization computing thereof |
CN102314331A (en) * | 2011-08-02 | 2012-01-11 | 深圳市国微电子股份有限公司 | Divider and realization method thereof |
US20140195581A1 (en) * | 2013-01-08 | 2014-07-10 | Analog Devices, Inc. | Fixed point division circuit utilizing floating point architecture |
US20160034256A1 (en) * | 2014-08-01 | 2016-02-04 | Imagination Technologies, Limited | Fast integer division |
CN108897523B (en) * | 2018-07-02 | 2021-01-26 | 京东方科技集团股份有限公司 | Divider and operation method thereof and electronic equipment |
-
2019
- 2019-03-26 JP JP2019058398A patent/JP7036075B2/en active Active
-
2020
- 2020-02-18 CN CN202010099219.7A patent/CN111752531B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS5741737A (en) * | 1980-08-22 | 1982-03-09 | Nec Corp | Dividing device |
JPH02242426A (en) * | 1989-03-16 | 1990-09-26 | Meidensha Corp | Division system for digital signal processor |
JPH06180640A (en) * | 1992-12-11 | 1994-06-28 | Canon Inc | Device and method for division |
JPH09222993A (en) * | 1996-02-14 | 1997-08-26 | Nec Corp | Divider |
JP2006023974A (en) * | 2004-07-08 | 2006-01-26 | Fujitsu Ltd | Remainder calculation processor and remainder calculation processing method |
JP2010033275A (en) * | 2008-07-28 | 2010-02-12 | Olympus Corp | Data processing method and data processor |
JP2015180983A (en) * | 2014-03-02 | 2015-10-15 | 裕 道脇 | Zero-division arithmetic processing program |
Also Published As
Publication number | Publication date |
---|---|
CN111752531A (en) | 2020-10-09 |
CN111752531B (en) | 2024-01-23 |
JP7036075B2 (en) | 2022-03-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP7036075B2 (en) | Integer divider and motor controller | |
CN108733349B (en) | Trigonometric function operation circuit based on fixed point number | |
JP4757328B2 (en) | Inverse tangent calculation device and inverse tangent calculation program | |
US8674632B2 (en) | Motor control device with a correcting unit determining a corrected rotation angle after a predetermined time from a detection time, control program therefor, and method for the control | |
CN111813371A (en) | Floating-point division operation method, system and readable medium for digital signal processing | |
CN109768755B (en) | Semiconductor device, angle value correction circuit and method thereof | |
KR102412746B1 (en) | Apparatus and method for performing floating-point square root operation | |
CN113138749A (en) | Trigonometric function calculation device and method based on CORDIC algorithm | |
US6014683A (en) | Arithmetic operation system for arithmetically operating a first operand having an actual point and a second operand having no actual point | |
KR20140138053A (en) | Fma-unit, in particular for use in a model calculation unit for pure hardware-based calculation of a function-model | |
JP2015015026A (en) | Model calculation unit for calculating function model based on data using data on various numeric format, and control device | |
JP2022103046A (en) | Signal generating device | |
JP4463533B2 (en) | Rotary encoder detection device | |
CN112104292A (en) | Motor control method and device, terminal equipment and storage medium | |
CA1173164A (en) | Fraction calculator | |
JP5765263B2 (en) | Motor control device and motor control method | |
JP2010102431A (en) | Floating decimal point arithmetic circuit, floating decimal point arithmetic method, and servo-controlled system | |
CN109849688B (en) | Motor control method and device for electric bicycle, controller and storage medium | |
JPH06259227A (en) | Arithmetic unit | |
WO2023100372A1 (en) | Data processing device, data processing method, and data processing program | |
JP2002112566A (en) | Motor controller | |
US20120102081A1 (en) | Low-latency arc-tangent calculation structure and calculation method thereof | |
JP2000032789A (en) | Pulse counter | |
CN109669667B (en) | Data processing method and device implemented on fixed-point DSP chip | |
JPH10149277A (en) | Multiplication device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20201222 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20211130 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20220112 |
|
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: 20220201 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20220214 |
|
R151 | Written notification of patent or utility model registration |
Ref document number: 7036075 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R151 |