JP2022103046A - Signal generating device - Google Patents

Signal generating device Download PDF

Info

Publication number
JP2022103046A
JP2022103046A JP2021160449A JP2021160449A JP2022103046A JP 2022103046 A JP2022103046 A JP 2022103046A JP 2021160449 A JP2021160449 A JP 2021160449A JP 2021160449 A JP2021160449 A JP 2021160449A JP 2022103046 A JP2022103046 A JP 2022103046A
Authority
JP
Japan
Prior art keywords
value
timer
processing
count
interrupt
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.)
Pending
Application number
JP2021160449A
Other languages
Japanese (ja)
Inventor
周平 村瀬
Shuhei MURASE
智久 ▲徳▼永
Tomohisa Tokunaga
大輔 水沼
Daisuke Mizunuma
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.)
Nidec Corp
Original Assignee
Nidec Corp
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 Nidec Corp filed Critical Nidec Corp
Priority to US17/560,481 priority Critical patent/US11797463B2/en
Priority to CN202111599772.8A priority patent/CN114690846B/en
Publication of JP2022103046A publication Critical patent/JP2022103046A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Transmission And Conversion Of Sensor Element Output (AREA)

Abstract

To provide a signal generating device that can simplify software and hardware required for generating a bi-phase pulse signal having a predetermined phase difference and can be realized by an inexpensive and general-purpose microcomputer.SOLUTION: A signal generating device includes: a first timer for outputting an interruption signal at a predetermined period; a second timer for outputting a first pulse signal and a second pulse signal having a predetermined phase difference; a third timer for counting the number of edges of the first pulse signal and the second pulse signal; and a processing part for performing interruption processing for controlling an output mode of the second timer each time when the interruption signal is generated. The processing part performs short-period processing without performing long-period processing when the number of interruption times is not equal to an initial value while performing predetermined short-period processing after performing predetermined long-period processing when the number of interruption times is equal to the initial value when starting interruption processing.SELECTED DRAWING: Figure 1

Description

本発明は、信号生成装置に関する。 The present invention relates to a signal generator.

一般的なインクリメント型のロータリエンコーダは、回転体の回転角度に応じて90°の位相差を有する2相のパルス信号(A相パルス信号及びB相パルス信号)を出力する。例えば、下記特許文献1には、磁気センサの出力信号を基に回転体の回転角度を算出し、回転角度の算出結果に基づいてA相パルス信号とB相パルス信号とを生成する回転検出装置が開示されている。 A general increment type rotary encoder outputs a two-phase pulse signal (A-phase pulse signal and B-phase pulse signal) having a phase difference of 90 ° according to the rotation angle of the rotating body. For example, in Patent Document 1 below, a rotation detection device that calculates the rotation angle of a rotating body based on the output signal of a magnetic sensor and generates an A-phase pulse signal and a B-phase pulse signal based on the calculation result of the rotation angle. Is disclosed.

特許第4823021号公報Japanese Patent No. 4823021

特許文献1の回転検出装置では、A相パルス信号とB相パルス信号とを生成するために必要なソフトウェア及びハードウェアが複雑化する。その結果、ソフトウェアを実行するプロセッサの処理負荷が増大し、ハードウェアのコストも増大するため、特許文献1の回転検出装置を実現するには、高価且つハイスペックな専用チップが必要である。 In the rotation detection device of Patent Document 1, the software and hardware required to generate the A-phase pulse signal and the B-phase pulse signal are complicated. As a result, the processing load of the processor that executes the software increases, and the cost of the hardware also increases. Therefore, in order to realize the rotation detection device of Patent Document 1, an expensive and high-spec dedicated chip is required.

本発明は上記事情に鑑みて、所定の位相差を有する2相のパルス信号を生成するために必要なソフトウェア及びハードウェアを簡素化でき、且つ安価な汎用マイコンによって実現可能な信号生成装置を提供することを一つの目的とする。 In view of the above circumstances, the present invention provides a signal generation device capable of simplifying software and hardware required for generating a two-phase pulse signal having a predetermined phase difference and being feasible by an inexpensive general-purpose microcomputer. One purpose is to do.

本発明の信号生成装置における一つの態様は、所定の周期で割込み信号を出力する第1タイマと、所定の位相差を有する第1パルス信号と第2パルス信号とを出力する第2タイマと、前記第1パルス信号及び前記第2パルス信号のエッジ数をカウントする第3タイマと、前記割込み信号が発生するごとに、前記第2タイマの出力モードを制御する割込み処理を行う処理部と、を備える。
前記処理部は、前記割込み処理の開始時に前記割込み信号の発生回数である割込み回数が初期値と等しい場合、所定の長周期処理を行った後に所定の短周期処理を行う一方、前記割込み回数が前記初期値と等しくない場合、前記長周期処理を行うことなく前記短周期処理を行う。
前記処理部は、前記長周期処理として、回転体の絶対角度を示す絶対角度情報を更新する角度更新処理と、更新後の前記絶対角度情報が示す絶対角度を時間の一次関数として表す絶対角度関数を算出する関数算出処理と、を実行する。
前記処理部は、前記短周期処理として、前記関数算出処理によって算出された前記絶対角度関数に基づいて前記絶対角度の推定値を角度推定値として算出する角度推定値算出処理と、前記第3タイマから前記エッジ数のカウント値を取得するカウント値取得処理と、前記カウント値に基づいて前記絶対角度の現在値を角度現在値として算出する角度現在値算出処理と、前記カウント値に基づいて前記第1パルス信号のレベルと前記第2パルス信号のレベルとの関係を表す信号状態値を算出する信号状態値算出処理と、前記角度推定値及び前記角度現在値に基づいて、前記第2タイマの前記出力モードを変化させるタイミングか否かを判定するタイミング判定処理と、前記タイミング判定処理において前記出力モードを変化させるタイミングと判定されたとき、前記信号状態値に基づいて前記第1パルス信号と前記第2パルス信号との一方のパルス信号の前記出力モードを、ハイレベル出力モードとローレベル出力モードとの一方に変化させる第1出力モード切替処理と、前記割込み回数を更新する割込み回数更新処理と、更新後の前記割込み回数が所定の第1閾値と等しい場合に、前記割込み回数を前記初期値にリセットする割込み回数リセット処理と、を実行する。
One aspect of the signal generator of the present invention is a first timer that outputs an interrupt signal at a predetermined cycle, a second timer that outputs a first pulse signal and a second pulse signal having a predetermined phase difference, and the like. A third timer that counts the number of edges of the first pulse signal and the second pulse signal, and a processing unit that performs interrupt processing that controls the output mode of the second timer each time the interrupt signal is generated. Be prepared.
When the number of interrupts, which is the number of times the interrupt signal is generated, is equal to the initial value at the start of the interrupt processing, the processing unit performs a predetermined long-period processing and then a predetermined short-period processing, while the number of interrupts is If it is not equal to the initial value, the short cycle process is performed without performing the long cycle process.
As the long cycle processing, the processing unit has an angle updating process for updating the absolute angle information indicating the absolute angle of the rotating body, and an absolute angle function for expressing the absolute angle indicated by the updated absolute angle information as a linear function of time. And the function calculation process to calculate.
As the short cycle processing, the processing unit has an angle estimation value calculation processing for calculating an estimated value of the absolute angle as an angle estimation value based on the absolute angle function calculated by the function calculation processing, and the third timer. The count value acquisition process for acquiring the count value of the number of edges from the above, the angle current value calculation process for calculating the current value of the absolute angle as the current angle value based on the count value, and the first The signal state value calculation process for calculating the signal state value representing the relationship between the level of the 1-pulse signal and the level of the second pulse signal, and the second timer based on the angle estimation value and the angle current value. The first pulse signal and the first pulse signal based on the signal state value when the timing determination process for determining whether or not the timing is to change the output mode and the timing for changing the output mode are determined in the timing determination process. The first output mode switching process for changing the output mode of one of the two pulse signals to one of the high level output mode and the low level output mode, the interrupt count update process for updating the interrupt count, and the interrupt count update process. When the number of interrupts after the update is equal to a predetermined first threshold value, the number of interrupts reset process for resetting the number of interrupts to the initial value is executed.

本発明の上記態様によれば、所定の位相差を有する2相のパルス信号を生成するために必要なソフトウェア及びハードウェアを簡素化でき、且つ安価な汎用マイコンによって実現可能な信号生成装置を提供できる。 According to the above aspect of the present invention, there is provided a signal generation device that can simplify the software and hardware required to generate a two-phase pulse signal having a predetermined phase difference and can be realized by an inexpensive general-purpose microcomputer. can.

図1は、本発明の第1実施形態における信号生成装置の構成を模式的に示すブロック図である。FIG. 1 is a block diagram schematically showing a configuration of a signal generation device according to the first embodiment of the present invention. 図2は、A相パルス信号の波形と、B相パルス信号の波形と、Z相パルス信号の波形と、信号状態値との関係の一例を示す図である。FIG. 2 is a diagram showing an example of the relationship between the waveform of the A-phase pulse signal, the waveform of the B-phase pulse signal, the waveform of the Z-phase pulse signal, and the signal state value. 図3は、割込み信号の発生タイミングと、割込み回数の変化タイミングと、割込み処理の実行タイミングと、A/D変換器の動作タイミングと、角度演算処理の実行タイミングとの時間的な対応関係を示すタイミングチャートである。FIG. 3 shows the temporal correspondence between the generation timing of the interrupt signal, the change timing of the number of interrupts, the execution timing of the interrupt processing, the operation timing of the A / D converter, and the execution timing of the angle calculation processing. It is a timing chart. 図4は、第1実施形態において処理部が実行する割込み処理を示すフローチャートである。FIG. 4 is a flowchart showing an interrupt process executed by the processing unit in the first embodiment. 図5は、絶対角度の遅延補償に関する説明図である。FIG. 5 is an explanatory diagram regarding delay compensation of an absolute angle. 図6は、第1実施形態の割込み処理によって第2タイマからA相パルス信号及びB相パルス信号が出力される一例を示す図である。FIG. 6 is a diagram showing an example in which an A-phase pulse signal and a B-phase pulse signal are output from the second timer by the interrupt processing of the first embodiment. 図7は、第3タイマの動作を示す図である。FIG. 7 is a diagram showing the operation of the third timer. 図8は、絶対角度とエッジカウント値との対応関係を示す図である。FIG. 8 is a diagram showing the correspondence between the absolute angle and the edge count value. 図9は、第2実施形態において処理部が実行する割込み処理を示すフローチャートである。FIG. 9 is a flowchart showing an interrupt process executed by the processing unit in the second embodiment. 図10は、第2実施形態の割込み処理に含まれる高速モード処理によって第2タイマからA相パルス信号及びB相パルス信号が出力される一例を示す図である。FIG. 10 is a diagram showing an example in which an A-phase pulse signal and a B-phase pulse signal are output from the second timer by the high-speed mode processing included in the interrupt processing of the second embodiment. 図11は、本発明の第3実施形態における信号生成装置の構成を模式的に示すブロック図である。FIG. 11 is a block diagram schematically showing the configuration of the signal generation device according to the third embodiment of the present invention. 図12は、第4タイマのカウント値と、第4タイマから出力されるZ相パルス信号との関係を示す図である。FIG. 12 is a diagram showing the relationship between the count value of the fourth timer and the Z-phase pulse signal output from the fourth timer. 図13は、第4タイマによるカウント中にロータが逆転した場合の処理について説明するために用いられる図である。FIG. 13 is a diagram used to explain processing when the rotor reverses during counting by the fourth timer.

以下、本発明の一実施形態について図面を参照しながら詳細に説明する。
〔第1実施形態〕
図1は、本発明の第1実施形態における信号生成装置10の構成を模式的に示すブロック図である。図1に示すように、第1実施形態における信号生成装置10は、A/D変換器11と、第1タイマ12と、第2タイマ13と、第3タイマ14と、記憶部15と、処理部16と、を備える。信号生成装置10は、センサ部20と電気的に接続される。センサ部20は、3つの磁気センサ21、22及び23を有する。磁気センサ21、22及び23のそれぞれは、回転体の回転角度に応じて変化する磁束強度を検出し、磁束強度の検出結果を示すアナログ信号を磁束検出信号として出力するホールセンサである。
Hereinafter, an embodiment of the present invention will be described in detail with reference to the drawings.
[First Embodiment]
FIG. 1 is a block diagram schematically showing the configuration of the signal generation device 10 according to the first embodiment of the present invention. As shown in FIG. 1, the signal generation device 10 in the first embodiment processes the A / D converter 11, the first timer 12, the second timer 13, the third timer 14, and the storage unit 15. A unit 16 is provided. The signal generation device 10 is electrically connected to the sensor unit 20. The sensor unit 20 has three magnetic sensors 21, 22 and 23. Each of the magnetic sensors 21, 22 and 23 is a hall sensor that detects the magnetic flux strength that changes according to the rotation angle of the rotating body and outputs an analog signal indicating the detection result of the magnetic flux strength as the magnetic flux detection signal.

本実施形態において回転体は、例えば3相ブラシレスDCモータのロータである。3相ブラシレスDCモータには、3相コイルに駆動電流を供給する制御基板が装着される。磁気センサ21、22及び23は、ロータの軸方向においてロータマグネットと対向する状態で制御基板に配置される。また、ロータの軸方向からみて、磁気センサ21、22及び23は、ロータの回転方向に沿って一定間隔で制御基板に配置される。一定間隔は、例えば120°間隔である。 In the present embodiment, the rotating body is, for example, a rotor of a three-phase brushless DC motor. A control board that supplies a drive current to a three-phase coil is mounted on a three-phase brushless DC motor. The magnetic sensors 21, 22 and 23 are arranged on the control board in a state of facing the rotor magnet in the axial direction of the rotor. Further, the magnetic sensors 21, 22 and 23 are arranged on the control board at regular intervals along the rotation direction of the rotor when viewed from the axial direction of the rotor. The constant interval is, for example, a 120 ° interval.

磁気センサ21は、U相における磁束強度の検出結果を示す磁束検出信号Huを出力する。磁気センサ22は、V相における磁束強度の検出結果を示す磁束検出信号Hvを出力する。磁気センサ23は、W相における磁束強度の検出結果を示す磁束検出信号Hwを出力する。3つの磁束検出信号Hu、Hv及びHwは、互いに電気角で120°の位相差を有する。 The magnetic sensor 21 outputs a magnetic flux detection signal Hu indicating a detection result of the magnetic flux intensity in the U phase. The magnetic sensor 22 outputs a magnetic flux detection signal Hv indicating a detection result of the magnetic flux intensity in the V phase. The magnetic sensor 23 outputs a magnetic flux detection signal Hw indicating a detection result of the magnetic flux intensity in the W phase. The three magnetic flux detection signals Hu, Hv and Hw have a phase difference of 120 ° in electrical angle from each other.

信号生成装置10は、例えば制御基板に配置されたMCU(Microcontroller Unit)などのマイクロプロセッサである。信号生成装置10は、センサ部20から出力される磁束検出信号Hu、Hv及びHwに基づいてロータの絶対角度θを算出し、絶対角度θの算出結果に基づいて所定の位相差を有する第1パルス信号と第2パルス信号とを生成する。本実施形態において所定の位相差は、例えば90°である。以下では、第1パルス信号をA相パルス信号PAと呼称し、第2パルス信号をB相パルス信号PBと呼称する。また、信号生成装置10は、絶対角度θの原点を示す原点パルス信号を生成する。以下では、原点パルス信号をZ相パルス信号PZと呼称する。 The signal generation device 10 is a microprocessor such as an MCU (Microcontroller Unit) arranged on a control board, for example. The signal generation device 10 calculates the absolute angle θ of the rotor based on the magnetic flux detection signals Hu, Hv, and Hw output from the sensor unit 20, and has a predetermined phase difference based on the calculation result of the absolute angle θ. A pulse signal and a second pulse signal are generated. In this embodiment, the predetermined phase difference is, for example, 90 °. Hereinafter, the first pulse signal is referred to as an A-phase pulse signal PA, and the second pulse signal is referred to as a B-phase pulse signal PB. Further, the signal generation device 10 generates an origin pulse signal indicating the origin of the absolute angle θ. Hereinafter, the origin pulse signal is referred to as a Z-phase pulse signal PZ.

センサ部20から出力される磁束検出信号Hu、Hv及びHwは、信号生成装置10のA/D変換器11に入力される。A/D変換器11は、磁束検出信号Hu、Hv及びHwのそれぞれを所定のサンプリング周波数でサンプリングすることによりデジタルデータに変換し、磁束検出信号Hu、Hv及びHwのデジタルデータを処理部16に出力する。 The magnetic flux detection signals Hu, Hv and Hw output from the sensor unit 20 are input to the A / D converter 11 of the signal generation device 10. The A / D converter 11 converts each of the magnetic flux detection signals Hu, Hv, and Hw into digital data by sampling at a predetermined sampling frequency, and converts the digital data of the magnetic flux detection signals Hu, Hv, and Hw into the processing unit 16. Output.

