JP2010074637A - Up/down counter device - Google Patents

Up/down counter device Download PDF

Info

Publication number
JP2010074637A
JP2010074637A JP2008241164A JP2008241164A JP2010074637A JP 2010074637 A JP2010074637 A JP 2010074637A JP 2008241164 A JP2008241164 A JP 2008241164A JP 2008241164 A JP2008241164 A JP 2008241164A JP 2010074637 A JP2010074637 A JP 2010074637A
Authority
JP
Japan
Prior art keywords
count value
pulse signal
movable body
phase
positive direction
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.)
Withdrawn
Application number
JP2008241164A
Other languages
Japanese (ja)
Inventor
Satoru Hayasaka
哲 早坂
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.)
Alps Alpine Co Ltd
Original Assignee
Alps Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alps Electric Co Ltd filed Critical Alps Electric Co Ltd
Priority to JP2008241164A priority Critical patent/JP2010074637A/en
Publication of JP2010074637A publication Critical patent/JP2010074637A/en
Withdrawn legal-status Critical Current

Links

Images

Landscapes

  • Transmission And Conversion Of Sensor Element Output (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a reliable up/down counter with a simple circuitry without using an external clock. <P>SOLUTION: The up/down counter device 10 outputs an up/down state signal (C) from two-phase pulse signals (A), (B) input to an up/down decoder 12 and generates a decoder pulse signal (D) synchronized with each of change points of the two-phase pulse signals. The decoder pulse signals are doubled in an EXOR gate 14 and the doubled pulse signals (E) are logically added to the up/down state signal in an AND gates 18, 20, to generate an up pulse signal (F) and a down pulse signal (G). The signals are counted in built-in hardware counters 22a, 22b of a CPU 22 in advance and thereafter are calculated at constant intervals in a software processor 22c. <P>COPYRIGHT: (C)2010,JPO&INPIT

Description

本発明は、可動体の位置変化に応じて生成されるパルス信号を用いてカウント処理を行うアップダウンカウンタ装置に関するものである。   The present invention relates to an up / down counter device that performs a counting process using a pulse signal generated according to a change in position of a movable body.

この種のアップダウンカウンタ装置に関する先行技術として、回転軸等の位置変化に応じて発生するパルスをカウンタにより計数し、その回転角や位置を検出するディジタルカウンタ装置が知られている(例えば、特許文献1参照。)。この先行技術は、可動体の位置変化に応じて生成される直交2相パルス信号の位相順序に応じてカウントアップ又はカウントダウンのいずれであるかを判別し、その判別直後のクロックパルスの立ち上がりに同期して一定時間内に立ち上がるカウントパルスを発生させておき、この間にカウントアップ状態であればカウント値をアップカウントし、カウントダウン状態であればカウント値をダウンカウントするアップダウンカウンタを備えたものである。特にこの先行技術は、カウントアップ又はカウントダウンを行うタイミングをクロック回路によって調整し、グリッジによる誤カウントが生じ得る期間を回避した上でアップダウンカウンタを動作させている点に特徴がある。   As a prior art relating to this type of up / down counter device, there is known a digital counter device that counts pulses generated according to a change in the position of a rotating shaft or the like by a counter and detects its rotation angle and position (for example, patents). Reference 1). This prior art determines whether it is counting up or counting down according to the phase order of the quadrature two-phase pulse signal generated according to the position change of the movable body, and synchronizes with the rising edge of the clock pulse immediately after the determination. A count pulse that rises within a certain period of time is generated, and an up / down counter that counts up the count value during the count-up state and counts down the count value during the count-down state is provided. . In particular, this prior art is characterized in that the up / down counter is operated after adjusting the timing of counting up or counting down by a clock circuit and avoiding a period during which erroneous counting due to glitch can occur.

またその他の先行技術として、パルスエンコーダの2相出力から可動体の位置変化の方向を判別(弁別)し、方向別のカウントパルスを出力する方向弁別回路が知られている(例えば、特許文献2参照。)。この先行技術は、2相パルス信号を2つのフリップフロップに振り分けて入力し、そのうち一方のフリップフロップを2段に構成してそれぞれから論理信号を出力することで、プロセッサに合計3ビットの方向弁別信号を認識させてカウントアップパルス又はカウントダウンパルスを発生させるものである。
特許第3195801号公報 特公平2−52808号公報
As another prior art, there is known a direction discriminating circuit that discriminates (discriminates) the direction of change in the position of the movable body from the two-phase output of the pulse encoder and outputs count pulses for each direction (for example, Patent Document 2). reference.). This prior art distributes and inputs a two-phase pulse signal to two flip-flops, and configures one of the flip-flops in two stages and outputs a logic signal from each of them, thereby allowing the processor to discriminate a total of 3 bits of direction. A signal is recognized to generate a count-up pulse or a count-down pulse.
Japanese Patent No. 3195801 Japanese Patent Publication No. 2-52808

しかしながら、上述した先行技術(特許文献1,2)はいずれも、外部クロックを利用した同期式カウンタであるため、それだけ回路構成が複雑化するし、なによりカウントアップ又はカウントダウンのタイミングがクロック周期に制約されてしまうという問題がある。また前者の先行技術(特許文献1)は、カウントアップの場合もカウントダウンの場合も共通のカウントパルス(許可信号)を使用しているため、位置変化の方向別に独立したパルスを使用する場合に比べて信頼性に問題がある。   However, since the above-described prior arts (Patent Documents 1 and 2) are all synchronous counters using an external clock, the circuit configuration is complicated accordingly, and the count-up or count-down timing is the clock cycle. There is a problem of being constrained. Further, the former prior art (Patent Document 1) uses a common count pulse (permission signal) for both count-up and count-down, and therefore, compared to the case where independent pulses are used for each direction of position change. There is a problem with reliability.

そこで本発明は、外部クロックを用いることなく、簡易な回路構成で位置変化の方向別に独立したカウントパルスを生成することにより、確実なアップダウンカウントを実現できる技術の提供を課題としたものである。   Accordingly, an object of the present invention is to provide a technique capable of realizing reliable up / down counting by generating independent count pulses for each direction of position change with a simple circuit configuration without using an external clock. .

本発明のアップダウンカウンタ装置は、方向判別部及び基準パルス発生部を備える。このうち方向判別部は、少なくとも2方向に変位可能な可動体の位置変化に応じて生成される2相パルス信号に基づいて位置変化の方向を判別し、その結果を正負のいずれかで表した方向判別信号を出力するものである。また基準パルス発生部は、2相パルス信号の各変化点に同期して基準パルス信号を発生する。   The up / down counter apparatus of the present invention includes a direction discriminating unit and a reference pulse generating unit. Among these, the direction discriminating unit discriminates the direction of the position change based on the two-phase pulse signal generated according to the position change of the movable body that can be displaced in at least two directions, and the result is expressed by either positive or negative. A direction discrimination signal is output. The reference pulse generator generates a reference pulse signal in synchronization with each change point of the two-phase pulse signal.

また本発明のアップダウンカウンタ装置は、正方向パルス発生部及び負方向パルス発生部を備えている。このうち正方向パルス発生部は、方向判別信号が正方向を表す場合、基準パルス信号に基づいて正方向パルス信号を発生する。負方向パルス発生部は、方向判別信号が正方向とは論理が反転した負方向を表す場合、基準パルス信号に基づいて負方向パルス信号を発生するものである。   The up / down counter device of the present invention includes a positive direction pulse generator and a negative direction pulse generator. Among these, the positive direction pulse generator generates a positive direction pulse signal based on the reference pulse signal when the direction determination signal indicates the positive direction. The negative direction pulse generator generates a negative direction pulse signal based on the reference pulse signal when the direction determination signal represents a negative direction whose logic is inverted from the positive direction.

そして本発明のアップダウンカウンタ装置は、正方向カウンタ、負方向カウンタ及び演算処理部を備えている。正方向カウンタは、正方向パルス信号の発生回数を正方向カウント値としてカウントする。また負方向カウンタは、負方向パルス信号の発生回数を負方向カウント値としてカウントする。そして演算処理部は、正方向カウント値と負方向カウント値との差分を可動体の位置変化量として算出する。   The up / down counter device of the present invention includes a positive direction counter, a negative direction counter, and an arithmetic processing unit. The positive direction counter counts the number of occurrences of the positive direction pulse signal as a positive direction count value. The negative direction counter counts the number of occurrences of the negative direction pulse signal as a negative direction count value. The arithmetic processing unit calculates the difference between the positive direction count value and the negative direction count value as the position change amount of the movable body.

本発明のアップダウンカウンタ装置によれば、基準パルス信号とは別に方向別の正方向パルス信号及び負方向パルス信号をそれぞれ独立に発生させているので、これらを正方向カウンタ及び負方向カウンタでそれぞれカウントすることにより、方向別の位置変化量をより正確に演算することができる。   According to the up / down counter device of the present invention, the positive direction pulse signal and the negative direction pulse signal are generated independently for each direction separately from the reference pulse signal, and these are respectively generated by the positive direction counter and the negative direction counter. By counting, the position change amount for each direction can be calculated more accurately.

また正方向パルス信号及び負方向パルス信号は、いずれも基準パルス信号に基づいて発生するものであり、基準パルス信号は、2相パルス信号の波形パターン(各変化点)に同期してリアルタイムに発生するものであるから、これらの波形が外部クロック信号に拘束されることはない。このように本発明では、特に外部クロックを用いなくても、常に正方向カウンタ及び負方向カウンタの各カウント値がリアルタイムに更新されるため、これら方向別のカウント値を用いて演算処理を行うことにより、可動体の位置変化の方向を反映した位置変化量を正確に算出することができる。   The positive pulse signal and the negative pulse signal are both generated based on the reference pulse signal. The reference pulse signal is generated in real time in synchronization with the waveform pattern (each change point) of the two-phase pulse signal. Therefore, these waveforms are not bound to the external clock signal. As described above, in the present invention, the count values of the positive direction counter and the negative direction counter are always updated in real time without using an external clock, so that the arithmetic processing is performed using the count values for each direction. Thus, the position change amount reflecting the direction of the position change of the movable body can be accurately calculated.

