JP6454619B2 - Pulse output device - Google Patents

Pulse output device Download PDF

Info

Publication number
JP6454619B2
JP6454619B2 JP2015155893A JP2015155893A JP6454619B2 JP 6454619 B2 JP6454619 B2 JP 6454619B2 JP 2015155893 A JP2015155893 A JP 2015155893A JP 2015155893 A JP2015155893 A JP 2015155893A JP 6454619 B2 JP6454619 B2 JP 6454619B2
Authority
JP
Japan
Prior art keywords
frequency
timer
output
pulse
clock
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.)
Active
Application number
JP2015155893A
Other languages
Japanese (ja)
Other versions
JP2017034622A (en
Inventor
喜彦 岡山
喜彦 岡山
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.)
Azbil Corp
Original Assignee
Azbil 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 Azbil Corp filed Critical Azbil Corp
Priority to JP2015155893A priority Critical patent/JP6454619B2/en
Publication of JP2017034622A publication Critical patent/JP2017034622A/en
Application granted granted Critical
Publication of JP6454619B2 publication Critical patent/JP6454619B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、タイマを利用してクロックを分周し広い周波数範囲のパルスを生成するパルス出力装置に関するものである。   The present invention relates to a pulse output device that generates a pulse in a wide frequency range by dividing a clock using a timer.

電磁流量計の流量出力には4−20mAの電流出力とパルス出力があり、いずれも流量の瞬時値を電流値やパルス周波数に変換して出力している(特許文献1参照)。電流出力の場合は多重レンジを使って小流量と大流量を切り替えてレンジ出力接点と組み合わせて外部に知らせることができる。一方、パルス出力の場合はパルスの数が単位時間当たりの流量になるので、レンジで分解能を上げることはできず、電流出力のようなレンジ切り替えは使えない。このため、0.00001Hz〜3000Hzといった低い周波数から高い周波数までパルスを連続的に作りださなけばならない。通常、パルス出力はコンピュータのタイマを使って分周する方法で実現している。   There are 4-20 mA current output and pulse output in the flow output of the electromagnetic flowmeter, and both output instantaneous values of flow rate converted into current values and pulse frequencies (see Patent Document 1). In the case of current output, a small flow rate and a large flow rate can be switched using a multiple range, and in combination with a range output contact, it can be notified to the outside. On the other hand, in the case of pulse output, since the number of pulses is a flow rate per unit time, the resolution cannot be increased by range, and range switching such as current output cannot be used. Therefore, pulses must be continuously generated from a low frequency such as 0.00001 Hz to 3000 Hz to a high frequency. Usually, the pulse output is realized by a frequency dividing method using a computer timer.

コンピュータのタイマを使って0.00001Hz〜3000Hzの広い周波数のパルスを生成しようとすると、複数のタイマを組み合わせる必要がある。この場合、各タイマは独立しているため、下段のタイマのタイムアウト出力を上段のタイマの入力としてカスケード構成になるが、このような構成では分周比をそのままタイマの設定値とすることはできない。その理由は、タイマ動作はカウント値が0(タイムアウト)になると、設定値をリロードしてカウントダウンをするという動作を繰り返すため、下段のタイマがタイムアウトしたとき上段のタイマもタイムアウトするとは限らないためである。   In order to generate a pulse having a wide frequency of 0.00001 Hz to 3000 Hz using a timer of a computer, it is necessary to combine a plurality of timers. In this case, since each timer is independent, the time-out output of the lower timer is used as the input of the upper timer to form a cascade configuration. However, in such a configuration, the division ratio cannot be set as the timer set value as it is. . The reason for this is that when the count value reaches 0 (timeout), the timer operation repeats the operation of reloading the set value and counting down, so when the lower timer times out, the upper timer does not always time out. is there.

タイマを3つ縦続接続した場合の分周比は、上段のタイマ設定値×中段のタイマ設定値×下段のタイマ設定値となるため、分周比(浮動小数点数)を3つの整数の積に因数分解してタイマ設定値を求める必要があるが、最適な3つの整数を見つけるのは難しい。
そこで、従来の実装では、例えば16ビットタイマを3つ使ってタイマ設定値2つをスパン周波数(出力したい最大周波数)と出力パーセント値から決め打ちして、最後の1つを割り算で求めて3つ目のタイマ設定値としていた。
When three timers are connected in cascade, the division ratio is the upper timer setting value x the middle timer setting value x the lower timer setting value, so the division ratio (floating point number) is a product of three integers. Although it is necessary to calculate the timer setting value by factoring, it is difficult to find the optimum three integers.
Therefore, in the conventional implementation, for example, three 16-bit timers are used, two timer setting values are determined from the span frequency (maximum frequency to be output) and the output percentage value, and the last one is obtained by division. It was the first timer setting value.

従来のパルス出力装置の構成を図5に示す。パルス出力装置は、複数の周波数のうちいずれか1つの周波数のクロックを選択的に出力することが可能なプリスケーラ(分周器)P0と、タイマT0〜T2とから構成される。   The configuration of a conventional pulse output device is shown in FIG. The pulse output device includes a prescaler (frequency divider) P0 that can selectively output a clock having any one of a plurality of frequencies, and timers T0 to T2.