第1タイマ12は、所定の周期で割込み信号INTを処理部16に出力する。具体的には、第1タイマ12は、不図示のクロック信号に同期してタイマカウント値をインクリメントし、タイマカウント値がタイマリセット値TRES1に到達すると、割込み信号INTを出力すると共にタイマカウント値をリセットする。このように、第1タイマ12から割込み信号INTが出力される周期は、タイマリセット値TRES1によって決定される。タイマリセット値TRES1は、処理部16によって第1タイマ12にセットされる。 The first timer 12 outputs an interrupt signal INT to the processing unit 16 at a predetermined cycle. Specifically, the first timer 12 increments the timer count value in synchronization with a clock signal (not shown), and when the timer count value reaches the timer reset value TRES1, outputs an interrupt signal INT and outputs the timer count value. Reset. In this way, the cycle in which the interrupt signal INT is output from the first timer 12 is determined by the timer reset value TRES1. The timer reset value TRES1 is set in the first timer 12 by the processing unit 16.

第2タイマ13は、90°の位相差を有するA相パルス信号PAとB相パルス信号PBとを出力する。第2タイマ13は、A相パルス信号PA及びB相パルス信号PBの出力モードとして、ハイレベル出力モードと、ローレベル出力モードと、比較出力モードと、を有する。A相パルス信号PAの出力モードがハイレベル出力モードのとき、第2タイマ13は、A相パルス信号PAのレベルをハイレベルにセットする。A相パルス信号PAの出力モードがローレベル出力モードのとき、第2タイマ13は、A相パルス信号PAのレベルをローレベルにセットする。B相パルス信号PBについても同様である。 The second timer 13 outputs the A-phase pulse signal PA and the B-phase pulse signal PB having a phase difference of 90 °. The second timer 13 has a high-level output mode, a low-level output mode, and a comparative output mode as output modes of the A-phase pulse signal PA and the B-phase pulse signal PB. When the output mode of the A-phase pulse signal PA is the high-level output mode, the second timer 13 sets the level of the A-phase pulse signal PA to a high level. When the output mode of the A-phase pulse signal PA is the low level output mode, the second timer 13 sets the level of the A-phase pulse signal PA to the low level. The same applies to the B-phase pulse signal PB.

一方、出力モードが比較出力モードのとき、第2タイマ13は、不図示のクロック信号に同期してタイマカウント値をインクリメントし、タイマカウント値がタイマリセット値TRES2に到達するごとに、タイマカウント値をリセットする。また、出力モードが比較出力モードのとき、第2タイマ13は、タイマカウント値が第1レベル反転閾値Acomに到達するごとに、A相パルス信号PAのレベルを反転させ、タイマカウント値が第2レベル反転閾値Bcomに到達するごとに、B相パルス信号PBのレベルを反転させる。 On the other hand, when the output mode is the comparative output mode, the second timer 13 increments the timer count value in synchronization with a clock signal (not shown), and each time the timer count value reaches the timer reset value TRES2, the timer count value is reached. To reset. Further, when the output mode is the comparative output mode, the second timer 13 inverts the level of the A-phase pulse signal PA every time the timer count value reaches the first level inversion threshold value Acom, and the timer count value becomes the second. Every time the level inversion threshold value Bcom is reached, the level of the B-phase pulse signal PB is inverted.

第2タイマ13の出力モードは、処理部16から第2タイマ13へ出力される出力モード設定信号MSETによって切り替えられる。タイマリセット値TRES2、第1レベル反転閾値Acom、及び第2レベル反転閾値Bcomは、処理部16によって第2タイマ13にセットされる。なお、第2タイマ13から出力されるA相パルス信号PA及びB相パルス信号PBは、第3タイマ14に入力される。 The output mode of the second timer 13 is switched by the output mode setting signal MSET output from the processing unit 16 to the second timer 13. The timer reset value TRES2, the first level inversion threshold value Acom, and the second level inversion threshold value Bcom are set in the second timer 13 by the processing unit 16. The A-phase pulse signal PA and the B-phase pulse signal PB output from the second timer 13 are input to the third timer 14.

第3タイマ14は、第2タイマ13から出力されるA相パルス信号PA及びB相パルス信号PBのエッジ数をカウントする。第3タイマ14は、エッジ数のカウント値が所定のタイマリセット値TRES3に到達すると、エッジ数のカウント値をリセットする。以下では、エッジ数のカウント値をエッジカウント値ECと呼称する。第3タイマ14は、エッジカウント値ECと所定のZ相出力閾値Zcom(第3閾値)とを比較し、エッジカウント値ECがZ相出力閾値Zcomより小さいときにハイレベルとなる信号を、絶対角度θの原点を示すZ相パルス信号PZとして出力する。タイマリセット値TRES3及びZ相出力閾値Zcomは、処理部16によって第3タイマ14にセットされる。第3タイマ14は、エッジカウント値ECを処理部16に出力する。 The third timer 14 counts the number of edges of the A-phase pulse signal PA and the B-phase pulse signal PB output from the second timer 13. When the count value of the number of edges reaches the predetermined timer reset value TRES3, the third timer 14 resets the count value of the number of edges. Hereinafter, the count value of the number of edges is referred to as an edge count value EC. The third timer 14 compares the edge count value EC with a predetermined Z-phase output threshold value Zcom (third threshold value), and outputs a signal that becomes a high level when the edge count value EC is smaller than the Z-phase output threshold value Zcom. It is output as a Z-phase pulse signal PZ indicating the origin of the angle θ. The timer reset value TRES3 and the Z-phase output threshold value Zcom are set in the third timer 14 by the processing unit 16. The third timer 14 outputs the edge count value EC to the processing unit 16.

記憶部15は、処理部16に各種処理を実行させるのに必要なプログラム及び設定値などを予め記憶する不揮発性メモリと、処理部16が各種処理を実行する際にデータの一時保存先として使用される揮発性メモリとを含む。不揮発性メモリは、例えばEEPROM(Electrically Erasable Programmable Read-Only Memory)及びフラッシュメモリなどである。揮発性メモリは、例えばRAM(Random Access Memory)及びレジスタなどである。不揮発性メモリには、設定値として、第1タイマ12のタイマリセット値TRES1、第3タイマ14のタイマリセット値TRES3及びZ相出力閾値Zthなどが記憶される。詳細は後述するが、第2タイマ13のタイマリセット値TRES2、第1レベル反転閾値Acom、及び第2レベル反転閾値Bcomは、処理部16によって算出される。 The storage unit 15 is used as a non-volatile memory for preliminarily storing programs and setting values necessary for the processing unit 16 to execute various processes, and as a temporary storage destination of data when the processing unit 16 executes various processes. Includes volatile memory. Examples of the non-volatile memory include EEPROM (Electrically Erasable Programmable Read-Only Memory) and flash memory. The volatile memory is, for example, a RAM (Random Access Memory) and a register. In the non-volatile memory, the timer reset value TRES1 of the first timer 12, the timer reset value TRES3 of the third timer 14, the Z-phase output threshold Zth, and the like are stored as set values. Although the details will be described later, the timer reset value TRES2 of the second timer 13, the first level inversion threshold value Acom, and the second level inversion threshold value Bcom are calculated by the processing unit 16.

処理部16は、記憶部15に記憶されたプログラムに従って各種処理を実行するプロセッサコアである。処理部16は、A/D変換器11から入力される磁束検出信号Hu、Hv及びHwのデジタルデータに基づいてロータの絶対角度θを算出する角度演算処理を実行する。また、処理部16は、割込み信号INTが発生するごとに、第2タイマ13の出力モードを制御する割込み処理を行う。処理部16が絶対角度θに基づいて第2タイマ13の出力モードを制御することにより、第2タイマ13から90°の位相差を有するA相パルス信号PAとB相パルス信号PBとが出力される。第2タイマ13からA相パルス信号PA及びB相パルス信号PBが出力されると、第3タイマ14から自動的にZ相パルス信号PZが出力される。 The processing unit 16 is a processor core that executes various processes according to a program stored in the storage unit 15. The processing unit 16 executes an angle calculation process for calculating the absolute angle θ of the rotor based on the digital data of the magnetic flux detection signals Hu, Hv, and Hw input from the A / D converter 11. Further, the processing unit 16 performs interrupt processing for controlling the output mode of the second timer 13 each time an interrupt signal INT is generated. By controlling the output mode of the second timer 13 based on the absolute angle θ, the processing unit 16 outputs the A-phase pulse signal PA and the B-phase pulse signal PB having a phase difference of 90 ° from the second timer 13. To. When the A-phase pulse signal PA and the B-phase pulse signal PB are output from the second timer 13, the Z-phase pulse signal PZ is automatically output from the third timer 14.

図2は、A相パルス信号PAの波形と、B相パルス信号PBの波形と、Z相パルス信号PZの波形と、信号状態値Stateとの関係の一例を示す図である。図2において、A相パルス信号PAの周期を「T」とすると、「a」、「b」、「c」及び「d」の長さは、それぞれT/4である。図2に示すように、B相パルス信号PBは、A相パルス信号PAに対して、T/4の遅延時間を有する。このように、A相パルス信号PAとB相パルス信号PBとの間に90°の位相差が存在する。Z相パルス信号PZの立ち上がりエッジは、A相パルス信号PAの立ち上がりエッジと同期して発生する。Z相パルス信号PZのパルス幅は、Z相出力閾値Zcomによって任意の値に調整可能である。 FIG. 2 is a diagram showing an example of the relationship between the waveform of the A-phase pulse signal PA, the waveform of the B-phase pulse signal PB, the waveform of the Z-phase pulse signal PZ, and the signal state value State. In FIG. 2, assuming that the period of the A-phase pulse signal PA is “T”, the lengths of “a”, “b”, “c” and “d” are T / 4, respectively. As shown in FIG. 2, the B-phase pulse signal PB has a delay time of T / 4 with respect to the A-phase pulse signal PA. As described above, there is a phase difference of 90 ° between the A-phase pulse signal PA and the B-phase pulse signal PB. The rising edge of the Z-phase pulse signal PZ is generated in synchronization with the rising edge of the A-phase pulse signal PA. The pulse width of the Z-phase pulse signal PZ can be adjusted to an arbitrary value by the Z-phase output threshold value Zcom.

なお、詳細は後述するが、図2に示す信号状態値Stateは、上記の割込み処理において処理部16がエッジカウント値ECに基づいて算出する値である。信号状態値Stateは、A相パルス信号PAのレベルとB相パルス信号PBのレベルとの関係を表す。例えば、信号状態値Stateが「0」の場合、信号状態値Stateは、A相パルス信号PA及びB相パルス信号PBの両方がハイレベルである状態を表す。信号状態値Stateが「1」の場合、信号状態値Stateは、A相パルス信号PAがハイレベルであり且つB相パルス信号PBがローレベルである状態を表す。信号状態値Stateが「2」の場合、信号状態値Stateは、A相パルス信号PA及びB相パルス信号PBの両方がローレベルである状態を表す。信号状態値Stateが「3」の場合、信号状態値Stateは、A相パルス信号PAがローレベルであり且つB相パルス信号PBがハイレベルである状態を表す。 Although details will be described later, the signal state value State shown in FIG. 2 is a value calculated by the processing unit 16 based on the edge count value EC in the above interrupt processing. The signal state value State represents the relationship between the level of the A-phase pulse signal PA and the level of the B-phase pulse signal PB. For example, when the signal state value State is "0", the signal state value State represents a state in which both the A-phase pulse signal PA and the B-phase pulse signal PB are at a high level. When the signal state value State is "1", the signal state value State represents a state in which the A-phase pulse signal PA is at a high level and the B-phase pulse signal PB is at a low level. When the signal state value State is "2", the signal state value State represents a state in which both the A-phase pulse signal PA and the B-phase pulse signal PB are at a low level. When the signal state value State is "3", the signal state value State represents a state in which the A-phase pulse signal PA is at a low level and the B-phase pulse signal PB is at a high level.

以下では、図3から図8を参照しながら、上記のように構成される信号生成装置10の動作について説明する。 Hereinafter, the operation of the signal generation device 10 configured as described above will be described with reference to FIGS. 3 to 8.

信号生成装置10が電源オフ状態から電源オン状態に切り替わると、処理部16は所定の初期化処理を実行する。処理部16は、初期化処理の一つとして、記憶部15から第1タイマ12のタイマリセット値TRES1を読み出し、読み出したタイマリセット値TRES1を第1タイマ12にセットする。また、処理部16は、初期化処理の一つとして、記憶部15から第3タイマ14のタイマリセット値TRES3及びZ相出力閾値Zcomを読み出し、読み出したタイマリセット値TRES3及びZ相出力閾値Zcomを第3タイマ14にセットする。さらに、処理部16は、初期化処理の一つとして、第3タイマ14のエッジカウント値を絶対角度θに応じた初期値に設定するが、この設定処理の詳細については後述する。 When the signal generation device 10 is switched from the power-off state to the power-on state, the processing unit 16 executes a predetermined initialization process. As one of the initialization processes, the processing unit 16 reads the timer reset value TRES1 of the first timer 12 from the storage unit 15, and sets the read timer reset value TRES1 in the first timer 12. Further, the processing unit 16 reads the timer reset value TRES3 and the Z-phase output threshold value Zcom of the third timer 14 from the storage unit 15 as one of the initialization processes, and reads the read timer reset value TRES3 and the Z-phase output threshold value Zcom. Set to the third timer 14. Further, the processing unit 16 sets the edge count value of the third timer 14 to the initial value corresponding to the absolute angle θ as one of the initialization processes, and the details of this setting process will be described later.

図3は、割込み信号INTの発生タイミングと、割込み回数countの変化タイミングと、割込み処理の実行タイミングと、A/D変換器11の動作タイミングと、角度演算処理の実行タイミングとの時間的な対応関係を示すタイミングチャートである。
第1タイマ12にタイマリセット値TRES1がセットされると、第1タイマ12は、不図示のクロック信号に同期してタイマカウント値をインクリメントし、タイマカウント値がタイマリセット値TRES1に到達すると、割込み信号INTを出力すると共にタイマカウント値をリセットする。これにより、図3に示すように、第1タイマ12から所定の周期TINTで割込み信号INTが出力される。
FIG. 3 shows the temporal correspondence between the generation timing of the interrupt signal INT, the change timing of the interrupt count, the execution timing of the interrupt processing, the operation timing of the A / D converter 11, and the execution timing of the angle calculation processing. It is a timing chart showing the relationship.
When the timer reset value TRES1 is set in the first timer 12, the first timer 12 increments the timer count value in synchronization with a clock signal (not shown), and when the timer count value reaches the timer reset value TRES1, an interrupt occurs. The signal INT is output and the timer count value is reset. As a result, as shown in FIG. 3, the interrupt signal INT is output from the first timer 12 in a predetermined period T INT .

図3に示すように、処理部16は、割込み信号INTが発生するごとに割込み処理を行うが、割込み処理の開始時に割込み信号INTの発生回数である割込み回数countが初期値「0」と等しい場合、所定の長周期処理を行った後に所定の短周期処理を行う一方、割込み回数countが初期値「0」と等しくない場合、長周期処理を行うことなく短周期処理を行う。 As shown in FIG. 3, the processing unit 16 performs interrupt processing every time an interrupt signal INT is generated, and the interrupt count count, which is the number of times the interrupt signal INT is generated at the start of the interrupt processing, is equal to the initial value "0". In this case, the predetermined short cycle processing is performed after the predetermined long cycle processing is performed, while the short cycle processing is performed without performing the long cycle processing when the interrupt count count is not equal to the initial value “0”.

図3に示すように、割込み回数countは最大値「N」を超えると初期値「0」にリセットされる。このように、割込み回数countがリセットされる周期Tperiodを「制御周期」と呼称する。制御周期Tperiodは、下記(1)式で表される。割込み処理に含まれる長周期処理は、制御周期Tperiodと等しい周期で繰り返し実行される処理である。割込み処理に含まれる短周期処理は、割込み信号INTの発生周期TINTと等しい周期で繰り返し実行される処理である。
Tperiod = (N+1) × TINT …(1)
As shown in FIG. 3, the interrupt count count is reset to the initial value “0” when the maximum value “N” is exceeded. In this way, the period T period in which the interrupt count count is reset is referred to as a "control period". The control period T period is expressed by the following equation (1). The long-period processing included in the interrupt processing is processing that is repeatedly executed in a period equal to the control period T period . The short-cycle processing included in the interrupt processing is a processing that is repeatedly executed in a cycle equal to the generation cycle T INT of the interrupt signal INT.
T period = (N + 1) × T INT … (1)

ロータが回転すると、センサ部20から互いに電気角で120°の位相差を有する磁束検出信号Hu、Hv及びHwが出力される。図3に示すように、割込み回数countが初期値「0」のときに、A/D変換器11によって磁束検出信号Hu、Hv及びHwのデジタル変換が開始され、割込み回数countが例えば「2」のときに、デジタル変換が終了する。つまり、割込み回数countが初期値「0」から「2」に変化する期間に、1制御周期における磁束検出信号Hu、Hv及びHwのデジタルデータが得られる。図3に示すように、処理部16は、磁束検出信号Hu、Hv及びHwのデジタルデータを取得すると、割込み処理を実行しない期間に角度演算処理を実行する。 When the rotor rotates, the sensor unit 20 outputs magnetic flux detection signals Hu, Hv, and Hw having a phase difference of 120 ° in electrical angle from each other. As shown in FIG. 3, when the interrupt count count is the initial value “0”, the A / D converter 11 starts digital conversion of the magnetic flux detection signals Hu, Hv, and Hw, and the interrupt count count is, for example, “2”. At, the digital conversion ends. That is, digital data of the magnetic flux detection signals Hu, Hv, and Hw in one control cycle can be obtained during the period when the interrupt count count changes from the initial value “0” to “2”. As shown in FIG. 3, when the processing unit 16 acquires the digital data of the magnetic flux detection signals Hu, Hv and Hw, the processing unit 16 executes the angle calculation process during the period when the interrupt process is not executed.