本発明のアップダウンカウンタ装置において、上記の演算処理部は以下の演算手法を採用する。すなわち演算処理部は、所定の演算周期ごとに正方向カウンタ及び負方向カウンタから正方向カウント値及び負方向カウント値をそれぞれ取得し、今回の演算周期で取得した正方向カウント値と前回の演算周期で取得した正方向カウント値との差から、今回の演算周期で取得した負方向カウント値と前回の演算周期で取得した負方向カウント値との差を減算した結果を位置変化量として算出する。   In the up / down counter apparatus of the present invention, the arithmetic processing unit employs the following arithmetic technique. That is, the arithmetic processing unit acquires the positive direction count value and the negative direction count value from the positive direction counter and the negative direction counter for each predetermined calculation period, and the positive direction count value acquired in the current calculation period and the previous calculation period. The position change amount is calculated by subtracting the difference between the negative direction count value acquired in the current calculation cycle and the negative direction count value acquired in the previous calculation cycle from the difference from the positive direction count value acquired in (1).

上記の演算手法を採用した場合、減算結果が正の値であれば、それは正方向への位置変化量であることを意味し、逆に減算結果が負の値であれば、それは負方向への位置変化量であることを意味するものとなる。したがって、得られた位置変化量には可動体の位置変化の方向が正確に反映されているので、演算処理部においてわざわざ方向判別信号を参照する必要がなく、それだけ演算処理の負担が軽減される。   When the above calculation method is adopted, if the subtraction result is a positive value, it means that the position change amount is in the positive direction. Conversely, if the subtraction result is a negative value, it is in the negative direction. It means that the position change amount of Therefore, since the direction of the position change of the movable body is accurately reflected in the obtained position change amount, there is no need to bother to refer to the direction determination signal in the calculation processing section, and the calculation processing load is reduced accordingly. .

また演算処理部は、可動体の現在位置を表す現在位置カウント値に位置変化量を加算することで現在位置カウント値を更新する処理を行ってもよい。   The arithmetic processing unit may perform a process of updating the current position count value by adding the position change amount to the current position count value representing the current position of the movable body.

上記のように位置変化量には方向が反映されているので、それまでの現在位置カウント値に位置変化量を単純加算するだけで最新の現在位置カウント値を得ることができる。したがって、ここでも演算処理部においてわざわざ方向判別信号を参照し、正方向であれば加算し、逆に負方向であれば減算するといった条件判断を行う必要がないことから、それだけ処理速度を向上することができる。   Since the direction is reflected in the position change amount as described above, the latest current position count value can be obtained by simply adding the position change amount to the current position count value so far. Accordingly, it is not necessary to refer to the direction determination signal in the arithmetic processing unit, and it is not necessary to make a condition determination such as adding in the positive direction and subtracting in the negative direction, so that the processing speed is improved accordingly. be able to.

本発明のアップダウンカウンタ装置は、不規則なタイミングで変位方向が切り替わり得る可動体の位置変化に応じて2相パルス信号を方向別の位相順序で出力するエンコーダと、演算処理部としての機能を有したプロセッサとを備えていてもよい。そしてこの場合、プロセッサが可動体の位置変化量を算出する演算周期は、可動体の一方向への位置変化に応じてエンコーダにより2相パルス信号が最後に出力された後、可動体の変位方向が他方向へ切り替わることで位相順序が逆転した状態の2相パルス信号がエンコーダから最初に出力されるまでの最短時間に比較して長く設定されているものとする。   The up / down counter device of the present invention has an encoder that outputs a two-phase pulse signal in a phase order according to a direction according to a change in position of a movable body whose displacement direction can be switched at irregular timing, and a function as an arithmetic processing unit. And a processor having the same. In this case, the calculation cycle in which the processor calculates the position change amount of the movable body is the displacement direction of the movable body after the two-phase pulse signal is finally output by the encoder according to the position change in one direction of the movable body. Is set to be longer than the shortest time until the first output of the two-phase pulse signal in which the phase order is reversed by switching in the other direction.

この場合、プロセッサが前回の演算処理を行ってから次の演算処理を行うまでの間に、2相パルス信号の位相順序が逆転していることがあるが、本発明では上記のように方向別のパルス信号をリアルタイムに発生させてそれぞれをカウントしているので、たとえ可動体の位置変化の方向が切り替わったとしても、これを正確に反映して位置変化量を算出することができる。これにより、エンコーダの性能とプロセッサによる演算処理の頻度とのバランスを適正化し、プロセッサのリソースを効率よく利用することができる。   In this case, the phase order of the two-phase pulse signal may be reversed between the time when the processor performs the previous arithmetic processing and the time when the next arithmetic processing is performed. Therefore, even if the direction of the position change of the movable body is switched, it is possible to calculate the position change amount by accurately reflecting this. Thereby, it is possible to optimize the balance between the performance of the encoder and the frequency of arithmetic processing by the processor, and to efficiently use the resources of the processor.

本発明のアップダウンカウンタ装置は、可動体の位置変化の方向を正確に反映した位置変化量を算出することができる。また、各種パルス信号の波形はもとの2相パルス信号の波形に依存するため、外部クロックに依存することなく簡易な回路構成を採用することができる。   The up / down counter device of the present invention can calculate a position change amount that accurately reflects the direction of the position change of the movable body. Further, since the waveforms of various pulse signals depend on the original two-phase pulse signal waveforms, a simple circuit configuration can be employed without depending on an external clock.

以下、本発明の実施形態について図面を参照しながら説明する。   Hereinafter, embodiments of the present invention will be described with reference to the drawings.

〔アップダウンカウンタ装置の構成〕
図1は、一実施形態のアップダウンカウンタ装置10の構成を概略的に示す図である。このアップダウンカウンタ装置10は、例えば図示しないパルスエンコーダ(ロータリ式、リニア式等)に接続されている。パルスエンコーダは、例えば図示しないモータの回転軸、プリンタの印字ヘッド、回転式又は直動式の操作部材等の可動体に取り付けられており、これら可動体の位置変化(回転式の場合は回転角変化)に応じて位相差が90°の2相(A相,B相)パルス信号を出力する。なおパルスエンコーダは、必要に応じて原点位置を表すZ相パルス信号を出力するものであってもよい。
[Configuration of Up / Down Counter Device]
FIG. 1 is a diagram schematically illustrating a configuration of an up / down counter device 10 according to an embodiment. The up / down counter device 10 is connected to, for example, a pulse encoder (rotary type, linear type, etc.) (not shown). The pulse encoder is attached to a movable body such as a rotating shaft of a motor (not shown), a print head of a printer, a rotary or direct-acting operation member, and the position change of these movable bodies (rotation angle in the case of a rotary type). 2 phase (A phase, B phase) pulse signals having a phase difference of 90 ° in accordance with (change). The pulse encoder may output a Z-phase pulse signal indicating the origin position as necessary.

〔方向判別部〕
アップダウンカウンタ装置10はUP/DOWNデコーダ12を備えており、このUP/DOWNデコーダ12にはパルスエンコーダから2相パルス信号が入力される。UP/DOWNデコーダ12は、入力されたA相パルス信号(図中(A))とB相パルス信号(図中(B))の位相順序から可動体の位置変化の方向を判別し、その結果を表す方向判別信号としてUP/DOWNステート信号(図中(C))を出力する。すなわちUP/DOWNステート信号は、例えばB相パルス信号の立ち下がり時にA相パルス信号がローレベルであればハイレベルとなり、逆にA相パルス信号がハイレベルであればローレベルとなる。
[Direction determination unit]
The up / down counter device 10 includes an UP / DOWN decoder 12 to which a two-phase pulse signal is input from the pulse encoder. The UP / DOWN decoder 12 determines the direction of change in the position of the movable body from the phase order of the input A-phase pulse signal ((A) in the figure) and B-phase pulse signal ((B) in the figure), and the result An UP / DOWN state signal ((C) in the figure) is output as a direction discrimination signal representing That is, the UP / DOWN state signal becomes high level if, for example, the A phase pulse signal is low level at the fall of the B phase pulse signal, and conversely becomes low level if the A phase pulse signal is high level.

このようなUP/DOWNステート信号は、ハイレベルのときに可動体の位置変化が正方向であることを表し、逆にローレベルのときは負方向であることを表すものとなる。なお、ここでいう位置変化の方向は、例えば軸の回転や部材の往復直動のように対向する2方向への位置変化が生じる場合、そのいずれか一方を「正方向」とし、他方の「負方向」とすることができる。   Such an UP / DOWN state signal indicates that the position change of the movable body is in the positive direction when it is at a high level, and conversely indicates that it is in the negative direction when it is at a low level. Note that the direction of the position change here is, for example, when a position change occurs in two opposite directions, such as rotation of a shaft or reciprocating linear movement of a member, one of them is defined as a “positive direction” and the other “ Negative direction ".

またUP/DOWNデコーダ12は、入力されたA相パルス信号及びB相パルス信号の各変化点(立ち上がり時と立ち下がり時)に同期してレベルが変化するデコーダパルス信号を出力する(図中(D))。   The UP / DOWN decoder 12 outputs a decoder pulse signal whose level changes in synchronization with each change point (at the time of rising and at the time of falling) of the input A-phase pulse signal and B-phase pulse signal (in the figure ( D)).

〔基準パルス発生部〕
アップダウンカウンタ装置10は、UP/DOWNデコーダ12の後段位置にEXORゲート14を備えており、このEXORゲート14にはUP/DOWNデコーダ12からデコーダパルス信号が入力されるものとなっている。このときEXORゲート14には、その一方の入力端子に対してデコーダパルス信号がそのまま入力され、他方の入力端子に対しては遅延回路16を介してデコーダパルス信号が入力されている。遅延回路16はデコーダパルス信号をわずかな時間(2相パルス信号の最短周期より短い時間)だけ遅延させて出力する。これによりEXORゲート14には、遅延時間分の位相差をもった2相のデコーダパルス信号が入力される。その結果、EXORゲート14からは、デコーダパルス信号の周波数を2逓倍した2倍パルス信号(図中(E))が出力される。
[Reference pulse generator]
The up / down counter device 10 includes an EXOR gate 14 at a position subsequent to the UP / DOWN decoder 12, and a decoder pulse signal is input to the EXOR gate 14 from the UP / DOWN decoder 12. At this time, the decoder pulse signal is input to the EXOR gate 14 as it is to one input terminal thereof, and the decoder pulse signal is input to the other input terminal via the delay circuit 16. The delay circuit 16 delays the decoder pulse signal by a short time (a time shorter than the shortest cycle of the two-phase pulse signal) and outputs it. As a result, a two-phase decoder pulse signal having a phase difference corresponding to the delay time is input to the EXOR gate 14. As a result, the EXOR gate 14 outputs a double pulse signal ((E) in the figure) obtained by multiplying the frequency of the decoder pulse signal by two.