プリスケーラP0は、周波数f1=7.3728MHzのクロックと、f1を8分周したf8=921.6KHzのクロックと、f1を32分周したf32=230.4KHzのクロックと、周波数fc32=900Hzのクロックの4つのうちいずれか1つの周波数のクロックを選択的に出力することができる。   The prescaler P0 includes a clock with a frequency f1 = 7.3728 MHz, a clock with f8 = 921.6 KHz obtained by dividing f1 by 8, a clock with f32 = 230.4 KHz obtained by dividing f1 by 32, and a clock with a frequency fc32 = 900 Hz. The clock having any one of the four frequencies can be selectively output.

3つのタイマT0〜T2のタイマ設定値を決定するには、まずタイマT1のタイマ設定値(分周比)をPV%値によって決める。PV%値は、電磁流量計で計測した瞬時流量値[m3/h]を設定スパン(最大瞬時流量[m3/h])で割って100倍した0〜100%の値である。ここでは、10%≦PV%≦115%の場合、タイマT1の設定値を1とし、1%≦PV%<10%〜15%の場合、タイマT1の設定値を10とし、0.08%≦PV%<1%〜2%の場合、タイマT1の設定値を100とし、0%≦PV%<0.08%の場合、タイマT1のパルス出力を停止とする。 In order to determine the timer setting values of the three timers T0 to T2, first, the timer setting value (frequency division ratio) of the timer T1 is determined by the PV% value. The PV% value is a value of 0 to 100% obtained by dividing the instantaneous flow rate value [m 3 / h] measured by the electromagnetic flow meter by the setting span (maximum instantaneous flow rate [m 3 / h]) and multiplying by 100. Here, when 10% ≦ PV% ≦ 115%, the set value of the timer T1 is 1, and when 1% ≦ PV% <10% to 15%, the set value of the timer T1 is 10, and 0.08% When ≦ PV% <1% to 2%, the set value of the timer T1 is set to 100, and when 0% ≦ PV% <0.08%, the pulse output of the timer T1 is stopped.

次に、タイマT2の設定値とプリスケーラP0から出力するクロックとを、スパン周波数から決定する。スパン周波数は、パルス重み口径から計算することができる。パルス重みとは、電磁流量計のパルス出力における1パルスあたりの流体の体積[m3]または質量[t]を表す。電磁流量計の口径[m]は、瞬時流量[m3/h]を計算するとき必要であり、電磁流量計の配管断面積[m2]は、π×口径[m]×口径[m]/4となる。この断面積を用いて、電磁流量計を流れる流体の瞬時流量[m3/h]は流速[m/s]×断面積[m2]×3600で計算できる。 Next, the set value of the timer T2 and the clock output from the prescaler P0 are determined from the span frequency. The span frequency can be calculated from the pulse weight aperture. The pulse weight represents the volume [m 3 ] or mass [t] of the fluid per pulse in the pulse output of the electromagnetic flow meter. The aperture [m] of the electromagnetic flow meter is necessary when calculating the instantaneous flow rate [m 3 / h], and the pipe cross-sectional area [m 2 ] of the electromagnetic flow meter is π × caliber [m] × caliber [m]. / 4. Using this cross-sectional area, the instantaneous flow rate [m 3 / h] of the fluid flowing through the electromagnetic flow meter can be calculated by the flow velocity [m / s] × cross-sectional area [m 2 ] × 3600.

パルス重み[m3]が指定されると、瞬時流量[m3/h]をパルス重み[m3]で割ることにより、1時間あたりのパルス数が得られるので、この1時間あたりのパルス数を3600倍すれば、電磁流量計で計測した瞬時流量[m3/h]に対応する瞬時パルス周波数[Hz](図5のパルス出力装置から出力するパルスの周波数)を求めることができる。スパン周波数[Hz]を求めるためには、予め設定されたスパン(最大瞬時流量[m3/h])をパルス重み[m3]で割って3600倍すればよい。 When the pulse weight [m 3 ] is specified, the number of pulses per hour can be obtained by dividing the instantaneous flow rate [m 3 / h] by the pulse weight [m 3 ]. Is multiplied by 3600, the instantaneous pulse frequency [Hz] (frequency of the pulse output from the pulse output device in FIG. 5) corresponding to the instantaneous flow rate [m 3 / h] measured by the electromagnetic flow meter can be obtained. In order to obtain the span frequency [Hz], a preset span (maximum instantaneous flow rate [m 3 / h]) is divided by the pulse weight [m 3 ] and multiplied by 3600.

以上のようにして求めたスパン周波数からクロックを決定する。0.029<スパン周波数≦3200の場合、プリスケーラP0から出力するクロックをf1=7.3728MHzのクロックとし、0.00288<スパン周波数≦0.029の場合、プリスケーラP0から出力するクロックをf8=921.6KHzのクロックとし、0.00072<スパン周波数≦0.00288の場合、プリスケーラP0から出力するクロックをf32=230.4KHzのクロックとし、スパン周波数≦0.00072の場合、プリスケーラP0から出力するクロックをfc32=900Hzのクロックとする。いずれの場合も、タイマT2の設定値は、クロック周波数÷(スパン周波数×4000)で計算できる。   The clock is determined from the span frequency obtained as described above. When 0.029 <span frequency ≦ 3200, the clock output from the prescaler P0 is f1 = 7.3728 MHz, and when 0.00288 <span frequency ≦ 0.029, the clock output from the prescaler P0 is f8 = 921. .6 KHz clock, if 0.00072 <span frequency ≦ 0.00288, the clock output from the prescaler P0 is f32 = 230.4 KHz, and if the span frequency ≦ 0.00072, the clock output from the prescaler P0. Is a clock of fc32 = 900 Hz. In any case, the set value of the timer T2 can be calculated by clock frequency / (span frequency × 4000).