処理部16は、角度演算処理において、磁束検出信号Hu、Hv及びHwのデジタルデータに基づいてロータの絶対角度θを算出する。絶対角度θの演算アルゴリズムとして、例えば特許第6233532号公報に記載のアルゴリズムを用いることができる。そのため、本明細書では絶対角度θの演算アルゴリズムについての説明を省略する。ただし、絶対角度θの演算アルゴリズムは、特許第6233532号公報に記載のアルゴリズムに限定されない。回転体の絶対角度を算出可能なアルゴリズムであれば、他の演算アルゴリズムを用いてもよい。 The processing unit 16 calculates the absolute angle θ of the rotor based on the digital data of the magnetic flux detection signals Hu, Hv, and Hw in the angle calculation process. As the calculation algorithm of the absolute angle θ, for example, the algorithm described in Japanese Patent No. 6233532 can be used. Therefore, in the present specification, the description of the calculation algorithm of the absolute angle θ will be omitted. However, the algorithm for calculating the absolute angle θ is not limited to the algorithm described in Japanese Patent No. 6233532. Any algorithm that can calculate the absolute angle of the rotating body may be used.

図3に示すように、割込み回数countが最大値「N」のときに、1制御周期内で実行される角度演算処理が終了する。処理部16は、角度演算処理が終了すると、絶対角度θの算出結果をグローバル変数gwThetaに代入する。絶対角度θを示すグローバル変数gwThetaの値が新しい値に書き換えられる周期は、制御周期Tperiodと等しい。言い換えれば、制御周期Tperiodは、ロータの絶対角度θが更新される周期である。 As shown in FIG. 3, when the interrupt count count is the maximum value “N”, the angle calculation process executed within one control cycle ends. When the angle calculation process is completed, the processing unit 16 substitutes the calculation result of the absolute angle θ into the global variable gwTheta. The period in which the value of the global variable gwTheta indicating the absolute angle θ is rewritten to a new value is equal to the control period T period . In other words, the control period T period is the period during which the absolute angle θ of the rotor is updated.

図4は、処理部16が実行する割込み処理を示すフローチャートである。上記のように、処理部16は、第1タイマ12から割込み信号INTが入力されると、図4に示す割込み処理を実行する。図4に示すように、処理部16は、割込み処理を開始すると、まず、割込み回数countが初期値「0」と等しいか否かを判定する(ステップS1)。処理部16は、ステップS1において「Yes」の場合、すなわち割込み回数countが初期値「0」と等しい場合、ステップS2の処理に移行する。一方、処理部16は、ステップS1において「No」の場合、すなわち割込み回数countが初期値「0」と等しくない場合、ステップS5の処理に移行する。 FIG. 4 is a flowchart showing interrupt processing executed by the processing unit 16. As described above, the processing unit 16 executes the interrupt processing shown in FIG. 4 when the interrupt signal INT is input from the first timer 12. As shown in FIG. 4, when the interrupt processing is started, the processing unit 16 first determines whether or not the interrupt count count is equal to the initial value "0" (step S1). The processing unit 16 shifts to the processing of step S2 in the case of “Yes” in step S1, that is, when the interrupt count count is equal to the initial value “0”. On the other hand, when the processing unit 16 is "No" in step S1, that is, when the interrupt count count is not equal to the initial value "0", the processing unit 16 shifts to the processing of step S5.

図4に示す割込み処理において、ステップS2からステップS4までの処理が長周期処理である。また、図4に示す割込み処理において、ステップS5からステップS13までの処理が短周期処理である。すなわち、割込み回数countが初期値「0」と等しい場合に、処理部16は、ステップS2からステップS4までの処理を含む長周期処理を実行した後に、ステップS5からステップS13までの処理を含む短周期処理を実行する。一方、割込み回数countが初期値「0」と等しくない場合、処理部16は、長周期処理を行うことなく短周期処理を実行する。 In the interrupt processing shown in FIG. 4, the processing from step S2 to step S4 is a long-period processing. Further, in the interrupt processing shown in FIG. 4, the processing from step S5 to step S13 is a short cycle processing. That is, when the interrupt count count is equal to the initial value "0", the processing unit 16 executes the long-period processing including the processing from step S2 to step S4, and then the short period including the processing from step S5 to step S13. Execute periodic processing. On the other hand, when the interrupt count count is not equal to the initial value "0", the processing unit 16 executes the short-period processing without performing the long-period processing.

処理部16は、長周期処理の一つの処理として、ロータの絶対角度θの今回値を取得する角度取得処理を実行する(ステップS2)。具体的には、ステップS2において、処理部16は、グローバル変数gwThetaの値を絶対角度θの今回値Thetaとして取得する。図3に示すように、絶対角度θの今回値Thetaは、現在の制御周期より1つ前の制御周期で算出された絶対角度θの値である。 The processing unit 16 executes an angle acquisition process for acquiring the current value of the absolute angle θ of the rotor as one of the long-period processes (step S2). Specifically, in step S2, the processing unit 16 acquires the value of the global variable gwTheta as the current value Theta of the absolute angle θ. As shown in FIG. 3, the current value Theta of the absolute angle θ is the value of the absolute angle θ calculated in the control cycle immediately before the current control cycle.

次に、処理部16は、長周期処理の一つの処理として、絶対角度θの今回値Theta及び絶対角度θの前回値Theta_prevに基づいて、絶対角度θを時間の一次関数として表す絶対角度関数を算出する関数算出処理を実行する(ステップS3及びS4)。なお、絶対角度θの前回値Theta_prevは、現在の制御周期より2つ前の制御周期で算出された絶対角度θの値である。 Next, as one of the long-period processing, the processing unit 16 creates an absolute angle function that expresses the absolute angle θ as a linear function of time based on the current value Theta of the absolute angle θ and the previous value Theta_prev of the absolute angle θ. The function calculation process to be calculated is executed (steps S3 and S4). The previous value Theta_prev of the absolute angle θ is the value of the absolute angle θ calculated in the control cycle two before the current control cycle.

具体的には、処理部16は、関数算出処理の一つとして、絶対角度θの今回値Thetaに遅延補償を施すことにより、絶対角度関数の切片を算出する切片算出処理を実行する(ステップS3)。絶対角度θの今回値Thetaには、以下のような時間遅れ成分が含まれる。上記のように、絶対角度θの今回値Thetaは、現在の制御周期より1つ前の制御周期で算出された絶対角度θの値である。そのため、絶対角度θの今回値Thetaは、1制御周期に相当する時間遅れを有する。また、絶対角度θの今回値Thetaは、磁気センサ21、22及び23の応答遅れに起因する時間遅れを有する。さらに、磁束検出信号Hu、Hv及びHwに対してローパスフィルタが設けられる場合、絶対角度θの今回値Thetaは、ローパスフィルタの周波数特性に起因する時間遅れを有する。 Specifically, as one of the function calculation processes, the processing unit 16 executes an intercept calculation process for calculating the intercept of the absolute angle function by applying delay compensation to the current value Theta of the absolute angle θ (step S3). ). The current value Theta of the absolute angle θ includes the following time delay components. As described above, the current value Theta of the absolute angle θ is the value of the absolute angle θ calculated in the control cycle immediately before the current control cycle. Therefore, the current value Theta of the absolute angle θ has a time delay corresponding to one control period. Further, the current value Theta of the absolute angle θ has a time delay due to the response delay of the magnetic sensors 21, 22 and 23. Further, when a low-pass filter is provided for the magnetic flux detection signals Hu, Hv and Hw, the current value Theta of the absolute angle θ has a time delay due to the frequency characteristic of the low-pass filter.

ステップS3において、処理部16は、上記のような時間遅れ成分を有する絶対角度θの今回値Thetaに遅延補償を施す。図5において、θは角度演算処理によって算出される絶対角度θであり、θtrueは絶対角度θの真値であり、θnewは遅延補償された絶対角度θである。図5に示すように、絶対角度θに時間遅れTdelayが存在すると、真値θnewに対して角度誤差θdelayが絶対角度θに発生する。この場合、遅延補償された絶対角度θnewは、下記(2)式で表される。下記(2)式において、θ(k)は絶対角度θの今回値Thetaと等しく、θ(k-1)は絶対角度θの前回値Theta_prevと等しい。下記(2)式において、右辺第2項は角度誤差θdelayと等しい。 In step S3, the processing unit 16 applies delay compensation to the current value Theta of the absolute angle θ having the time delay component as described above. In FIG. 5, θ is the absolute angle θ calculated by the angle calculation process, θ true is the true value of the absolute angle θ, and θ new is the delay-compensated absolute angle θ. As shown in FIG. 5, when a time delay T delay exists at the absolute angle θ, an angle error θ delay occurs at the absolute angle θ with respect to the true value θ new . In this case, the delay-compensated absolute angle θ new is expressed by the following equation (2). In the following equation (2), θ (k) is equal to the current value Theta of the absolute angle θ, and θ (k-1) is equal to the previous value Theta_prev of the absolute angle θ. In the following equation (2), the second term on the right side is equal to the angle error θ delay .

Figure 2022103046000002
Figure 2022103046000002

ステップS3において、処理部16は、上記(2)式に基づいて遅延補償された絶対角度θnewを絶対角度関数の切片として算出する。処理部16は、遅延補償された絶対角度θnewの算出結果を切片Theta_new_lowとして取得する。なお、上記(2)式に含まれる時間遅れTdelayとして、上述した時間遅れの要因を考慮したシミュレーションを行うことで得られた計算値を用いてもよいし、或いは実験を行うことで得られた実測値を用いてもよい。 In step S3, the processing unit 16 calculates the delay-compensated absolute angle θ new based on the above equation (2) as the intercept of the absolute angle function. The processing unit 16 acquires the calculation result of the delay-compensated absolute angle θ new as the intercept Theta_new_low. As the time delay T delay included in the above equation (2), the calculated value obtained by performing the simulation considering the above-mentioned factor of the time delay may be used, or it may be obtained by conducting an experiment. The measured value may be used.

次に、処理部16は、関数算出処理の一つとして、絶対角度θの今回値Thetaから前回値Theta_prevを減算することにより、絶対角度関数の傾きを算出する傾き算出処理を実行する(ステップS4)。具体的には、ステップS4において、処理部16は、下記(3)式に基づいて絶対角度関数の傾きTheta_extrを算出する。
Theta_extr = Theta - Theta_prev …(3)
Next, as one of the function calculation processes, the processing unit 16 executes a slope calculation process for calculating the slope of the absolute angle function by subtracting the previous value Theta_prev from the current value Theta of the absolute angle θ (step S4). ). Specifically, in step S4, the processing unit 16 calculates the slope Theta_extr of the absolute angle function based on the following equation (3).
Theta_extr = Theta --Theta_prev… (3)

処理部16が上記のステップS3及びS4を含む関数算出処理を実行することにより、最終的に下記(4)式で表される絶対角度関数θ(count)が得られる。
θ(count) = Theta_new_low + Theta_extr/(N+1) × count …(4)
When the processing unit 16 executes the function calculation process including the above steps S3 and S4, the absolute angle function θ (count) represented by the following equation (4) is finally obtained.
θ (count) = Theta_new_low + Theta_extr / (N + 1) × count… (4)

以上のステップS2からステップS4までの処理が、制御周期Tperiodと等しい周期で繰り返し実行される長周期処理である。続いて、短周期処理について説明する。 The above processes from step S2 to step S4 are long-period processes that are repeatedly executed in a cycle equal to the control cycle T period . Subsequently, the short cycle processing will be described.

処理部16は、短周期処理の一つとして、関数算出処理によって算出された絶対角度関数に基づいて絶対角度θの推定値を角度推定値として算出する角度推定値算出処理を実行する(ステップS5)。具体的には、ステップS5において、処理部16は、上記(4)式に割込み回数countの値を代入することにより算出したθ(count)の値を、角度推定値Theta_estとして取得する。 As one of the short-period processes, the processing unit 16 executes an angle estimation value calculation process for calculating an estimated value of the absolute angle θ as an angle estimated value based on the absolute angle function calculated by the function calculation process (step S5). ). Specifically, in step S5, the processing unit 16 acquires the value of θ (count) calculated by substituting the value of the interrupt count into the above equation (4) as the angle estimation value Theta_est.

次に、処理部16は、第3タイマ14からエッジカウント値ECを取得するカウント値取得処理を実行し(ステップS6)、取得したエッジカウント値ECに基づいて絶対角度θの現在値を角度現在値として算出する角度現在値算出処理を実行する(ステップS7)。具体的には、ステップS7において、処理部16は、下記(5)式に基づいて角度現在値Theta_edge_nowを算出する。
Theta_edge_now = edge_now × EDGE2THETA …(5)
Next, the processing unit 16 executes a count value acquisition process for acquiring the edge count value EC from the third timer 14 (step S6), and sets the current value of the absolute angle θ to the current angle based on the acquired edge count value EC (step S6). The angle current value calculation process to be calculated as a value is executed (step S7). Specifically, in step S7, the processing unit 16 calculates the current angle Theta_edge_now based on the following equation (5).
Theta_edge_now = edge_now × EDGE2THETA… (5)

上記(5)式において、edge_nowは、エッジカウント値ECが代入される変数である。EDGE2THETAは、エッジカウント値ECから例えば32ビットの角度に変換する係数である。信号生成装置10の分解能をN_EDGEとすると、EDGE2THETAは下記(6)式で表される。なお、分解能は、ロータが1回転する間にA相パルス信号PA及びB相パルス信号PBに発生するエッジ数である。
EDGE2THETA = 2^32 / N_EDGE …(6)
In the above equation (5), edge_now is a variable to which the edge count value EC is assigned. EDGE2THETA is a coefficient for converting an edge count value EC into, for example, a 32-bit angle. Assuming that the resolution of the signal generator 10 is N_EDGE, EDGE2THETA is expressed by the following equation (6). The resolution is the number of edges generated in the A-phase pulse signal PA and the B-phase pulse signal PB during one rotation of the rotor.
EDGE2THETA = 2 ^ 32 / N_EDGE… (6)

次に、処理部16は、エッジカウント値ECに基づいて信号状態値Stateを算出する信号状態値算出処理を実行する(ステップS8)。既に述べたように、信号状態値Stateは、A相パルス信号PAのレベルとB相パルス信号PBのレベルとの関係を表す値である(図2参照)。具体的には、ステップS8において、処理部16は、下記(7)式に基づいて信号状態値Stateを算出する。下記(7)式は、エッジカウント値ECを示す変数edge_nowの下位2ビットを取得するために、変数edge_nowの値と3(2進数表現で11)との論理積を演算するという意味である。
State = edge_now・(11) …(7)
Next, the processing unit 16 executes a signal state value calculation process for calculating the signal state value State based on the edge count value EC (step S8). As described above, the signal state value State is a value representing the relationship between the level of the A-phase pulse signal PA and the level of the B-phase pulse signal PB (see FIG. 2). Specifically, in step S8, the processing unit 16 calculates the signal state value State based on the following equation (7). The following equation (7) means that the logical product of the value of the variable edge_now and 3 (11 in binary notation) is calculated in order to acquire the lower 2 bits of the variable edge_now indicating the edge count value EC.
State = edge_now ・ (11)… (7)

次に、処理部16は、ステップS5で算出された角度推定値Theta_estと、ステップS7で算出された角度現在値Theta_edge_nowとに基づいて、第2タイマ13の出力モードを変化させるタイミングか否かを判定するタイミング判定処理を実行する(ステップS9)。具体的には、ステップS9において、処理部16は、角度推定値Theta_estから角度現在値Theta_edge_nowを減算することで得られる差分値Theta_diff_lowの絶対値が所定の閾値Dth(第2閾値)よりも大きいか否かを判定する。なお、処理部16は、下記(8)式に基づいて差分値Theta_diff_lowを算出する。
Theta_diff _low = Theta_est - Theta_edge_now …(8)
Next, the processing unit 16 determines whether or not it is the timing to change the output mode of the second timer 13 based on the angle estimated value Theta_est calculated in step S5 and the current angle value Theta_edge_now calculated in step S7. The determination timing determination process is executed (step S9). Specifically, in step S9, whether the processing unit 16 has an absolute value of the difference value Theta_diff_low obtained by subtracting the current angle value Theta_edge_now from the angle estimated value Theta_est is larger than the predetermined threshold value Dth (second threshold value). Judge whether or not. The processing unit 16 calculates the difference value Theta_diff_low based on the following equation (8).
Theta_diff _low = Theta_est --Theta_edge_now… (8)

処理部16は、ステップS9において「Yes」の場合、すなわち差分値Theta_diff_lowの絶対値が所定の閾値Dthよりも大きい場合に、第2タイマ13の出力モードを変化させるタイミングと判定してステップS10の処理に移行する。一方、処理部16は、ステップS9において「No」の場合、すなわち差分値Theta_diff_lowの絶対値が所定の閾値Dth以下の場合、ステップS10の処理を行わずにステップS11の処理に移行する。 In the case of "Yes" in step S9, that is, when the absolute value of the difference value Theta_diff_low is larger than the predetermined threshold value Dth, the processing unit 16 determines that it is the timing to change the output mode of the second timer 13, and determines in step S10. Move to processing. On the other hand, when the processing unit 16 is "No" in step S9, that is, when the absolute value of the difference value Theta_diff_low is equal to or less than the predetermined threshold value Dth, the processing unit 16 shifts to the processing of step S11 without performing the processing of step S10.