またアップダウンカウンタ装置10は、EXORゲート14の後段位置に2つのANDゲート18,20を備えており、これらANDゲート18,20には、それぞれ上記のUP/DOWNステート信号及び2倍パルス信号が分配して入力されている。このうち一方のANDゲート18には、各信号がそのまま入力されているが、他方のANDゲート20には、UP/DOWNステート信号が論理反転した状態で入力されている。   Further, the up / down counter device 10 includes two AND gates 18 and 20 at positions subsequent to the EXOR gate 14, and the AND gates 18 and 20 receive the above UP / DOWN state signal and double pulse signal, respectively. It is distributed and input. Of these, each signal is inputted as it is to one AND gate 18, but the UP / DOWN state signal is inputted to the other AND gate 20 in a logically inverted state.

〔正方向パルス発生部,負方向パルス発生部〕
このような回路構成により、一方のANDゲート18は、UP/DOWNステート信号がハイレベル(正方向を表す)の場合、2倍パルス信号に同期してUPパルス信号(図中(F))を出力することができる。また他方のANDゲート20は、UP/DOWNステート信号がローレベル(負方向を表す)の場合、2倍パルス信号に同期してDOWNパルス信号(図中(G))を出力することができる。
[Positive direction pulse generator, Negative direction pulse generator]
With such a circuit configuration, one AND gate 18 outputs an UP pulse signal ((F) in the figure) in synchronization with the double pulse signal when the UP / DOWN state signal is at a high level (indicating the positive direction). Can be output. The other AND gate 20 can output a DOWN pulse signal ((G) in the figure) in synchronization with the double pulse signal when the UP / DOWN state signal is at a low level (indicating a negative direction).

〔正方向カウンタ,負方向カウンタ〕
アップダウンカウンタ装置10は、演算処理機能を有したプロセッサとしてCPU22を備えている。このCPU22は、図示しないCPUコアをはじめとして、各種レジスタやメインメモリ、EEPROM等のリソースが集積された半導体LSIである。またCPU22は、各入力ポートに対応した内蔵ハードカウンタ22a,22bを有している。上記のANDゲート18,20からそれぞれ出力されたUPパルス信号及びDOWNパルス信号は、それぞれ図示しない入力ポートを通じてCPU22に入力され、その内部で内蔵ハードカウンタ22a,22bに取り込まれる。
[Positive direction counter, Negative direction counter]
The up / down counter apparatus 10 includes a CPU 22 as a processor having an arithmetic processing function. The CPU 22 is a semiconductor LSI in which resources such as various registers, a main memory, and an EEPROM are integrated, including a CPU core (not shown). The CPU 22 has built-in hard counters 22a and 22b corresponding to the input ports. The UP pulse signal and the DOWN pulse signal respectively output from the AND gates 18 and 20 are input to the CPU 22 through input ports (not shown), and are taken into the internal hard counters 22a and 22b.

これら内蔵ハードカウンタ22a,22bはNビットのバイナリカウンタ(例えば0h〜FFFFh)で構成されており、各内蔵ハードカウンタ22a,22bは、CPU22に対するUPパルス信号又はDOWNパルス信号の各入力回数(発生回数)に応じて内部カウント値をインクリメントする。したがって一方の内蔵ハードカウンタ22aは、UPパルス信号の発生回数を正方向カウント値としてカウントする正方向カウンタ(UPカウンタ)として機能し、他方の内蔵ハードカウンタ22bは、DOWNパルス信号の発生回数を負方向カウント値としてカウントする負方向カウンタ(DOWNカウンタ)として機能する。   These built-in hard counters 22a and 22b are composed of N-bit binary counters (for example, 0h to FFFFh). ) To increment the internal count value. Accordingly, one of the built-in hard counters 22a functions as a positive direction counter (UP counter) that counts the number of occurrences of the UP pulse signal as a positive direction count value, and the other built-in hard counter 22b decrements the number of occurrences of the DOWN pulse signal. It functions as a negative direction counter (DOWN counter) that counts as a direction count value.

〔演算処理部〕
またCPU22は、上記のリソースで構成されるソフトウェア処理部22cを有している。ソフトウェア処理部22cは、例えばCPU22に内蔵のROMに記憶されたプログラム(例えばメイン処理及び各種割込処理)を実行し、その過程で内蔵ハードカウンタ22a,22bから各カウント値(図中(H),(J))をロードする。そしてソフトウェア処理部22cは、ロードした各カウント値を用いて演算処理を行い、可動体の位置変化量やその現在位置情報を算出する。なおソフトウェア処理部22cは、必要に応じて各内蔵ハードカウンタ22a,22bのカウント値をリセットすることもできる。
[Operation processing unit]
In addition, the CPU 22 has a software processing unit 22c composed of the above resources. The software processing unit 22c executes, for example, a program (for example, main processing and various interrupt processing) stored in a ROM built in the CPU 22, and in the process, count values ((H) in the figure) from the built-in hardware counters 22a and 22b. , (J)). Then, the software processing unit 22c performs arithmetic processing using each loaded count value, and calculates the position change amount of the movable body and its current position information. The software processing unit 22c can also reset the count values of the built-in hard counters 22a and 22b as necessary.

〔動作例〕
図2は、可動体の位置変化に伴う各種信号の出力波形の変化例とCPU22内部でのカウント値の変化例を示したタイミングチャートである。
[Operation example]
FIG. 2 is a timing chart showing an example of changes in output waveforms of various signals accompanying changes in the position of the movable body and an example of changes in count values inside the CPU 22.

〔正転時の変化例〕
例えば、回転変位する可動体の位置変化の方向が初期において正方向(正転)であった場合、各信号波形は以下の変化となる。
[Example of change during normal rotation]
For example, when the direction of the position change of the movable body that is rotationally displaced is initially in the positive direction (forward rotation), each signal waveform has the following changes.

〔2相パルス信号〕
図2中(A),(B):可動体の位置変化に応じて先にA相パルス信号が出力され、これに対して90°の位相差をもってB相パルス信号が出力される。
[2-phase pulse signal]
In FIG. 2, (A), (B): The A-phase pulse signal is output first according to the change in the position of the movable body, and the B-phase pulse signal is output with a phase difference of 90 °.

〔UP/DOWNステート信号〕
図2中(C):また可動体の正転中(正方向への移動中)、上記のようにUP/DOWNステート信号はハイレベルとなっている。
[UP / DOWN state signal]
In FIG. 2, (C): While the movable body is rotating forward (moving in the forward direction), the UP / DOWN state signal is at the high level as described above.

〔デコーダパルス信号〕
図2中(D):可動体の正転中、デコーダパルス信号はA相パルス信号の立ち上がりに同期して立ち上がり、次にB相パルス信号の立ち上がりが生じると、これに同期してローレベルに変化する。そして、この後にA相パルス信号が立ち下がりを生じると、これに同期してデコーダパルス信号は再びハイレベルに変化し、次にB相パルス信号が立ち下がると、これに同期してデコーダパルス信号はローレベルに変化する。
[Decoder pulse signal]
In FIG. 2, (D): During the forward rotation of the movable body, the decoder pulse signal rises in synchronization with the rise of the A phase pulse signal, and then rises to the low level in synchronization with the rise of the B phase pulse signal. Change. When the A-phase pulse signal subsequently falls, the decoder pulse signal changes to high level again in synchronization with this, and when the B-phase pulse signal falls next, the decoder pulse signal is synchronized with this. Changes to a low level.

〔2倍パルス信号〕
図2中(E):2倍パルス信号は、特に可動体の回転方向に依存することなく、単にデコーダパルス信号の2逓倍波形として出力される。このような2倍パルス信号は、次のUPパルス信号及びDOWNパルス信号をそれぞれ生成する際の基となる基準パルス信号として利用することができる。
[Double pulse signal]
In FIG. 2, (E): The double pulse signal is simply output as a double waveform of the decoder pulse signal without depending on the rotation direction of the movable body. Such a double pulse signal can be used as a reference pulse signal that is a basis for generating the next UP pulse signal and DOWN pulse signal.

〔UPパルス信号〕
図2中(F):可動体の正転中はUP/DOWNステート信号がハイレベルとなっているので、一方のANDゲート18からは2倍パルス信号に基づいてUPパルス信号が出力される。
[UP pulse signal]
In FIG. 2, (F): Since the UP / DOWN state signal is at a high level during normal rotation of the movable body, an UP pulse signal is output from one AND gate 18 based on the double pulse signal.

〔DOWNパルス信号〕
図2中(G):これに対し、可動体の正転中は他方のANDゲート20で論理積が成立しないため、DOWNパルス信号が発生することはない。
[DOWN pulse signal]
In FIG. 2, (G): On the other hand, the logical product is not established in the other AND gate 20 during the forward rotation of the movable body, so that a DOWN pulse signal is not generated.

〔UPカウント値〕
図2中(H):内蔵ハードカウンタ22aのUPカウント値は、例えばその初期値を「0」とすると、UPパルス信号が発生するごとにインクリメント(+1)されていく。
[UP count value]
In FIG. 2, (H): The UP count value of the built-in hardware counter 22a is incremented (+1) each time an UP pulse signal is generated, for example, when its initial value is “0”.

〔DOWNカウント値〕
図2中(I):これに対し、もう1つの内蔵ハードカウンタ22bのカウント値は、DOWNパルス信号が入力されないことら、可動体の正転中はその初期値「0」のまま変化しないことがわかる。
[DOWN count value]
In FIG. 2, (I): On the other hand, the count value of the other built-in hard counter 22b does not change to its initial value “0” during normal rotation of the movable body because the DOWN pulse signal is not input. I understand.