最後に、瞬時パルス周波数[Hz]=クロック周波数/(タイマT0の設定値×タイマT1の設定値×タイマT2の設定値)という関係が成立するように、タイマT0の設定値を決定する。   Finally, the setting value of the timer T0 is determined so that the relationship of instantaneous pulse frequency [Hz] = clock frequency / (setting value of the timer T0 × setting value of the timer T1 × setting value of the timer T2) is established.

特開平5−273008号公報JP-A-5-273008

以上のように従来のパルス出力装置では、タイマT0の設定値を求める割り算の結果を整数値に丸めるときの小数点以下の値が大きいと、出力パルスの周波数誤差が大きくなるという問題点があった。また、条件判断で不連続なタイマ設定値をタイマT0〜T2に設定するため、連続性に問題があり、出力パルスの周波数を滑らかに変化させることが難しいという問題点があった。また、出力パルスの周波数を変化させる場合、タイマがタイムアウトするまで新しい周波数に移れないため、応答性が悪いという問題点があった。   As described above, the conventional pulse output device has a problem that the frequency error of the output pulse increases if the value after the decimal point when rounding the result of division for obtaining the set value of the timer T0 to an integer value is large. . Further, since the discontinuous timer set values are set in the timers T0 to T2 in the condition determination, there is a problem in continuity, and it is difficult to smoothly change the frequency of the output pulse. Further, when changing the frequency of the output pulse, there is a problem that the response is poor because the frequency cannot be shifted to a new frequency until the timer times out.

本発明は、上記課題を解決するためになされたもので、周波数誤差が小さく、滑らかな周波数変化が可能で、応答性に優れたパルス出力が可能なパルス出力装置を提供することを目的とする。   The present invention has been made to solve the above-described problems, and an object of the present invention is to provide a pulse output device that has a small frequency error, can smoothly change the frequency, and can output a pulse with excellent response. .

本発明のパルス出力装置は、複数の周波数のうちいずれか1つの周波数のクロックを選択的に出力することが可能なプリスケーラと、このプリスケーラの出力を入力クロックとするnビット(nは2のべき乗の値で、16以上の値)の第1のタイマと、この第1のタイマの出力を入力クロックとするnビットの第2のタイマと、この第2のタイマから出力させる所望の出力パルスの周波数に応じて前記プリスケーラから出力させるクロックの周波数を決定するクロック周波数決定手段と、前記第1、第2のタイマの設定値を決定するタイマ設定値決定手段とを備え、前記タイマ設定値決定手段は、前記プリスケーラから出力させるクロックの周波数と前記所望の出力パルスの周波数とからn×2ビットの分周比を決定し、このn×2ビットの分周比の上位nビットの値に1を加えた値を、前記第2のタイマの設定値とし、前記n×2ビットの分周比を前記第2のタイマの設定値で割った商を、前記第1のタイマの設定値とすることを特徴とするものである。
また、本発明のパルス出力装置の1構成例において、前記クロック周波数決定手段は、前記所望の出力パルスの周波数の低下に伴って、前記プリスケーラから出力させるクロックの周波数と前記所望の出力パルスの周波数とで決まるn×2ビットの分周比が前記第1、第2のタイマの設定値の最大値の2乗の数値範囲に収まらなくなったときに、前記プリスケーラから出力させるクロックの周波数を下げる方向に切り替えることを特徴とするものである。
The pulse output device of the present invention includes a prescaler capable of selectively outputting a clock having any one of a plurality of frequencies, and n bits (n is a power of 2) using the output of the prescaler as an input clock. A first timer having a value of 16 or more), an n-bit second timer using the output of the first timer as an input clock, and a desired output pulse to be output from the second timer. A clock frequency determining unit that determines a frequency of a clock to be output from the prescaler according to a frequency; and a timer setting value determining unit that determines a setting value of the first and second timers. Determines a division ratio of n × 2 bits from the frequency of the clock output from the prescaler and the frequency of the desired output pulse, and divides this n × 2 bits. The value obtained by adding 1 to the value of the upper n bits of the frequency ratio is set as the second timer setting value, and the quotient obtained by dividing the frequency dividing ratio of n × 2 bits by the setting value of the second timer is as follows: The set value of the first timer is used.
Further, in one configuration example of the pulse output device according to the present invention, the clock frequency determining means may reduce the frequency of the desired output pulse as the frequency of the clock output from the prescaler and the frequency of the desired output pulse. The frequency of the clock output from the prescaler is lowered when the n × 2 bit frequency division ratio determined by the values does not fall within the square of the maximum value of the first and second timer set values. It is characterized by switching to.

本発明によれば、2つのタイマの縦続接続でパルス出力装置を実現することができる。本発明では、プリスケーラの周波数とタイマ設定値の決定の際に複雑な判断が不要となり、出力パルスの周波数から一意にプリスケーラの周波数と2つのタイマの設定値を決めることができるので、従来よりもアルゴリズムが単純となり、クロック周波数決定手段とタイマ設定値決定手段の処理負荷を小さくすることができる。本発明では、出力パルスの周波数誤差を小さくすることができる。また、本発明では、タイマ設定値が連続的になり、出力パルスの滑らかな周波数変化が期待できる。また、本発明では、出力パルスの周波数を変化させるときの応答性を向上させることができる。   According to the present invention, a pulse output device can be realized by a cascade connection of two timers. In the present invention, complicated determination is not required when determining the prescaler frequency and the timer set value, and the prescaler frequency and the set values of the two timers can be uniquely determined from the output pulse frequency. The algorithm is simplified, and the processing load on the clock frequency determining means and the timer set value determining means can be reduced. In the present invention, the frequency error of the output pulse can be reduced. In the present invention, the timer set value becomes continuous, and a smooth frequency change of the output pulse can be expected. Further, in the present invention, it is possible to improve the responsiveness when changing the frequency of the output pulse.