処理部16は、タイミング判定処理において出力モードを変化させるタイミングと判定されたとき、信号状態値Stateに基づいて、A相パルス信号PAとB相パルス信号PBとの一方のパルス信号の出力モードを、ハイレベル出力モードとローレベル出力モードとの一方に変化させる第1出力モード切替処理を実行する(ステップS10)。 When the processing unit 16 determines that the timing is to change the output mode in the timing determination process, the processing unit 16 sets the output mode of one of the pulse signals of the A-phase pulse signal PA and the B-phase pulse signal PB based on the signal state value State. , The first output mode switching process for changing to one of the high level output mode and the low level output mode is executed (step S10).

具体的には、ステップS10において、処理部16は、信号状態値Stateが「0」の場合、A相パルス信号PAの出力モード及びB相パルス信号PBの出力モードの両方をハイレベル出力モードにセットする。ステップS10において、処理部16は、信号状態値Stateが「1」の場合、A相パルス信号PAの出力モードをハイレベル出力モードにセットするとともに、B相パルス信号PBの出力モードをローレベル出力モードにセットする。ステップS10において、処理部16は、信号状態値Stateが「2」の場合、A相パルス信号PAの出力モード及びB相パルス信号PBの出力モードの両方をローレベル出力モードにセットする。ステップS10において、処理部16は、信号状態値Stateが「3」の場合、A相パルス信号PAの出力モードをローレベル出力モードにセットするとともに、B相パルス信号PBの出力モードをハイレベル出力モードにセットする。 Specifically, in step S10, when the signal state value State is "0", the processing unit 16 sets both the output mode of the A-phase pulse signal PA and the output mode of the B-phase pulse signal PB to the high-level output mode. set. In step S10, when the signal state value State is "1", the processing unit 16 sets the output mode of the A-phase pulse signal PA to the high-level output mode and outputs the output mode of the B-phase pulse signal PB to the low level. Set to mode. In step S10, when the signal state value State is "2", the processing unit 16 sets both the output mode of the A-phase pulse signal PA and the output mode of the B-phase pulse signal PB to the low-level output mode. In step S10, when the signal state value State is "3", the processing unit 16 sets the output mode of the A-phase pulse signal PA to the low-level output mode and outputs the output mode of the B-phase pulse signal PB to the high-level output. Set to mode.

処理部16は、ステップS10の処理を行った後、またはステップS9において「No」と判定した場合に、割込み回数countを更新する割込み回数更新処理を実行する(ステップS11)。具体的には、ステップS11において、処理部16は、割込み回数countの値をインクリメントする。 The processing unit 16 executes an interrupt count update process for updating the interrupt count count after performing the process in step S10 or when determining "No" in step S9 (step S11). Specifically, in step S11, the processing unit 16 increments the value of the interrupt count count.

次に、処理部16は、更新後の割込み回数countが所定の閾値M(第1閾値)と等しい場合に、割込み回数countを初期値「0」にリセットする割込み回数リセット処理を実行する(ステップS12及びS13)。具体的には、処理部16は、割込み回数countが閾値Mと等しいか否かを判定する(ステップS12)。閾値Mは、割込み回数countの最大値「N」に「1」を加算した値である。処理部16は、ステップS12において「Yes」の場合、すなわち割込み回数countが閾値M(=N+1)と等しい場合に、割込み回数countを初期値「0」にリセットして割込み処理を終了する(ステップS13)。一方、処理部16は、ステップS12において「No」の場合、すなわち割込み回数countが閾値Mと等しくない場合、ステップS13の処理を行わずに割込み処理を終了する。 Next, the processing unit 16 executes an interrupt count reset process for resetting the interrupt count to the initial value "0" when the updated interrupt count count is equal to a predetermined threshold value M (first threshold value) (step). S12 and S13). Specifically, the processing unit 16 determines whether or not the interrupt count count is equal to the threshold value M (step S12). The threshold value M is a value obtained by adding "1" to the maximum value "N" of the interrupt count. In the case of "Yes" in step S12, that is, when the interrupt count count is equal to the threshold value M (= N + 1), the processing unit 16 resets the interrupt count count to the initial value "0" and ends the interrupt processing (step). S13). On the other hand, when "No" in step S12, that is, when the interrupt count count is not equal to the threshold value M, the processing unit 16 ends the interrupt processing without performing the processing in step S13.

割込み信号INTが発生するごとに、処理部16が上記のような割込み処理を行うことにより、第2タイマ13からA相パルス信号PA及びB相パルス信号PBが出力される。以下、図6を参照しながら、第1実施形態の割込み処理によって第2タイマ13からA相パルス信号及びB相パルス信号が出力される一例を説明する。 Each time the interrupt signal INT is generated, the processing unit 16 performs the interrupt processing as described above, so that the A-phase pulse signal PA and the B-phase pulse signal PB are output from the second timer 13. Hereinafter, an example in which the A-phase pulse signal and the B-phase pulse signal are output from the second timer 13 by the interrupt processing of the first embodiment will be described with reference to FIG.

図6において、直線Lは、割込み回数countが「0」の時に算出された絶対角度関数θ(count)を示す。直線Lの傾きが、絶対角度関数θ(count)の傾きTheta_extr である。直線L上の点P0の値は、割込み回数countが「0」の時に算出された角度推定値Theta_estである。点P0の値は、絶対角度関数θ(count)の切片Theta_new_lowと等しい。直線L上の点P2の値は、割込み回数countが「2」の時に算出された角度推定値Theta_estである。直線L上の点P3の値は、割込み回数countが「3」の時に算出された角度推定値Theta_estである。直線L上の点P5の値は、割込み回数countが「5」の時に算出された角度推定値Theta_estである。直線L上の点P7の値は、割込み回数countが「7」の時に算出された角度推定値Theta_estである。 In FIG. 6, the straight line L indicates an absolute angle function θ (count) calculated when the interrupt count count is “0”. The slope of the straight line L is the slope Theta_extr of the absolute angle function θ (count). The value of the point P0 on the straight line L is the angle estimation value Theta_est calculated when the interrupt count count is “0”. The value of point P0 is equal to the intercept Theta_new_low of the absolute angle function θ (count). The value of the point P2 on the straight line L is the angle estimation value Theta_est calculated when the interrupt count count is “2”. The value of the point P3 on the straight line L is the angle estimation value Theta_est calculated when the interrupt count count is “3”. The value of the point P5 on the straight line L is the angle estimation value Theta_est calculated when the interrupt count count is “5”. The value of the point P7 on the straight line L is the angle estimation value Theta_est calculated when the interrupt count count is “7”.

図6に示すように、割込み回数countが「2」に変化する前に、信号状態値Stateが「0」であり、A相パルス信号PAの出力モード及びB相パルス信号PBの出力モードの両方がハイレベル出力モードにセットされていると仮定する。この場合、割込み回数countが「2」に変化する前は、第2タイマ13から出力されるA相パルス信号PA及びB相パルス信号PBの両方がハイレベルとなる。 As shown in FIG. 6, the signal state value State is “0” before the interrupt count count changes to “2”, and both the output mode of the A-phase pulse signal PA and the output mode of the B-phase pulse signal PB. Is set to high level output mode. In this case, both the A-phase pulse signal PA and the B-phase pulse signal PB output from the second timer 13 become high levels before the interrupt count count changes to “2”.

図6に示すように、割込み回数countが「2」に変化したときに、信号状態値Stateが「3」となり、角度推定値Theta_est(点P2の値)と角度現在値Theta_edge_now との差分値Theta_diff_lowの絶対値が閾値Dthより大きくなると仮定する。この場合、処理部16は、信号状態値Stateに基づいて、A相パルス信号PAの出力モードのみをローレベル出力モードに変化させる。その結果、図6に示すように、割込み回数countが「2」に変化するタイミングで、第2タイマ13から出力されるA相パルス信号PAのみがローレベルに変化する。 As shown in FIG. 6, when the interrupt count count changes to "2", the signal state value State becomes "3", and the difference value between the angle estimated value Theta_est (value of point P2) and the current angle value Theta_edge_now is Theta_diff_low. It is assumed that the absolute value of is larger than the threshold value Dth. In this case, the processing unit 16 changes only the output mode of the A-phase pulse signal PA to the low-level output mode based on the signal state value State. As a result, as shown in FIG. 6, only the A-phase pulse signal PA output from the second timer 13 changes to the low level at the timing when the interrupt count count changes to “2”.

図6に示すように、割込み回数countが「3」に変化したときに、信号状態値Stateが「2」となり、角度推定値Theta_est(点P3の値)と角度現在値Theta_edge_now との差分値Theta_diff_lowの絶対値が閾値Dthより大きくなると仮定する。この場合、処理部16は、信号状態値Stateに基づいて、B相パルス信号PBの出力モードのみをローレベル出力モードに変化させる。その結果、図6に示すように、割込み回数countが「3」に変化するタイミングで、第2タイマ13から出力されるB相パルス信号PBのみがローレベルに変化する。 As shown in FIG. 6, when the interrupt count count changes to "3", the signal state value State becomes "2", and the difference value between the angle estimated value Theta_est (value of point P3) and the current angle value Theta_edge_now is Theta_diff_low. It is assumed that the absolute value of is larger than the threshold value Dth. In this case, the processing unit 16 changes only the output mode of the B-phase pulse signal PB to the low-level output mode based on the signal state value State. As a result, as shown in FIG. 6, only the B-phase pulse signal PB output from the second timer 13 changes to the low level at the timing when the interrupt count count changes to “3”.

図6に示すように、割込み回数countが「5」に変化したときに、信号状態値Stateが「1」となり、角度推定値Theta_est(点P5の値)と角度現在値Theta_edge_now との差分値Theta_diff_lowの絶対値が閾値Dthより大きくなると仮定する。この場合、処理部16は、信号状態値Stateに基づいて、A相パルス信号PAの出力モードのみをハイレベル出力モードに変化させる。その結果、図6に示すように、割込み回数countが「5」に変化するタイミングで、第2タイマ13から出力されるA相パルス信号PAのみがハイレベルに変化する。 As shown in FIG. 6, when the interrupt count count changes to "5", the signal state value State becomes "1", and the difference value between the angle estimation value Theta_est (value of point P5) and the angle current value Theta_edge_now is Theta_diff_low. It is assumed that the absolute value of is larger than the threshold value Dth. In this case, the processing unit 16 changes only the output mode of the A-phase pulse signal PA to the high-level output mode based on the signal state value State. As a result, as shown in FIG. 6, only the A-phase pulse signal PA output from the second timer 13 changes to a high level at the timing when the interrupt count count changes to “5”.

図6に示すように、割込み回数countが「7」に変化したときに、信号状態値Stateが「0」となり、角度推定値Theta_est(点P7の値)と角度現在値Theta_edge_now との差分値Theta_diff_lowの絶対値が閾値Dthより大きくなると仮定する。この場合、処理部16は、信号状態値Stateに基づいて、B相パルス信号PBの出力モードのみをハイレベル出力モードに変化させる。その結果、図6に示すように、割込み回数countが「7」に変化するタイミングで、第2タイマ13から出力されるB相パルス信号PBのみがハイレベルに変化する。 As shown in FIG. 6, when the interrupt count count changes to "7", the signal state value State becomes "0", and the difference value between the angle estimated value Theta_est (value of point P7) and the current angle value Theta_edge_now is Theta_diff_low. It is assumed that the absolute value of is larger than the threshold value Dth. In this case, the processing unit 16 changes only the output mode of the B-phase pulse signal PB to the high-level output mode based on the signal state value State. As a result, as shown in FIG. 6, only the B-phase pulse signal PB output from the second timer 13 changes to a high level at the timing when the interrupt count count changes to “7”.

上記のような割込み処理によって第2タイマ13からA相パルス信号PA及びB相パルス信号PBが出力されると、図7に示すように、第3タイマ14は、A相パルス信号PA及びB相パルス信号PBのエッジ数をカウントし、エッジカウント値ECがタイマリセット値TRES3に到達すると、エッジカウント値ECをリセットする。また、図7に示すように、第3タイマ14は、エッジカウント値ECとZ相出力閾値Zcomとを比較し、エッジカウント値ECがZ相出力閾値Zcomより小さいときにハイレベルとなる信号をZ相パルス信号PZとして出力する。図7において、ENCresは分解能を示す。タイマリセット値TRES3は、「ENCres-1」の値に設定される。 When the A-phase pulse signal PA and the B-phase pulse signal PB are output from the second timer 13 by the interrupt processing as described above, as shown in FIG. 7, the third timer 14 has the A-phase pulse signal PA and the B-phase. The number of edges of the pulse signal PB is counted, and when the edge count value EC reaches the timer reset value TRES3, the edge count value EC is reset. Further, as shown in FIG. 7, the third timer 14 compares the edge count value EC and the Z-phase output threshold value Zcom, and outputs a signal that becomes a high level when the edge count value EC is smaller than the Z-phase output threshold value Zcom. It is output as a Z-phase pulse signal PZ. In FIG. 7, ENC res indicates resolution. The timer reset value TRES3 is set to the value of "ENC res -1".

信号生成装置10が電源オン状態に切り替えられたとき、第3タイマ14のエッジカウント値は「0」であるため、図8に示す関係となるように、絶対角度に応じてエッジカウント値の初期値を設定する必要がある。そこで、本実施形態では、信号生成装置10が電源オン状態に切り替えられたとき、処理部16は、初期化処理の一つとして、下記(9)式及び(10)式に基づいて、エッジカウント値ECの初期値を設定する処理を行う。なお、下記(9)式及び(10)式において、TIM_CNTは、エッジカウント値の初期値を表す。また、本明細書において、(uint32)(X)は、Xを符号無し32ビットにキャストすることを表し、Y>>Zは、YをZビット右にシフトすることを表す。 When the signal generator 10 is switched to the power-on state, the edge count value of the third timer 14 is "0". Therefore, as shown in FIG. 8, the initial edge count value is set according to the absolute angle. You need to set the value. Therefore, in the present embodiment, when the signal generation device 10 is switched to the power-on state, the processing unit 16 counts the edges based on the following equations (9) and (10) as one of the initialization processes. Performs the process of setting the initial value of the value EC. In the following equations (9) and (10), TIM_CNT represents the initial value of the edge count value. Further, in the present specification, (uint32) (X) means that X is cast to unsigned 32 bits, and Y >> Z means that Y is shifted to the right by Z bits.

Figure 2022103046000003
Figure 2022103046000003

Figure 2022103046000004
Figure 2022103046000004

以上説明したように、第1実施形態の信号生成装置10は、所定の周期で割込み信号INTを出力する第1タイマ12と、所定の位相差を有するA相パルス信号PA及びB相パルス信号PBとを出力する第2タイマ13と、A相パルス信号PA及びB相パルス信号PBのエッジ数をカウントする第3タイマ14と、割込み信号INTが発生するごとに、第2タイマ13の出力モードを制御する割込み処理を行う処理部16と、を備える。
処理部16は、割込み処理の開始時に割込み回数が初期値と等しい場合、所定の長周期処理を行った後に所定の短周期処理を行う一方、割込み回数が初期値と等しくない場合、長周期処理を行うことなく短周期処理を行う。
処理部16は、長周期処理として、角度取得処理及び関数算出処理を実行する。処理部16は、短周期処理として、角度推定値算出処理、カウント値取得処理、角度現在値算出処理、信号状態値算出処理、タイミング判定処理、第1出力モード切替処理、割込み回数更新処理、及び割込み回数リセット処理を実行する。
以上のような第1実施形態の信号生成装置10によれば、3つのタイマ以外のハードウェアを使用せずに、プロセッサコアである処理部16によるソフトウェア的な処理によって回転体の絶対角度からA相パルス信号PA及びB相パルス信号PBを生成することができる。タイマは、MCUなどの汎用マイコンに一般的に搭載される回路である。従って、本実施形態によれば、所定の位相差を有する2相のパルス信号を生成するために必要なソフトウェア及びハードウェアを簡素化でき、且つ安価な汎用マイコンによって実現可能な信号生成装置10を提供できる。
As described above, the signal generation device 10 of the first embodiment has a first timer 12 that outputs an interrupt signal INT in a predetermined cycle, and an A-phase pulse signal PA and a B-phase pulse signal PB having a predetermined phase difference. A second timer 13 that outputs the above, a third timer 14 that counts the number of edges of the A-phase pulse signal PA and the B-phase pulse signal PB, and an output mode of the second timer 13 each time an interrupt signal INT is generated. A processing unit 16 that performs interrupt processing to be controlled is provided.
When the number of interrupts is equal to the initial value at the start of interrupt processing, the processing unit 16 performs predetermined short-period processing after performing predetermined long-period processing, while long-period processing is performed when the number of interrupts is not equal to the initial value. Perform short-period processing without performing.
The processing unit 16 executes an angle acquisition process and a function calculation process as long-period processes. The processing unit 16 performs angle estimation value calculation processing, count value acquisition processing, angle current value calculation processing, signal state value calculation processing, timing determination processing, first output mode switching processing, interrupt count update processing, and as short-cycle processing. Executes interrupt count reset processing.
According to the signal generation device 10 of the first embodiment as described above, A from the absolute angle of the rotating body by software-like processing by the processing unit 16 which is the processor core without using hardware other than the three timers. The phase pulse signal PA and the B phase pulse signal PB can be generated. The timer is a circuit generally mounted on a general-purpose microcomputer such as an MCU. Therefore, according to the present embodiment, there is a signal generation device 10 that can simplify the software and hardware required to generate a two-phase pulse signal having a predetermined phase difference, and can be realized by an inexpensive general-purpose microcomputer. Can be provided.