〔反転時の変化例〕
これに対し、回転変位する可動体の位置変化の方向が正方向(正転)から負方向(逆転)に切り替わった場合、各信号波形は以下の変化となる。
[Example of change during inversion]
On the other hand, when the direction of positional change of the movable body that is rotationally displaced is switched from the positive direction (forward rotation) to the negative direction (reverse rotation), each signal waveform has the following changes.

〔2相パルス信号〕
図2中(A),(B):図中に正転から逆転への切り替わり時が太い破線で示されているように、可動体が逆転すると、その位置変化に応じて今度はB相パルス信号が先に出力され、これに対して90°の位相差をもってA相パルス信号が出力されるため、正転時とは位相順序が入れ替わった状態となる。
[2-phase pulse signal]
In FIG. 2, (A) and (B): When the movable body reverses, as indicated by a thick broken line, the B-phase pulse is changed in response to the change in position as indicated by the thick broken line in FIG. Since the signal is output first, and the A-phase pulse signal is output with a phase difference of 90 ° with respect to this, the phase order is changed from that in the forward rotation.

〔UP/DOWNステート信号〕
図2中(C):可動体の位置変化が逆転に切り替わると(正方向→負方向)、A相パルス信号が立ち下がる前にB相パルス信号が立ち上がる。このとき図中に矢印付の破線で示すように、UP/DOWNステート信号はハイレベルからローレベルに切り替わる。
[UP / DOWN state signal]
In FIG. 2, (C): When the change in position of the movable body is switched to reverse (positive direction → negative direction), the B-phase pulse signal rises before the A-phase pulse signal falls. At this time, as indicated by a broken line with an arrow in the figure, the UP / DOWN state signal is switched from the high level to the low level.

〔デコーダパルス信号〕
図2中(D):可動体の逆転中、デコーダパルス信号はB相パルス信号の立ち上がりに同期して立ち上がり、次にA相パルス信号の立ち上がりが生じると、これに同期してローレベルに変化する。そして、この後にB相パルス信号が立ち下がりを生じると、これに同期してデコーダパルス信号は再びハイレベルに変化し、次にA相パルス信号が立ち下がると、これに同期してデコーダパルス信号はローレベルに変化する波形パターンを示す。
[Decoder pulse signal]
In FIG. 2, (D): During the reversal of the movable body, the decoder pulse signal rises in synchronization with the rise of the B-phase pulse signal, and then changes to the low level in synchronization with the rise of the A-phase pulse signal. To do. When the B-phase pulse signal subsequently falls, the decoder pulse signal changes to high level again in synchronization with this, and when the A-phase pulse signal falls next, the decoder pulse signal synchronizes with this. Indicates a waveform pattern that changes to a low level.

〔2倍パルス信号〕
図2中(E):可動体が逆転に切り替わっても、2倍パルス信号はデコーダパルス信号の2逓倍波形として出力される。
[Double pulse signal]
In FIG. 2, (E): Even if the movable body is switched to reverse rotation, the double pulse signal is output as a double waveform of the decoder pulse signal.

〔UPパルス信号〕
図2中(F):可動体の逆転中はUP/DOWNステート信号がローレベルとなっているので、UPパルス信号は発生しなくなる。
[UP pulse signal]
In FIG. 2, (F): Since the UP / DOWN state signal is at a low level during the reverse rotation of the movable body, the UP pulse signal is not generated.

〔DOWNパルス信号〕
図2中(G):これに対して可動体の逆転中は、他方のANDゲート20からDOWNパルス信号が出力される。
[DOWN pulse signal]
In FIG. 2, (G): On the other hand, the DOWN pulse signal is output from the other AND gate 20 during the reverse rotation of the movable body.

〔UPカウント値〕
図2中(H):可動体の逆転中、内蔵ハードカウンタ22aのUPカウント値は、例えば正転中に「10」までインクリメントされていたとすると、そのまま変化しなくなる。
[UP count value]
In FIG. 2, (H): During the reverse rotation of the movable body, if the UP count value of the built-in hard counter 22a is incremented to “10” during the normal rotation, for example, it does not change as it is.

〔DOWNカウント値〕
図2中(I):これに対し、もう1つの内蔵ハードカウンタ22bのカウント値は、その初期値「0」からDOWNパルス信号が入力されるごとにインクリメント(+1)されていくことがわかる。
[DOWN count value]
In FIG. 2, (I): On the other hand, it can be seen that the count value of another built-in hard counter 22b is incremented (+1) every time a DOWN pulse signal is input from its initial value “0”.

〔ソフトカウント値〕
図2中(J):CPU22は、ソフトウェア処理部22cにおいて演算処理を実行する。この演算処理では、ソフトウェア処理部22cはその時点でのUPカウント値及びDOWNカウント値をそれぞれ内蔵ハードカウンタ22a,22bから取得(ロード)して、可動体の位置変化量を算出する。そしてソフトウェア処理部22cは、算出した位置変化量を前回のソフトカウント値に加算し、今回のソフトカウント値を更新する。
[Soft count value]
In FIG. 2, (J): The CPU 22 executes arithmetic processing in the software processing unit 22c. In this calculation process, the software processing unit 22c acquires (loads) the UP count value and the DOWN count value at that time from the built-in hardware counters 22a and 22b, and calculates the position change amount of the movable body. The software processing unit 22c adds the calculated position change amount to the previous soft count value, and updates the current soft count value.

〔タイマ割込処理〕
図3は、ソフトウェア処理部22cにおいて実行される演算処理の手順例を示すフローチャートである。ソフトウェア処理部22cは、メインプログラムの実行中に例えば1ms周期でタイマ割り込みを発生させ、図3の演算処理を実行する。以下、演算処理の各手順について説明する。
[Timer interrupt processing]
FIG. 3 is a flowchart illustrating an exemplary procedure of arithmetic processing executed in the software processing unit 22c. The software processing unit 22c generates a timer interrupt, for example, at a cycle of 1 ms during execution of the main program, and executes the arithmetic processing of FIG. Hereinafter, each procedure of the arithmetic processing will be described.

ステップS10:ソフトウェア処理部22cは、一方の内蔵ハードカウンタ22aからUPカウント値をロードする。
ステップS12:またソフトウェア処理部22cは、他方の内蔵ハードカウンタ22bからDOWNカウント値をロードする。
Step S10: The software processing unit 22c loads the UP count value from one of the built-in hardware counters 22a.
Step S12: The software processing unit 22c loads the DOWN count value from the other built-in hard counter 22b.

ステップS14:ソフトウェア処理部22cは、以下の演算を行う。すなわち、今回ロードしたUPカウント値(Cp1)とレジスタに保存されている前回のUPカウント値(Cp0)との差(Cp1−Cp0)から、今回ロードしたDOWNカウント値(Cn1)とレジスタに保存されている前回のDOWNカウント値(Cn0)との差(Cn1−Cn0)を減算し、その結果を位置変化量とする。このとき位置変化量(ΔPs)は、例えば以下の式で表される。
ΔPs={+(Cp1−Cp0)−(Cn1−Cn0)}
Step S14: The software processing unit 22c performs the following calculation. That is, the DOWN count value (Cn1) loaded this time and the register are stored in the register from the difference (Cp1-Cp0) between the UP count value (Cp1) loaded this time and the previous UP count value (Cp0) stored in the register. The difference (Cn1-Cn0) from the previous DOWN count value (Cn0) is subtracted, and the result is used as the position change amount. At this time, the position change amount (ΔPs) is expressed by the following equation, for example.
ΔPs = {+ (Cp1−Cp0) − (Cn1−Cn0)}

ステップS14:そしてソフトウェア処理部22cは、算出した位置変化量(ΔPs)を前回のソフトカウント値(Ps0)に加算して今回のソフトカウント値(Ps1)を更新する。このとき今回のソフトカウント値(Ps1)は、例えば以下の式で表される。
Ps1=Ps0+ΔPs
Step S14: The software processing unit 22c adds the calculated position change amount (ΔPs) to the previous soft count value (Ps0) to update the current soft count value (Ps1). At this time, the current soft count value (Ps1) is expressed by the following equation, for example.
Ps1 = Ps0 + ΔPs

〔演算例〕
ここで、以下に演算例を挙げて説明する。
先ず、全てのカウント値の初期値を「0」として、可動体が正転を開始した場合を想定する(図2中(H),(I),(J))。
[Operation example]
Here, an example of calculation will be described below.
First, it is assumed that the initial value of all count values is “0” and the movable body starts normal rotation ((H), (I), (J) in FIG. 2).

〔図2中時刻t0〕
正転開始直後(A相パルス信号の発生前)のタイミングで割り込みが発生したとすると、未だUPカウント値及びDOWNカウント値は「0」のままであるため、今回のソフトカウント値は「0」となる(図2中(J)の初期値参照)。
[Time t0 in FIG. 2]
If an interrupt occurs immediately after the start of forward rotation (before the generation of the A-phase pulse signal), the UP count value and the DOWN count value are still “0”, so the current soft count value is “0”. (Refer to the initial value of (J) in FIG. 2).

〔図2中時刻t0〜t1〕
この後、可動体の位置変化に応じて2相パルス信号が生成されると、UPカウント値が増加(0→1→2→3)していく。なお、DOWNカウント値は初期値「0」のままである。2相パルス信号が生成される周期は可動体の回転速度に依存するが、パルスエンコーダの分解能は最短周期で数十μs程度である。したがって、CPU22のタイマ割込周期に比較すると2相パルス信号の発生周期の方が短いことから、次のタイマ割込が発生するまでの間に数回分のUPパルス信号が発生する。
[Times t0 to t1 in FIG. 2]
Thereafter, when a two-phase pulse signal is generated according to a change in the position of the movable body, the UP count value increases (0 → 1 → 2 → 3). The DOWN count value remains the initial value “0”. Although the cycle in which the two-phase pulse signal is generated depends on the rotational speed of the movable body, the resolution of the pulse encoder is about several tens of μs in the shortest cycle. Therefore, since the generation period of the two-phase pulse signal is shorter than the timer interrupt period of the CPU 22, several UP pulse signals are generated until the next timer interrupt occurs.