本発明の実施の形態に係るパルス出力装置の構成を示すブロック図である。It is a block diagram which shows the structure of the pulse output device which concerns on embodiment of this invention. 本発明の実施の形態に係るパルス出力装置のタイマ設定値決定処理を説明するフローチャートである。It is a flowchart explaining the timer setting value determination process of the pulse output device which concerns on embodiment of this invention. 従来のパルス出力装置と本発明の実施の形態に係るパルス出力装置の出力パルスの周波数誤差を示す図である。It is a figure which shows the frequency error of the output pulse of the conventional pulse output device and the pulse output device which concerns on embodiment of this invention. 本発明の実施の形態に係るパルス出力装置のタイマ設定値の連続性を検証した結果を示す図である。It is a figure which shows the result of having verified the continuity of the timer setting value of the pulse output device which concerns on embodiment of this invention. 従来のパルス出力装置の構成を示すブロック図である。It is a block diagram which shows the structure of the conventional pulse output device.

以下、本発明の実施の形態について図面を参照して説明する。図1は本発明の実施の形態に係るパルス出力装置の構成を示すブロック図である。本実施の形態のパルス出力装置は、複数の周波数のうちいずれか1つの周波数のクロックを選択的に出力することが可能なプリスケーラ(分周器)P0と、プリスケーラP0の出力を入力クロックとして、ダウンカウントを行なう16ビットのカウンタであるタイマT1と、タイマT1の出力パルスを入力クロックとして、ダウンカウントを行なう16ビットのカウンタであるタイマT2と、タイマT2から出力させる所望の出力パルスの周波数に応じてプリスケーラP0から出力させるクロックの周波数を決定するクロック周波数決定部1と、タイマT1,T2の設定値を決定するタイマ設定値決定部2とから構成される。   Hereinafter, embodiments of the present invention will be described with reference to the drawings. FIG. 1 is a block diagram showing a configuration of a pulse output device according to an embodiment of the present invention. The pulse output device of the present embodiment has a prescaler (frequency divider) P0 capable of selectively outputting a clock having any one of a plurality of frequencies, and an output of the prescaler P0 as an input clock. A timer T1 that is a 16-bit counter that performs down-counting, a timer T2 that is a 16-bit counter that performs down-counting using the output pulse of the timer T1 as an input clock, and a desired output pulse frequency output from the timer T2 Accordingly, the clock frequency determination unit 1 determines the frequency of the clock output from the prescaler P0, and the timer set value determination unit 2 determines the set values of the timers T1 and T2.

プリスケーラP0とタイマT1,T2としては、コンピュータに内蔵されているものを用いる。このコンピュータのCPU(Central Processing Unit)は、コンピュータのメモリに格納されたプログラムに従って処理を実行し、クロック周波数決定部1およびタイマ設定値決定部2として機能する。   As the prescaler P0 and the timers T1 and T2, those built in the computer are used. A CPU (Central Processing Unit) of this computer executes processing according to a program stored in the memory of the computer, and functions as a clock frequency determination unit 1 and a timer set value determination unit 2.

以下、本実施の形態のパルス出力装置のタイマ設定値決定処理について図2を参照して説明する。まず、クロック周波数決定部1は、プリスケーラP0から出力させるクロックの周波数fclkを決定する(図2ステップS1)。具体的には、クロック周波数決定部1は、パルス出力装置から出力させたいパルスの周波数foが0.00006Hz未満の場合、fclk=fc32=900HzのクロックをプリスケーラP0から出力させ、周波数foが0.00006Hz〜0.00021Hzの場合、fclk=f32=230.4KHzのクロックをプリスケーラP0から出力させ、周波数foが0.00022Hz〜0.00171Hzの場合、fclk=f8=921.6KHzのクロックをプリスケーラP0から出力させ、周波数foが0.00172Hz以上の場合、fclk=f1=7.3728MHzのクロックをプリスケーラP0から出力させる。   Hereinafter, the timer set value determination process of the pulse output device of the present embodiment will be described with reference to FIG. First, the clock frequency determination unit 1 determines the frequency fclk of the clock output from the prescaler P0 (step S1 in FIG. 2). Specifically, when the frequency fo of the pulse to be output from the pulse output device is less than 0.00006 Hz, the clock frequency determination unit 1 outputs a clock of fclk = fc32 = 900 Hz from the prescaler P0, and the frequency fo is 0. When 00006 Hz to 0.00021 Hz, a clock of fclk = f32 = 230.4 KHz is output from the prescaler P0, and when the frequency fo is 0.00022 Hz to 0.00171 Hz, a clock of fclk = f8 = 921.6 KHz is output from the prescaler P0. When the frequency fo is 0.00172 Hz or higher, a clock of fclk = f1 = 7.3728 MHz is output from the prescaler P0.