第1実施形態において、処理部16は、関数算出処理において、絶対角度の今回値に遅延補償を施すことにより、絶対角度関数の切片を算出する切片算出処理と、絶対角度の今回値から前回値を減算することにより、前記絶対角度関数の傾きを算出する傾き算出処理と、を実行する。
このように、絶対角度の推定値(角度推定値)の算出に必要な絶対角度関数の切片を、絶対角度の今回値に存在する遅れ時間を考慮して算出することより、角度推定値をより高精度に得ることができる。
In the first embodiment, in the function calculation process, the processing unit 16 performs the section calculation process of calculating the section of the absolute angle function by applying delay compensation to the current value of the absolute angle, and the previous value from the current value of the absolute angle. By subtracting, the slope calculation process for calculating the slope of the absolute angle function is executed.
In this way, the intercept of the absolute angle function required for calculating the estimated value of the absolute angle (angle estimated value) is calculated in consideration of the delay time existing in the current value of the absolute angle, so that the angle estimated value can be obtained. It can be obtained with high accuracy.

第1実施形態において、処理部16は、タイミング判定処理において、角度推定値から角度現在値を減算することで得られる差分値の絶対値が所定の第2閾値(Dth)よりも大きい場合に、第2タイマ13の出力モードを変化させるタイミングと判定する。
これにより、A相パルス信号PA及びB相パルス信号PBに発生するチャタリングを抑制できる。また、第2閾値(Dth)の設定値によってチャタリングの抑制度合いと応答性とのバランスを調整可能である。
In the first embodiment, the processing unit 16 determines that the absolute value of the difference value obtained by subtracting the current angle value from the estimated angle value is larger than a predetermined second threshold value (Dth) in the timing determination process. It is determined that the timing is to change the output mode of the second timer 13.
As a result, chattering generated in the A-phase pulse signal PA and the B-phase pulse signal PB can be suppressed. Further, the balance between the degree of chattering suppression and the responsiveness can be adjusted by the setting value of the second threshold value (Dth).

第1実施形態において、第3タイマ14は、エッジカウント値が所定のタイマリセット値に到達すると、エッジカウント値をリセットする。
これによれば、第3タイマ14のタイマリセット値の設定によって分解能を任意に調整可能である。
In the first embodiment, the third timer 14 resets the edge count value when the edge count value reaches a predetermined timer reset value.
According to this, the resolution can be arbitrarily adjusted by setting the timer reset value of the third timer 14.

第1実施形態において、第3タイマ14は、エッジカウント値と所定の第3閾値(Zcom)とを比較し、エッジカウント値が第3閾値より小さいときにハイレベルとなる信号を、絶対角度の原点を示すZ相パルス信号PZとして出力する。
これによれば、A相パルス信号PA及びB相パルス信号PBのエッジ数に基づいて絶対角度の原点を示すZ相パルス信号PZを生成することが可能である。
In the first embodiment, the third timer 14 compares the edge count value with a predetermined third threshold value (Zcom), and outputs a signal having a high level when the edge count value is smaller than the third threshold value at an absolute angle. It is output as a Z-phase pulse signal PZ indicating the origin.
According to this, it is possible to generate a Z-phase pulse signal PZ indicating the origin of an absolute angle based on the number of edges of the A-phase pulse signal PA and the B-phase pulse signal PB.

〔第2実施形態〕
次に、本発明の第2実施形態について説明する。
第2実施形態における信号生成装置10の構成は、第1実施形態と同様である。しかしながら、第2実施形態において処理部16が実行する割込み処理が、第1実施形態の割込み処理と異なる。第2実施形態の割込み処理では、ロータの回転速度に応じて動作モードを低速モードと高速モードとの間で切り替えることにより、回転速度に応じて適切な精度を保った状態でA相パルス信号PA及びB相パルス信号PBを生成する。
[Second Embodiment]
Next, a second embodiment of the present invention will be described.
The configuration of the signal generation device 10 in the second embodiment is the same as that in the first embodiment. However, the interrupt processing executed by the processing unit 16 in the second embodiment is different from the interrupt processing in the first embodiment. In the interrupt processing of the second embodiment, the operation mode is switched between the low speed mode and the high speed mode according to the rotation speed of the rotor, so that the A-phase pulse signal PA is maintained in an appropriate accuracy according to the rotation speed. And the B-phase pulse signal PB is generated.

図9は、第2実施形態において処理部16が実行する割込み処理を示すフローチャートである。処理部16は、第1タイマ12から割込み信号INTが入力されると、図9に示す割込み処理を実行する。 FIG. 9 is a flowchart showing an interrupt process executed by the processing unit 16 in the second embodiment. When the interrupt signal INT is input from the first timer 12, the processing unit 16 executes the interrupt processing shown in FIG.

図9に示すように、処理部16は、割込み処理を開始すると、まず、割込み回数countが初期値「0」と等しいか否かを判定する(ステップS100)。処理部16は、ステップS100において「Yes」の場合、すなわち割込み回数countが初期値「0」と等しい場合、ステップS101の処理に移行する。一方、処理部16は、ステップS100において「No」の場合、すなわち割込み回数countが初期値「0」と等しくない場合、ステップS108の処理に移行する。 As shown in FIG. 9, when the interrupt processing is started, the processing unit 16 first determines whether or not the interrupt count count is equal to the initial value “0” (step S100). The processing unit 16 shifts to the processing of step S101 in the case of "Yes" in step S100, that is, when the interrupt count count is equal to the initial value "0". On the other hand, when the processing unit 16 is "No" in step S100, that is, when the interrupt count count is not equal to the initial value "0", the processing unit 16 shifts to the processing of step S108.

図9に示す割込み処理において、ステップS101からステップS107までの処理と、ステップS113からステップS117までの処理とが長周期処理に含まれる。また、図9に示す割込み処理において、ステップS108からステップS112までの処理が短周期処理に含まれる。すなわち、割込み回数countが初期値「0」と等しい場合に、処理部16は、ステップS101からステップS107と、ステップS113からステップS117とを含む長周期処理を実行した後に、ステップS108からステップS112を含む短周期処理を実行する。一方、割込み回数countが初期値「0」と等しくない場合、処理部16は、長周期処理を行うことなく短周期処理を実行する。 In the interrupt processing shown in FIG. 9, the processing from step S101 to step S107 and the processing from step S113 to step S117 are included in the long-period processing. Further, in the interrupt processing shown in FIG. 9, the processing from step S108 to step S112 is included in the short cycle processing. That is, when the interrupt count count is equal to the initial value "0", the processing unit 16 executes long-period processing including steps S101 to S107 and steps S113 to S117, and then steps S108 to S112. Perform short-period processing including. On the other hand, when the interrupt count count is not equal to the initial value "0", the processing unit 16 executes the short-period processing without performing the long-period processing.

処理部16は、長周期処理の一つの処理として、ロータの絶対角度θの今回値Thetaを取得する角度取得処理を実行する(ステップS101)。このステップS101の処理は、第1実施形態におけるステップS2の処理と同じであるので説明を省略する。 The processing unit 16 executes an angle acquisition process for acquiring the current value Theta of the absolute angle θ of the rotor as one of the long-period processes (step S101). Since the process of step S101 is the same as the process of step S2 in the first embodiment, the description thereof will be omitted.

次に、処理部16は、長周期処理の一つの処理として、絶対角度θの今回値Thetaに遅延補償を施すことにより、絶対角度関数の切片Theta_new_lowを算出する切片算出処理を実行する(ステップS102)。このステップS102の処理は、第1実施形態におけるステップS3の処理と同じであるので、説明を省略する。 Next, the processing unit 16 executes an intercept calculation process for calculating the intercept Theta_new_low of the absolute angle function by applying delay compensation to the current value Theta of the absolute angle θ as one process of the long cycle process (step S102). ). Since the process of step S102 is the same as the process of step S3 in the first embodiment, the description thereof will be omitted.

次に、処理部16は、長周期処理の一つの処理として、絶対角度θの今回値Theta及び前回値Theta_prevに基づいて、ロータの回転速度を算出する速度算出処理を実行する(ステップS103)。具体的には、ステップS103において、処理部16は、下記(11)式及び下記(12)式に基づいて、ロータの回転速度Speedを算出する。 Next, the processing unit 16 executes a speed calculation process for calculating the rotation speed of the rotor based on the current value Theta and the previous value Theta_prev of the absolute angle θ as one process of the long period process (step S103). Specifically, in step S103, the processing unit 16 calculates the rotation speed Speed of the rotor based on the following equation (11) and the following equation (12).

Figure 2022103046000005
Figure 2022103046000005

次に、処理部16は、長周期処理の一つの処理として、動作モードが高速モードであるか否かを判定する第1動作モード判定処理を実行する(ステップS104)。処理部16は、第1動作モード判定処理において動作モードが高速モードであると判定された場合、すなわちステップS104において「Yes」の場合に、回転速度Speedが所定の下限閾値以下か否かを判定する下限閾値判定処理を実行する(ステップS105)。 Next, the processing unit 16 executes a first operation mode determination process for determining whether or not the operation mode is a high-speed mode as one of the long-period processes (step S104). The processing unit 16 determines whether or not the rotation speed Speed is equal to or less than a predetermined lower limit threshold value when the operation mode is determined to be the high-speed mode in the first operation mode determination process, that is, when “Yes” in step S104. The lower limit threshold value determination process is executed (step S105).

例えば、動作モードを切り替える回転速度の基準値は下記(13)式で表される。下記(13)式において、ENCresは分解能であり、fLOW_algoは割込み信号INTの発生周波数(周期TINTの逆数)と等しい。例えば、以下の説明における下限閾値は、下記(13)式で表される基準値の-20%で設定され、上限閾値は、下記(13)式で表される基準値の+20%で設定されてもよい。 For example, the reference value of the rotation speed for switching the operation mode is expressed by the following equation (13). In the following equation (13), ENC res is the resolution, and f LOW_algo is equal to the generation frequency of the interrupt signal INT (the reciprocal of the period T INT ). For example, the lower limit threshold value in the following description is set by -20% of the reference value represented by the following equation (13), and the upper limit threshold value is set by + 20% of the reference value represented by the following equation (13). You may.

Figure 2022103046000006
Figure 2022103046000006

処理部16は、下限閾値判定処理において回転速度Speedが下限閾値以下であると判定された場合、すなわちステップS105において「Yes」の場合に、動作モードを高速モードから低速モードに切り替える第1モード切り替え処理を実行する(ステップS106)。そして、処理部16は、低速モード処理A(低速モードの第1処理)として関数算出処理の一つである傾き算出処理を実行する(ステップS107)。傾き算出処理は、第1実施形態におけるステップS4の処理と同じであるので説明を省略する。処理部16は、低速モード処理Aを行うことにより、上記(4)式で表される絶対角度関数θ(count)を取得する。 The processing unit 16 switches the operation mode from the high speed mode to the low speed mode when it is determined in the lower limit threshold value determination process that the rotation speed Speed is equal to or less than the lower limit threshold value, that is, when “Yes” in step S105. The process is executed (step S106). Then, the processing unit 16 executes the inclination calculation process, which is one of the function calculation processes, as the low-speed mode process A (first process in the low-speed mode) (step S107). Since the inclination calculation process is the same as the process of step S4 in the first embodiment, the description thereof will be omitted. The processing unit 16 acquires the absolute angle function θ (count) represented by the above equation (4) by performing the low-speed mode processing A.

処理部16は、上記のステップS101からステップS107までを長周期処理として行った後、または割込み処理の開始時に割込み回数countが初期値「0」と等しくない場合に、動作モードが低速モードであるか否かを判定する第2動作モード判定処理を短周期処理として実行する(ステップS108)。 The processing unit 16 operates in the low-speed mode after performing the above steps S101 to S107 as long-period processing, or when the interrupt count count is not equal to the initial value "0" at the start of interrupt processing. The second operation mode determination process for determining whether or not to perform is executed as a short-period process (step S108).

処理部16は、第2動作モード判定処理において動作モードが低速モードであると判定された場合、すなわちステップS108において「Yes」の場合に、低速モードの第2処理として行われる低速モード処理B(ステップS109)と、割込み回数更新処理(ステップ110)および割込み回数リセット処理(ステップS111及びS112)とを、短周期処理として実行する。 The processing unit 16 performs low-speed mode processing B (low-speed mode processing B) performed as the second processing of the low-speed mode when the operation mode is determined to be the low-speed mode in the second operation mode determination processing, that is, when “Yes” in step S108. Step S109), the interrupt count update process (step 110), and the interrupt count reset process (steps S111 and S112) are executed as short cycle processes.

低速モード処理Bは、第1実施形態おける角度推定値算出処理(ステップS5)、カウント値取得処理(ステップS6)、角度現在値算出処理(ステップS7)、信号状態値算出処理(ステップS8)、タイミング判定処理(ステップS9)、および第1出力モード切替処理(ステップS10)を含む。従って、ステップS109の処理として実行される低速モード処理Bの説明は省略する。また、ステップS110からステップS112までの処理は、第1実施形態におけるステップS11からステップS13までの処理と同じであるので、説明を省略する。 The low-speed mode process B includes an angle estimation value calculation process (step S5), a count value acquisition process (step S6), an angle current value calculation process (step S7), and a signal state value calculation process (step S8) in the first embodiment. The timing determination process (step S9) and the first output mode switching process (step S10) are included. Therefore, the description of the low-speed mode process B executed as the process of step S109 will be omitted. Further, since the processing from step S110 to step S112 is the same as the processing from step S11 to step S13 in the first embodiment, the description thereof will be omitted.

また、処理部16は、第1動作モード判定処理において動作モードが高速モードでないと判定された場合、すなわちステップS104において「No」の場合に、回転速度Speedが所定の上限閾値以上か否かを判定する上限閾値判定処理を実行する(ステップS113)。 Further, the processing unit 16 determines whether or not the rotation speed Speed is equal to or higher than a predetermined upper limit threshold value when the operation mode is determined not to be the high-speed mode in the first operation mode determination process, that is, when “No” in step S104. The upper limit threshold value determination process for determination is executed (step S113).

処理部16は、上限閾値判定処理において回転速度Speedが上限閾値以上でないと判定された場合、すなわちステップS113において「No」の場合に、低速モード処理Aとして関数算出処理の一つである傾き算出処理を実行する(ステップS114)。処理部16は、低速モード処理Aを行うことにより、上記(4)式で表される絶対角度関数θ(count)を取得する。 When the rotation speed Speed is determined not to be equal to or higher than the upper limit threshold value in the upper limit threshold value determination process, that is, when “No” in step S113, the processing unit 16 calculates the inclination, which is one of the function calculation processes, as the low speed mode process A. The process is executed (step S114). The processing unit 16 acquires the absolute angle function θ (count) represented by the above equation (4) by performing the low-speed mode processing A.

処理部16は、上記のステップS101からステップS104と、ステップS113からステップS114とを長周期処理として行った後、または割込み処理の開始時に割込み回数countが初期値「0」と等しくない場合に、動作モードが低速モードであるか否かを判定する第2動作モード判定処理を短周期処理として実行する(ステップS108)。 The processing unit 16 performs steps S101 to S104 and steps S113 to S114 as long-period processing, or when the interrupt count count is not equal to the initial value "0" at the start of interrupt processing. The second operation mode determination process for determining whether or not the operation mode is the low speed mode is executed as a short cycle process (step S108).

処理部16は、第2動作モード判定処理において動作モードが低速モードであると判定された場合、すなわちステップS108において「Yes」の場合に、低速モードの第2処理として行われる低速モード処理B(ステップS109)と、割込み回数更新処理(ステップ110)および割込み回数リセット処理(ステップS111及びS112)とを、短周期処理として実行する。 The processing unit 16 performs low-speed mode processing B (low-speed mode processing B) performed as the second processing of the low-speed mode when the operation mode is determined to be the low-speed mode in the second operation mode determination processing, that is, when “Yes” in step S108. Step S109), the interrupt count update process (step 110), and the interrupt count reset process (steps S111 and S112) are executed as short cycle processes.

また、処理部16は、下限閾値判定処理において回転速度Speedが下限閾値以下でないと判定された場合、すなわちステップS105において「No」の場合に、高速モードの処理(高速モード処理)を長周期処理として実行する(ステップS115)。処理部16は、上記のステップS101からステップS105と、ステップS115とを長周期処理として行った後、または割込み処理の開始時に割込み回数countが初期値「0」と等しくない場合に、動作モードが低速モードであるか否かを判定する第2動作モード判定処理(ステップS108)と、割込み回数更新処理(ステップ110)および割込み回数リセット処理(ステップS111及びS112)とを、短周期処理として実行する。 Further, the processing unit 16 performs long-period processing for high-speed mode processing (high-speed mode processing) when it is determined in the lower limit threshold value determination processing that the rotation speed Speed is not equal to or less than the lower limit threshold value, that is, when “No” in step S105. (Step S115). The processing unit 16 changes the operation mode after performing steps S101 to S105 and S115 as long-period processing, or when the interrupt count count is not equal to the initial value "0" at the start of interrupt processing. The second operation mode determination process (step S108) for determining whether or not the mode is low speed, the interrupt count update process (step 110), and the interrupt count reset process (steps S111 and S112) are executed as short cycle processes. ..