〔図2中時刻t1〕
そして次のタイマ割り込みが発生して演算処理が実行されると、今回のUPカウント値「3」、今回のDOWNカウント「0」がそれぞれロードされる。これらカウント値を用いて上記の演算処理を実行すると、今回の位置変化量として「+3」が算出される(ステップS14)。これにより、今回のソフトカウント値は「3」に更新される(ステップS16)。なお、位置変化量の「+3」は、今回の変化量が「正方向に3」であることを意味する。以下の説明で「正方向」は正転方向を意味し、「負方向」は逆転方向を意味するものとなる。
[Time t1 in FIG. 2]
When the next timer interrupt occurs and the arithmetic processing is executed, the current UP count value “3” and the current DOWN count “0” are loaded, respectively. When the above calculation processing is executed using these count values, “+3” is calculated as the current position change amount (step S14). Thus, the current soft count value is updated to “3” (step S16). The positional change amount “+3” means that the current change amount is “3 in the positive direction”. In the following description, “positive direction” means the forward direction, and “negative direction” means the reverse direction.

〔図2中時刻t3〕
正転中に行われる最後の演算処理のタイミングにおいて、今回のUPカウント値は「9」であり、また今回のDOWNカウント値は「0」である(図2中(H),(J))。そして前回の演算処理におけるUPカウント値は「6」であり、また前回のDOWNカウント値が「0」であるから、今回の位置変化量は「+3」として算出される。これを前回のソフトカウント値「6」に加算すると、更新された今回のソフトカウント値は「9」となる(図2中(J))。
[Time t3 in FIG. 2]
At the timing of the last calculation process performed during normal rotation, the current UP count value is “9”, and the current DOWN count value is “0” ((H) and (J) in FIG. 2). . Since the UP count value in the previous calculation process is “6” and the previous DOWN count value is “0”, the current position change amount is calculated as “+3”. When this is added to the previous soft count value “6”, the updated soft count value becomes “9” ((J) in FIG. 2).

〔図2中時刻t3〜t4〕
次に、可動体が正転から逆転に切り替わった場合を想定する。正転中の最後の演算処理を実行後、UPパルス信号が発生しなくなる代わりにDOWNパルス信号が発生する(図2中(F),(G))。その結果、UPカウント値は最後にインクリメントされた値である「10」のまま変化しなくなり、今度はDOWNカウント値が初期値「0」から1ずつインクリメントされていく(図2中(H),(I))。またこの間に、A相パルス信号とB相パルス信号との位相順序の入れ替わりが発生しており、その最短時間(図2中参照符号τ)は割込周期よりも短い。
[Times t3 to t4 in FIG. 2]
Next, it is assumed that the movable body is switched from normal rotation to reverse rotation. After the last calculation process during forward rotation, the DOWN pulse signal is generated instead of the UP pulse signal not being generated ((F), (G) in FIG. 2). As a result, the UP count value does not change with “10” which is the last incremented value, and this time, the DOWN count value is incremented by 1 from the initial value “0” ((H) in FIG. 2). (I)). During this time, the phase sequence of the A-phase pulse signal and the B-phase pulse signal is switched, and the shortest time (reference symbol τ in FIG. 2) is shorter than the interrupt cycle.

〔図2中時刻t4〕
逆転開始後に行われる最初の演算処理のタイミングにおいて、今回のUPカウント値は「10」であるが、今回のDOWNカウント値は「1」に増加している(図2中(H),(J))。このとき、前回(正転中の最後)の演算処理におけるUPカウント値は「9」であり、そして前回のDOWNカウント値は「0」であるから、今回の位置変化量は「±0(=+1−1)」として算出される。これを前回のソフトカウント値「9」に加算すると、今回のソフトカウント値は変わらず「9」として更新される(図2中(J))。なお、位置変化量の「±0」は、今回の変化量が「正方向にも負方向にも0(変化なし)」であることを意味している。
[Time t4 in FIG. 2]
At the timing of the first arithmetic processing performed after the start of reverse rotation, the current UP count value is “10”, but the current DOWN count value is increased to “1” ((H), (J )). At this time, since the UP count value in the previous (the last during forward rotation) calculation operation is “9” and the previous DOWN count value is “0”, the current position change amount is “± 0 (= + 1-1) ". When this is added to the previous soft count value “9”, the current soft count value remains unchanged and is updated as “9” ((J) in FIG. 2). The position change amount “± 0” means that the current change amount is “0 (no change) in both the positive and negative directions”.

〔図2中時刻t5〕
これ以降は同様にして、逆転中の次の演算処理タイミングにおいて今回のUPカウント値は「10」のままであり、また今回のDOWNカウント値は「4」である(図2中(H),(J))。そして前回の演算処理におけるUPカウント値は「10」であり、また前回のDOWNカウント値が「1」であるから、今回の位置変化量は「−3」として算出される。これを前回のソフトカウント値「9」に加算すると、更新された今回のソフトカウント値は「6」となる(図2中(J))。このとき位置変化量の「−3」は、今回の変化量が「負方向に3」であることを意味している。
[Time t5 in FIG. 2]
Thereafter, similarly, the current UP count value remains “10” and the current DOWN count value is “4” at the next arithmetic processing timing during the reverse rotation ((H) in FIG. 2). (J)). Since the UP count value in the previous calculation process is “10” and the previous DOWN count value is “1”, the current position change amount is calculated as “−3”. When this is added to the previous soft count value “9”, the updated soft count value becomes “6” ((J) in FIG. 2). At this time, the position change amount “−3” means that the current change amount is “3 in the negative direction”.

〔図2中時刻t6〕
また同様に、その次の演算処理タイミングにおいても今回のUPカウント値は「10」であるが、逆転が進むにつれて今回のDOWNカウント値は「7」に増加している(図2中(H),(J))。そして前回の演算処理におけるUPカウント値は「10」であり、また前回のDOWNカウント値が「4」であるから、今回の位置変化量は「−3」として算出される。これを前回のソフトカウント値「6」に加算すると、更新された今回のソフトカウント値は「3」となる(図2中(J))。
[Time t6 in FIG. 2]
Similarly, at the next arithmetic processing timing, the current UP count value is “10”, but the current DOWN count value increases to “7” as the reverse rotation proceeds ((H) in FIG. 2). , (J)). Since the UP count value in the previous calculation process is “10” and the previous DOWN count value is “4”, the current position change amount is calculated as “−3”. When this is added to the previous soft count value “6”, the updated soft count value becomes “3” ((J) in FIG. 2).

これにより、CPU22のソフトウェア処理部22cは、このように1ms周期で更新したソフトカウント値を可動体の現在位置を表す情報として利用することができる。このような現在位置を表す情報は、例えばメインプログラム上で回転軸の回転速度や角加速度を求めたり、ユーザによる操作部材の操作量(操作角度)を検出したりする用途に当てることができる。   As a result, the software processing unit 22c of the CPU 22 can use the soft count value updated in a cycle of 1 ms as information indicating the current position of the movable body. Such information representing the current position can be applied to, for example, the purpose of obtaining the rotational speed and angular acceleration of the rotating shaft on the main program, or detecting the operation amount (operation angle) of the operation member by the user.

〔他の演算手法〕
その他の演算手法として、以下の例を用いてもよい。
ソフトウェア処理部22cは、演算処理のタイミングにおいて今回のUPカウント値と今回のDOWNカウント値とをそれぞれロードし、これらの差分を位置変化量として算出してもよい。ただしこの場合、算出された位置変化量は初期値からの変化量として扱うことができる。
[Other calculation methods]
The following examples may be used as other calculation methods.
The software processing unit 22c may load the current UP count value and the current DOWN count value at the timing of the arithmetic processing, and calculate the difference between them as a position change amount. However, in this case, the calculated position change amount can be handled as a change amount from the initial value.

具体的には、初期の演算処理タイミング(図2中時刻t0)において、UPカウント値が「0」であり、またDOWNカウント値も「0」であるから、これらの差分「0」が初期値からの変化量となる。したがって、今回のソフトカウント値は「0」として算出することができる。   Specifically, at the initial calculation processing timing (time t0 in FIG. 2), the UP count value is “0” and the DOWN count value is also “0”, so that the difference “0” is the initial value. The amount of change from Therefore, the current soft count value can be calculated as “0”.

同様に、次の演算処理タイミング(図2中時刻t1)では、UPカウント値が「3」に増えているが、DOWNカウント値は「0」のままであるから、これらの差分「3」が初期値からの変化量となる。したがって、今回のソフトカウント値は「3」として算出することができる。   Similarly, at the next arithmetic processing timing (time t1 in FIG. 2), the UP count value increases to “3”, but the DOWN count value remains “0”, so that the difference “3” is The amount of change from the initial value. Therefore, the current soft count value can be calculated as “3”.

また正転中の最後の演算処理タイミング(図2中時刻t3)では、UPカウント値が「9」であるが、DOWNカウント値は「0」のままであるから、これらの差分「9」が初期値からの変化量となる。したがって、今回のソフトカウント値は「9」として算出することができる。   In addition, at the last calculation processing timing during forward rotation (time t3 in FIG. 2), the UP count value is “9”, but the DOWN count value remains “0”. The amount of change from the initial value. Therefore, the current soft count value can be calculated as “9”.

次に、可動体が正転から逆転に変化した後の最初の演算処理タイミング(図2中時刻t4)では、UPカウント値が「10」であり、DOWNカウント値は「1」に増えているから、これらの差分「9」が初期値からの変化量となる。したがって、今回のソフトカウント値は「9」として算出することができる。これにより、上記の演算手法と同様に正確なソフトカウント値を算出することができる。   Next, at the first calculation processing timing (time t4 in FIG. 2) after the movable body changes from normal rotation to reverse rotation, the UP count value is “10” and the DOWN count value is increased to “1”. Therefore, the difference “9” is the amount of change from the initial value. Therefore, the current soft count value can be calculated as “9”. Accordingly, an accurate soft count value can be calculated in the same manner as the above calculation method.

以上が本実施形態のアップダウンカウンタ装置10による演算例であるが、以下に比較例となるアップダウンカウンタ装置を挙げ、その演算手法との対比をもって本実施形態の優位性を検証するものとする。   The above is an example of calculation by the up / down counter device 10 of the present embodiment. The up / down counter device as a comparative example is given below, and the superiority of the present embodiment is verified by comparison with the calculation method. .