このようにクロックの周波数fclkは、出力したいパルスの周波数foで一意に決まる。このクロック周波数fclkの決定方法は、所望の出力パルスの周波数foの低下に伴って、クロック周波数fclkとパルスの周波数foとで決まる32ビット(2つのタイマT1,T2の合計のビット数)の分周比がタイマT1,T2の設定値の最大値(16ビットのカウンタの場合で65535)の2乗の数値範囲に収まらなくなったときに、クロックの周波数fclkを下げる方向に切り替えるというものである。   Thus, the clock frequency fclk is uniquely determined by the pulse frequency fo to be output. This method of determining the clock frequency fclk is a 32-bit (the total number of bits of the two timers T1 and T2) determined by the clock frequency fclk and the pulse frequency fo as the desired output pulse frequency fo decreases. When the frequency ratio does not fall within the square value range of the maximum value of the set values of the timers T1 and T2 (65535 in the case of a 16-bit counter), the clock frequency fclk is switched to a lowering direction.

次に、タイマ設定値決定部2は、タイマT1,T2の設定値を決定する。まず、タイマ設定値決定部2は、プリスケーラP0から出力させるクロックの周波数fclkとパルス出力装置から出力させたいパルスの周波数foとから、32ビットの分周比DRを次式のように計算する(図2ステップS2)。
DR=fclk/fo ・・・(1)
Next, the timer set value determination unit 2 determines the set values of the timers T1 and T2. First, the timer set value determination unit 2 calculates a 32-bit frequency division ratio DR from the clock frequency fclk output from the prescaler P0 and the pulse frequency fo desired to be output from the pulse output device as follows: FIG. 2 step S2).
DR = fclk / fo (1)

続いて、タイマ設定値決定部2は、32ビットの分周比DRの上位16ビットの値に1を加えた値を、上段のタイマT2の設定値(分周比)R2とする(図2ステップS3)。分周比DRの上位16ビットの値に1を加える理由は、下段のタイマT1の設定値が最大値65535を超えないようにするためである。   Subsequently, the timer set value determining unit 2 sets a value obtained by adding 1 to the value of the upper 16 bits of the 32-bit frequency division ratio DR as the set value (frequency division ratio) R2 of the upper timer T2 (FIG. 2). Step S3). The reason why 1 is added to the value of the upper 16 bits of the frequency division ratio DR is to prevent the set value of the lower timer T1 from exceeding the maximum value 65535.

また、タイマ設定値決定部2は、32ビットの分周比DRを上段のタイマT2の設定値R2で割った商を、下段のタイマT1の設定値(分周比)R1とする(図2ステップS4)。
そして、タイマ設定値決定部2は、ステップS3,S4で決定した設定値R1,R2をそれぞれタイマT1,T2に設定する(図2ステップS5)。こうして、タイマ設定値決定処理が終了する。図2のタイマ設定値決定処理は、出力したいパルスの周波数foが変わる度(電磁流量計のパルス出力の場合には、瞬時流量値が変わる度)に行われる。
Further, the timer set value determining unit 2 sets a quotient obtained by dividing the 32-bit frequency division ratio DR by the set value R2 of the upper timer T2 as a set value (frequency division ratio) R1 of the lower timer T1 (FIG. 2). Step S4).
Then, the timer set value determination unit 2 sets the set values R1 and R2 determined in steps S3 and S4 in the timers T1 and T2, respectively (step S5 in FIG. 2). Thus, the timer set value determination process ends. The timer set value determination process in FIG. 2 is performed every time the frequency fo of the pulse to be output changes (in the case of the pulse output of the electromagnetic flow meter, every time the instantaneous flow value changes).

タイマT1は、プリスケーラP0から入力されるクロックと同期して設定値R1からダウンカウントを行ない(クロックが入力される度にカウント値が1減少)、タイムアウト(カウント値が0)になると、タイマ設定値決定部2からカウント値が設定値R1に再設定され、カウント値が0になったときのクロックの次のクロックから再びダウンカウントを開始するという動作を繰り返す。   The timer T1 counts down from the set value R1 in synchronization with the clock input from the prescaler P0 (the count value is decremented by 1 every time the clock is input), and when the time-out (count value is 0), the timer is set. The count determination unit 2 resets the count value to the set value R1, and repeats the operation of starting the down-count again from the clock next to the clock when the count value becomes zero.

同様に、タイマT2は、タイマT1の出力パルスを入力クロックとして、このクロックと同期して設定値R2からダウンカウントを行ない、タイムアウトになると、タイマ設定値決定部2からカウント値が設定値R2に再設定され、カウント値が0になったときのクロックの次のクロックから再びダウンカウントを開始するという動作を繰り返す。   Similarly, the timer T2 uses the output pulse of the timer T1 as an input clock, counts down from the set value R2 in synchronization with this clock, and when the time-out occurs, the timer set value determination unit 2 sets the count value to the set value R2. The operation of resetting and starting the down-count again from the clock next to the clock when the count value becomes 0 is repeated.