さらに、処理部16は、上限閾値判定処理において回転速度Speedが上限閾値以上であると判定された場合、すなわちステップS113において「Yes」の場合に、動作モードを低速モードから高速モードに切り替える第2モード切り替え処理(ステップS116)と、高速モード処理(ステップS117)とを、長周期処理として実行する。 Further, the processing unit 16 switches the operation mode from the low speed mode to the high speed mode when it is determined in the upper limit threshold value determination process that the rotation speed Speed is equal to or higher than the upper limit threshold value, that is, when “Yes” in step S113. The mode switching process (step S116) and the high-speed mode process (step S117) are executed as long-period processes.

処理部16は、上記のステップS101からステップS104と、ステップS113、ステップS116及びステップS117とを長周期処理して行った後、または割込み処理の開始時に割込み回数countが初期値「0」と等しくない場合に、動作モードが低速モードであるか否かを判定する第2動作モード判定処理(ステップS108)と、割込み回数更新処理(ステップ110)および割込み回数リセット処理(ステップS111及びS112)とを、短周期処理として実行する。 The processing unit 16 performs long-period processing of steps S101 to S104, steps S113, S116, and S117, or at the start of interrupt processing, the interrupt count count is equal to the initial value "0". If not, the second operation mode determination process (step S108) for determining whether or not the operation mode is the low speed mode, the interrupt count update process (step 110), and the interrupt count reset process (steps S111 and S112) are performed. , Execute as a short cycle process.

処理部16は、高速モード処理として、パラメータ決定処理と、パラメータセット処理と、第2出力モード切替処理とを実行する。パラメータ決定処理とは、第2タイマ13の制御パラメータであるタイマリセット値TRES2、第1レベル反転閾値Acom及び第2レベル反転閾値Bcomを決定する処理である。パラメータセット処理とは、タイマリセット値TRES2、第1レベル反転閾値Acom及び第2レベル反転閾値Bcomを第2タイマ13にセットする処理である。第2出力モード切替処理とは、第2タイマ13の出力モードを比較出力モードに切り替える処理である。 The processing unit 16 executes parameter determination processing, parameter set processing, and second output mode switching processing as high-speed mode processing. The parameter determination process is a process of determining the timer reset value TRES2, the first level inversion threshold value Acom, and the second level inversion threshold value Bcom, which are the control parameters of the second timer 13. The parameter set process is a process of setting the timer reset value TRES2, the first level inversion threshold value Acom, and the second level inversion threshold value Bcom in the second timer 13. The second output mode switching process is a process of switching the output mode of the second timer 13 to the comparison output mode.

第2タイマ13のタイマリセット値TRES2は、回転速度の逆数に比例する値である。そのため、タイマリセット値TRES2が小さいほど、A相パルス信号PA及びB相パルス信号PBの出力周波数は高くなり、タイマリセット値TRES2が大きいほど、A相パルス信号PA及びB相パルス信号PBの出力周波数は低くなる。処理部16は、パラメータ決定処理において、下記(14)式に基づいてタイマリセット値TRES2を算出する。下記(14)式において、TimArr(k)がタイマリセット値TRES2である。また、下記(14)式において、KARRDIVは、計算時の桁落ちを防ぐための係数である。 The timer reset value TRES2 of the second timer 13 is a value proportional to the reciprocal of the rotation speed. Therefore, the smaller the timer reset value TRES2, the higher the output frequencies of the A-phase pulse signal PA and the B-phase pulse signal PB, and the larger the timer reset value TRES2, the higher the output frequencies of the A-phase pulse signal PA and the B-phase pulse signal PB. Will be low. The processing unit 16 calculates the timer reset value TRES2 based on the following equation (14) in the parameter determination process. In the following equation (14), Tim Arr (k) is the timer reset value TRES2. Further, in the following equation (14), the KARR DIV is a coefficient for preventing a digit loss at the time of calculation.

Figure 2022103046000007
Figure 2022103046000007

上記(14)式において、除算時に発生する余りfrac(k)を次の制御周期に持ち越す端数処理を行うことにより、累積誤差の発生を抑制する。frac(k)は、下記(15)式に基づいて算出される。下記(15)式において、Quo(k)は、上記(14)式の右辺における大括弧内の演算式の整数部(商)である。また、KARRは、下記(16)式により設定される。なお、下記(16)式において、fcは制御周波数(制御周期の逆数)である。また、下記(16)式において、fsysはクロック周波数である。 In the above equation (14), the occurrence of cumulative error is suppressed by performing rounding processing to carry over the remainder frac (k) generated at the time of division to the next control cycle. frac (k) is calculated based on the following equation (15). In the following equation (15), Quo (k) is the integer part (quotient) of the arithmetic expression in brackets on the right side of the above equation (14). Further, KARR is set by the following equation (16). In the following equation (16), fc is the control frequency (the reciprocal of the control cycle). Further, in the following equation (16), fsys is a clock frequency.

Figure 2022103046000008
Figure 2022103046000008

Figure 2022103046000009
Figure 2022103046000009

ここで、除算における計算精度を保つために分子であるKARRの値をできるだけ大きく設定することは好ましい。そのために、KARRが232より小さい値かつできるだけ大きい値となるようにKARRDIVの値を設定することが好ましい。 Here, it is preferable to set the value of KARR, which is a numerator, as large as possible in order to maintain the calculation accuracy in division. Therefore, it is preferable to set the value of KARR DIV so that KARR is smaller than 2 32 and as large as possible.

また、処理部16は、パラメータ決定処理において、第1レベル反転閾値Acom及び第2レベル反転閾値Bcomを以下のように算出する。例えば、A相パルス信号PAとB相パルス信号PBとの位相差を90°にするには、下記(17)式の関係が成立すればよい。 Further, the processing unit 16 calculates the first level inversion threshold value Acom and the second level inversion threshold value Bcom in the parameter determination process as follows. For example, in order to make the phase difference between the A-phase pulse signal PA and the B-phase pulse signal PB 90 °, the relationship of the following equation (17) may be established.

Figure 2022103046000010
Figure 2022103046000010

処理部16は、上記(17)式の関係が成立するように、第1レベル反転閾値Acom及び第2レベル反転閾値Bcomを算出する。第1レベル反転閾値Acomと第2レベル反転閾値Bcomとの大小関係は、回転方向(回転速度Speedの符号)と信号状態値Stateとを用いて表1の関係に基づいて決定される。 The processing unit 16 calculates the first level inversion threshold value Acom and the second level inversion threshold value Bcom so that the relationship of the above equation (17) is established. The magnitude relationship between the first level inversion threshold value Acom and the second level inversion threshold value Bcom is determined based on the relationship in Table 1 using the rotation direction (sign of rotation speed Speed) and the signal state value State.

Figure 2022103046000011
Figure 2022103046000011

処理部16は、上記のように決定したタイマリセット値TRES2、第1レベル反転閾値Acom及び第2レベル反転閾値Bcomを第2タイマ13にセットするとともに、第2タイマ13の出力モードを比較出力モードに切り替える。その結果、図10に示すように、第2タイマ13は、不図示のクロック信号に同期してタイマカウント値TCをインクリメントし、タイマカウント値TCがタイマリセット値TRES2に到達するごとに、タイマカウント値TCをリセットする。また、第2タイマ13は、タイマカウント値TCが第1レベル反転閾値Acomに到達するごとに、A相パルス信号PAのレベルを反転させ、タイマカウント値TCが第2レベル反転閾値Bcomに到達するごとに、B相パルス信号PBのレベルを反転させる。 The processing unit 16 sets the timer reset value TRES2, the first level inversion threshold value Acom, and the second level inversion threshold value Bcom determined as described above in the second timer 13, and sets the output mode of the second timer 13 to the comparison output mode. Switch to. As a result, as shown in FIG. 10, the second timer 13 increments the timer count value TC in synchronization with a clock signal (not shown), and each time the timer count value TC reaches the timer reset value TRES2, the timer count is counted. Reset the value TC. Further, the second timer 13 inverts the level of the A-phase pulse signal PA every time the timer count value TC reaches the first level inversion threshold value Acom, and the timer count value TC reaches the second level inversion threshold value Bcom. Each time, the level of the B-phase pulse signal PB is inverted.

以上のように、第2実施形態の割込み処理によれば、ロータの回転速度が下限閾値以下のときに動作モードが低速モードに切り替わり、低速モードの処理として第1実施形態で説明した処理が実行されることにより、ロータの回転速度に対して適切な精度を保った状態で90°の位相差を有するA相パルス信号PA及びB相パルス信号PBが生成される。一方、第2実施形態の割込み処理によれば、ロータの回転速度が上限閾値以上のときに動作モードが高速モードに切り替わり、上述の高速モード処理が実行されることにより、ロータの回転速度に対して適切な精度を保った状態で90°の位相差を有するA相パルス信号PA及びB相パルス信号PBが生成される。
このように、第2実施形態の割込み処理によれば、ロータの回転速度に応じて動作モードを低速モードと高速モードとの間で切り替えることにより、回転速度に応じて適切な精度を保った状態でA相パルス信号PA及びB相パルス信号PBを生成することができる。
As described above, according to the interrupt processing of the second embodiment, the operation mode is switched to the low speed mode when the rotation speed of the rotor is equal to or less than the lower limit, and the processing described in the first embodiment is executed as the processing of the low speed mode. As a result, the A-phase pulse signal PA and the B-phase pulse signal PB having a phase difference of 90 ° are generated while maintaining appropriate accuracy with respect to the rotation speed of the rotor. On the other hand, according to the interrupt processing of the second embodiment, when the rotation speed of the rotor is equal to or higher than the upper limit threshold value, the operation mode is switched to the high-speed mode, and the above-mentioned high-speed mode processing is executed, so that the rotation speed of the rotor is increased. A-phase pulse signal PA and B-phase pulse signal PB having a phase difference of 90 ° are generated while maintaining appropriate accuracy.
As described above, according to the interrupt processing of the second embodiment, by switching the operation mode between the low speed mode and the high speed mode according to the rotation speed of the rotor, an appropriate accuracy is maintained according to the rotation speed. Can generate an A-phase pulse signal PA and a B-phase pulse signal PB.

〔第3実施形態〕
次に、本発明の第3実施形態について説明する。
図11は、本発明の第3実施形態における信号生成装置10の構成を模式的に示すブロック図である。図11に示すように、第3実施形態における信号生成装置10は、A/D変換器11と、第1タイマ12と、第2タイマ13と、第3タイマ14と、記憶部15と、処理部16とに加えて、第4タイマ17を備える。
[Third Embodiment]
Next, a third embodiment of the present invention will be described.
FIG. 11 is a block diagram schematically showing the configuration of the signal generation device 10 according to the third embodiment of the present invention. As shown in FIG. 11, the signal generation device 10 in the third embodiment processes the A / D converter 11, the first timer 12, the second timer 13, the third timer 14, and the storage unit 15. In addition to the unit 16, a fourth timer 17 is provided.

このように、第3実施形態における信号生成装置10は、第4タイマ17を新たに備える点で第1実施形態と異なる。また、第3実施形態における第3タイマ14は、Z相パルス信号PZを出力しない点で第1実施形態と異なる。すなわち、第3実施形態における第3タイマ14は、第2タイマ13から出力されるA相パルス信号PA及びB相パルス信号PBのエッジ数をカウントし、エッジカウント値ECを処理部16に出力する機能と、エッジカウント値ECがタイマリセット値TRES3に到達したときにエッジカウント値ECをリセットする機能とを有する点で第1実施形態と一致する。 As described above, the signal generation device 10 in the third embodiment is different from the first embodiment in that the fourth timer 17 is newly provided. Further, the third timer 14 in the third embodiment is different from the first embodiment in that it does not output the Z-phase pulse signal PZ. That is, the third timer 14 in the third embodiment counts the number of edges of the A-phase pulse signal PA and the B-phase pulse signal PB output from the second timer 13, and outputs the edge count value EC to the processing unit 16. It is consistent with the first embodiment in that it has a function and a function of resetting the edge count value EC when the edge count value EC reaches the timer reset value TRES3.

第4タイマ17は、第2タイマ13から出力されるA相パルス信号PA及びB相パルス信号PBのエッジ数をカウントする。第4タイマ17は、エッジ数のカウント値CNTが所定のタイマリセット値TRES4に到達すると、カウント値CNTをリセットする。第4タイマ17は、エッジ数のカウント値CNTと所定のZ相出力閾値Zcom(第4閾値)とを比較し、カウント値CNTがZ相出力閾値Zcomより小さいときにハイレベルとなる信号を、絶対角度θの原点を示すZ相パルス信号PZとして出力する。タイマリセット値TRES4及びZ相出力閾値Zcomは、処理部16によって第4タイマ17にセットされる。 The fourth timer 17 counts the number of edges of the A-phase pulse signal PA and the B-phase pulse signal PB output from the second timer 13. The fourth timer 17 resets the count value CNT when the count value CNT of the number of edges reaches a predetermined timer reset value TRES4. The fourth timer 17 compares the count value CNT of the number of edges with a predetermined Z-phase output threshold value Zcom (fourth threshold value), and outputs a signal that becomes a high level when the count value CNT is smaller than the Z-phase output threshold value Zcom. It is output as a Z-phase pulse signal PZ indicating the origin of the absolute angle θ. The timer reset value TRES4 and the Z-phase output threshold value Zcom are set in the fourth timer 17 by the processing unit 16.

図12は、第4タイマ17のカウント値CNTと、第4タイマ17から出力されるZ相パルス信号PZとの関係を示す図である。図12において、一点鎖線は、第3タイマ14のエッジカウント値ECを示す。図12では、一例として、ロータが1回転する間に、Z相パルス信号PZとして4つのパルス信号Z0、Z1、Z2及びZ3が出力される場合を示している。タイマリセット値TRES4として「1535」がセットされたとき、第4タイマ17のカウント値CNTは「0」から「1535」に向かって上昇し、カウント値CNTが「1535」に到達すると、カウント値CNTは「0」にリセットされる。このように、第4タイマ17のカウント値CNTが「0」から「1535」に向かって上昇している期間において、カウント値CNTがZ相出力閾値Zcomより小さいときに、Z相パルス信号PZとしてパルス信号Z0が出力される。 FIG. 12 is a diagram showing the relationship between the count value CNT of the fourth timer 17 and the Z-phase pulse signal PZ output from the fourth timer 17. In FIG. 12, the alternate long and short dash line indicates the edge count value EC of the third timer 14. FIG. 12 shows, as an example, a case where four pulse signals Z0, Z1, Z2 and Z3 are output as Z-phase pulse signals PZ during one rotation of the rotor. When "1535" is set as the timer reset value TRES4, the count value CNT of the fourth timer 17 increases from "0" to "1535", and when the count value CNT reaches "1535", the count value CNT increases. Is reset to "0". In this way, when the count value CNT of the fourth timer 17 is smaller than the Z phase output threshold Zcom in the period in which the count value CNT is rising from "0" to "1535", it is used as the Z phase pulse signal PZ. The pulse signal Z0 is output.

タイマリセット値TRES4として「2559」がセットされたとき、第4タイマ17のカウント値CNTは「0」から「2559」に向かって上昇し、カウント値CNTが「2559」に到達すると、カウント値CNTは「0」にリセットされる。このように、第4タイマ17のカウント値CNTが「0」から「2559」に向かって上昇している期間において、カウント値CNTがZ相出力閾値Zcomより小さいときに、Z相パルス信号PZとしてパルス信号Z1が出力される。 When "2559" is set as the timer reset value TRES4, the count value CNT of the fourth timer 17 rises from "0" to "2559", and when the count value CNT reaches "2559", the count value CNT Is reset to "0". In this way, when the count value CNT of the fourth timer 17 is smaller than the Z phase output threshold Zcom in the period in which the count value CNT is rising from "0" to "2559", it is used as the Z phase pulse signal PZ. The pulse signal Z1 is output.

タイマリセット値TRES4として「1023」がセットされたとき、第4タイマ17のカウント値CNTは「0」から「1023」に向かって上昇し、カウント値CNTが「1023」に到達すると、カウント値CNTは「0」にリセットされる。このように、第4タイマ17のカウント値CNTが「0」から「1023」に向かって上昇している期間において、カウント値CNTがZ相出力閾値Zcomより小さいときに、Z相パルス信号PZとしてパルス信号Z2が出力される。 When "1023" is set as the timer reset value TRES4, the count value CNT of the fourth timer 17 increases from "0" to "1023", and when the count value CNT reaches "1023", the count value CNT Is reset to "0". As described above, when the count value CNT of the fourth timer 17 is smaller than the Z phase output threshold Zcom in the period in which the count value CNT is rising from "0" to "1023", it is used as the Z phase pulse signal PZ. The pulse signal Z2 is output.

タイマリセット値TRES4として「3071」がセットされたとき、第4タイマ17のカウント値CNTは「0」から「3071」に向かって上昇し、カウント値CNTが「3071」に到達すると、カウント値CNTは「0」にリセットされる。このように、第4タイマ17のカウント値CNTが「0」から「3071」に向かって上昇している期間において、カウント値CNTがZ相出力閾値Zcomより小さいときに、Z相パルス信号PZとしてパルス信号Z3が出力される。 When "3071" is set as the timer reset value TRES4, the count value CNT of the fourth timer 17 increases from "0" to "3071", and when the count value CNT reaches "3071", the count value CNT increases. Is reset to "0". In this way, when the count value CNT of the fourth timer 17 is smaller than the Z-phase output threshold Zcom in the period in which the count value CNT is rising from "0" to "3071", it is used as the Z-phase pulse signal PZ. The pulse signal Z3 is output.