〔比較例〕
図4は、比較例となるアップダウンカウンタ装置100の構成を概略的に示した図である。比較例のアップダウンカウンタ装置100は、一実施形態で挙げたUP/DOWNデコーダ12及びCPU22だけを用いたシンプルな構成である。これらハードウェアは、いずれも一実施形態と同様であるため、ここでは重複した説明を省略する。このような構成であっても、例えば以下のようにアップダウンカウンタとしての基本的な機能を実現することができる。
[Comparative Example]
FIG. 4 is a diagram schematically showing a configuration of an up / down counter device 100 as a comparative example. The up / down counter apparatus 100 of the comparative example has a simple configuration using only the UP / DOWN decoder 12 and the CPU 22 described in the embodiment. Since all of these hardware is the same as that of the embodiment, the redundant description is omitted here. Even with such a configuration, for example, a basic function as an up / down counter can be realized as follows.

先ずUP/DOWNデコーダ12には、図示しないパルスエンコーダから2相パルス信号(図中(A),(B))がそれぞれ入力される。そしてUP/DOWNデコーダ12は、これら2相パルス信号に基づいて可動体の回転方向を判別し、その判別結果信号としてUP/DOWNステート信号(図中(C))を出力する。またUP/DOWNデコーダ12は、A相パルス信号及びB相パルス信号の各変化点に同期してデコーダパルス信号(図中(D))を発生させる。   First, a two-phase pulse signal ((A) and (B) in the figure) is input to the UP / DOWN decoder 12 from a pulse encoder (not shown). The UP / DOWN decoder 12 discriminates the rotation direction of the movable body based on these two-phase pulse signals, and outputs an UP / DOWN state signal ((C) in the figure) as the discrimination result signal. The UP / DOWN decoder 12 generates a decoder pulse signal ((D) in the figure) in synchronization with each change point of the A-phase pulse signal and the B-phase pulse signal.

比較例のハード構成では、UP/DOWNデコーダ12から出力されるUP/DOWNステート信号はCPU22のソフトウェア処理部22cに入力されている。またデコーダパルス信号は、特に論理ゲートを通ることなく、そのまま内蔵ハードカウンタ22aに入力される。   In the hardware configuration of the comparative example, the UP / DOWN state signal output from the UP / DOWN decoder 12 is input to the software processing unit 22 c of the CPU 22. The decoder pulse signal is directly input to the built-in hard counter 22a without passing through the logic gate.

〔動作例〕
図5は、比較例のアップダウンカウンタ装置100による各種信号の出力波形の変化例とCPU22内部でのカウント値の変化例を示したタイミングチャートである。
[Operation example]
FIG. 5 is a timing chart showing a change example of output waveforms of various signals by the up / down counter apparatus 100 of the comparative example and a change example of the count value inside the CPU 22.

〔正転時の変化例〕
比較例において、回転変位する可動体の位置変化の方向が初期において正方向(正転)であった場合、各信号波形は以下の変化となる。
[Example of change during normal rotation]
In the comparative example, when the direction of the position change of the movable body that is rotationally displaced is initially a positive direction (forward rotation), each signal waveform has the following changes.

〔2相パルス信号〕
図5中(A),(B):可動体の位置変化に応じて先にA相パルス信号が出力され、これに対して90°の位相差をもってB相パルス信号が出力される点は上述した一実施形態と同様である。
[2-phase pulse signal]
In FIG. 5, (A) and (B): the A-phase pulse signal is output first according to the change in the position of the movable body, and the B-phase pulse signal is output with a phase difference of 90 ° relative to this. This is the same as the embodiment.

〔UP/DOWNステート信号〕
図5中(C):ここでも同様に、可動体の正転中(正方向への移動中)、UP/DOWNステート信号はハイレベルとなっている。
[UP / DOWN state signal]
In FIG. 5, (C): Similarly, the UP / DOWN state signal is at a high level while the movable body is rotating forward (moving in the forward direction).

〔デコーダパルス信号〕
図5中(D):デコーダパル信号の波形も一実施形態と同様である。すなわち可動体の正転中、デコーダパルス信号はA相パルス信号の立ち上がりに同期して立ち上がり、次にB相パルス信号の立ち上がりが生じると、これに同期してローレベルに変化する。そして、この後にA相パルス信号が立ち下がりを生じると、これに同期してデコーダパルス信号は再びハイレベルに変化し、次にB相パルス信号が立ち下がると、これに同期してデコーダパルス信号はローレベルに変化する。
[Decoder pulse signal]
(D) in FIG. 5: The waveform of the decoder pal signal is the same as that of the embodiment. That is, during the forward rotation of the movable body, the decoder pulse signal rises in synchronization with the rise of the A-phase pulse signal, and then changes to the low level in synchronization with the rise of the B-phase pulse signal. When the A-phase pulse signal subsequently falls, the decoder pulse signal changes to high level again in synchronization with this, and when the B-phase pulse signal falls next, the decoder pulse signal is synchronized with this. Changes to a low level.

〔ハードカウント値〕
図5中(E):比較例では、デコーダパルス信号の各変化点(立ち上がりエッジ及び立ち下がりエッジ)に同期してハードカウント値がカウントされていく。すなわち内蔵ハードカウンタ22aは、例えば初期カウント値を「0」とすると、デコーダパルス信号のレベルが変化(ローレベル→ハイレベル/ハイレベル→ローレベル)するごとにハードカウント値をインクリメント(+1)する。
[Hard count value]
In FIG. 5, (E): In the comparative example, the hard count value is counted in synchronization with each change point (rising edge and falling edge) of the decoder pulse signal. That is, when the initial count value is set to “0”, for example, the built-in hard counter 22a increments (+1) the hard count value every time the level of the decoder pulse signal changes (low level → high level / high level → low level). .

〔反転時の変化例〕
比較例において、回転変位する可動体の位置変化の方向が正方向(正転)から負方向(逆転)に切り替わった場合、各信号波形は以下の変化となる。
[Example of change during inversion]
In the comparative example, when the direction of the position change of the rotationally displaced movable body is switched from the positive direction (forward rotation) to the negative direction (reverse rotation), each signal waveform has the following changes.

〔2相パルス信号〕
図5中(A),(B):比較例においても一実施形態と同様に、可動体が逆転すると、その位置変化に応じて今度はB相パルス信号が先に出力され、これに対して90°の位相差をもってA相パルス信号が出力されるため、正転時とは位相順序が入れ替わった状態となる。
[2-phase pulse signal]
5A and 5B: In the comparative example, as in the embodiment, when the movable body is reversed, the B-phase pulse signal is output first in response to the change in position. Since the A-phase pulse signal is output with a phase difference of 90 °, the phase order is changed from that during forward rotation.

〔UP/DOWNステート信号〕
図5中(C):ここでも同様に、可動体の位置変化が逆転に切り替わり(正方向→負方向)、A相パルス信号が立ち下がる前にB相パルス信号が立ち上がることで、UP/DOWNステート信号はハイレベルからローレベルに切り替わる。
[UP / DOWN state signal]
In FIG. 5, (C): Similarly, the position change of the movable body is switched to reverse (positive direction → negative direction), and the B-phase pulse signal rises before the A-phase pulse signal falls, so UP / DOWN The state signal is switched from the high level to the low level.

〔デコーダパルス信号〕
図5中(D):また、デコーダパルス信号についても一実施形態と同様の波形を示す(説明は省略)。
[Decoder pulse signal]
(D) in FIG. 5: The decoder pulse signal also has the same waveform as that of the embodiment (description is omitted).

〔ハードカウント値〕
図2中(E):比較例では、可動体が正転から逆転に切り替わったとしても、引き続きデコーダパルス信号の各変化点に同期してハードカウント値が単純にインクリメント(+1)されていく。
[Hard count value]
In FIG. 2, (E): In the comparative example, even if the movable body is switched from normal rotation to reverse rotation, the hard count value is simply incremented (+1) in synchronization with each change point of the decoder pulse signal.

〔正転中のソフトカウント値〕
比較例において、ソフトウェア処理部22cの演算周期(タイマ割込周期)内にハードカウント値が変化していたとしても、その可動体の位置変化の方向が一定であれば、今回のハードカウント値と前回のハードカウント値との差を位置変化量とし、これを前回のソフトカウント値に加算することで、今回のソフトカウント値を正しく更新することができる。
[Soft count value during normal rotation]
In the comparative example, even if the hard count value has changed within the calculation cycle (timer interrupt cycle) of the software processing unit 22c, if the direction of the position change of the movable body is constant, The current soft count value can be correctly updated by using the difference from the previous hard count value as the position change amount and adding this to the previous soft count value.

〔実際のソフトカウント値〕
図5中(G):すなわちソフトウェア処理部22cは、演算処理のタイミングにおいてUP/DOWNステート信号がハイレベルであることを確認すると、今回のハードカウント値と前回のハードカウント値との差を演算し、その結果を前回のソフトカウント値に加算する。これにより、実際のソフトカウント値は以下の演算例で示されるものとなる。
[Actual soft count value]
In FIG. 5, (G): That is, when the software processing unit 22c confirms that the UP / DOWN state signal is at the high level at the timing of the arithmetic processing, the software processing unit 22c calculates the difference between the current hard count value and the previous hard count value. The result is added to the previous soft count value. Thereby, the actual soft count value is shown in the following calculation example.

〔図5中時刻t0〕
正転開始直後(A相パルス信号の発生前)のタイミングで割り込みが発生したとすると、未だハードカウント値は「0」のままであるため、今回のソフトカウント値は「0」となる(図5中(G)の初期値参照)。
[Time t0 in FIG. 5]
If an interrupt occurs immediately after the start of forward rotation (before the generation of the A-phase pulse signal), the hard count value is still “0”, so that the current soft count value is “0” (FIG. 5 (Refer to the initial value in (G)).

〔図5中時刻t0〜t1〕
この後、可動体の位置変化に応じて2相パルス信号が生成されると、デコーダパルス信号の変化点(ローレベル→ハイレベル→ローレベル→ハイレベル)ごとにハードカウント値が増加(0→1→2→3)していく。
[Times t0 to t1 in FIG. 5]
Thereafter, when a two-phase pulse signal is generated in accordance with the change in position of the movable body, the hard count value increases (0 →) at each change point (low level → high level → low level → high level) of the decoder pulse signal. 1 → 2 → 3)