こうして、プリスケーラP0から入力されるクロックを、タイマT1,T2の設定値R1,R2で決まる分周比(R1×R2)で分周することができ、所望の周波数foのパルスを出力することができる。本実施の形態のタイマ設定値決定処理によれば、タイマT1の方に大きい値が設定される。このような設定を行なう理由は、出力したいパルスの周波数foが変化したときに、高い周波数の分周タイマT1の設定値R1のみが変化し、低い周波数の分周タイマT2の設定値R2ができるだけ変化しないようにするためである。   In this way, the clock input from the prescaler P0 can be divided by the division ratio (R1 × R2) determined by the set values R1 and R2 of the timers T1 and T2, and a pulse having a desired frequency fo can be output. it can. According to the timer set value determination process of the present embodiment, a larger value is set for the timer T1. The reason for this setting is that when the frequency fo of the pulse to be output changes, only the set value R1 of the high frequency division timer T1 changes, and the set value R2 of the low frequency division timer T2 can be as much as possible. This is to prevent changes.

図3は、図5に示した従来のパルス出力装置と本実施の形態のパルス出力装置の出力パルスの周波数誤差を示す図である。図3における30は従来のパルス出力装置の出力パルスの周波数誤差を示し、31は本実施の形態のパルス出力装置の出力パルスの周波数誤差を示している。図3によれば、本実施の形態のパルス出力装置の方が出力パルスの周波数誤差が概ね小さいことが分かる。   FIG. 3 is a diagram showing a frequency error between output pulses of the conventional pulse output device shown in FIG. 5 and the pulse output device of the present embodiment. In FIG. 3, 30 indicates the frequency error of the output pulse of the conventional pulse output device, and 31 indicates the frequency error of the output pulse of the pulse output device of the present embodiment. According to FIG. 3, it can be seen that the frequency error of the output pulse is generally smaller in the pulse output device of the present embodiment.

図4は、本実施の形態のパルス出力装置のタイマ設定値の連続性を検証した結果を示す図である。従来のパルス出力装置については、スパン周波数を0.01Hzとし、プリスケーラP0から出力させるクロックをf8=921.6KHzのクロックとしている。本実施の形態によれば、タイマ設定値の変化が連続的になるのと、タイマT1の設定値を65535に近い大きい値にできるため、設定値の書き込みとタイムアウトのタイミングが一致する確率を小さくすることができる。   FIG. 4 is a diagram showing a result of verifying the continuity of the timer set value of the pulse output device of the present embodiment. In the conventional pulse output device, the span frequency is 0.01 Hz, and the clock output from the prescaler P0 is f8 = 921.6 KHz. According to the present embodiment, if the change of the timer set value is continuous, the set value of the timer T1 can be set to a large value close to 65535, so that the probability that the write of the set value coincides with the timing of the timeout is reduced. can do.

次に、従来のパルス出力装置と本実施の形態のパルス出力装置の出力パルスの周波数が切り替わる時間について比較する。例えばスパン周波数が3000Hzで、出力パルスの周波数を2.4Hz(0.08%)から3000Hz(100%)に切り替える場合、出力パルスの周波数が2.4HzのときのタイマT2の設定値は1、タイマT1の設定値は100、タイマT0の設定値は30720となる。また、出力パルスの周波数が3000HzのときのタイマT2の設定値は1、タイマT1の設定値は1、タイマT0の設定値は2458となる。いずれの場合も、プリスケーラP0から出力させるクロックはf1=7.3728MHzのクロックである。   Next, the time for switching the frequency of the output pulse of the conventional pulse output device and the pulse output device of the present embodiment will be compared. For example, when the span frequency is 3000 Hz and the output pulse frequency is switched from 2.4 Hz (0.08%) to 3000 Hz (100%), the set value of the timer T2 when the output pulse frequency is 2.4 Hz is 1, The set value of the timer T1 is 100, and the set value of the timer T0 is 30720. When the frequency of the output pulse is 3000 Hz, the set value of the timer T2 is 1, the set value of the timer T1 is 1, and the set value of the timer T0 is 2458. In either case, the clock output from the prescaler P0 is a clock of f1 = 7.3728 MHz.

T0がタイムアウトする時間は30720/7372800=0.0042秒、T1がタイムアウトする時間は2458/7372800×100=0.0333秒、T2がタイムアウトする時間は2458/7372800×1=0.0003秒となる。その結果、従来のパルス出力装置において出力パルスの周波数が2.4Hzから3000Hzに切り替わる時間は、0.0042秒+0.0333秒+0.0003秒=0.0378秒となる。   The time for T0 to time out is 30720/7372800 = 0.422 seconds, the time for T1 to time out is 2458/7372800 × 100 = 0.0333 seconds, and the time for T2 to time out is 2458/7372800 × 1 = 0.0003 seconds. . As a result, in the conventional pulse output device, the time for switching the frequency of the output pulse from 2.4 Hz to 3000 Hz is 0.0042 seconds + 0.0333 seconds + 0.0003 seconds = 0.0378 seconds.

一方、本実施の形態のパルス出力装置において、出力パルスの周波数が2.4HzのときのタイマT2の設定値は47、タイマT1の設定値は65361となる。また、出力パルスの周波数が3000HzのときのタイマT2の設定値は1、タイマT1の設定値は2458となる。いずれの場合も、プリスケーラP0から出力させるクロックはf1=7.3728MHzのクロックである。   On the other hand, in the pulse output device of the present embodiment, the set value of timer T2 is 47 and the set value of timer T1 is 65361 when the frequency of the output pulse is 2.4 Hz. When the output pulse frequency is 3000 Hz, the set value of the timer T2 is 1, and the set value of the timer T1 is 2458. In either case, the clock output from the prescaler P0 is a clock of f1 = 7.3728 MHz.

