JPH0145097B2 - - Google Patents
Info
- Publication number
- JPH0145097B2 JPH0145097B2 JP8666783A JP8666783A JPH0145097B2 JP H0145097 B2 JPH0145097 B2 JP H0145097B2 JP 8666783 A JP8666783 A JP 8666783A JP 8666783 A JP8666783 A JP 8666783A JP H0145097 B2 JPH0145097 B2 JP H0145097B2
- Authority
- JP
- Japan
- Prior art keywords
- stage
- register
- contents
- shift register
- count
- 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.)
- Expired
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F17/00—Digital computing or data processing equipment or methods, specially adapted for specific functions
- G06F17/10—Complex mathematical operations
- G06F17/18—Complex mathematical operations for evaluating statistical data, e.g. average values, frequency distributions, probability functions, regression analysis
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Mathematical Physics (AREA)
- Computational Mathematics (AREA)
- Mathematical Analysis (AREA)
- Life Sciences & Earth Sciences (AREA)
- Operations Research (AREA)
- Probability & Statistics with Applications (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Algebra (AREA)
- Evolutionary Biology (AREA)
- Databases & Information Systems (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Bioinformatics & Computational Biology (AREA)
- Complex Calculations (AREA)
Description
【発明の詳細な説明】
(技術分野)
本発明はある一定時間内の値の平均値を順次求
め、該平均値の更に一定時間内の値の平均値を求
める二重移動平均値の検出をデイジタル回路で実
現するものである。Detailed Description of the Invention (Technical Field) The present invention detects a double moving average value in which the average value of values within a certain period of time is sequentially determined, and the average value of the values within a certain period of time is further calculated from the average value. This is realized using digital circuits.
(従来技術)
移動平均値をデイジタル回路で実現する方法は
特願昭57−211495号の明細書に記載されている方
法等がある。第1図は前記の従来例であり、該従
来例の動作を簡単に説明する。同図において1は
入力端子で1、0の2値のいずれかが入力され
る。2はM+1段のシフトレジスタ(Mは正の整
数とする)、3はサンプリングクロツク用発振器、
4は論理回路でありシフトレジスタ2の最初にデ
ータが書き込まれる第1段目と、最後にデータが
書き込まれる第M+1段目の内容を入力する。5
は少なくともMまでカウントできるアツプダウン
カウンタ、6はデイジタルコンパレータである。
入力端子1のデータはサンプリングクロツク用発
振器3のクロツクに従つてサンプリングし、M+
1段シフトレジスタ(以下シフトレジスタとい
う)の第1段目Aに読み込まれる。前記データは
サンプリングクロツク用発振器3のクロツクが1
サイクル進む毎に右側にシフトし、M個のサンプ
リングクロツクによつてシフトレジスタ2のM+
1段目Bまでシフトする。論理回路4は第2図に
示す論理動作をするものでシフトレジスタ2の1
段目Aの内容と、M+1段目Bの内容によつてア
ツプダウンカウンタ5のアツプカウントあるいは
ダウンカウントを決定する。サンプリングクロツ
ク用発振器3の周波数cは入力端子1に加えられ
る信号をできるだけ忠実にサンプリングするよう
な高い周波数であり、次の式で決められる周波数
が選ばれる。(Prior Art) A method for realizing a moving average value using a digital circuit includes the method described in the specification of Japanese Patent Application No. 57-211495. FIG. 1 shows the above-mentioned conventional example, and the operation of the conventional example will be briefly explained. In the figure, 1 is an input terminal, and one of two values, 1 and 0, is input. 2 is an M+1 stage shift register (M is a positive integer); 3 is a sampling clock oscillator;
4 is a logic circuit which inputs the contents of the first stage of the shift register 2 where data is written first and the M+1th stage where data is written last. 5
is an up-down counter that can count up to at least M, and 6 is a digital comparator.
The data at input terminal 1 is sampled according to the clock of sampling clock oscillator 3, and
The data is read into the first stage A of a one-stage shift register (hereinafter referred to as shift register). The data is stored when the clock of the sampling clock oscillator 3 is 1.
It shifts to the right every cycle, and M+ of shift register 2 is shifted to the right by M sampling clocks.
Shift to 1st stage B. The logic circuit 4 performs the logical operation shown in FIG.
The up-count or down-count of the up-down counter 5 is determined based on the contents of the stage A and the contents of the M+1 stage B. The frequency c of the sampling clock oscillator 3 is a high frequency that samples the signal applied to the input terminal 1 as faithfully as possible, and is determined by the following equation.
c=M/T 但しTは平均値を得ようとする時間長である。 c=M/T However, T is the time length for obtaining the average value.
次に前述の如く構成した回路の動作を説明す
る。まずシフトレジスタ2の各段の内容及びアツ
プダウンカウンタの各ビツトの内容はすべて
「0」であるとする。サンプリングクロツク用発
振器3が1サイクル進むとサンプリングデータは
前記シフトレジスタ2の1段目Aに取り込まれ
る。この値が「1」であつたとすると次のサンプ
リングクロツクでシフトレジスタ2の2段目にA
の値が移ると共に第2図の論理動作によつてアツ
プダウンカウンタ5は1ビツトアツプカウントす
る。以下サンプリングクロツクに従つてサンプリ
ングデータがシフトレジスタ2内を順次移動し、
サンプリングデータの「1」の数だけアツプダウ
ンカウンタ5の内容が増加する。サンプリングク
ロツク数がM+1になると最初のサンプリングデ
ータはシフトレジスタ2のM+1段目Bに現れ、
2段目〜M+1段目の各段の内容が「1」である
数はアツプダウンカウンタ5の内容と一致する。
次にシフトレジスタ2の1段目AとM+1段目B
の値が一致したときは、2段目〜M+1段目の
「1」の数は次のサンプリングクロツクでシフト
レジスタ2の内容が1段ずつ移つても変化しな
い。このときはアツプダウンカウンタ5の内容も
変化しない。またシフトレジスタ2の1段目Aの
内容が「1」でM+1段目Bの内容が「0」のと
きは、次のサンプリングクロツクで2段目〜M+
1段目の「1」の数は1つ増加しアツプダウンカ
ウンタ5の内容も1つ増加する。逆にシフトレジ
スタ2の1段目Aの内容が「0」でM+1段目B
の内容が「1」のときはシフトレジスタ2の2段
目〜M+1段目の「1」の数は1つ減少し、アツ
プダウンカウンタ5の内容も1つ減少する。前述
の如くシフトレジスタ2の2段目〜M+1段目の
「1」の数とアツプダウンカウンタ5の内容とは
常に一致することとなる。またシフトレジスタ2
の2段目〜M+1段目の内容の「1」の数はその
時刻からTだけ遡つた時間までの間で、どれだけ
の割合で「1」の数があつたかを示すもので、こ
の数とMを比較すれば前記時間内の時間平均を求
めていることになる。シフトレジスタ2の内容は
サンプリングクロツク用発振器3の周期に従つて
順次変化していくのでT時間内の移動平均が求め
られる。デイジタルコンパレータ6にM/2を設定
すれば平均値が1/2を越えたかどうかを出力端子
7に得ることができる。なお第1図の回路でシフ
トレジスタ2の2段目〜M+1段目の「1」の数
とアツプダウンカウンタ5の内容が何らかの原因
で、例えば雑音等の擾乱で一致しなくなるとそれ
以降は正しい移動平均値を示さなくなる。これを
防ぐために考えられたものが第3図に示す従来例
である。第3図において8,9は論理回路、第1
図と同一符号のものは同一または均等部分を示
す。論理回路8はアツプダウンカウンタ5の内容
がMになつたとき論理回路4の出力を入力する論
理回路9のゲートを閉じて論理回路4からアツプ
カウントの指示が出てもカウントさせず、逆にア
ツプダウンカウンタ5の内容が0のときは論理回
路4からダウンカウントの指示が出てもカウント
させないようにする。前述のように構成すればサ
ンプリングデータがM個以上連続して「1」又は
「0」となるときに自動的に補正を行うので正し
い移動平均値を示すようになる。 Next, the operation of the circuit configured as described above will be explained. First, it is assumed that the contents of each stage of the shift register 2 and the contents of each bit of the up-down counter are all "0". When the sampling clock oscillator 3 advances by one cycle, the sampling data is taken into the first stage A of the shift register 2. If this value is "1", the second stage of shift register 2 will be
As the value changes, the up-down counter 5 counts up by 1 bit according to the logic operation shown in FIG. Thereafter, the sampling data is sequentially moved in the shift register 2 according to the sampling clock,
The contents of the up-down counter 5 are increased by the number of "1"s in the sampling data. When the number of sampling clocks reaches M+1, the first sampling data appears at the M+1st stage B of the shift register 2.
The numbers whose contents are "1" in each of the second to M+1st rows match the contents of the up-down counter 5.
Next, 1st stage A and M+1st stage B of shift register 2
When the values match, the number of "1"s in the second to M+1 stages does not change even if the contents of the shift register 2 are shifted one stage at a time at the next sampling clock. At this time, the contents of the up-down counter 5 do not change either. In addition, when the content of the first stage A of shift register 2 is "1" and the content of M+1 stage B is "0", the next sampling clock shifts the second stage to M+.
The number of "1"s in the first row increases by one, and the contents of the up-down counter 5 also increase by one. Conversely, if the contents of the first stage A of shift register 2 are "0", the contents of the M+1st stage B
When the content of is "1", the number of "1"s in the second to M+1 stages of the shift register 2 decreases by one, and the content of the up-down counter 5 also decreases by one. As described above, the number of "1"s in the second to M+1 stages of the shift register 2 always matches the contents of the up-down counter 5. Also shift register 2
The number of "1"s in the contents of the second to M+1st rows indicates how often there were "1"s from that time to the time T back, and this number By comparing M and M, it means that the time average within the above-mentioned time period is being calculated. Since the contents of the shift register 2 change sequentially in accordance with the period of the sampling clock oscillator 3, a moving average within time T is obtained. By setting M/2 in the digital comparator 6, it is possible to obtain at the output terminal 7 whether the average value exceeds 1/2. In addition, in the circuit shown in Fig. 1, if the number of "1"s in the second to M+1 stages of the shift register 2 and the contents of the up-down counter 5 do not match for some reason, for example due to disturbances such as noise, from then on they are correct. It no longer shows the moving average value. A conventional example shown in FIG. 3 has been devised to prevent this. In Fig. 3, 8 and 9 are logic circuits,
The same reference numerals as in the figures indicate the same or equivalent parts. When the content of the up-down counter 5 reaches M, the logic circuit 8 closes the gate of the logic circuit 9 which inputs the output of the logic circuit 4, and does not count up even if an up-count instruction is issued from the logic circuit 4. When the content of the up-down counter 5 is 0, even if a down-counting instruction is issued from the logic circuit 4, the up-down counter 5 is not allowed to count. With the configuration as described above, when M or more pieces of sampling data are consecutively "1" or "0", correction is automatically performed, so that a correct moving average value is indicated.
ところで移動平均は一種の低域波器と考えら
れるが1段だけの移動平均では減衰量が不足し、
必要な減衰量が得られないときに二段縦続した移
動平均(以下二重移動平均値という)を求める必
要がある場合がある。第1図又は第3図の出力端
子7に現われる出力は移動平均値がある設定値
(例えば1/2)を越えたかどうかを表わすもので移
動平均値そのものを表わしているわけではない。
従つて前記出力を次の移動平均値検出回路の入力
とするわけにはいかない。又アツプダウンカウン
タ5の内容は移動平均値を表わしているが、多値
となつているので、この多値のさらに移動平均を
求めようとすると極めて複雑な手順が必要であ
る。 By the way, a moving average can be considered a type of low-frequency wave filter, but a moving average with only one stage does not have enough attenuation.
When the required amount of attenuation cannot be obtained, it may be necessary to obtain a two-stage moving average (hereinafter referred to as a double moving average value). The output appearing at the output terminal 7 in FIG. 1 or 3 indicates whether the moving average value exceeds a certain set value (for example, 1/2), and does not represent the moving average value itself.
Therefore, the output cannot be used as an input to the next moving average value detection circuit. Further, the contents of the up-down counter 5 represent a moving average value, but since it is multi-valued, an extremely complicated procedure is required to further obtain a moving average of this multi-valued value.
(発明の目的)
本発明の目的は前記欠点を除去し、極めて簡単
に二重移動平均値を求め該平均値がある設定値を
越えたかどうかを検出する回路をデイジタル回路
で実現する方式を提供するものである。以下図面
を用いて本発明の内容を詳細に説明する。(Object of the Invention) An object of the present invention is to eliminate the above-mentioned drawbacks and to provide a method for realizing a circuit using a digital circuit that extremely easily obtains a double moving average value and detects whether the average value exceeds a certain set value. It is something to do. The contents of the present invention will be explained in detail below using the drawings.
(発明の構成)
本発明の構成は、サンプリングクロツク用発振
器と、該発振器に同期して書き込まれるM+1
(Mは正の整数)段シフトレジスタと、少なくと
もMまでカウントできるアツプダウンカウンタ
と、前記M+1段シフトレジスタの1段目と最後
にデータが書き込まれるM+1段目のデータが同
じ値のときはカウントせず、M+1段シフトレジ
スタの1段目とM+1段目のデータが異なる値の
ときは異なる状態に応じて前記発振器と同期して
アツプカウント又はダウンカウントすること、更
にアツプダウンカウンタのカウント数が「M」の
ときはアツプカウントの条件が成立してもアツプ
カウントせず、アツプダウンカウンタのカウント
数が「0」となつたときはダウンカウントの条件
が成立してもダウンカウントしない2組の移動平
均値検出回路を、前段のM+1段シフトレジスタ
のM段目の出力を後段のM+1段シフトレジスタ
の1段目に書き込むように接続し、少なくとも
M2+Mまで格納できるレジスタと、前段のアツ
プダウンカウンタのカウント内容をレジスタに加
算する加算器と、後段のアツプダウンカウンタの
カウント内容をレジスタから減算する減算器と、
デイジタルコンパレータを有し、レジスタの内容
が減算を完了した時点でM2を越えているときは
レジスタの内容をM2とし、レジスタの内容が減
算を完了した時点で「0」以下のときは「0」と
し、前記デイジタルコンパレータでレジスタの内
容と一定値とを比較し、該一定値を越えたかどう
かを判定することを特徴とした二重移動平均値検
出方式である。以下実施例について詳細に説明す
る。(Configuration of the Invention) The configuration of the present invention includes a sampling clock oscillator and an M+1 clock that is written in synchronization with the oscillator.
(M is a positive integer) stage shift register, an up-down counter that can count up to at least M, and a count when the data in the first stage and the M+1 stage where data is finally written in the M+1 stage shift register are the same value. If the data in the first stage and the M+1 stage of the M+1 stage shift register have different values, the up-count or down-count is performed in synchronization with the oscillator according to the different states, and furthermore, the count number of the up-down counter is When it is "M", up-counting does not occur even if the up-counting conditions are met, and when the count number of the up-down counter reaches "0", it does not count down even if the down-counting conditions are met. The moving average value detection circuit is connected so that the output of the Mth stage of the M+1 stage shift register in the preceding stage is written to the first stage of the M+1 stage shift register in the succeeding stage, and at least
A register that can store up to M 2 +M, an adder that adds the count contents of the up-down counter in the previous stage to the register, and a subtractor that subtracts the count contents of the up-down counter in the subsequent stage from the register.
It has a digital comparator, and if the contents of the register exceeds M2 at the time the subtraction is completed, the contents of the register are set to M2 , and if the contents of the register are less than "0" at the time the subtraction is completed, it is set to "M2". 0'', and the digital comparator compares the contents of the register with a constant value to determine whether or not the constant value has been exceeded. Examples will be described in detail below.
(実施例の説明)
まず移動平均を求めるアルゴリズムを説明す
る。信号のk番目のサンプリング値をxkとする。
xkは1か0である。k番目の移動平均ykは
yk=1/MM-1
〓m=0
xk-n ……(1)
但しMは移動平均を行おうとするサンプルの個
数でk番目のサンプルからk番目を含め過去M個
のサンプル値の平均をとる。移動平均値ykのさら
に移動平均値zkはサンプル値xkの二重移動平均値
となり次式で表わされる。(Description of Examples) First, an algorithm for calculating a moving average will be explained. Let x k be the kth sampling value of the signal.
x k is 1 or 0. The k-th moving average y k is y k = 1/M M-1 〓 m=0 x kn ...(1) where M is the number of samples for which moving average is to be performed, including the k-th sample from the k-th sample. Take the average of the past M sample values. The moving average value z k of the moving average value y k becomes a double moving average value of the sample value x k and is expressed by the following equation.
zk=1/MM-1 〓n=0 yk-o ……(2) (2)式は次のように変形される。 z k =1/M M-1 〓 n=0 y ko ...(2) Equation (2) is transformed as follows.
zk=1/MM-1
〓n=0
・1/MM-1
〓m=0
xk-n-o=1/M2 M-1
〓n=0 M-1
〓m=0
xk-n-o ……(3)
二重移動平均値zkをmについて展開して考える
と
ここで、xkは、1又は0であるから、二重移動
平均値zkは最大値zk(nax)と、最小値zk(nio)は
zk(nax)=1/M2(1+…+M+…1)=1/M
2×{M(M+1)/2×2−M}=1……(4)
zk(nio)=0 ……(5)
となり、zk(nax)はxkが少なくとも2M個連続して
「1」であつた場合、又、zk(nio)は、xkが少なくと
も2M個連続して、「0」であつた場合に起る。以
後は、M2で正規化した二重移動平均値〔zk〕で
考察する。即ち、
〔zk〕=M2・zk ……(6)
とする。 z k =1/M M-1 〓 n=0・1/M M-1 〓 m=0 x kno =1/M 2 M-1 〓 n=0 M-1 〓 m=0 x kno ……( 3) Expanding the double moving average value z k with respect to m, we get Here, since x k is 1 or 0, the double moving average value z k is the maximum value z k (nax) and the minimum value z k (nio) is z k (nax) = 1/M 2 ( 1+...+M+...1)=1/M
2 × {M (M + 1) / 2 × 2 - M} = 1 ... (4) z k (nio) = 0 ... (5) and z k (nax) means that x k is at least 2M consecutive z k(nio) occurs when x k is "0" for at least 2M consecutive times. Hereafter, the double moving average value [z k ] normalized by M 2 will be considered. That is, [z k ]=M 2 · z k ...(6).
k番目の二重移動平均値と、(k+1)番目の
二重移動平均値を比較してみると、
〔zk〕=xk+2xk-1+…+Mxk-(M-1)+…+
xk-(2M-2)
〔zk+1〕=xk+1+2xk+…+Mxk-(M-2)+…
+xk-(2M-3)
即ち、k番目に、(xk+1+xk+…+xk-(M-2))を
加算し、(xk-(M-1)+…+xk-(2M-2))を減算すれ
ば、(k+1)番目になる。従つて、k+1番目
は、
〔zk+1〕=〔zk〕+(M-2
〓m=-1
xk-n−2M-2
〓m=-1
xk-n)
一般式化すると、
〔zk〕=〔zk-1〕+(M-1
〓m=0
xk-n−2M-2
〓m=M
xk-n) ……(7)
これは、(2)式と、(6)式から、
〔zk〕=〔yk〕+…+〔yk-(M-1)〕
〔zk-1〕=〔yk-1〕+…+〔yk-M〕
であるから、(7)式は、
〔zk〕=〔zk-1〕+(〔yk〕−〔yk-M〕) ……(8)
と同じ意味で、
yk→M-1
〓m=0
xk-n、
yk-M→M-1
〓m=0
xk-(n+M)=2M-2
〓m=M
xk-n
にそれぞれ対応している。但し、〔yk〕=M・ykと
する。ここで、漸化式
〔zk〕=〔zk-1〕+(〔yk〕−〔yk-M〕)
を考えると、i≦0で〔zi〕=0、〔yi〕=0と仮定
すれば
〔z1\〕=〔zD〕+(〔y0〕−〔y−M〕)
〔z2\〕=〔z1\〕+(〔y1〕−〔y1-M〕)
〓 \
〓 〓
〔zM\〕=〔zM-1\〕+(〔yM〕−〔y0〕)
〓 〓
+)〔zk〕=〔zk-1\〕+(〔yk〕−〔yk-M〕)
〔zk〕=〔z0〕+(K
〓i=0
yi−K
〓i=0
yi−M)
ところでM
〓i=0
〔yi-M〕=0、〔z0〕=0であるから
〔zk〕=k
〓i=0
〔yi〕−k
〓i=M
〔yi-M〕 ……(9)
ここで、
〔yi〕=M-1
〓m=0
xi-n、〔yi-M〕=2M-2
〓m=M
xi-n
である。 Comparing the kth double moving average value and the (k+1)th double moving average value, [z k ]=x k +2x k-1 +...+Mx k-(M-1) +... +
x k-(2M-2) [z k+1 ]=x k+1 +2x k +…+Mx k-(M-2) +…
+x k-(2M-3) , that is, (x k+1 +x k +...+x k-(M-2) ) is added to the kth, (x k-(M-1) +...+x k- (2M-2) ), it becomes (k+1)th. Therefore, the k+1st is [z k+1 ] = [z k ] + ( M-2 〓 m=-1 x kn − 2M-2 〓 m=-1 x kn ) When generalized, [z k ] = [z k-1 ] + ( M-1 〓 m=0 x kn − 2M-2 〓 m=M x kn ) ...(7) From equations (2) and (6), [z k ]=[y k ]+…+[y k-(M-1) ] [z k-1 ]=[y k-1 ]+…+[y kM ], so Equation (7) is [z k ]=[z k-1 ]+([y k ]−[y kM ]) ……same meaning as (8), y k → M-1 〓 m=0 x kn , y kM → M-1 〓 m=0 x k-(n+M) = 2M-2 〓 m=M x kn , respectively. However, [y k ]=M·y k . Here, considering the recurrence formula [z k ]=[z k-1 ]+([y k ]−[y kM ]), if i≦0, [z i ]=0, [y i ]=0 If we assume that [ z 1 \] = [z D ] + ( [ y 0 ]−[y− M ]) 〓 〓 〓 〓 〓 [z M \] = [z M-1 \] + ([y M ] - [y 0 ]) 〓 〓 +) [z k ] = [z k-1 \] + ([ y k ]−[y kM ]) [z k ]=[z 0 ]+( K 〓 i=0 yi− K 〓 i=0 yi−M) By the way, M 〓 i=0 [y iM ]=0, [ Since z 0 ]=0, [z k ]= k 〓 i=0 [y i ]− k 〓 i=M [y iM ] ……(9) Here, [y i ]= M-1 〓 m =0 x in , [y iM ] = 2M-2 〓 m=M x in .
(9)式の第一項は、サンプル値xiのi=0〜(M
−1)までの移動平均を、第二項はサンプル値xi
のi=M〜(2M−1)までの移動平均を、それ
ぞれ過去からの総和を行ないそれぞれの加算、減
算を行えばよいことを示している。移動平均は、
特に時間的な制限が無ければ無限に続くものであ
るからk
〓i=0
〔yi〕、k
〓i=M
〔yi-M〕は、無限大に発散する。これを防ぐた
め、次の変形を行なう。 The first term of equation (9) is i =0 to (M
−1), the second term is the sample value x i
This shows that it is sufficient to sum up the moving averages from i=M to (2M-1) from the past, and then perform the respective additions and subtractions. The moving average is
In particular, if there is no time limit, it will continue indefinitely, so k 〓 i=0 [y i ] and k 〓 i=M [y iM ] will diverge to infinity. To prevent this, the following modification is performed.
即ち、
M-1
〓i=0
〔yi-M〕=0であるからk
〓i=M
〔yi-M〕=M-1
〓i=0
〔yi-M〕+k
〓i=M
〔yi-M〕=k
〓i=0
〔yi-M〕
……(10)
(9)、(10)式より
〔zk〕=k
〓i=0
〔yi〕−k
〓i=M
〔yi-M〕=k
〓i=0
〔yi〕−k
〓i=0
〔yi-M〕=k
〓i=0
(〔yi〕−〔yi-M〕)
すなわち、
M2・zk=k
〓i=0
(M・yi−M・yi-M) ……(11)
しかるに、zk(nax)=1、zk(nio)=0であるから、
(M・yi−M・yi-M)の総和は、発散することは無
い。 That is,
M-1 〓 i=0 [y iM ] = 0, so k 〓 i=M [y iM ] = M-1 〓 i=0 [y iM ] + k 〓 i=M [y iM ] = k 〓 i=0 [y iM ] ...(10) From equations (9) and (10), [z k ]= k 〓 i=0 [y i ]− k 〓 i=M [y iM ]= k 〓 i= 0 [y i ] −k 〓 i=0 [y iM ]= k 〓 i=0 ([y i ]−[y iM ]) That is, M 2・z k = k 〓 i=0 (M・y i −M・y iM ) ...(11) However, since z k(nax) = 1 and z k(nio) = 0,
The sum of (M·y i −M·y iM ) never diverges.
本発明は(11)式を実現し、その値が、あらかじめ
設定された値を超えたかどうかを、出力するため
のものであつて、第4図にその1例を示す。同図
において2−1,2−2はM+1段シフトレジス
タ(以下シフトレジスタという)、4−1,4−
2は論理回路、5−1,5−2はアツプダウンカ
ウンタ、12は少なくともM2+Mまで格納する
ことができるレジスタ(以下単にレジスタとい
う)、10はレジスタ12の内容と、アツプダウ
ンカウンタ5−1の内容を加算して、レジスタ1
2にその結果を格納する加算器、11はレジスタ
12の内容からアツプダウンカウンタ5−2の内
容を減算し、その結果をレジスタ12に格納する
減算器、13はコンパレータでレジスタ12の内
容をある一定値、例えばM2/2と比較して、その値
を越えたかどうかを出力端子14に出力する。 The present invention is for realizing equation (11) and outputting whether the value exceeds a preset value, and an example thereof is shown in FIG. In the same figure, 2-1, 2-2 are M+1 stage shift registers (hereinafter referred to as shift registers), 4-1, 4-
2 is a logic circuit; 5-1 and 5-2 are up-down counters; 12 is a register that can store at least M 2 +M (hereinafter simply referred to as a register); 10 is the contents of register 12 and an up-down counter 5- Add the contents of register 1 and add the contents of register 1.
2 is an adder that stores the result; 11 is a subtracter that subtracts the contents of up-down counter 5-2 from the contents of register 12 and stores the result in register 12; 13 is a comparator that stores the contents of register 12; It compares it with a fixed value, for example M 2 /2, and outputs to the output terminal 14 whether or not the value has been exceeded.
シフトレジスタ2−2の第1段目Aにはシフト
レジスタ2−1の第M段目の内容がサンプリング
クロツク用発振器3のクロツクに従つて書き込ま
れる。従つてシフトレジスタ2−1のM+1段目
Bの内容とシフトレジスタ2−2の1段目Aの内
容は常に一致するからシフトレジスタ2−1及び
2−2の代りに2M+1段シフトレジスタを置き、
そのM+1段目の内容を論理回路4−1及び4−
2に接続しても同様な動作となる。次に第4図に
示す回路の動作を説明する。アツプダウンカウン
タ5−1の内容は(1)式の両辺をM倍したものに等
しい。即ち
M・yk=k
〓m=0
xk-n ……(12)
シフトレジスタ2−2の1段目Aにはシフトレ
ジスタ2−1の1段目Aよりサンプリングデータ
でM個遅れて書き込まれるからアツプダウンカウ
ンタ5−2の内容は(12)式より
M・yk-M=M-1
〓m=0
xk-n-M ……(13)
従つてレジスタ12の内容はk
〓i=0
(M・yi−M・yi-M)となり(11)
式を満足する。従つて平均値が0〜1の任意の値
を越えたかどうかを検出するときには0〜1の任
意の値にM2を乗じた数をデイジタルコンパレー
タ13に設定すればよく、又二重移動平均値が1/
2を越えたかどうかを検出するときにはM2/2をデ
イジタルコンパレータ13に設定すれば出力端子
14に出力させることができる。 The contents of the Mth stage of the shift register 2-1 are written into the first stage A of the shift register 2-2 in accordance with the clock of the sampling clock oscillator 3. Therefore, the contents of the M+1 stage B of the shift register 2-1 and the contents of the 1st stage A of the shift register 2-2 always match, so a 2M+1 stage shift register is placed in place of the shift registers 2-1 and 2-2. ,
The contents of the M+1st stage are stored in logic circuits 4-1 and 4-.
2, the same operation will occur. Next, the operation of the circuit shown in FIG. 4 will be explained. The contents of the up-down counter 5-1 are equal to both sides of equation (1) multiplied by M. That is, M・y k = k 〓 m=0 x kn ...(12) The sampling data is written to the first stage A of the shift register 2-2 with a delay of M times from the first stage A of the shift register 2-1. From equation (12), the contents of the up-down counter 5-2 are M・y kM = M-1 〓 m=0 x knM ……(13) Therefore, the contents of the register 12 are k 〓 i=0 (M・y i −M・y iM ), which satisfies equation (11). Therefore, to detect whether the average value exceeds an arbitrary value between 0 and 1, it is sufficient to set the number obtained by multiplying an arbitrary value between 0 and 1 by M 2 in the digital comparator 13, and also set the double moving average value. is 1/
When detecting whether the value exceeds 2, by setting M 2 /2 in the digital comparator 13, it can be outputted to the output terminal 14.
以上説明したように第1の実施例では簡単な構
成で二重移動平均値を検出することが可能であ
る。 As explained above, in the first embodiment, it is possible to detect a double moving average value with a simple configuration.
本発明に係る第2の実施例を第5図に示す。第
5図に示す回路は誤動作が起つたときの回復手段
を二重移動平均値検出回路にも考えることがで
き、その実施例を示すものである。論理回路8−
1はアツプダウンカウンタ5−1の内容がMにな
つたとき、論理回路4−1の出力を入力する論理
回路9−1のゲートを閉じて論理回路4−1から
アツプカウントの指示が出てもカウントさせず逆
にアツプダウンカウンタ5−1の内容が「0」の
ときは論理回路4−1からダウンカウントの指示
が出ても論理回路9−1のゲートを閉じてカウン
トさせないようにする。このような構成にすれば
シフトレジスタ2−1の2段目〜M+1段目まで
の「1」の数がアツプダウンカウンタ5−1の内
容と合わなくなつても自動的に回復することは第
3図の説明で述べた通りである。また論理回路8
−2は論理回路8−1に、論理回路9−2は論理
回路9−1にそれぞれ対応しその働きも同様であ
る。同様にレジスタ12についても考えることが
できる。まず(4)式およびその前後の説明よりk番
目の二重移動平均値zkの最大値zk(nax)はサンプリ
ングデータxkが少なくとも2M個連続して「1」
のとき出現し、その値は1である。即ちレジスタ
12の内容の最大値はM2である。同様に(5)式よ
りzkの最小値zk(nio)はサンプリングデータxkが少
なくとも2M個連続して「0」のとき出現し、そ
の値は0でレジスタ12の内容も0である。ここ
でレジスタ12の内容が何らかの原因(例えば電
気的擾乱等)で正しい値よりも大になつたときに
はサンプリングデータが少なくとも2M個「1」
が続く前にレジスタ12の内容はM2となり、そ
の後レジスタ12の有限bit長で決定される最大
値を折り返し点として符号反転された2進数値を
示すことになると共に、特別の修正を行わない限
りレジスタ12は永久に正しい値からズレた値を
示すようになる。同様にレジスタ12の内容が正
しい値よりも小さくなつたときはサンプリングデ
ータが少なくとも2M個連続して「0」となる前
にレジスタ12の内容は0となりやはり符号反転
した2進数値を示す。これを防ぐために用意した
のが論理回路15でレジスタ12の内容が正しい
値からズレたときに自動的に正しい値に復帰させ
る働きを持つもので、アツプダウンカウンタ5−
1に対する論理回路8−1及び論理回路9−1の
働きと同様の効果を持つものである。即ち加算器
10による加算及び減算器11による減算後のレ
ジスタ12の値がM2を越えているときは、M2を
レジスタ12に設定し、同様にレジスタ12の値
が負になつたときは0をレジスタ12に設定す
る。前述の如く構成すればレジスタ12の内容が
何らかの原因で正しい値よりも大になつたときに
はサンプリングデータが少なくとも2M個「1」
が続いたときにレジスタ12の値がM2に補正さ
れてそれ以降は正しい値を示すようになり、逆に
正しい値よりも小になつたときはサンプリングデ
ータが少なくとも2M個連続して「0」となつた
ときに補正されてそれ以降は正しい値を示すよう
になる。サンプリングデータが少なくとも2M個
連続して「1」又は「0」となることは極めて高
い確準で起るので、レジスタ12の内容が正しい
値からずれることが起つたとしても、直ちに補正
され正しい値を示すようになる。以上説明した実
施例ではシフトレジスタ2−1及び2−2の段数
として一般的にM+1段としたがこれを2N+1段
(Nは正の整数とする)とすれば数値判定の簡略
化に顕著な効果をもたらす。以下にこれを説明す
る。 A second embodiment according to the present invention is shown in FIG. The circuit shown in FIG. 5 can also be considered as a double moving average value detection circuit as a recovery means when a malfunction occurs, and shows an embodiment thereof. Logic circuit 8-
1, when the content of the up-down counter 5-1 reaches M, the gate of the logic circuit 9-1 that inputs the output of the logic circuit 4-1 is closed, and the logic circuit 4-1 issues an up-count instruction. Conversely, when the content of the up-down counter 5-1 is "0", the gate of the logic circuit 9-1 is closed to prevent counting even if a down-count instruction is issued from the logic circuit 4-1. . With this configuration, even if the number of "1"s from the second stage to the M+1 stage of the shift register 2-1 does not match the contents of the up-down counter 5-1, it will automatically recover. This is as described in the explanation of Figure 3. Also, logic circuit 8
-2 corresponds to the logic circuit 8-1, and the logic circuit 9-2 corresponds to the logic circuit 9-1, and their functions are the same. Similarly, the register 12 can also be considered. First, from equation (4) and the explanations before and after it, the maximum value z k(nax) of the k-th double moving average value z k is "1" when at least 2M sampling data x k are consecutive.
Appears when , and its value is 1. That is, the maximum value of the contents of register 12 is M2 . Similarly, from equation (5), the minimum value z k(nio) of z k appears when at least 2M pieces of sampling data x k are consecutively "0", and the value is 0 and the contents of register 12 are also 0. . If the contents of the register 12 become larger than the correct value for some reason (such as electrical disturbance), at least 2M pieces of sampling data become "1".
The contents of register 12 become M 2 before continuing, and after that, the maximum value determined by the finite bit length of register 12 is the turning point, and the binary value is sign-inverted, and no special modification is performed. Until then, the register 12 will forever show a value that deviates from the correct value. Similarly, when the contents of the register 12 become smaller than the correct value, the contents of the register 12 become 0 before at least 2M consecutive pieces of sampling data become "0", and also indicate a binary value whose sign has been inverted. To prevent this, we have prepared a logic circuit 15 which has the function of automatically returning the contents of the register 12 to the correct value when it deviates from the correct value.
This has an effect similar to that of the logic circuit 8-1 and the logic circuit 9-1 for the logic circuit 1. That is, when the value of register 12 after addition by adder 10 and subtraction by subtracter 11 exceeds M 2 , M 2 is set in register 12, and similarly, when the value of register 12 becomes negative, Set 0 to register 12. If configured as described above, when the contents of register 12 become larger than the correct value for some reason, at least 2M pieces of sampling data will be "1".
continues, the value in register 12 is corrected to M 2 and from then on it shows the correct value, and conversely, when it becomes smaller than the correct value, at least 2M pieces of sampling data consecutively show "0". ”, it will be corrected and the correct value will be shown from then on. There is a very high probability that at least 2M pieces of sampling data will be "1" or "0" consecutively, so even if the contents of register 12 deviate from the correct value, it will be immediately corrected and the correct value will be returned. It comes to show. In the embodiment described above, the number of stages of the shift registers 2-1 and 2-2 is generally set to M+1 stages, but if this is set to 2 N +1 stages (N is a positive integer), numerical determination can be simplified. It has a remarkable effect. This will be explained below.
シフトレジスタ2−1及び2−2の段数を2N+
1段としても構成に変更はない。従つて第4図及
び第6図を用いて説明する。まず第4図でシフト
レジスタ2−1及び2−2の段数を2N+1段とす
るので、該シフトレジスタ2−1及び2−2の2
段目〜2N+1段目の「1」の数の最大値は2Nであ
る。従つてアツプダウンカウンタ5−1及び5−
2は少なくともN+1ビツトの容量があれば良
く、前記アツプダウンカウンタ5−1,5−2が
N+1ビツトの容量であるとすれば、それが最大
値を示すときはMSBが「1」で他のビツトは全
て「0」となる。次にレジスタ12の最大値は加
算及び減算が完了した時点においては(2N)2=
22Nであるからレジスタ12の容量は少なくとも
2N+1ビツトあれば良い。 The number of stages of shift registers 2-1 and 2-2 is 2 N +
There is no change in the configuration of the first stage. Therefore, explanation will be given using FIGS. 4 and 6. First, in FIG. 4, the number of stages of the shift registers 2-1 and 2-2 is set to 2 N +1 stages, so the number of stages of the shift registers 2-1 and 2-2 is
The maximum value of the number of "1"s in the 2 N + 1st row is 2 N. Therefore, up-down counters 5-1 and 5-
2 only needs to have a capacity of at least N+1 bits, and if the up-down counters 5-1 and 5-2 have a capacity of N+1 bits, when it indicates the maximum value, the MSB is "1" and the other All bits become "0". Next, the maximum value of register 12 is (2 N ) 2 = at the time when addition and subtraction are completed.
2 2N , so the capacity of register 12 is at least
2N+1 bits is enough.
第6図によつてレジスタ12の数値と、各ビツ
トとの対応を説明する。ここでレジスタ12の容
量は2N+1ビツトとするとレジスタ12の内容
の最大値は前述のように22NであるからMSBのみ
が「1」で他のビツトはすべて「0」となる。又
(22N)/2=22N-1のときはMSBの次のビツトのみが
「1」で他のビツトは全て「0」であり、(22N)/2
−1=22N-1−1のときはMSBと、MSBの次のビ
ツトが「0」で他のビツトは全て「1」である。
二重移動平均値が1/2を越えたときをレジスタ1
2の内容が(22N)/2以上のときに対応させ、二重移
動平均値が1/2を越えないときをレジスタ12の
内容が(22N)/2−1以下のときに対応させればコン
パレータ13の判定は極めて簡単になる。即ちレ
ジスタ12のMSBとMSBの次のビツトのみに着
目すれば良く、
(1) MSBとMSBの次のビツトが共に「0」であ
れば二重移動平均値は1/2を越えていない。 The correspondence between the numerical value of the register 12 and each bit will be explained with reference to FIG. Here, assuming that the capacity of the register 12 is 2N+1 bits, the maximum value of the contents of the register 12 is 22N as described above, so only the MSB is "1" and all other bits are "0". Also, when (2 2N )/2 = 2 2N-1 , only the next bit of the MSB is "1" and all other bits are "0", so (2 2N )/2 - 1 = 2 2N-1 When it is -1, the MSB and the bit following the MSB are "0" and all other bits are "1".
When the double moving average value exceeds 1/2, register 1
When the content of register 12 is (2 2N )/2 or more, it corresponds, and when the double moving average value does not exceed 1/2, it corresponds when the content of register 12 is less than (2 2N )/2 - 1. If so, the determination by the comparator 13 becomes extremely simple. That is, it is only necessary to pay attention to the MSB of the register 12 and the bit following the MSB. (1) If both the MSB and the bit following the MSB are "0", the double moving average value does not exceed 1/2.
(2) MSBか又はMSBの次のビツトのどちらかが
「1」であれば二重移動平均値は1/2を越えてい
る。(2) If either the MSB or the next bit of the MSB is "1", the double moving average value exceeds 1/2.
という情報を出力端子14に出せば良い。通常の
適用では二重移動平均値が1/2を越えているかど
うかを知れば良いので本方式が適用できる。なお
レジスタ12の内容の最大値は加算を完了して、
減算がまだ完了していない時点では22N+2Nとな
るがこれはMSBが「1」で、更にLSBから数え
てN+1ビツト目が「1」となることを示し、レ
ジスタ12はオーバフローを起すことはないので
問題はない。又シフトレジスタ2−1の2N+1段
目Bとシフトレジスタ2−2の1段目Aとは常に
同じ値を示すので、前記2つのシフトレジスタ2
−1,2−2を合わせて22N+1+1段とし、その
2N+1+1段目の値を論理回路4−1及び4−2に
接続しても同様の動作となることは言うまでもな
い。All you have to do is output this information to the output terminal 14. In normal applications, this method can be applied because it is only necessary to know whether the double moving average value exceeds 1/2. Note that the maximum value of the contents of register 12 is determined by completing the addition.
When the subtraction is not yet completed, it becomes 2 2N + 2 N , which means that the MSB is "1" and the N+1st bit counting from the LSB becomes "1", causing register 12 to overflow. There are no problems, so there is no problem. Also, since the 2 N +1st stage B of the shift register 2-1 and the first stage A of the shift register 2-2 always show the same value, the two shift registers 2
-1, 2-2 are combined to make 2 2N+1 +1 stage, and
It goes without saying that the same operation will occur even if the value of the 2 N+1 +1st stage is connected to the logic circuits 4-1 and 4-2.
次に第5図について説明する。同図の場合にお
いても第4図と同様にシフトレジスタ2−1及び
2−2の段数を2N+1段とすると、前記シフトレ
ジスタ2−1,2−2の2段目〜2N+1段目の
「1」の数の最大値は2Nであり、アツプダウンカ
ウンタ5−1及び5−2は少なくともN+1ビツ
トの容量があれば良い。従つて前記アツプダウン
カウンタ5−1,5−2がN+1ビツトの容量で
あれば、それが最大値を示すときはMSBが「1」
で他のビツトは全て「0」であり、それ以外のと
きはMSBは「0」となる。従つてシフトレジス
タ2−1及び2−2の2段目〜2N+1段目の
「1」の数とそれに対応するアツプダウンカウン
タ5−1及び5−2の内容がそれぞれ合わなくな
つたときには次のように回復される。即ちアツプ
ダウンカウンタ5−1のMSBが「1」となつた
ときは論理回路8−1がこれを検出して、論理回
路4−1の出力を入力する論理回路9−1のゲー
トを閉じて論理回路4−1からアツプカウントの
指示が出てもカウントさせず、逆にアツプダウン
カウンタ5−1の内容が0のときは論理回路4−
1からダウンカウントの指示が出ても論理回路9
−1のゲートを閉じてカウントさせないようにす
る。前記構成にすればシフトレジスタ2−1の2
段目〜2N+1段目の「1」の数と、アツプダウン
カウンタ5−1の内容が合わなくなつても自動的
に回復することは第3図の説明の中で述べたとお
りであるが、論理回路8−1が簡略化される。又
論理回路8−2は論理回路8−1に、又論理回路
9−2は論理回路9−1にそれぞれ対応し、その
働きも同様である。更に論理回路15はレジスタ
12の内容が何らかの原因で正しい値からずれた
ときに自動的に正しい値に復帰させる働きを持つ
ものでシフトレジスタ2−1及び2−2にM+1
段を使つた場合と同様の働きをするものである。
但しデイジタルコンパレータ13及び論理回路1
5の数値判定が簡略化される。レジスタ12、デ
イジタルコンパレータ13及び論理回路15の構
成には種々のものが考えられる。次に一例を示
す。 Next, FIG. 5 will be explained. In the case of the same figure, if the number of stages of shift registers 2-1 and 2-2 is 2 N +1 stages as in FIG. The maximum number of "1"s is 2N , and the up-down counters 5-1 and 5-2 only need to have a capacity of at least N+1 bits. Therefore, if the up-down counters 5-1 and 5-2 have a capacity of N+1 bits, the MSB is "1" when it indicates the maximum value.
All other bits are ``0'', and the MSB is ``0'' in all other cases. Therefore, when the number of "1"s in the second to 2 N +1 stages of the shift registers 2-1 and 2-2 and the contents of the corresponding up-down counters 5-1 and 5-2 no longer match, It is recovered as follows. That is, when the MSB of the up-down counter 5-1 becomes "1", the logic circuit 8-1 detects this and closes the gate of the logic circuit 9-1 which inputs the output of the logic circuit 4-1. Even if an up-count instruction is issued from the logic circuit 4-1, it does not count, and conversely, when the content of the up-down counter 5-1 is 0, the logic circuit 4-1
Even if a down count instruction is issued from 1, the logic circuit 9
-1 gate is closed to prevent counting. With the above configuration, 2 of shift register 2-1
As mentioned in the explanation of Fig. 3, even if the number of "1" in the 2nd to 1st rows and the contents of the up-down counter 5-1 do not match, the system automatically recovers. However, the logic circuit 8-1 is simplified. Further, the logic circuit 8-2 corresponds to the logic circuit 8-1, and the logic circuit 9-2 corresponds to the logic circuit 9-1, and their functions are the same. Furthermore, the logic circuit 15 has the function of automatically restoring the contents of the register 12 to the correct value when it deviates from the correct value for some reason, and inputs M+1 to the shift registers 2-1 and 2-2.
This works in the same way as when using stages.
However, digital comparator 13 and logic circuit 1
5 is simplified. Various configurations of the register 12, digital comparator 13, and logic circuit 15 are possible. An example is shown below.
まずレジスタ12は2N+2ビツトで構成し、
負の数値は2の補数で表わすものとし、MSBが
「1」であれば負であるとする。またオーバーフ
ロー、アンダーフローは適切に処理されるものと
する。レジスタ12の数値と、各ビツトとの対応
を第7図に示す。第6図との違いは符号ビツトと
して1ビツト加えた事と、負の数値を2の補数の
形で考慮していることである。 First, register 12 consists of 2N+2 bits,
Negative numbers are expressed as two's complement numbers, and if the MSB is "1", it is considered negative. Also, overflows and underflows shall be handled appropriately. FIG. 7 shows the correspondence between the numerical value of the register 12 and each bit. The difference from FIG. 6 is that one bit is added as a sign bit, and negative numbers are considered in the form of two's complement.
次に論理回路15の働きを説明する。加算器1
0による加算及び減算器11による減算後のレジ
スタ12のMSBの符号ビツトが「1」ならば、
即ち負ならばこれを論理回路15で検出してレジ
スタ12の内容を0に設定する。又同様に加算、
減算後のレジスタ12のMSBが「0」でMSBの
次のビツトが「1」なら、即ち22N−1を越えて
いるならレジスタ12のMSBおよびMSBの次の
ビツトに「0」を、他のビツトにすべて「1」を
設定する。即ち最大値は22Nであるが、論理回路
15で設定する最大値は22N−1とする。このよ
うにすると最大値に1の誤差が出るがこれは二重
移動平均値の誤差としては1/22Nであり無視できる
値である。以上のように構成すればレジスタ12
の内容の最大値は22N−1に、最小値は0に制限
され何らかの誤動作でレジスタ12の内容が正し
い値からずれてもシフトレジスタ2−1,2−2
がM+1段の場合と同様に自動的に回復できる。
論理回路15の設定が終つた時点でデイジタルコ
ンパレータ13はレジスタ12のMSBの次の次
のビツトを調べ「1」ならば二重移動平均値は1/
2を越えているとし、「0」ならば1/2を越えてい
ないとして出力端子14に出力する。加算、減算
後のレジスタ12の内容が正で22N−1を越えな
いときは、論理回路15の設定は行わないから加
算、減算後にデイジタルコンパレータ13が前述
と同様の動作を行つて出力端子14に出力する。
なおレジスタ12は符号ビツト及びアンダーフロ
ーを考慮しているので、加算器10による加算後
に、減算器11による減算を行う順序を逆にし
て、しかる後に論理回路15、デイジタルコンパ
レータ13を動作させるようにしても全く同様の
結果が得られる。又加算、減算(又は減算、加
算)後に、レジスタ12の内容が22N−1を越え
ているときに論理回路15の働きでレジスタ12
に22Nを設定するようにしても良い。この場合デ
イジタルコンパレータ13の判定はレジスタ12
のMSBの次のビツトとMSBの次の次のビツトの
2ビツトを見ることになる。即ちMSBの次のビ
ツトと、MSBの次の次のビツトのどちらかが
「1」であれば二重移動平均は1/2を越えていると
する。それ以外では1/2を越えていないとすれば
良い。以上はレジスタ12を2N+2ビツトで構
成する例を示した。次にレジスタ12を2N+1
ビツトで構成する例について説明する。 Next, the function of the logic circuit 15 will be explained. Adder 1
If the sign bit of the MSB of register 12 after addition by 0 and subtraction by subtractor 11 is "1", then
That is, if it is negative, the logic circuit 15 detects this and sets the contents of the register 12 to 0. Similarly, add
If the MSB of register 12 after subtraction is ``0'' and the next bit of the MSB is ``1'', that is, if it exceeds 2 2N -1, then set ``0'' to the MSB of register 12 and the next bit of the MSB, and so on. Set all bits to "1". That is, the maximum value is 2 2N , but the maximum value set by the logic circuit 15 is 2 2N -1. If this is done, an error of 1 will occur in the maximum value, but this is 1/2 2N as an error in the double moving average value and is a negligible value. If configured as above, register 12
The maximum value of the contents of is limited to 2 2N -1, and the minimum value is limited to 0. Even if the contents of register 12 deviate from the correct value due to some malfunction, shift registers 2-1 and 2-2
can be automatically recovered in the same way as when it is M+1 stage.
When the setting of the logic circuit 15 is completed, the digital comparator 13 checks the bit next to the MSB of the register 12 and if it is "1", the double moving average value is 1/
If the value exceeds 2, and if it is "0", it is assumed that the value does not exceed 1/2 and is output to the output terminal 14. If the contents of the register 12 after addition and subtraction are positive and do not exceed 2 2N -1, the logic circuit 15 is not set. Output to.
Since the register 12 takes into account the sign bit and underflow, the order in which subtracter 11 performs subtraction after addition by adder 10 is reversed, and then logic circuit 15 and digital comparator 13 are operated. You can get exactly the same results. Also, after addition or subtraction (or subtraction or addition), when the contents of register 12 exceed 2 2N -1, the logic circuit 15
You may also set 2 2N to . In this case, the judgment of the digital comparator 13 is based on the register 12.
You will see two bits: the next bit after the MSB and the next bit after the MSB. That is, if either the next bit after the MSB or the next bit after the MSB is "1", the double moving average exceeds 1/2. Otherwise, it is fine as long as it does not exceed 1/2. The above example shows that the register 12 is composed of 2N+2 bits. Next, set register 12 to 2N+1
An example composed of bits will be explained.
第8図にレジスタ12の数値と、各ビツトとの
対応を示す。レジスタ12の負の数値は第7図の
場合と同様に2の補数で表わし、MSBが「1」
なら負とする。但しMSBの次のビツトが「0」
なら正として扱う。加算、減算後レジスタ12の
MSBが「1」でMSBの次のビツトが「0」な
ら、即ち22N−1を越えているなら論理回路15
が22N−1をレジスタ12に設定する。又レジス
タ12のMSBが「1」でMSBの次のビツトが
「1」なら、即ち負なら同様に0を設定する。デ
イジタルコンパレータ13の判定はMSBの次の
ビツトで行えば二重移動平均値が1/2を越えてい
るかどうかがわかる。又加算、減算後のレジスタ
12の内容が22N−1を越えているときに論理回
路15で、レジスタ12に22Nを設定する方法も
使うことができ、この場合はデイジタルコンパレ
ータ13の判定はMSBと、MSBの次のビツトの
2ビツトを使つて判定することになる。 FIG. 8 shows the correspondence between the numerical value of the register 12 and each bit. The negative value in register 12 is expressed in two's complement as in the case of Fig. 7, and the MSB is "1".
If so, take it as negative. However, the next bit of MSB is “0”
If so, treat it as correct. After addition and subtraction, register 12
If the MSB is "1" and the next bit after the MSB is "0", that is, if it exceeds 2 2N -1, then the logic circuit 15
sets 2 2N −1 in register 12. Also, if the MSB of the register 12 is "1" and the next bit of the MSB is "1", that is, if it is negative, 0 is similarly set. If the judgment by the digital comparator 13 is made using the next bit of the MSB, it can be determined whether the double moving average value exceeds 1/2. It is also possible to use a method in which the logic circuit 15 sets 2 2N in the register 12 when the contents of the register 12 after addition or subtraction exceeds 2 2N -1; in this case, the judgment of the digital comparator 13 is The determination is made using two bits: the MSB and the next bit after the MSB.
以上述べた如くシフトレジスタ2−1及び2−
2に2N+1段を使えば、論理回路15及びデイジ
タルコンパレータ13の数値判定が極めて簡単に
なる。 As mentioned above, shift registers 2-1 and 2-
If 2 N +1 stages are used for 2, the numerical judgment of the logic circuit 15 and the digital comparator 13 becomes extremely simple.
(発明の効果)
以上説明したように本発明によれば、簡単なデ
イジタル回路を構成することにより二重移動平均
値をデイジタル的に簡単に求めることができるの
でLSI化に有用である。(Effects of the Invention) As explained above, according to the present invention, the double moving average value can be easily obtained digitally by configuring a simple digital circuit, and is therefore useful for LSI implementation.
第1図、第3図は従来の構成を示す回路図、第
2図は論理回路の動作を示す説明図、第4図は本
発明に係る第1、第3の実施例を示す回路図、第
5図は本発明に係る第2、第4の実施例を示す回
路図、第6図、第7図及び第8図はレジスタの数
値と各ビツトとの対応を示す説明図である。
1……入力端子、2,2−1,2−2……シフ
トレジスタ、3……サンプリングクロツク用発振
器、4,4−1,4−2,8,8−1,8−2,
9,9−1,9−2,15……論理回路、5,5
−1,5−2……アツプダウンカウンタ、6,1
3……デイジタルコンパレータ、10……加算
器、11……減算器、12……レジスタ、7,1
4……出力端子。
1 and 3 are circuit diagrams showing a conventional configuration, FIG. 2 is an explanatory diagram showing the operation of a logic circuit, and FIG. 4 is a circuit diagram showing a first and third embodiment according to the present invention, FIG. 5 is a circuit diagram showing the second and fourth embodiments of the present invention, and FIGS. 6, 7, and 8 are explanatory diagrams showing the correspondence between the numerical values of the register and each bit. 1... Input terminal, 2, 2-1, 2-2... Shift register, 3... Sampling clock oscillator, 4, 4-1, 4-2, 8, 8-1, 8-2,
9, 9-1, 9-2, 15...Logic circuit, 5, 5
-1,5-2...Updown counter, 6,1
3...Digital comparator, 10...Adder, 11...Subtractor, 12...Register, 7,1
4...Output terminal.
Claims (1)
に同期して書き込まれるM+1(Mは正の整数)
段シフトレジスタと、少なくともMまでカウント
できるアツプダウンカウンタと、前記M+1段シ
フトレジスタの1段目と最後にデータが書き込ま
れるM+1段目のデータが同じ値のときはカウン
トせず、M+1段シフトレジスタの1段目とM+
1段目のデータが異なる値のときは異なる状態に
応じて前記発振器と同期してアツプカウント又は
ダウンカウントする2組の移動平均値検出回路
を、前段のM+1段シフトレジスタのM段目の出
力を後段のM+1段シフトレジスタの1段目に書
き込むように接続し、少なくともM2+Mまで格
納できるレジスタと、前段のアツプダウンカウン
タのカウント内容をレジスタに加算する加算器
と、後段のアツプダウンカウンタのカウント内容
をレジスタから減算する減算器と、デイジタルコ
ンパレータを有し、該デイジタルコンパレータで
前記レジスタの内容と一定値とを比較し、該一定
値を越えたかどうかを判定することを特徴とした
二重移動平均値検出方式。 2 シフトレジスタの段数を2N+1段(Nは正の
整数)、アツプダウンカウンタをN+1ビツトの
容量とする2組の移動平均値検出回路を、前段の
2N+1段シフトレジスタの2N段目の出力を後段の
2N+1段シフトレジスタの1段目に書き込むよう
に接続した特許請求の範囲第1項記載の二重移動
平均値検出方式。 3 サンプリングクロツク用発振器と、該発振器
に同期して書き込まれるM+1(Mは正の整数)
段シフトレジスタと、少なくともMまでカウント
できるアツプダウンカウンタと、前記M+1段シ
フトレジスタの1段目と最後にデータが書き込ま
れるM+1段目のデータが同じ値のときはカウン
トせず、M+1段シフトレジスタの1段目とM+
1段目のデータが異なる値のときは異なる状態に
応じて前記発振器と同期してアツプカウント又は
ダウンカウントし、かつアツプダウンカウンタの
カウント数が「M」のときはアツプカウントの条
件が成立してもアツプカウントせず、アツプダウ
ンカウンタのカウント数が「0」となつたときは
ダウンカウントの条件が成立してもダウンカウン
トしない2組の移動平均値検出回路を、前段のM
+1段シフトレジスタのM段目の出力を後段のM
+1段シフトレジスタの1段目に書き込むように
接続し、少なくともM2+Mまで格納できるレジ
スタと、前段のアツプダウンカウンタのカウント
内容をレジスタに加算する加算器と、後段のアツ
プダウンカウンタのカウント内容をレジスタから
減算する減算器と、デイジタルコンパレータを有
し、レジスタの内容が減算を完了した時点でM2
を越えているときはレジスタの内容をM2とし、
レジスタの内容が減算を完了した時点で「0」以
下のときは「0」とし、前記デイジタルコンパレ
ータでレジスタの内容と一定値とを比較し、該一
定値を越えたかどうかを判定することを特徴とし
た二重移動平均値検出方式。 4 シフトレジスタの段数を2N+1段(Nは正の
整数)、アツプダウンカウンタをN+1ビツトの
容量とする2組の移動平均値検出回路を、前段の
2N+1段シフトレジスタの2N段目の出力を後段の
2N+1段シフトレジスタの1段目に書き込むよう
に接続し、レジスタを2N+1まで格納できる2N
+1レジスタとし、N+1ビツトアツプダウンカ
ウンタのMSBが「1」となつたときはアツプカ
ウントの条件が成立してもアツプカウントせず、
N+1ビツトアツプダウンカウンタの各ビツトが
全て「0」となつたときはダウンカウントの条件
が成立してもダウンカウントせず、2N+1レジ
スタが加算又は減算を完了した時点で2N+1レ
ジスタの内容が22N−1を越えているときは前記
内容を22N−1又は22Nとし、2N+1レジスタの
内容が負のときは前記内容を「0」とすることを
特徴とした特許請求の範囲第3項記載の二重移動
平均値検出方式。[Claims] 1. A sampling clock oscillator and M+1 (M is a positive integer) written in synchronization with the oscillator.
A stage shift register, an up-down counter that can count up to at least M, and an M+1 stage shift register that does not count when the first stage of the M+1 stage shift register and the data of the M+1 stage where data is finally written are the same value. 1st stage and M+
When the first stage data has different values, two sets of moving average value detection circuits that perform up-counting or down-counting in synchronization with the oscillator according to different states are connected to the M-stage output of the M+1-stage shift register in the previous stage. A register that can store at least M 2 +M, an adder that adds the count contents of the up-down counter in the previous stage to the register, and an up-down counter in the latter stage. A subtracter that subtracts the count contents of the register from the register, and a digital comparator, the digital comparator compares the contents of the register with a constant value, and determines whether or not the register exceeds the constant value. Heavy moving average value detection method. 2. Two sets of moving average value detection circuits each having a shift register with 2 N +1 stages (N is a positive integer) and an up-down counter with a capacity of N+1 bits are installed in the previous stage.
The output of the 2N stage of the 2 N +1 stage shift register is
2. The double moving average value detection method according to claim 1, which is connected to write to the first stage of a 2 N +1 stage shift register. 3 Sampling clock oscillator and M+1 written in synchronization with the oscillator (M is a positive integer)
A stage shift register, an up-down counter that can count up to at least M, and an M+1 stage shift register that does not count when the first stage of the M+1 stage shift register and the data of the M+1 stage where data is finally written are the same value. 1st stage and M+
When the first stage data has different values, up-counting or down-counting is performed in synchronization with the oscillator according to different states, and when the count number of the up-down counter is "M", the up-counting condition is satisfied. Two sets of moving average value detection circuits that do not count up even when the up-down counter reaches "0" and do not count down even if the down-counting conditions are met are connected to the M in the previous stage.
The output of the Mth stage of the +1 stage shift register is transferred to the Mth stage of the subsequent stage.
A register connected to write to the first stage of the +1 stage shift register and capable of storing at least M 2 +M, an adder that adds the count contents of the up-down counter in the previous stage to the register, and the count contents of the up-down counter in the subsequent stage. It has a subtractor that subtracts M from the register and a digital comparator, and when the contents of the register are M 2 when the subtraction is completed,
If it exceeds, set the contents of the register to M 2 ,
If the contents of the register are "0" or less at the time when the subtraction is completed, it is set as "0", and the digital comparator compares the contents of the register with a certain value to determine whether the value exceeds the certain value. Double moving average value detection method. 4 Two sets of moving average value detection circuits each having a shift register stage of 2 N +1 stages (N is a positive integer) and an up-down counter having a capacity of N+1 bits are installed in the previous stage.
The output of the 2N stage of the 2 N +1 stage shift register is
2N + 1-stage shift register, connected to write to the first stage and capable of storing up to 2N+1 registers.
+1 register, and when the MSB of the N+1 bit up-down counter becomes "1", it does not count up even if the up-counting conditions are met;
When each bit of the N+1 bit up-down counter becomes "0", it does not count down even if the down-counting conditions are met, and when the 2N+1 register completes addition or subtraction, the contents of the 2N+1 register become 2 2N. Claim 3, characterized in that when the content exceeds -1, the content is set to 2 2N -1 or 2 2N , and when the content of the 2N+1 register is negative, the content is set to "0". double moving average value detection method.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP8666783A JPS59212978A (en) | 1983-05-19 | 1983-05-19 | Detection system of double running mean value |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP8666783A JPS59212978A (en) | 1983-05-19 | 1983-05-19 | Detection system of double running mean value |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JPS59212978A JPS59212978A (en) | 1984-12-01 |
| JPH0145097B2 true JPH0145097B2 (en) | 1989-10-02 |
Family
ID=13893380
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP8666783A Granted JPS59212978A (en) | 1983-05-19 | 1983-05-19 | Detection system of double running mean value |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JPS59212978A (en) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP4703194B2 (en) * | 2005-01-17 | 2011-06-15 | 三洋電機株式会社 | Sold-out detection system for beverage dispensers |
| JP5806442B2 (en) * | 2008-12-01 | 2015-11-10 | セイコーエプソン株式会社 | Frequency change measuring device |
-
1983
- 1983-05-19 JP JP8666783A patent/JPS59212978A/en active Granted
Also Published As
| Publication number | Publication date |
|---|---|
| JPS59212978A (en) | 1984-12-01 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US4379338A (en) | Arithmetic circuit with overflow detection capability | |
| US4193118A (en) | Low pass digital averaging filter | |
| EP0356598A1 (en) | Digital filter for a modem sigma-delta analog-to-digital converter | |
| US4561065A (en) | Arithmetic processing device using sampled input data and several previous output data | |
| US5553103A (en) | Circuit including a subtractor, an adder, and first and second clocked registers connected in series | |
| US3609568A (en) | Stable digital filter apparatus | |
| EP0510756A2 (en) | Sample tuning recovery for receivers using Viterbi processing | |
| EP0374214B1 (en) | Variable rate rectangular matched filter | |
| JPH0145097B2 (en) | ||
| US5768322A (en) | Transferred data recovery apparatus | |
| KR100474819B1 (en) | Method for detecting a signal and an apparatus thereof in a data recording/reproducing apparatus | |
| US6590948B1 (en) | Parallel asynchronous sample rate reducer | |
| JPH069106B2 (en) | Digital data detector | |
| JPS6131488B2 (en) | ||
| JPH0410776B2 (en) | ||
| US6542539B1 (en) | Multiported register file for coefficient use in filters | |
| JPH0138244B2 (en) | ||
| JPH09128213A (en) | Block floating processing system and method | |
| JP3074958B2 (en) | Serial multiplier with addition function | |
| CN111310522A (en) | Method and equipment for removing direct current | |
| KR930009103B1 (en) | Digital Audio Signal Interpolator | |
| JPH0311124B2 (en) | ||
| SU1529246A1 (en) | Device for adaptive sliding levelling-out | |
| JPH084234B2 (en) | Metric calculation method | |
| JPH08125494A (en) | Moving average filter |