〔図5中時刻t1〕
そして次のタイマ割り込みが発生して演算処理が実行されると、今回のハードカウント値として「3」がソフトウェア処理部22cにロードされる。一方、ソフトウェア処理部22cには前回のハードカウント値として「0」が保存されているので、これらの差「3(=3−0)」を前回のソフトカウント値「0」に加算すると、今回のソフトカウント値は「3」となる。
[Time t1 in FIG. 5]
When the next timer interrupt occurs and the arithmetic processing is executed, “3” is loaded as the current hard count value into the software processing unit 22c. On the other hand, since “0” is stored as the previous hard count value in the software processing unit 22c, if the difference “3 (= 3-0)” is added to the previous soft count value “0”, this time The soft count value of “3” is “3”.

〔図5中時刻t3〕
正転中に行われる最後の演算処理のタイミングにおいて、今回のハードカウント値は「9」である(図5中(E))。そして前回の演算処理(図5中時刻t2)におけるハードカウント値は「6」であるから、これらの差「3(=9−6)」を前回のソフトカウント値「6」に加算すると、実際に求められる今回のソフトカウント値は「9」となる(図5中(G))。
[Time t3 in FIG. 5]
At the timing of the last calculation process performed during normal rotation, the current hard count value is “9” ((E) in FIG. 5). Since the hard count value in the previous calculation process (time t2 in FIG. 5) is “6”, adding these differences “3 (= 9−6)” to the previous soft count value “6” actually This time, the soft count value obtained in this step is “9” ((G) in FIG. 5).

〔図2中時刻t3〜t4〕
次に、可動体が正転から逆転に切り替わった場合を想定する。正転中の最後の演算処理を実行後、デコーダパルス信号の変化が2回発生している(図5中(D))。その結果、ハードカウント値は2回インクリメントされて「11」となっている(図5中(E))。
[Times t3 to t4 in FIG. 2]
Next, it is assumed that the movable body is switched from normal rotation to reverse rotation. After execution of the last arithmetic processing during normal rotation, the decoder pulse signal changes twice ((D) in FIG. 5). As a result, the hard count value is incremented twice to “11” ((E) in FIG. 5).

〔図5中時刻t4〕
したがって、逆転開始後に行われる最初の演算処理のタイミングにおいて、今回のUPカウント値は「11」である(図5中(E))。このとき、前回(正転中の最後)の演算処理におけるハードカウント値は「9」であり、これらの差として「2(=11−9)」が求められる。ただし、今回は可動体の逆転によってUP/DOWNステート信号がローレベルに切り替わっているので、ハードカウント値の差「2」を前回のソフトカウント値「9」から減算した結果が実際に得られる今回のソフトカウント値「7(=9−2)」となってしまう(図5中(G))。
[Time t4 in FIG. 5]
Therefore, the current UP count value is “11” at the timing of the first arithmetic processing performed after the start of reverse rotation ((E) in FIG. 5). At this time, the hard count value in the previous computation process (the last during forward rotation) is “9”, and “2 (= 11−9)” is obtained as the difference between them. However, since the UP / DOWN state signal is switched to low level due to the reverse rotation of the movable body this time, the result of actually subtracting the hard count value difference “2” from the previous soft count value “9” is actually obtained. The soft count value becomes “7 (= 9−2)” ((G) in FIG. 5).

〔図5中時刻t5〕
これ以降も同様にして、逆転中の次の演算処理タイミングにおいて今回のハードカウント値が「14」であり(図5中(E))、前回の演算処理におけるハードカウント値は「11」であるから、これらの差「3」を前回のソフトカウント値「7」から減算すると、実際に得られる今回のソフトカウント値は「4」になってしまう(図5中(G))。
[Time t5 in FIG. 5]
Similarly, the hard count value this time is “14” at the next arithmetic processing timing during the reverse rotation ((E) in FIG. 5), and the hard count value in the previous arithmetic processing is “11”. Therefore, when the difference “3” is subtracted from the previous soft count value “7”, the actual soft count value actually obtained becomes “4” ((G) in FIG. 5).

〔図5中時刻t6〕
また同様に、その次の演算処理タイミングにおいて、逆転が進むにつれて今回のハードカウント値が「17」に増加している(図5中(E))。そして前回の演算処理におけるハードカウント値が「14」であったから、これらの差「3」を前回のソフトカウント値「4」から減算すると、実際に得られる今回のソフトカウント値は「1」になってしまう(図5中(G))。
[Time t6 in FIG. 5]
Similarly, at the next arithmetic processing timing, the current hard count value increases to “17” as the reverse rotation proceeds ((E) in FIG. 5). Since the hard count value in the previous calculation process was “14”, when the difference “3” is subtracted from the previous soft count value “4”, the actual soft count value actually obtained is “1”. (G in FIG. 5).

以上の結果を正しいソフトカウント値(図5中(F))と比較すると、そこには常にカウント誤差「2」が存在しており、これは演算処理において誤カウントが発生したことを意味している。このようなカウント誤差は、演算周期内にデコーダパルス信号の変化が多く発生するほど顕著となり、その後のCPU22によるプログラム処理に望ましくないインパクト(例えば、ユーザの操作に対する応答遅れ等)を与える結果となる。   When the above result is compared with the correct soft count value ((F) in FIG. 5), there is always a count error “2”, which means that an erroneous count has occurred in the arithmetic processing. Yes. Such a count error becomes more prominent as more changes in the decoder pulse signal occur within the calculation cycle, resulting in an undesirable impact (for example, a response delay to a user operation) on the subsequent program processing by the CPU 22. .

これに対し本実施形態では、位置変化の方向別にUPパルス信号とDOWNパルス信号とを独立に発生させているので、演算周期内に位置変化の方向が切り替わった場合であっても、その間のUPカウント値とDOWNカウント値の差分から正しい位置変化量を求めることができる。これにより、常に正確なソフトカウント値を得ることができるので、その後のCPU22によるプログラム処理の円滑な進行に大きく寄与する。   On the other hand, in the present embodiment, the UP pulse signal and the DOWN pulse signal are generated independently for each position change direction. Therefore, even if the position change direction is switched within the calculation cycle, the UP pulse signal between them is changed. The correct position change amount can be obtained from the difference between the count value and the DOWN count value. Thereby, since an accurate soft count value can always be obtained, it greatly contributes to the smooth progress of the program processing by the CPU 22 thereafter.

〔その他の実施形態〕
図6は、他の実施形態のアップダウンカウンタ装置200の構成を概略的に示す図である。上述した一実施形態では、可動体の位置変化が1次元で行われることを想定しているが、位置変化が多次元で行われる場合、図6に示されるアップダウンカウンタ装置200の構成により対応が可能である。
[Other Embodiments]
FIG. 6 is a diagram schematically showing a configuration of an up / down counter apparatus 200 according to another embodiment. In the above-described embodiment, it is assumed that the position change of the movable body is performed in one dimension. However, when the position change is performed in a multi-dimension, it is possible to cope with the configuration of the up / down counter apparatus 200 shown in FIG. Is possible.

すなわち、多次元に対応したアップダウンカウンタ装置200は、複数の波形生成部50を備えており、個々の波形生成部50は、上述した一実施形態と同様の回路構成(CPU22を除く)を有している。CPU22には、多数ある入力ポートに各波形生成部50からUPパルス信号及びDOWNパルス信号が入力されており、各波形生成部50に対応して内蔵ハードカウンタ22a,22bの組が割り当てられている。   That is, the multi-dimensional up / down counter apparatus 200 includes a plurality of waveform generation units 50, and each waveform generation unit 50 has the same circuit configuration (except for the CPU 22) as in the above-described embodiment. is doing. The CPU 22 receives UP pulse signals and DOWN pulse signals from each waveform generation unit 50 at a number of input ports, and a set of built-in hard counters 22 a and 22 b is assigned to each waveform generation unit 50. .

このようなアップダウンカウンタ装置200によれば、ソフトウェア処理部22cにおいて波形生成部50ごとにソフトカウント値を演算し、これらを用いて2次元座標上での可動体の位置を検出したり、あるいは3次元空間内での可動体の位置を検出したりすることができる。   According to such an up / down counter device 200, the software processing unit 22c calculates the soft count value for each waveform generation unit 50, and uses these to detect the position of the movable body on the two-dimensional coordinates, or It is possible to detect the position of the movable body in the three-dimensional space.

本発明は上述した実施形態に制約されることはない。実施形態で挙げた各種のパルス波形は、実際の可動体(例えばユーザにより操作される部材)の変位速度によってパルス幅やその間隔は不規則となるため、その都度、カウント用の信号波形の周期も不規則に変化する。   The present invention is not limited to the embodiment described above. In the various pulse waveforms described in the embodiments, the pulse width and the interval thereof are irregular depending on the displacement speed of the actual movable body (for example, a member operated by the user). Changes irregularly.

また一実施形態では、1ms周期でソフトカウント値の演算処理を行っているが、演算処理を行うタイミングは適宜に変更可能である。ただし、一般に演算処理の周期(割込周期)を長くすると、その後のプログラム処理における繊細さが低下する傾向にあり、逆に周期を短くすると、ソフトカウント値の演算処理だけにリソースが割かれてしまい、その他のプログラム処理が滞る傾向にある。このため、実用的な周期を設定して演算処理を行うと、使用するパルスエンコーダの性能との関係から、ほとんどの場合は1周期以内に2相パルスエッジが複数回立ち上がる状況が生じることになる。したがって、一実施形態のように2相パルス信号からUP/DOWNステート信号を生成するだけでなく、方向別のUPパルス信号とDOWNパルス信号を発生させ、これらを独立にカウントしてソフトカウント値を求める演算手法であれば、外部クロックを用いることなく正確な演算が可能となるため、極めて実用性の高いアップダウンカウンタ装置が得られる。   In one embodiment, the calculation processing of the soft count value is performed at a cycle of 1 ms, but the timing of performing the calculation processing can be changed as appropriate. However, generally, if the calculation processing cycle (interrupt cycle) is lengthened, the sensitivity of the subsequent program processing tends to decrease. Conversely, if the cycle is shortened, resources are allocated only to the calculation processing of the soft count value. Therefore, other program processing tends to be delayed. For this reason, when a calculation period is set and a calculation process is performed, in most cases, a situation where a two-phase pulse edge rises a plurality of times within one period occurs due to the performance of the pulse encoder used. . Therefore, not only the UP / DOWN state signal is generated from the two-phase pulse signal as in the embodiment, but also the UP pulse signal and the DOWN pulse signal for each direction are generated, and these are counted independently to obtain the soft count value. If the desired calculation method is used, an accurate calculation can be performed without using an external clock, so that an up / down counter device with extremely high practicality can be obtained.