本実施の形態においてT1がタイムアウトする時間は65361/7372800=0.0089秒、T2がタイムアウトする時間は2458/7372800×47=0.0157秒となる。その結果、本実施の形態のパルス出力装置において出力パルスの周波数が2.4Hzから3000Hzに切り替わる時間は、0.0089秒+0.0157秒=0.0246秒となる。   In this embodiment, the time for T1 to timeout is 65361/7372800 = 0.0089 seconds, and the time for T2 to time out is 2458/7372800 × 47 = 0.157 seconds. As a result, in the pulse output device of the present embodiment, the time for the frequency of the output pulse to switch from 2.4 Hz to 3000 Hz is 0.0089 seconds + 0.0157 seconds = 0.0246 seconds.

このように、本実施の形態のパルス出力装置の方が出力パルスの周波数が早く切り替わることが分かる。その理由は、上記のとおり、本実施の形態では、下段のタイマT1の方に65535に近い大きい値が設定されるため、上段のタイマT2には小さい値が設定されることになり、従来のパルス出力装置のタイマT2の設定値×タイマT1の設定値よりも小さい値が本実施の形態のタイマT2に設定されるためである。さらに、本実施の形態では、プリスケーラP0から出力するクロックの周波数も切り替えているため、高周波数に移行したとき、下段のタイマT1が早くタイムアウトするためである。   Thus, it can be seen that the frequency of the output pulse is switched faster in the pulse output device of the present embodiment. The reason for this is that, as described above, in the present embodiment, a large value close to 65535 is set in the lower timer T1, and thus a smaller value is set in the upper timer T2. This is because a value smaller than the set value of timer T2 of the pulse output device × the set value of timer T1 is set in timer T2 of the present embodiment. Furthermore, in this embodiment, since the frequency of the clock output from the prescaler P0 is also switched, the lower timer T1 times out early when the frequency is shifted to a high frequency.

以上のように、従来のパルス出力装置では3つのタイマを縦続接続していたのに対し、本実施の形態では2つのタイマT1,T2の縦続接続でパルス出力装置を実現することができる。本実施の形態では、プリスケーラP0の周波数とタイマ設定値の決定の際に複雑な判断が不要となり、出力パルスの周波数foから一意にプリスケーラP0の周波数と2つのタイマT1,T2の設定値を決めることができるので、従来よりもアルゴリズムが単純となり、CPUの負荷を小さくすることができる。   As described above, in the conventional pulse output device, three timers are connected in cascade, but in this embodiment, a pulse output device can be realized by connecting two timers T1 and T2 in cascade. In the present embodiment, complicated determination is not required when determining the frequency of the prescaler P0 and the timer set value, and the frequency of the prescaler P0 and the set values of the two timers T1 and T2 are uniquely determined from the frequency fo of the output pulse. Therefore, the algorithm becomes simpler than before, and the load on the CPU can be reduced.

また、本実施の形態では、出力パルスの周波数誤差を小さくすることができる。従来のパルス出力装置では条件判断で不連続なタイマ設定値を設定することになるが、本実施の形態では条件判断はないのでタイマ設定値が連続的になり、出力パルスの滑らかな周波数変化が期待できる。また、本実施の形態では、出力パルスの周波数を変化させるときの応答性を向上させることができる。   In this embodiment, the frequency error of the output pulse can be reduced. In the conventional pulse output device, a discontinuous timer setting value is set by the condition determination. However, in this embodiment, since the condition determination is not made, the timer setting value becomes continuous and the output pulse has a smooth frequency change. I can expect. Moreover, in this Embodiment, the responsiveness when changing the frequency of an output pulse can be improved.

なお、本実施の形態では、広い周波数範囲のパルスを生成するため、タイマT1,T2として16ビットのタイマ(カウンタ)を用いているが、これに限るものではなく、nビット(nは2のべき乗の値で、16以上の値)のタイマを使用すればよい。   In this embodiment, a 16-bit timer (counter) is used as the timers T1 and T2 in order to generate pulses in a wide frequency range. However, the present invention is not limited to this, and n bits (n is 2). A timer having a power value of 16 or more may be used.

本発明は、クロックを分周して広い周波数範囲のパルスを生成する技術に適用することができる。   The present invention can be applied to a technique for generating a pulse in a wide frequency range by dividing a clock.

1…クロック周波数決定部、2…タイマ設定値決定部、P0…プリスケーラ、T1,T2…タイマ。   DESCRIPTION OF SYMBOLS 1 ... Clock frequency determination part, 2 ... Timer setting value determination part, P0 ... Prescaler, T1, T2 ... Timer.

Claims (2)