以下では、パルス信号Z0の立ち上がりエッジからパルス信号Z1の立ち上がりエッジまでの区間を「Z0区間」と呼称する。また、パルス信号Z1の立ち上がりエッジからパルス信号Z2の立ち上がりエッジまでの区間を「Z1区間」と呼称する。また、パルス信号Z2の立ち上がりエッジからパルス信号Z3の立ち上がりエッジまでの区間を「Z2区間」と呼称する。さらに、パルス信号Z3の立ち上がりエッジからパルス信号Z0の立ち上がりエッジまでの区間を「Z3区間」と呼称する。 Hereinafter, the section from the rising edge of the pulse signal Z0 to the rising edge of the pulse signal Z1 is referred to as a “Z0 section”. Further, the section from the rising edge of the pulse signal Z1 to the rising edge of the pulse signal Z2 is referred to as a "Z1 section". Further, the section from the rising edge of the pulse signal Z2 to the rising edge of the pulse signal Z3 is referred to as a "Z2 section". Further, the section from the rising edge of the pulse signal Z3 to the rising edge of the pulse signal Z0 is referred to as a "Z3 section".

処理部16は、Z0区間でのカウント中に、次のZ1区間で用いられるタイマリセット値TRES4である「2559」を、第4タイマ17の内部レジスタの一つであるシャドウレジスタにセットする。Z0区間が終了したとき、すなわち、第4タイマ17のカウント値CNTが「1535」に到達して「0」にリセットされたとき、第4タイマ17の内部レジスタの一つであるオートリロードレジスタにシャドウレジスタの値(「2559」)が転送されることにより、Z1区間におけるタイマリセット値TRES4がセットされる。 While counting in the Z0 section, the processing unit 16 sets the timer reset value TRES4 "2559" used in the next Z1 section in the shadow register, which is one of the internal registers of the fourth timer 17. When the Z0 section ends, that is, when the count value CNT of the 4th timer 17 reaches "1535" and is reset to "0", the auto reload register, which is one of the internal registers of the 4th timer 17, is set. By transferring the value of the shadow register (“2559”), the timer reset value TRES4 in the Z1 section is set.

処理部16は、Z1区間でのカウント中に、次のZ2区間で用いられるタイマリセット値TRES4である「1023」を、第4タイマ17のシャドウレジスタにセットする。Z1区間が終了したとき、すなわち、第4タイマ17のカウント値CNTが「2559」に到達して「0」にリセットされたとき、シャドウレジスタの値(「1023」)がオートリロードレジスタに転送されることにより、Z2区間におけるタイマリセット値TRES4がセットされる。 While counting in the Z1 section, the processing unit 16 sets the timer reset value TRES4 "1023" used in the next Z2 section in the shadow register of the fourth timer 17. When the Z1 section ends, that is, when the count value CNT of the fourth timer 17 reaches "2559" and is reset to "0", the value of the shadow register ("1023") is transferred to the auto reload register. As a result, the timer reset value TRES4 in the Z2 section is set.

処理部16は、Z2区間でのカウント中に、次のZ3区間で用いられるタイマリセット値TRES4である「3071」を、第4タイマ17のシャドウレジスタにセットする。Z2区間が終了したとき、すなわち、第4タイマ17のカウント値CNTが「1023」に到達して「0」にリセットされたとき、シャドウレジスタの値(「3071」)がオートリロードレジスタに転送されることにより、Z3区間におけるタイマリセット値TRES4がセットされる。 While counting in the Z2 section, the processing unit 16 sets the timer reset value TRES4 "3071" used in the next Z3 section in the shadow register of the fourth timer 17. When the Z2 section ends, that is, when the count value CNT of the fourth timer 17 reaches "1023" and is reset to "0", the value of the shadow register ("3071") is transferred to the auto reload register. As a result, the timer reset value TRES4 in the Z3 section is set.

処理部16は、Z3区間でのカウント中に、次のZ0区間で用いられるタイマリセット値TRES4である「1535」を、第4タイマ17のシャドウレジスタにセットする。Z3区間が終了したとき、すなわち、第4タイマ17のカウント値CNTが「3071」に到達して「0」にリセットされたとき、シャドウレジスタの値(「1535」)がオートリロードレジスタに転送されることにより、Z0区間におけるタイマリセット値TRES4がセットされる。 While counting in the Z3 section, the processing unit 16 sets the timer reset value TRES4 "1535" used in the next Z0 section in the shadow register of the fourth timer 17. When the Z3 section ends, that is, when the count value CNT of the fourth timer 17 reaches "3071" and is reset to "0", the value of the shadow register ("1535") is transferred to the auto reload register. As a result, the timer reset value TRES4 in the Z0 section is set.

第3タイマ14と同様に、信号生成装置10が電源オフ状態から電源オン状態に切り替えられたとき、第4タイマ17のカウント値CNTは「0」にリセットされる。そのため、信号生成装置10の起動時において、第4タイマ17のカウント値CNTの初期値を設定する必要がある。図12に示すように、例えば、信号生成装置10の起動時に算出されたTIM_CNTの値が「2048」である場合、処理部16は、表2に示すテーブルデータに基づいて、起動時の初期位置がZ1区間にあると判別する。なお、表2に示すテーブルデータは、予め記憶部15に記憶されている。 Similar to the third timer 14, when the signal generation device 10 is switched from the power off state to the power on state, the count value CNT of the fourth timer 17 is reset to “0”. Therefore, it is necessary to set the initial value of the count value CNT of the fourth timer 17 at the time of starting the signal generation device 10. As shown in FIG. 12, for example, when the value of TIM_CNT calculated at the time of starting the signal generation device 10 is "2048", the processing unit 16 performs the initial position at the time of starting based on the table data shown in Table 2. Is determined to be in the Z1 section. The table data shown in Table 2 is stored in the storage unit 15 in advance.

Figure 2022103046000012
Figure 2022103046000012

処理部16は、上記のように判別したZ1区間の1つ前のZ区間であるZ0区間のタイマリセット値TRES4(「1535」)を表2に示すテーブルデータから取得した後、下記(18)式に基づいて、第4タイマ17のカウント値CNTの初期値を設定する。信号生成装置10の起動時に算出されたTIM_CNTの値が「2048」である場合、下記(18)式により、第4タイマ17のカウント値CNTの初期値は、「512」に設定される。
カウント値CNTの初期値=TIM_CNT-(Z0区間のTRES4+1)…(18)
The processing unit 16 acquires the timer reset value TRES4 (“1535”) of the Z0 section, which is the Z section immediately before the Z1 section determined as described above, from the table data shown in Table 2, and then obtains the following (18). Based on the equation, the initial value of the count value CNT of the fourth timer 17 is set. When the value of TIM_CNT calculated at the time of starting the signal generation device 10 is "2048", the initial value of the count value CNT of the fourth timer 17 is set to "512" by the following equation (18).
Initial value of count value CNT = TIM_CNT- (TRES4 + 1 in Z0 section) ... (18)

続いて、図13を参照しながら、第4タイマ17によるカウント中にロータが逆転した場合の処理について説明する。図13に示すように、タイマリセット値TRES4として「1023」が第4タイマ17のオートリロードレジスタにセットされた状態で、第4タイマ17のカウント値CNTがアンダーフローすると、点線100で示すようにカウント値CNTが変化することにより、Z区間(この場合、Z0区間)に誤りが生じる。 Subsequently, with reference to FIG. 13, processing when the rotor reverses during counting by the fourth timer 17 will be described. As shown in FIG. 13, when the count value CNT of the 4th timer 17 underflows while "1023" is set in the auto reload register of the 4th timer 17 as the timer reset value TRES4, as shown by the dotted line 100. As the count value CNT changes, an error occurs in the Z section (in this case, the Z0 section).

そこで、処理部16は、第1タイマ12の周期処理(すなわち、短周期処理)において、以下の比較処理を行う。なお、以下の比較処理において、iは現在のZ区間のインデックスを表し、TRES4[i]は、現在のZ区間で用いられる第4タイマ17のタイマリセット値を表す。
(1)CNT<TRES4[i]/2の場合、シャドウレジスタにTRES4[i-1]をセットする。
(2)CNT>TRES4[i]/2の場合、シャドウレジスタにTRES4[i+1]をセットする。
Therefore, the processing unit 16 performs the following comparison processing in the periodic processing (that is, short-period processing) of the first timer 12. In the following comparison process, i represents the index of the current Z section, and TRES4 [i] represents the timer reset value of the fourth timer 17 used in the current Z section.
(1) When CNT <TRES4 [i] / 2, TRES4 [i-1] is set in the shadow register.
(2) When CNT> TRES4 [i] / 2, TRES4 [i + 1] is set in the shadow register.

例えば、図13において、Z1区間におけるカウント値CNTがTRES4[1]/2より小さい場合、処理部16は、シャドウレジスタにTRES4[0]をセットする。一方、図13において、Z1区間におけるカウント値CNTがTRES4[1]/2より大きい場合、処理部16は、シャドウレジスタにTRES4[2]をセットする。これにより、Z1区間におけるカウント中にロータが逆転したとしても、Z区間に誤りが生じることを防ぐことができる。 For example, in FIG. 13, when the count value CNT in the Z1 section is smaller than TRES4 [1] / 2, the processing unit 16 sets TRES4 [0] in the shadow register. On the other hand, in FIG. 13, when the count value CNT in the Z1 section is larger than TRES4 [1] / 2, the processing unit 16 sets TRES4 [2] in the shadow register. As a result, even if the rotor reverses during counting in the Z1 section, it is possible to prevent an error from occurring in the Z section.

以上のように、第3実施形態によれば、ロータが1回転する間に、第4タイマ17から絶対角度θの基準となるZ相パルス信号PZを複数個出力することができる。これに対して、第1実施形態では、第3タイマ14のタイマリセット値TRES3が「ENCres-1」の値に設定されるため、ロータが1回転する間に、第3タイマ14からZ相パルス信号PZを1つしか出力できない。従って、第3実施形態によれば、1回転未満で原点調整に必要な絶対位置を検出したいという顧客からの要望に対応することが可能である。 As described above, according to the third embodiment, a plurality of Z-phase pulse signals PZ that serve as a reference for the absolute angle θ can be output from the fourth timer 17 while the rotor makes one rotation. On the other hand, in the first embodiment, the timer reset value TRES3 of the third timer 14 is set to the value of "ENC res -1", so that the third timer 14 to the Z phase are set during one rotation of the rotor. Only one pulse signal PZ can be output. Therefore, according to the third embodiment, it is possible to meet the customer's request to detect the absolute position required for the origin adjustment in less than one rotation.

〔変形例〕
本発明は上記実施形態に限定されず、本明細書において説明した各構成は、相互に矛盾しない範囲内において、適宜組み合わせることができる。
[Modification example]
The present invention is not limited to the above-described embodiment, and the configurations described in the present specification can be appropriately combined within a range that does not contradict each other.

例えば、上記第2実施形態において、オートリロードレジスタを用いて第2タイマ13のタイマリセット値TRES2を設定する場合、図10に示すように、タイマリセット値TRES2を更新するタイミングが、本来の更新すべきタイミング(制御周期と同一のタイミング)よりも常に遅れることになる。そのため、単純に、回転速度Speedからタイマリセット値TRES2(TimArr)を算出する方法では累積誤差が発生する可能性がある。このような累積誤差の発生を抑制するアルゴリズムを高速モード処理の一つとして加えてもよい。 For example, in the second embodiment, when the timer reset value TRES2 of the second timer 13 is set by using the auto reload register, the timing for updating the timer reset value TRES2 is originally updated as shown in FIG. It will always be behind the timing that should be (the timing that is the same as the control cycle). Therefore, a cumulative error may occur in the method of simply calculating the timer reset value TRES2 (TimArr) from the rotation speed Speed. An algorithm for suppressing the occurrence of such a cumulative error may be added as one of the high-speed mode processing.

また、例えば、上記第1から第3実施形態では、回転体が3相ブラシレスDCモータのロータである場合を説明したが、回転体はロータに限定されない。
また、上記第1から第3実施形態では、センサ部20が3つの磁気センサ21、22及び23を有する場合を例示したが、回転体の種類または絶対角度の演算アルゴリズムの内容に応じて、磁気センサの種類、数、または配置などを適宜変更してもよい。
さらに、上記第1から第3実施形態において、所定の位相差は90°に限定されず、任意の値に設定可能である。
Further, for example, in the first to third embodiments, the case where the rotating body is a rotor of a three-phase brushless DC motor has been described, but the rotating body is not limited to the rotor.
Further, in the first to third embodiments, the case where the sensor unit 20 has three magnetic sensors 21, 22 and 23 is illustrated, but depending on the type of the rotating body or the content of the absolute angle calculation algorithm, the magnetism The type, number, or arrangement of sensors may be changed as appropriate.
Further, in the first to third embodiments, the predetermined phase difference is not limited to 90 ° and can be set to any value.

10…信号生成装置、11…A/D変換器、12…第1タイマ、13…第2タイマ、14…第3タイマ、15…記憶部、16…処理部、17…第4タイマ、20…センサ部、21、22、23…磁気センサ、INT…割込み信号、PA…A相パルス信号(第1パルス信号)、PB…B相パルス信号(第2パルス信号)、PZ…Z相パルス信号(原点パルス信号) 10 ... Signal generator, 11 ... A / D converter, 12 ... 1st timer, 13 ... 2nd timer, 14 ... 3rd timer, 15 ... Storage unit, 16 ... Processing unit, 17 ... 4th timer, 20 ... Sensor unit, 21, 22, 23 ... Magnetic sensor, INT ... Interruption signal, PA ... A phase pulse signal (first pulse signal), PB ... B phase pulse signal (second pulse signal), PZ ... Z phase pulse signal ( Origin pulse signal)

Claims (11)