また本発明のアップダウンカウンタ装置は、回転軸やプリンタ印字ヘッド、回転式のつまみ、スイング式のレバー等の位置検出用だけでなく、ジョイスティックやトラックボール等の操作部材の位置を検出する用途にも好適であり、その産業上の利用価値は極めて高い。   The up / down counter device of the present invention is not only used for detecting the position of a rotary shaft, printer print head, rotary knob, swing type lever, etc., but also for detecting the position of an operation member such as a joystick or a trackball. And its industrial utility value is extremely high.

一実施形態のアップダウンカウンタ装置の構成を概略的に示す図である。It is a figure showing roughly the composition of the up-down counter device of one embodiment. 各種信号の出力波形の変化例とカウント値の変化例を示したタイミングチャートである。It is the timing chart which showed the example of change of the output waveform of various signals, and the example of change of count value. 演算処理の手順例を示すフローチャートである。It is a flowchart which shows the example of a procedure of a calculation process. 比較例となるアップダウンカウンタ装置の構成を概略的に示した図である。It is the figure which showed schematically the structure of the up-down counter apparatus used as a comparative example. 比較例のアップダウンカウンタ装置による各種信号の出力波形の変化例とカウント値の変化例を示したタイミングチャートである。It is the timing chart which showed the example of a change of the output waveform of various signals by the up-down counter apparatus of a comparative example, and the example of a change of count value. 他の実施形態のアップダウンカウンタ装置の構成を概略的に示す図である。It is a figure which shows schematically the structure of the up / down counter apparatus of other embodiment.

符号の説明Explanation of symbols

10 アップダウンカウンタ装置
12 UP/DOWNデコーダ
14 EXORゲート
16 遅延回路
18,20 ANDゲート
22 CPU
22a 内蔵ハードカウンタ
22b 内蔵ハードカウンタ
22c ソフトウェア処理部
10 Up / Down Counter Device 12 UP / DOWN Decoder 14 EXOR Gate 16 Delay Circuit 18, 20 AND Gate 22 CPU
22a Built-in hard counter 22b Built-in hard counter 22c Software processing unit

Claims (4)

少なくとも2方向に変位可能な可動体の位置変化に応じて生成される2相パルス信号に基づいて位置変化の方向を判別し、その結果を正負のいずれかで表した方向判別信号を出力する方向判別部と、
前記2相パルス信号の各変化点に同期して基準パルス信号を発生する基準パルス発生部と、
前記方向判別信号が正方向を表す場合、前記基準パルス信号に基づいて正方向パルス信号を発生する正方向パルス発生部と、
前記方向判別信号が正方向とは論理が反転した負方向を表す場合、前記基準パルス信号に基づいて負方向パルス信号を発生する負方向パルス発生部と、
前記正方向パルス信号の発生回数を正方向カウント値としてカウントする正方向カウンタと、
前記負方向パルス信号の発生回数を負方向カウント値としてカウントする負方向カウンタと、
前記正方向カウント値と前記負方向カウント値との差分を前記可動体の位置変化量として算出する演算処理部と
を備えたアップダウンカウンタ装置。
Direction to determine the direction of position change based on a two-phase pulse signal generated according to the change in position of the movable body that can be displaced in at least two directions, and to output a direction determination signal representing the result as either positive or negative A discriminator;
A reference pulse generator for generating a reference pulse signal in synchronization with each change point of the two-phase pulse signal;
When the direction determination signal represents a positive direction, a positive direction pulse generator that generates a positive direction pulse signal based on the reference pulse signal;
A negative direction pulse generator that generates a negative direction pulse signal based on the reference pulse signal, when the direction determination signal represents a negative direction in which logic is inverted as a positive direction;
A positive direction counter that counts the number of occurrences of the positive direction pulse signal as a positive direction count value;
A negative direction counter that counts the number of occurrences of the negative direction pulse signal as a negative direction count value;
An up / down counter device comprising: an arithmetic processing unit that calculates a difference between the positive direction count value and the negative direction count value as a position change amount of the movable body.
請求項1に記載のアップダウンカウンタ装置において、
前記演算処理部は、
所定の演算周期ごとに前記正方向カウンタ及び前記負方向カウンタから前記正方向カウント値及び前記負方向カウント値をそれぞれ取得し、今回の演算周期で取得した前記正方向カウント値と前回の演算周期で取得した前記正方向カウント値との差から、今回の演算周期で取得した前記負方向カウント値と前回の演算周期で取得した前記負方向カウント値との差を減算した結果を前記位置変化量として算出することを特徴とするアップダウンカウンタ装置。
The up / down counter device according to claim 1,
The arithmetic processing unit includes:
The positive direction count value and the negative direction count value are respectively acquired from the positive direction counter and the negative direction counter for each predetermined calculation cycle, and the positive direction count value acquired in the current calculation cycle and the previous calculation cycle are obtained. The position change amount is obtained by subtracting the difference between the negative direction count value acquired in the current calculation cycle and the negative direction count value acquired in the previous calculation cycle from the difference from the acquired positive direction count value. An up / down counter device characterized by calculating.
請求項1又は2に記載のアップダウンカウンタ装置において、
前記演算処理部は、
前記可動体の現在位置を表す現在位置カウント値に前記位置変化量を加算することで前記現在位置カウント値を更新する処理を行うことを特徴とするアップダウンカウンタ装置。
In the up-down counter apparatus according to claim 1 or 2,
The arithmetic processing unit includes:
An up / down counter device that performs a process of updating the current position count value by adding the position change amount to a current position count value representing a current position of the movable body.
請求項1から3のいずれかに記載のアップダウンカウンタ装置において、
不規則なタイミングで変位方向が切り替わり得る前記可動体の位置変化に応じて前記2相パルス信号を方向別の位相順序で出力するエンコーダと、
前記演算処理部としての機能を有したプロセッサとを備え、
前記プロセッサが前記可動体の位置変化量を算出する演算周期は、前記可動体の一方向への位置変化に応じて前記エンコーダにより前記2相パルス信号が最後に出力された後、前記可動体の変位方向が他方向へ切り替わることで位相順序が逆転した状態の前記2相パルス信号が前記エンコーダから最初に出力されるまでの最短時間に比較して長く設定されていることを特徴とするアップダウンカウンタ装置。
In the up-down counter apparatus in any one of Claim 1 to 3,
An encoder that outputs the two-phase pulse signals in a phase order according to directions according to a change in position of the movable body whose displacement direction can be switched at irregular timing;
A processor having a function as the arithmetic processing unit,
The calculation cycle in which the processor calculates the amount of change in the position of the movable body is such that after the two-phase pulse signal is last output by the encoder in accordance with the position change in one direction of the movable body, Up-down characterized by being set longer than the shortest time until the two-phase pulse signal in which the phase order is reversed by switching the displacement direction to another direction is first output from the encoder Counter device.
JP2008241164A 2008-09-19 2008-09-19 Up/down counter device Withdrawn JP2010074637A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2008241164A JP2010074637A (en) 2008-09-19 2008-09-19 Up/down counter device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2008241164A JP2010074637A (en) 2008-09-19 2008-09-19 Up/down counter device

Publications (1)

Publication Number Publication Date
JP2010074637A true JP2010074637A (en) 2010-04-02

Family

ID=42205980

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2008241164A Withdrawn JP2010074637A (en) 2008-09-19 2008-09-19 Up/down counter device

Country Status (1)

Country Link
JP (1) JP2010074637A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2533748A (en) * 2013-10-18 2016-06-29 Ibm Polymorphic encryption key matrices
CN112152608A (en) * 2020-08-21 2020-12-29 广东韶钢松山股份有限公司 PLC pulse signal counting method and device, computer equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2533748A (en) * 2013-10-18 2016-06-29 Ibm Polymorphic encryption key matrices
CN112152608A (en) * 2020-08-21 2020-12-29 广东韶钢松山股份有限公司 PLC pulse signal counting method and device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
JP2720642B2 (en) Multi-turn absolute value encoder
CN108535507B (en) Computer storage medium for incremental encoder speed measurement
JP2010043981A (en) Angle position detector and rotational speed detector of rotor
JP2010074637A (en) Up/down counter device
JPH06118090A (en) Speed detector
JP4198639B2 (en) Interrupt generation circuit
JP6300371B2 (en) Motor drive control device and motor drive control method
JP6825260B2 (en) Speed detector and speed control system
JP2006214972A (en) Signal processor for rotation detector
JP4352921B2 (en) Rotation position detector
US7535382B2 (en) High speed quadrature counter
JP2008128721A (en) Pulse signal processing circuit of encoder, and motor control device
JP4519183B2 (en) AB phase signal generator, RD converter and angle detection device
JP4289983B2 (en) Phase velocity detector
KR101670541B1 (en) Apparatus for simplification of input signal
JP6000652B2 (en) Pulse motor control device and pulse signal generation method
JP6101117B2 (en) Pulse motor control device
JP4551780B2 (en) Encoder signal processing circuit
US6310458B1 (en) Blended velocity estimation
JP3067729B2 (en) Encoder signal processing method and device
JP2010172056A (en) Speed pattern generating apparatus
JP3045644B2 (en) Carrier movement controller and pulse frequency converter
JP3248369B2 (en) Rotary body position detection circuit
JP4206780B2 (en) Rotation position detector
JP2010220420A (en) Motor control circuit

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20111206