複数の周波数のうちいずれか1つの周波数のクロックを選択的に出力することが可能なプリスケーラと、
このプリスケーラの出力を入力クロックとするnビット(nは2のべき乗の値で、16以上の値)の第1のタイマと、
この第1のタイマの出力を入力クロックとするnビットの第2のタイマと、
この第2のタイマから出力させる所望の出力パルスの周波数に応じて前記プリスケーラから出力させるクロックの周波数を決定するクロック周波数決定手段と、
前記第1、第2のタイマの設定値を決定するタイマ設定値決定手段とを備え、
前記タイマ設定値決定手段は、前記プリスケーラから出力させるクロックの周波数と前記所望の出力パルスの周波数とからn×2ビットの分周比を決定し、このn×2ビットの分周比の上位nビットの値に1を加えた値を、前記第2のタイマの設定値とし、前記n×2ビットの分周比を前記第2のタイマの設定値で割った商を、前記第1のタイマの設定値とすることを特徴とするパルス出力装置。
A prescaler capable of selectively outputting a clock of any one of a plurality of frequencies;
A first timer of n bits (n is a power of 2 and a value of 16 or more) using the output of the prescaler as an input clock;
An n-bit second timer using the output of the first timer as an input clock;
Clock frequency determining means for determining a frequency of a clock to be output from the prescaler according to a frequency of a desired output pulse to be output from the second timer;
Timer setting value determining means for determining setting values of the first and second timers,
The timer set value determining means determines an n × 2 bit division ratio from the frequency of the clock output from the prescaler and the frequency of the desired output pulse, and the upper n of the n × 2 bit division ratio A value obtained by adding 1 to the bit value is used as a setting value of the second timer, and a quotient obtained by dividing the division ratio of n × 2 bits by the setting value of the second timer is used as the first timer. A pulse output device characterized by having a set value of.
請求項1記載のパルス出力装置において、
前記クロック周波数決定手段は、前記所望の出力パルスの周波数の低下に伴って、前記プリスケーラから出力させるクロックの周波数と前記所望の出力パルスの周波数とで決まるn×2ビットの分周比が前記第1、第2のタイマの設定値の最大値の2乗の数値範囲に収まらなくなったときに、前記プリスケーラから出力させるクロックの周波数を下げる方向に切り替えることを特徴とするパルス出力装置。
The pulse output device according to claim 1, wherein
The clock frequency determining means has a frequency division ratio of n × 2 bits determined by the frequency of the clock output from the prescaler and the frequency of the desired output pulse as the frequency of the desired output pulse decreases. 1. A pulse output device characterized by switching to a direction of decreasing the frequency of a clock output from the prescaler when the set value of the second timer does not fall within the square value range of the maximum value.
JP2015155893A 2015-08-06 2015-08-06 Pulse output device Active JP6454619B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2015155893A JP6454619B2 (en) 2015-08-06 2015-08-06 Pulse output device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2015155893A JP6454619B2 (en) 2015-08-06 2015-08-06 Pulse output device

Publications (2)

Publication Number Publication Date
JP2017034622A JP2017034622A (en) 2017-02-09
JP6454619B2 true JP6454619B2 (en) 2019-01-16

Family

ID=57989028

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2015155893A Active JP6454619B2 (en) 2015-08-06 2015-08-06 Pulse output device

Country Status (1)

Country Link
JP (1) JP6454619B2 (en)

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS54100202A (en) * 1978-01-25 1979-08-07 Nippon Gakki Seizo Kk Automatic channel selection device for receiving unit
US4477920A (en) * 1982-02-26 1984-10-16 Hewlett-Packard Company Variable resolution counter
JPS59190724A (en) * 1983-04-14 1984-10-29 Fuji Electric Co Ltd Frequency variable pulse generator
JPH04107009A (en) * 1990-08-28 1992-04-08 Fuji Facom Corp Programmable pulse oscillator
JPH05273008A (en) * 1992-03-25 1993-10-22 Tokico Ltd Pulse output circuit for flowmeter
US5337339A (en) * 1992-10-15 1994-08-09 Hewlett-Packard Company High frequency programmable divider
DE19930168C2 (en) * 1999-06-30 2001-07-19 Infineon Technologies Ag Circuit arrangement for a frequency divider
JP2008236557A (en) * 2007-03-22 2008-10-02 Toshiba Corp Frequency synthesizer and radio communication apparatus using same

Also Published As

Publication number Publication date
JP2017034622A (en) 2017-02-09

Similar Documents

Publication Publication Date Title
TWI568187B (en) Variable frequency ratiometric multiphase pulse width modulation generation
JP2008028854A (en) Clock generator
JP5494858B2 (en) Clock signal dividing circuit and clock signal dividing method
JP6481533B2 (en) Digitally controlled oscillator circuit
JP4679273B2 (en) Clock data recovery circuit
JP2018101869A (en) Delay circuit, count value generation circuit and physical quantity sensor
JP2009065533A (en) Jitter detecting circuit and semiconductor device
US9255950B2 (en) Method and arrangement for frequency determination
JP6454619B2 (en) Pulse output device
JP6299516B2 (en) Time measurement circuit
KR101297413B1 (en) Adaptive clock generating apparatus and method thereof
CN103856211B (en) Enumerator, method of counting and frequency divider
JP5928590B2 (en) Clock signal generating apparatus, clock signal generating method, and computer-readable recording medium
JP6247546B2 (en) Fractional N frequency synthesizer and setting method thereof
US9590637B1 (en) High-speed programmable frequency divider with 50% output duty cycle
CN104135286A (en) Digital frequency synthesizer and digital frequency synthesis method thereof
US6914463B2 (en) Frequency output generation through alternating between selected frequencies
JP4434277B2 (en) Clock generation circuit and method of using the same
JP2005339245A (en) Interruption generation circuit
JP5579099B2 (en) Clock generating apparatus, DLL (Digital Locked Loop) circuit, and clock generating method
JP5854003B2 (en) Digitally controlled oscillator and variable frequency oscillator
JP4614129B2 (en) Network load tester
JP5225299B2 (en) Spread spectrum clock generator
CN107078723B (en) Signal processing system and method of signal processing
JP2017033498A (en) Pulse output device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20180327

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20181126

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20181211

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20181217

R150 Certificate of patent or registration of utility model

Ref document number: 6454619

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150