所定の周期で割込み信号を出力する第1タイマと、
所定の位相差を有する第1パルス信号と第2パルス信号とを出力する第2タイマと、
前記第1パルス信号及び前記第2パルス信号のエッジ数をカウントする第3タイマと、
前記割込み信号が発生するごとに、前記第2タイマの出力モードを制御する割込み処理を行う処理部と、
を備え、
前記処理部は、前記割込み処理の開始時に前記割込み信号の発生回数である割込み回数が初期値と等しい場合、所定の長周期処理を行った後に所定の短周期処理を行う一方、前記割込み回数が前記初期値と等しくない場合、前記長周期処理を行うことなく前記短周期処理を行い、
前記処理部は、前記長周期処理として、
回転体の絶対角度の今回値を取得する角度取得処理と、
前記絶対角度の今回値及び前回値に基づいて、前記絶対角度を時間の一次関数として表す絶対角度関数を算出する関数算出処理と、
を実行し、
前記処理部は、前記短周期処理として、
前記関数算出処理によって算出された前記絶対角度関数に基づいて前記絶対角度の推定値を角度推定値として算出する角度推定値算出処理と、
前記第3タイマから前記エッジ数のカウント値を取得するカウント値取得処理と、
前記カウント値に基づいて前記絶対角度の現在値を角度現在値として算出する角度現在値算出処理と、
前記カウント値に基づいて前記第1パルス信号のレベルと前記第2パルス信号のレベルとの関係を表す信号状態値を算出する信号状態値算出処理と、
前記角度推定値及び前記角度現在値に基づいて、前記第2タイマの前記出力モードを変化させるタイミングか否かを判定するタイミング判定処理と、
前記タイミング判定処理において前記出力モードを変化させるタイミングと判定されたとき、前記信号状態値に基づいて前記第1パルス信号と前記第2パルス信号との一方のパルス信号の前記出力モードを、ハイレベル出力モードとローレベル出力モードとの一方に変化させる第1出力モード切替処理と、
前記割込み回数を更新する割込み回数更新処理と、
更新後の前記割込み回数が所定の第1閾値と等しい場合に、前記割込み回数を前記初期値にリセットする割込み回数リセット処理と、
を実行する、
信号生成装置。
The first timer that outputs an interrupt signal at a predetermined cycle,
A second timer that outputs a first pulse signal and a second pulse signal having a predetermined phase difference, and
A third timer that counts the number of edges of the first pulse signal and the second pulse signal, and
A processing unit that performs interrupt processing that controls the output mode of the second timer each time the interrupt signal is generated.
Equipped with
When the number of interrupts, which is the number of times the interrupt signal is generated, is equal to the initial value at the start of the interrupt processing, the processing unit performs a predetermined long-period processing and then a predetermined short-period processing, while the number of interrupts is If it is not equal to the initial value, the short-period processing is performed without performing the long-period processing, and the short-period processing is performed.
The processing unit performs the long-period processing.
Angle acquisition process to acquire the current value of the absolute angle of the rotating body,
A function calculation process that calculates an absolute angle function that expresses the absolute angle as a linear function of time based on the current value and the previous value of the absolute angle.
And run
The processing unit performs the short cycle processing.
Angle estimation value calculation processing that calculates the estimated value of the absolute angle as an angle estimation value based on the absolute angle function calculated by the function calculation processing, and
A count value acquisition process for acquiring the count value of the number of edges from the third timer, and
Angle current value calculation processing that calculates the current value of the absolute angle as the current angle value based on the count value, and
A signal state value calculation process for calculating a signal state value representing the relationship between the level of the first pulse signal and the level of the second pulse signal based on the count value, and
A timing determination process for determining whether or not it is a timing to change the output mode of the second timer based on the angle estimation value and the angle current value.
When it is determined in the timing determination process that the timing is to change the output mode, the output mode of one of the first pulse signal and the second pulse signal is set to a high level based on the signal state value. The first output mode switching process that changes to one of the output mode and the low level output mode,
The interrupt count update process for updating the interrupt count and
When the number of interrupts after the update is equal to the predetermined first threshold value, the interrupt count reset process for resetting the interrupt count to the initial value, and the interrupt count reset process.
To execute,
Signal generator.
前記処理部は、前記関数算出処理において、
前記絶対角度の今回値に遅延補償を施すことにより、前記絶対角度関数の切片を算出する切片算出処理と、
前記絶対角度の今回値から前回値を減算することにより、前記絶対角度関数の傾きを算出する傾き算出処理と、
を実行する、
請求項1に記載の信号生成装置。
The processing unit is in the function calculation process.
The intercept calculation process for calculating the intercept of the absolute angle function by applying delay compensation to the current value of the absolute angle, and
The slope calculation process that calculates the slope of the absolute angle function by subtracting the previous value from the current value of the absolute angle,
To execute,
The signal generator according to claim 1.
前記処理部は、前記タイミング判定処理において、前記角度推定値から前記角度現在値を減算することで得られる差分値の絶対値が所定の第2閾値よりも大きい場合に、前記第2タイマの前記出力モードを変化させるタイミングと判定する、
請求項1または請求項2に記載の信号生成装置。
When the absolute value of the difference value obtained by subtracting the current angle value from the estimated angle value in the timing determination process is larger than the predetermined second threshold value, the processing unit said the second timer. Judging that it is the timing to change the output mode,
The signal generator according to claim 1 or 2.
前記第3タイマは、前記エッジ数のカウント値が所定のタイマリセット値に到達すると、前記カウント値をリセットする、
請求項1から請求項3のいずれか一項に記載の信号生成装置。
The third timer resets the count value when the count value of the number of edges reaches a predetermined timer reset value.
The signal generator according to any one of claims 1 to 3.
前記第3タイマは、前記エッジ数のカウント値と所定の第3閾値とを比較し、前記カウント値が前記第3閾値より小さいときにハイレベルとなる信号を、前記絶対角度の原点を示す原点パルス信号として出力する、
請求項4に記載の信号生成装置。
The third timer compares the count value of the number of edges with a predetermined third threshold value, and sends a signal that becomes a high level when the count value is smaller than the third threshold value to the origin indicating the origin of the absolute angle. Output as a pulse signal,
The signal generator according to claim 4.
前記第2タイマから出力される前記第1パルス信号及び前記第2パルス信号のエッジ数をカウントする第4タイマを備え、
前記第4タイマは、
前記エッジ数のカウント値が所定のタイマリセット値に到達すると、前記カウント値をリセットし、
前記エッジ数のカウント値と所定の第4閾値とを比較し、前記カウント値が前記第4閾値より小さいときにハイレベルとなる信号を、前記絶対角度の原点を示す原点パルス信号として出力する、
請求項1から請求項3のいずれか一項に記載の信号生成装置。
A fourth timer for counting the number of edges of the first pulse signal and the second pulse signal output from the second timer is provided.
The fourth timer is
When the count value of the number of edges reaches a predetermined timer reset value, the count value is reset.
The count value of the number of edges is compared with a predetermined fourth threshold value, and a signal that becomes a high level when the count value is smaller than the fourth threshold value is output as an origin pulse signal indicating the origin of the absolute angle.
The signal generator according to any one of claims 1 to 3.
前記処理部は、前記割込み処理の開始時に前記割込み回数が前記初期値と等しい場合、前記長周期処理として、
前記角度取得処理と、
前記絶対角度の今回値と前回値とに基づいて、前記回転体の回転速度を算出する速度算出処理と、
動作モードが高速モードであるか否かを判定する第1動作モード判定処理と、
前記第1動作モード判定処理において前記動作モードが前記高速モードであると判定された場合に、前記回転速度が所定の下限閾値以下か否かを判定する下限閾値判定処理と、
前記下限閾値判定処理において前記回転速度が前記下限閾値以下であると判定された場合に、前記動作モードを前記高速モードから低速モードに切り替える第1モード切り替え処理と、
前記低速モードの第1処理として行われる前記関数算出処理と、
を実行し、
前記処理部は、前記長周期処理を行った後、または前記割込み処理の開始時に前記割込み回数が前記初期値と等しくない場合に行われる前記短周期処理として、
前記動作モードが前記低速モードであるか否かを判定する第2動作モード判定処理と、
前記第2動作モード判定処理において前記動作モードが前記低速モードであると判定された場合に行われる前記低速モードの第2処理と、
前記割込み回数更新処理および前記割込み回数リセット処理と、
を実行し、
前記低速モードの前記第2処理は、前記角度推定値算出処理、前記カウント値取得処理、前記角度現在値算出処理、前記信号状態値算出処理、前記タイミング判定処理、および前記第1出力モード切替処理を含む、
請求項1から請求項6のいずれか一項に記載の信号生成装置。
When the number of interrupts is equal to the initial value at the start of the interrupt processing, the processing unit performs the long-period processing.
The angle acquisition process and
A speed calculation process for calculating the rotation speed of the rotating body based on the current value and the previous value of the absolute angle, and
The first operation mode determination process for determining whether or not the operation mode is a high-speed mode, and
When the operation mode is determined to be the high-speed mode in the first operation mode determination process, the lower limit threshold value determination process for determining whether or not the rotation speed is equal to or less than a predetermined lower limit threshold value,
The first mode switching process for switching the operation mode from the high speed mode to the low speed mode when the rotation speed is determined to be equal to or lower than the lower limit threshold value in the lower limit threshold value determination process.
The function calculation process performed as the first process of the low-speed mode and
And run
The processing unit performs the short-period processing after performing the long-period processing or when the number of interrupts is not equal to the initial value at the start of the interrupt processing.
A second operation mode determination process for determining whether or not the operation mode is the low speed mode, and
The second process of the low speed mode, which is performed when the operation mode is determined to be the low speed mode in the second operation mode determination process,
The interrupt count update process and the interrupt count reset process,
And run
The second process of the low speed mode includes the angle estimation value calculation process, the count value acquisition process, the angle current value calculation process, the signal state value calculation process, the timing determination process, and the first output mode switching process. including,
The signal generator according to any one of claims 1 to 6.
前記処理部は、前記割込み処理の開始時に前記割込み回数が前記初期値と等しい場合、前記長周期処理として、
前記角度取得処理と、
前記絶対角度の今回値と前回値とに基づいて、前記回転体の回転速度を算出する速度算出処理と、
動作モードが高速モードであるか否かを判定する第1動作モード判定処理と、
前記第1動作モード判定処理において前記動作モードが前記高速モードでないと判定された場合に、前記回転速度が所定の上限閾値以上か否かを判定する上限閾値判定処理と、
前記上限閾値判定処理において前記回転速度が前記上限閾値以上でないと判定された場合に、低速モードの第1処理として行われる前記関数算出処理と、
を実行し、
前記処理部は、前記長周期処理を行った後、または前記割込み処理の開始時に前記割込み回数が前記初期値と等しくない場合に行われる前記短周期処理として、
前記動作モードが前記低速モードであるか否かを判定する第2動作モード判定処理と、
前記第2動作モード判定処理において前記動作モードが前記低速モードであると判定された場合に行われる前記低速モードの第2処理と、
前記割込み回数更新処理および前記割込み回数リセット処理と、
を実行し、
前記低速モードの前記第2処理は、前記角度推定値算出処理、前記カウント値取得処理、前記角度現在値算出処理、前記信号状態値算出処理、前記タイミング判定処理、および前記第1出力モード切替処理を含む、
請求項1から請求項6のいずれか一項に記載の信号生成装置。
When the number of interrupts is equal to the initial value at the start of the interrupt processing, the processing unit performs the long-period processing.
The angle acquisition process and
A speed calculation process for calculating the rotation speed of the rotating body based on the current value and the previous value of the absolute angle, and
The first operation mode determination process for determining whether or not the operation mode is a high-speed mode, and
When the operation mode is determined not to be the high-speed mode in the first operation mode determination process, the upper limit threshold value determination process for determining whether or not the rotation speed is equal to or higher than a predetermined upper limit threshold value.
When it is determined in the upper limit threshold value determination process that the rotation speed is not equal to or higher than the upper limit threshold value, the function calculation process performed as the first process of the low speed mode and the function calculation process.
And run
The processing unit performs the short-period processing after performing the long-period processing or when the number of interrupts is not equal to the initial value at the start of the interrupt processing.
A second operation mode determination process for determining whether or not the operation mode is the low speed mode, and
The second process of the low speed mode, which is performed when the operation mode is determined to be the low speed mode in the second operation mode determination process,
The interrupt count update process and the interrupt count reset process,
And run
The second process of the low speed mode includes the angle estimation value calculation process, the count value acquisition process, the angle current value calculation process, the signal state value calculation process, the timing determination process, and the first output mode switching process. including,
The signal generator according to any one of claims 1 to 6.
前記処理部は、前記割込み処理の開始時に前記割込み回数が前記初期値と等しい場合、前記長周期処理として、
前記角度取得処理と、
前記絶対角度の今回値と前回値とに基づいて、前記回転体の回転速度を算出する速度算出処理と、
動作モードが高速モードであるか否かを判定する第1動作モード判定処理と、
前記第1動作モード判定処理において前記動作モードが前記高速モードであると判定された場合に、前記回転速度が所定の下限閾値以下か否かを判定する下限閾値判定処理と、
前記下限閾値判定処理において前記回転速度が前記下限閾値以下でないと判定された場合に行われる前記高速モードの処理と、
を実行し、
前記処理部は、前記長周期処理を行った後、または前記割込み処理の開始時に前記割込み回数が前記初期値と等しくない場合に行われる前記短周期処理として、
前記動作モードが低速モードであるか否かを判定する第2動作モード判定処理と、
前記割込み回数更新処理および前記割込み回数リセット処理と、
を実行する、
請求項1から請求項6のいずれか一項に記載の信号生成装置。
When the number of interrupts is equal to the initial value at the start of the interrupt processing, the processing unit performs the long-period processing.
The angle acquisition process and
A speed calculation process for calculating the rotation speed of the rotating body based on the current value and the previous value of the absolute angle, and
The first operation mode determination process for determining whether or not the operation mode is a high-speed mode, and
When the operation mode is determined to be the high-speed mode in the first operation mode determination process, the lower limit threshold value determination process for determining whether or not the rotation speed is equal to or less than a predetermined lower limit threshold value,
The high-speed mode processing performed when the rotation speed is determined not to be equal to or lower than the lower limit threshold value in the lower limit threshold value determination processing.
And run
The processing unit performs the short-period processing after performing the long-period processing or when the number of interrupts is not equal to the initial value at the start of the interrupt processing.
The second operation mode determination process for determining whether or not the operation mode is the low speed mode, and
The interrupt count update process and the interrupt count reset process,
To execute,
The signal generator according to any one of claims 1 to 6.
前記処理部は、前記割込み処理の開始時に前記割込み回数が前記初期値と等しい場合、前記長周期処理として、
前記角度取得処理と、
前記絶対角度の今回値と前回値とに基づいて、前記回転体の回転速度を算出する速度算出処理と、
動作モードが高速モードであるか否かを判定する第1動作モード判定処理と、
前記第1動作モード判定処理において前記動作モードが前記高速モードでないと判定された場合に、前記回転速度が所定の上限閾値以上か否かを判定する上限閾値判定処理と、
前記上限閾値判定処理において前記回転速度が前記上限閾値以上であると判定された場合に、前記動作モードを低速モードから前記高速モードに切り替える第2モード切り替え処理と、
前記高速モードの処理と、
を実行し、
前記処理部は、前記長周期処理を行った後、または前記割込み処理の開始時に前記割込み回数が前記初期値と等しくない場合に行われる前記短周期処理として、
前記動作モードが前記低速モードであるか否かを判定する第2動作モード判定処理と、
前記割込み回数更新処理および前記割込み回数リセット処理と、
を実行する、
請求項1から請求項6のいずれか一項に記載の信号生成装置。
When the number of interrupts is equal to the initial value at the start of the interrupt processing, the processing unit performs the long-period processing.
The angle acquisition process and
A speed calculation process for calculating the rotation speed of the rotating body based on the current value and the previous value of the absolute angle, and
The first operation mode determination process for determining whether or not the operation mode is a high-speed mode, and
When the operation mode is determined not to be the high-speed mode in the first operation mode determination process, the upper limit threshold value determination process for determining whether or not the rotation speed is equal to or higher than a predetermined upper limit threshold value.
A second mode switching process for switching the operation mode from the low speed mode to the high speed mode when the rotation speed is determined to be equal to or higher than the upper limit threshold value in the upper limit threshold value determination process.
The high-speed mode processing and
And run
The processing unit performs the short-period processing after performing the long-period processing or when the number of interrupts is not equal to the initial value at the start of the interrupt processing.
A second operation mode determination process for determining whether or not the operation mode is the low speed mode, and
The interrupt count update process and the interrupt count reset process,
To execute,
The signal generator according to any one of claims 1 to 6.
前記処理部は、前記高速モードの処理として、
前記第2タイマの制御パラメータであるタイマリセット値、第1レベル反転閾値及び第2レベル反転閾値を決定するパラメータ決定処理と、
前記タイマリセット値、前記第1レベル反転閾値及び第2レベル反転閾値を前記第2タイマにセットするパラメータセット処理と、
前記第2タイマの前記出力モードを比較出力モードに切り替える第2出力モード切替処理と、
を実行し、
前記第2タイマは、
自動更新されるタイマカウント値が前記タイマリセット値に到達するごとに、前記タイマカウント値をリセットし、
前記タイマカウント値が前記第1レベル反転閾値に到達するごとに、前記第1パルス信号のレベルを反転させ、
前記タイマカウント値が前記第2レベル反転閾値に到達するごとに、前記第2パルス信号のレベルを反転させる、
請求項9または請求項10に記載の信号生成装置。
The processing unit is used as processing in the high-speed mode.
The parameter determination process for determining the timer reset value, the first level inversion threshold value, and the second level inversion threshold value, which are the control parameters of the second timer,
Parameter set processing for setting the timer reset value, the first level inversion threshold value, and the second level inversion threshold value in the second timer, and
The second output mode switching process for switching the output mode of the second timer to the comparison output mode, and
And run
The second timer is
Every time the automatically updated timer count value reaches the timer reset value, the timer count value is reset.
Every time the timer count value reaches the first level inversion threshold value, the level of the first pulse signal is inverted.
Every time the timer count value reaches the second level inversion threshold value, the level of the second pulse signal is inverted.
The signal generator according to claim 9 or 10.
JP2021160449A 2020-12-25 2021-09-30 Signal generating device Pending JP2022103046A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US17/560,481 US11797463B2 (en) 2020-12-25 2021-12-23 Signal generation device
CN202111599772.8A CN114690846B (en) 2020-12-25 2021-12-24 Signal generating device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2020216357 2020-12-25
JP2020216357 2020-12-25

Publications (1)

Publication Number Publication Date
JP2022103046A true JP2022103046A (en) 2022-07-07

Family

ID=82272604

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2021160449A Pending JP2022103046A (en) 2020-12-25 2021-09-30 Signal generating device

Country Status (1)

Country Link
JP (1) JP2022103046A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116578631A (en) * 2023-07-13 2023-08-11 国仪量子(合肥)技术有限公司 Data interaction method, data acquisition equipment, data processing equipment and interaction system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116578631A (en) * 2023-07-13 2023-08-11 国仪量子(合肥)技术有限公司 Data interaction method, data acquisition equipment, data processing equipment and interaction system
CN116578631B (en) * 2023-07-13 2023-10-13 国仪量子(合肥)技术有限公司 Data interaction method, data acquisition equipment, data processing equipment and interaction system

Similar Documents

Publication Publication Date Title
JP5502605B2 (en) Motor control device
JP5917294B2 (en) Motor drive circuit
KR102588927B1 (en) Motor control method
CN109983688B (en) Brushless motor control device and brushless motor control method
CN109768755B (en) Semiconductor device, angle value correction circuit and method thereof
CN107431452B (en) Motor drive device and control method for motor drive device
JP2022103046A (en) Signal generating device
CN112970188B (en) Position estimation device and position estimation method
US11722087B2 (en) PWM signal measurement device, motor drive control device, PWM signal measurement method, and motor drive control method
JP2013238431A (en) Resolver device
CN114690846B (en) Signal generating device
US10895866B1 (en) Position error correction for electric motors
US9523566B2 (en) Electric circuit and method for estimating the angular position of a rotor of an electric motor, and device for controlling an electric motor
JP2006017725A (en) Method of measuring revolution of motor
JP4367555B2 (en) Energization timing determination circuit and motor energization timing determination method
JP7006513B2 (en) Motor control device
KR100659156B1 (en) Method for controlling speed of brushless DC motor using two hall sensors and PLL
WO2024004474A1 (en) Angle detection device and angle detection method
US20230384082A1 (en) Angle error correction device
JP2011041374A (en) Motor controller
CN112290847B (en) Rotation angle estimation device
WO2023100886A1 (en) Signal generation device and elevator
EP3913789A1 (en) Motor control device
JP2010220420A (en) Motor control circuit
CN112187121A (en) Motor drive control device and motor drive control method