JP3950793B2 - Digital / analog conversion method and apparatus - Google Patents
Digital / analog conversion method and apparatus Download PDFInfo
- Publication number
- JP3950793B2 JP3950793B2 JP2002375332A JP2002375332A JP3950793B2 JP 3950793 B2 JP3950793 B2 JP 3950793B2 JP 2002375332 A JP2002375332 A JP 2002375332A JP 2002375332 A JP2002375332 A JP 2002375332A JP 3950793 B2 JP3950793 B2 JP 3950793B2
- Authority
- JP
- Japan
- Prior art keywords
- output
- value
- digital
- analog
- low
- 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 - Fee Related
Links
Images
Description
【0001】
【発明の属する技術分野】
本発明は、マイクロコンピュータのポート出力を制御して所定のアナログ信号を得るためのデジタル/アナログ変換方法およびデジタル/アナログ変換装置に関する。
【0002】
【従来の技術】
従来のデジタル/アナログ(D/A)変換装置の回路構成としては、図7に示すようなものが知られている(例えば、特許文献1参照。)。
【0003】
マイクロコンピュータ01は、アップカウンタ02と、タイマレジスタ03と、コンパレータ04と、アナログ/デジタル(A/D)変換器05とを備えている。アップカウンタ02内部クロックが入力されると、内部バスを通じ、カウント時間が予め決めた時間に対応する値がタイマレジスタ03にセットされる。アップカウンタ02のアップカウンタ値とタイマレジスタ03の値とがコンパレータ04により比較され、両者の値が一致したときマイクロコンピュータ01に割り込みが発生するとともに、アップカウンタ02がクリアされる。
【0004】
このように、タイマレジスタ03に所望のデータをセットすることで一定時間毎の割り込みを発生させることができ、タイマ割り込みの中で処理された結果がPWM信号VAとしてポート出力される。
【0005】
このVAは抵抗R1およびコンデンサC1とから構成されるローパスフィルタ06により積分され、VBに示すアナログ波形に変換される。このVBは非反転増幅器07に入力されてVCが得られる。なお、このVCは、抵抗R4およびコンデンサC2とから構成されるローパスフィルタ08を通過することにより、電圧リップルを軽減された後、ボルテージフォロワ09からVDとして出力されるとともに、A/D変換部05にも電圧変換されたVC'として入力される。
【0006】
マイクロコンピュータ01は、A/D変換部05に入力されたVC'とD/A出力設定値VTとを比較し、VT>VC'のときにはポート出力をロー、VT>VC'のときにはポート出力をハイとする。
【0007】
このように、従来のD/A変換装置では、タイマ割り込みルーチンを利用することにより、マイクロコンピュータ01のタイマを独占することなく、マイクロコンピュータ01からポート出力されたPWM信号VAを、所望のアナログ信号VDに変換することができる。
【0008】
【特許文献1】
特開平6−4218号公報
【0009】
【発明が解決しようとする課題】
しかしながら、上記従来のD/A変換装置では、マイクロコンピュータ01から出力されたPWM信号VAを、ローパスフィルタ06を用いてアナログ信号VBに変換しているため、VBには一定周期のリップルが含まれる。従って、このリップルを取り除くために、VBをPWM信号の周期に対して十分長い時定数のローパスフィルタ08を用いる必要があった。
【0010】
すなわち、D/A出力設定値VTを変えるためにPWM信号VAのデューティを変化させたときの応答性が悪く、VCがD/A出力設定値VTとなるまでの応答遅れが大きいという問題があった。
【0011】
本発明は、上記問題に着目してなされたもので、その目的とするところは、リップルの抑制と高応答性との両立を達成できるデジタル/アナログ変換方法およびデジタル/アナログ変換装置を提供することにある。
【0012】
【課題を解決するための手段】
上述の目的を達成するため、本発明請求項1に記載のデジタル/アナログ変換方法では、マイクロコンピュータに対する一定時間毎の割り込み発生時に実行されるデジタル/アナログ変換方法において、出力設定値に基づいてマイクロコンピュータの出力ポートから出力される信号をローパスフィルタに入力し、このローパスフィルタから出力されるアナログ信号を対応するデジタル信号に変換し、変換されたデジタル信号値と出力設定値との差の絶対値を求め、この絶対値が予め設定されたしきい値以上のとき、前記出力設定値とデジタル信号値とを比較し、前記出力設定値がデジタル信号値よりも大きいとき、前記絶対値に比例した時間出力ポートをハイとした後、出力ポートをスリーステートとする一方、前記出力設定値がデジタル信号値以下であるとき、前記絶対値に比例した時間出力ポートをローとした後、出力ポートをスリーステートとすることを特徴とする。
【0013】
請求項2に記載の発明では、請求項1に記載のデジタル/アナログ変換方法において、前記ローパスフィルタのカットオフ周波数を、割り込み時間の間隔以下の周期に設定したことを特徴とする。
【0014】
請求項3に記載のデジタル/アナログ変換装置では、マイクロコンピュータと、このマイクロコンピュータに所定時間毎に割り込みをかけるタイマと、前記マイクロコンピュータの出力ポートから出力される信号をアナログ信号に変換して出力するローパスフィルタと、このローパスフィルタから出力されるアナログ信号を対応するデジタル信号に変換するアナログ/デジタル変換手段と、を備え、前記マイクロコンピュータは、割り込みが発生したとき、変換されたデジタル信号値と出力設定値との差の絶対値を求め、前記出力設定値とデジタル信号値とを比較し、前記出力設定値がデジタル信号値よりも大きいとき、前記絶対値に比例した時間出力ポートをハイとした後、出力ポートをスリーステートとする一方、出力設定値がデジタル信号値以下であるとき、前記絶対値に比例した時間出力ポートをローとした後、出力ポートをスリーステートとするポート出力判断部を備えることを特徴とする。
【0015】
請求項4に記載の発明では、請求項3に記載のデジタル/アナログ変換装置において、前記ローパスフィルタのカットオフ周波数を、割り込み時間の間隔以下の周期に設定したことを特徴とする。
【0016】
請求項5に記載の発明では、請求項3または請求項4に記載のデジタル/アナログ変換装置において、前記ポート出力判断部は、前記絶対値と予め設定されたしきい値とを比較し、絶対値がしきい値を超えていないとき、次回の割り込み発生時まで出力ポートをスリーステートのまま保持することを特徴とする。
【0017】
請求項6に記載の発明では、請求項3ないし請求項5のいずれか1項に記載のデジタル/アナログ変換装置において、前記ポート出力判断部は、予めハイとローで別々に設定した比例係数に前記絶対値を乗じて出力ポートをハイまたはローとする時間を設定することを特徴とする。
【0018】
請求項7に記載の発明では、請求項3ないし請求項6に記載のデジタル/アナログ変換装置において、前記マイクロコンピュータに出力ポートを複数設定するとともに、この出力ポート毎にタイマ、ローパスフィルタをそれぞれ設け、前記アナログ/デジタル変換手段にローパスフィルタから出力されるアナログ信号の数に応じて複数のチャンネルを設定し、前記マイクロコンピュータに、アナログ/デジタル変換手段に入力されたアナログ信号がどのチャンネルに入力されたかを検出するチャンネル検出部を設け、検出されたチャンネルに対応する出力ポートから信号を出力することを特徴とする。
【0019】
【発明の効果】
請求項1に記載のデジタル/アナログ変換方法では、タイマ割り込み時に、ローパスフィルタから出力されたアナログ信号に対応するデジタル信号値と出力設定値との差の絶対値を求めるとともに、この絶対値が予め設定されたしきい値以上のとき、出力設定値とデジタル信号値とを比較する。
【0020】
そして、出力設定値がデジタル信号値よりも大きい場合には、絶対値に比例した時間出力ポートをハイとし、その後、出力ポートをスリーステート(入力モード)とする。一方、出力設定値がデジタル信号値以下である場合には、絶対値に比例した時間出力ポートをローとし、その後、出力ポートをスリーステートとする。
【0021】
すなわち、本発明では、理論的には、レベルを変化させた一瞬のみ出力ポートより信号が出力されるため、ローパスフィルタの時定数を小さく設定することができ、高応答性とリップルの抑制の両立を図ることができる。
【0022】
請求項2に記載のデジタル/アナログ変換方法では、ローパスフィルタのカットオフ周波数を割り込み時間の間隔と同一または短い周期に設定することにより、応答性をさらに向上させることができる。
【0023】
請求項3に記載のデジタル/アナログ変換装置では、ポート出力判断部は、タイマ割り込み時に、アナログ/デジタル変換手段から出力されたデジタル信号値と出力設定値との差の絶対値を求め、さらに出力設定値とデジタル信号値とを比較する。
【0024】
そして、出力設定値がデジタル信号値よりも大きい場合には、絶対値に比例した時間出力ポートをハイとし、その後、出力ポートをスリーステート(入力モード)とする。一方、出力設定がデジタル信号値以下である場合には、絶対値に比例した時間出力ポートをローとし、その後、出力ポートをスリーステートとする。
【0025】
従って、レベルを変化させた一瞬のみ出力ポートより信号が出力されるため、ローパスフィルタの時定数を小さく設定することができ、高応答性とリップルの抑制の両立を図ることができる。
【0026】
また、アナログ/デジタル変換手段の分解能を高くすることにより、得られるアナログ信号の分解能を向上させることができる。
【0027】
請求項4に記載のデジタル/アナログ変換装置では、ローパスフィルタのカットオフ周波数を割り込み時間の間隔と同一または短い周期に設定することにより、応答性をさらに向上させることができる。
【0028】
請求項5に記載のデジタル/アナログ変換装置では、絶対値がしきい値を超えていない場合には、次回の割り込み発生時まで出力ポートをスリーステートのまま保持することにより、ノイズ等で常にアナログ/デジタル変換手段から出力されるデジタル信号値が出力設定値と一致しないとき、タイマ割り込み毎にデジタル信号値と出力設定値との差の絶対値に比例した時間分出力ポートがハイまたはローになることに起因してアナログ値が不安定になるのを防止することができる。
【0029】
請求項6に記載のデジタル/アナログ変換装置では、ハイとローで別々の比例係数を設定することにより、応答性が必要な側のみ速くすることが可能である。
【0030】
請求項7に記載のデジタル/アナログ変換装置では、アナログ/デジタル変換手段に入力されたアナログ信号がどのチャンネルに入力されたかを検出し、検出されたチャンネルに対応する出力ポートから信号を出力することにより、所望のアナログ信号を複数出力することができる。
【0031】
【発明の実施の形態】
以下に、本発明のデジタル/アナログ変換装置を実現する実施の形態を、第1実施例と第2実施例とに基づいて説明する。
【0032】
(第1実施例)
まず、構成を説明する。
図1は、第1実施例のデジタル/アナログ変換装置の回路図である。
【0033】
マイクロコンピュータ1は、ポート出力判断部2と、A/D変換部(アナログ/デジタル変換手段)3とを備えている。ポート出力判断部2は、一定時間毎に発生するタイマ割り込み要求に応じて、セットされたD/A出力設定値VTとA/D変換部3からの信号VC'とを比較し、出力ポートPC1からVAを出力する。
【0034】
このVAの出力タイミングを図2に示す。図に示すように、ポート出力VAは、"ローレベル(ロー)"、"ハイレベル(ハイ)"および"ハイ・インピーダンス状態(スリーステート)"のデジタルデータとして出力される。このVAは、抵抗R1およびコンデンサC1で構成されるローパスフィルタ4を通して積分され、アナログ信号VBとなった後、非反転増幅器5により増幅されて最終出力Vcが得られる。また、Vcは、A/D変換部3の入力ポートAN1にも電圧変換されたVC'として入力されている。
【0035】
非反転増幅器5のゲイン(増幅率)は、(最終的に欲しい最大出力電圧)/(VC'の最大値)により決定される。
【0036】
なお、図2中のP1〜P3のパルスにおいて、D/A出力設定値VTが変化していないにも拘わらず、パルスが出力されているのは、コンデンサC1または非反転増幅器5の入力の漏れ電流等でA/D変換出力電圧VC'が低下したためである。
【0037】
図3は、D/A出力設定値VT一定時において、コンデンサC1および非反転増幅器5の入力漏れ電流等が無い状態であり、ポート出力VAは、スリーステートのままとなる。
【0038】
本実施例のD/A変換回路の構成は、図7に示した従来のD/A変換回路からローパスフィルタ08とボルテージフォロワ09を削除したものと略同一の構成となっている。
【0039】
さらに、ローパスフィルタ4についても、図7のローパスフィルタ06における抵抗R1およびコンデンサC1よりも、時定数の小さな抵抗R1′およびコンデンサC1′が用いられている。そして、ローパスフィルタ4のカットオフ周波数は、タイマの割り込み時間の間隔よりも短い周期に設定されている。
【0040】
次に、作用を説明する。
[D/A変換制御処理]
マイクロコンピュータ1では、メインとなる所定の制御の他に、D/A出力設定値VTをセットするサブルーチンが実行される。このサブルーチンでは、別のルーチン等により決定された目標値、つまりD/A出力設定値VTがセットされる。タイマ割り込み時間が設定されると、所定時間ごとにタイマ割り込みが発生する。このタイマ割り込みが発生すると、タイマ割り込みルーチンが実行される。
【0041】
図4は、マイクロコンピュータ1のタイマ割り込みルーチンで実行されるD/A変換制御処理の流れを示すフローチャートである。
【0042】
ステップS1では、A/D変換部3から出力されたA/D変換値VC'を読み込む。
【0043】
ステップS2では、D/A出力設定値VTを読み込む。
【0044】
ステップS3では、A/D変換値VC'とD/A出力設定値VTとの差の絶対値を求め、結果をマイクロコンピュータ1のRAM上に確保したリザルトR1に書き込む。
【0045】
ステップS4では、リザルトR1と予め設定されたしきい値A1とを比較し、リザルトR1がしきい値A1よりも小さい場合には本制御を終了し、リザルトR1がしきい値A1以上である場合にはステップS5へ進む。
【0046】
ステップS5では、A/D変換値VC'とD/A出力設定値VTとを比較し、VTがVCを超えている場合にはステップS6に進み、VTがVC以下の場合にはステップS7へ進む。
【0047】
ステップS6では、リザルトR1に予め設定された比例係数A2を乗じた値をRAM上に確保したON時間C1に書き込み、ポート出力VAのレベルを"ハイ"とする。
【0048】
ステップS7では、リザルトR1に予め設定された比例係数A3を乗じた値をRAM上に確保したON時間C1に書き込み、ポート出力VAのレベルを"ロー"とする。
【0049】
なお、本実施例では、ON時間C1は、ステップS8→ステップS9→ステップS8をループする回数として設定している。
【0050】
ステップS8では、ON時間C1が0かどうかを判断し、ON時間C1が0である場合にはステップS10へ進み、ON時間C1が0以外である場合にはステップS9へ進む。
【0051】
ステップS9では、ON時間C1をデクリメントする。
【0052】
ステップS10では、ポートの入出力方向を入力(スリーステート)にして本制御を終了する。
【0053】
[D/A変換制御作用]
D/A出力設定値VTがA/D変換値VC'よりも大きく、その差がしきい値A1以上である場合には、図4のフローチャートにおいて、ステップS1→ステップS2→ステップS3→ステップS4→ステップS5→ステップS6→ステップS8→ステップS10へと進む流れとなる。
【0054】
すなわち、ステップS6において、ON時間C1をリザルトR1と比例係数A2とを乗じて設定するとともにポート出力VAをハイとし、ステップS8とステップS9において、ON時間C1が0となるまでカウントダウンした後、ステップS10においてポート出力をスリーステートとする。
【0055】
D/A出力設定値VTがA/D変換値VC'以下であり、その差がしきい値A1以上である場合には、図4のフローチャートにおいて、ステップS1→ステップS2→ステップS3→ステップS4→ステップS5→ステップS7→ステップS8→ステップS10へと進む流れとなる。
【0056】
すなわち、ステップS7において、ON時間C1をリザルトR1と比例係数A3とを乗じて設定するとともにポート出力VAをローとし、ステップS8とステップS9において、ON時間C1が0となるまでカウントダウンした後、ステップS10においてポート出力をスリーステートとする。
【0057】
D/A出力設定値VTとA/D変換値VC'との差がしきい値A1よりも小さい場合には、図4のフローチャートにおいて、ステップS1→ステップS2→ステップS3→ステップS4へと進み、ポート出力VAの状態を変えずに本制御を終了する。
【0058】
次に、効果を説明する。
本実施の形態のデジタル/アナログ変換装置は、次に列挙する効果を奏する。
【0059】
(1) 出力設定値VTがデジタル信号値VC'よりも大きい場合には、リザルトR1に比例したON時間C1の間出力ポートPC1をハイとした後、出力ポートPC1をスリーステート(入力モード)とする一方、出力設定値VTがデジタル信号値VC'以下である場合には、リザルトR1に比例したON時間C1の間出力ポートPC1をローとした後、出力ポートPC1をスリーステートとすることにより、ローパスフィルタ4の時定数を小さく設定することができ、高応答性とリップルの抑制の両立を図ることができる。
【0060】
(2) ローパスフィルタ4として時定数の小さな抵抗R1′およびコンデンサC1′を用い、カットオフ周波数を、タイマの割り込み時間の間隔よりも短い周期に設定したため、高応答性を確保することができる。
【0061】
(3) リザルトR1がしきい値A1以下である場合には、出力ポートPC1をスリーステートのままとすることにより、ノイズ等で常にA/D変換部3から出力されるA/D変換出力電圧VC'が出力設定値VTと一致しないとき、タイマ割り込み毎に出力ポートPC1がハイまたはローとなった場合であっても、アナログ信号VCが不安定になるのを防止することができる。
【0062】
(4) D/A出力設定値VTがA/D変換値VC'よりも大きい場合にはON時間C1をリザルトR1と比例係数A2とを乗じて設定し、D/A出力設定値VTがA/D変換値VC'以下である場合にはON時間C1をリザルトR1と比例係数A3とを乗じて設定することとしたため、応答性が必要な側のみ速くすることが可能である。
【0063】
(第2実施例)
まず、構成を説明する。
第2実施例のデジタル/アナログ変換回路の構成は、第1実施例の構成に、D/A出力回路を1チャンネル追加したものである。
【0064】
ローパスフィルタ4と非反転増幅器5をもう1回路追加し、A/D変換部3は、入力チャンネルを2チャンネル(AN1とAN2)とし、追加した出力回路のフィードバック電圧VC''を追加したチャンネルに入力する。
【0065】
D/A出力回路が2チャンネルとなることにより変更したポート出力判断部2も2チャンネルとする。
【0066】
次に、作用を説明する。
[D/A変換制御処理]
第2実施例のD/A変換制御処理は、図4に示したフローチャートにおいて、ステップS1とステップS2との間にステップS21を追加し、ステップS10の後にステップS22を追加したものであり、図4と異なる部分のみ説明する。
【0067】
ステップS21では、A/D変換部3のチャンネルがこれから出力するポートに対応するチャンネル(AN1またはAN2)になっているかをチェックする。A/D変換部3のチャンネルがこれから出力するポートに対応するチャンネルになっている場合にはステップS2へ進み、A/D変換部3のチャンネルがこれから出力するポートに対応するチャンネルになっていない場合、本制御を終了する。
【0068】
ステップS4では、リザルトR1と予め設定されたしきい値A1とを比較し、リザルトR1がしきい値A1よりも小さい場合にはステップS22へ進み、リザルトR1がしきい値A1以上である場合にはステップS5へ進む。
【0069】
ステップS22では、A/D変換部3のチャンネルを別のチャンネルに変更して本制御を終了する。
【0070】
次に、効果を説明する。
(5) A/D変換部3のチャンネルがこれから出力するポートに対応するチャンネルになっている場合にのみ対応する出力ポートPC1(PC2)からポート信号VA(VA')を出力するため、所望のアナログ信号を複数出力することができる。
【0071】
(その他の実施例)
【0072】
以上、本発明の実施の形態を第1実施例および第2実施例に基づいて説明してきたが、本発明の具体的な構成は、第1実施例および第2実施例に限定されるものではなく、発明の要旨を逸脱しない範囲の設計変更等があっても本発明に含まれる。
【0073】
例えば、しきい値A1および比例係数A2,A3の値は、予め実験等により設定しても、装置を実際に動作させてから設定してもよい。
【図面の簡単な説明】
【図1】第1実施例のデジタル/アナログ変換装置の回路図である。
【図2】ポート出力VAの出力タイミングを示す図である。
【図3】コンデンサC1および非反転増幅器5の入力漏れ電流等が無い状態でのポート出力VAの出力タイミングを示す図である。
【図4】第1実施例に係るマイクロコンピュータ1のタイマ割り込みルーチンで実行されるD/A変換制御処理の流れを示すフローチャートである。
【図5】第2実施例のデジタル/アナログ変換装置の回路図である。
【図6】第2実施例に係るマイクロコンピュータ1のタイマ割り込みルーチンで実行されるD/A変換制御処理の流れを示すフローチャートである。
【図7】従来のデジタル/アナログ変換装置の回路図である。
【符号の説明】
1 マイクロコンピュータ
2 ポート出力判断部
3 A/D変換部
4 ローパスフィルタ
5 非反転増幅器[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a digital / analog conversion method and a digital / analog conversion device for obtaining a predetermined analog signal by controlling a port output of a microcomputer.
[0002]
[Prior art]
As a circuit configuration of a conventional digital / analog (D / A) conversion device, one as shown in FIG. 7 is known (for example, refer to Patent Document 1).
[0003]
The
[0004]
As described above, by setting desired data in the
[0005]
This V A is integrated by a low-pass filter 06 composed of a resistor R 1 and a capacitor C 1 and converted into an analog waveform indicated by V B. This V B is input to the non-inverting amplifier 07 to obtain V C. The voltage V C is reduced as a voltage ripple by passing through a low-pass filter 08 including a resistor R 4 and a capacitor C 2, and then output from the voltage follower 09 as V D. Also input to the
[0006]
The
[0007]
As described above, in the conventional D / A converter, by using the timer interrupt routine, the PWM signal V A output from the
[0008]
[Patent Document 1]
Japanese Patent Laid-Open No. 6-4218
[Problems to be solved by the invention]
However, the conventional D / A converting device, a PWM signal V A output from the
[0010]
That is, poor response when changing the duty of the PWM signal V A to alter the D / A output setting value V T, is large response delay until V C is D / A output setting value V T There was a problem.
[0011]
The present invention has been made paying attention to the above problems, and an object of the present invention is to provide a digital / analog conversion method and a digital / analog conversion apparatus capable of achieving both suppression of ripple and high response. It is in.
[0012]
[Means for Solving the Problems]
In order to achieve the above object, in the digital / analog conversion method according to the first aspect of the present invention, in the digital / analog conversion method executed at the time of occurrence of an interrupt to the microcomputer at regular intervals, the micro / analog conversion method is performed based on the output set value. The signal output from the computer output port is input to the low-pass filter, the analog signal output from this low-pass filter is converted to the corresponding digital signal, and the absolute value of the difference between the converted digital signal value and the output setting value When the absolute value is equal to or greater than a preset threshold value, the output set value is compared with the digital signal value, and when the output set value is greater than the digital signal value, the output value is proportional to the absolute value. After setting the time output port to high, the output port is set to three-state while the output set value is When it is a value or less, after the low time output port proportional to the absolute value, characterized in that the output port and three-state.
[0013]
According to a second aspect of the present invention, in the digital / analog conversion method according to the first aspect, the cut-off frequency of the low-pass filter is set to a period equal to or less than the interval of interrupt times.
[0014]
4. The digital / analog converter according to
[0015]
According to a fourth aspect of the present invention, in the digital / analog conversion device according to the third aspect, the cut-off frequency of the low-pass filter is set to a period equal to or less than the interrupt time interval.
[0016]
According to a fifth aspect of the present invention, in the digital / analog conversion device according to the third or fourth aspect, the port output determination unit compares the absolute value with a preset threshold value, When the value does not exceed the threshold value, the output port is held in the three state until the next interrupt occurrence.
[0017]
According to a sixth aspect of the present invention, in the digital / analog conversion device according to any one of the third to fifth aspects, the port output determination unit sets a proportional coefficient set separately for high and low in advance. The absolute value is multiplied to set a time for the output port to be high or low.
[0018]
According to a seventh aspect of the present invention, in the digital / analog conversion device according to the third to sixth aspects, a plurality of output ports are set in the microcomputer, and a timer and a low-pass filter are provided for each output port. A plurality of channels are set according to the number of analog signals output from the low-pass filter in the analog / digital conversion means, and the analog signal input to the analog / digital conversion means is input to which channel to the microcomputer. A channel detection unit for detecting whether or not the signal is detected and a signal is output from an output port corresponding to the detected channel.
[0019]
【The invention's effect】
In the digital / analog conversion method according to claim 1, the absolute value of the difference between the digital signal value corresponding to the analog signal output from the low-pass filter and the output set value is obtained at the time of timer interruption, and the absolute value is calculated in advance. When the set threshold value is exceeded, the output set value is compared with the digital signal value.
[0020]
When the output set value is larger than the digital signal value, the time output port proportional to the absolute value is set to high, and then the output port is set to three-state (input mode). On the other hand, when the output set value is equal to or less than the digital signal value, the time output port proportional to the absolute value is set to low, and then the output port is set to three-state.
[0021]
That is, in the present invention, since a signal is output from the output port only for a moment when the level is changed, the time constant of the low-pass filter can be set small, and both high responsiveness and ripple suppression are compatible. Can be achieved.
[0022]
In the digital / analog conversion method according to the second aspect, the responsiveness can be further improved by setting the cut-off frequency of the low-pass filter to be equal to or shorter than the interrupt time interval.
[0023]
In the digital / analog conversion device according to
[0024]
When the output set value is larger than the digital signal value, the time output port proportional to the absolute value is set to high, and then the output port is set to three-state (input mode). On the other hand, when the output setting is equal to or less than the digital signal value, the time output port proportional to the absolute value is set to low, and then the output port is set to three-state.
[0025]
Therefore, since a signal is output from the output port only for a moment when the level is changed, the time constant of the low-pass filter can be set small, and both high response and suppression of ripple can be achieved.
[0026]
Further, the resolution of the obtained analog signal can be improved by increasing the resolution of the analog / digital conversion means.
[0027]
In the digital / analog conversion device according to
[0028]
In the digital / analog conversion device according to
[0029]
In the digital / analog conversion device according to the sixth aspect, it is possible to increase the speed only on the side where responsiveness is required by setting different proportional coefficients for high and low.
[0030]
8. The digital / analog conversion device according to
[0031]
DETAILED DESCRIPTION OF THE INVENTION
In the following, an embodiment for realizing a digital / analog conversion device of the present invention will be described based on a first example and a second example.
[0032]
(First embodiment)
First, the configuration will be described.
FIG. 1 is a circuit diagram of a digital / analog converter according to the first embodiment.
[0033]
The microcomputer 1 includes a port
[0034]
The output timing of VA is shown in FIG. As shown in the figure, the port output V A is output as digital data of “low level (low)”, “high level (high)”, and “high impedance state (three state)”. This V A is integrated through a low-
[0035]
The gain (amplification factor) of the
[0036]
Note that, in the pulses P 1 to P 3 in FIG. 2, the pulse is output even though the D / A output set value V T is not changed, the capacitor C 1 or the
[0037]
3, the D / A output setting value V T constant at a state input leakage current or the like is not of the capacitor C 1 and the
[0038]
The configuration of the D / A conversion circuit of this embodiment is substantially the same as that of the conventional D / A conversion circuit shown in FIG. 7 except that the low-pass filter 08 and the voltage follower 09 are deleted.
[0039]
Further, the low-
[0040]
Next, the operation will be described.
[D / A conversion control processing]
In the microcomputer 1, in addition to the main predetermined control, a subroutine for setting the D / A output set value V T is executed. In this subroutine, a target value determined by another routine or the like, that is, a D / A output set value V T is set. When the timer interrupt time is set, a timer interrupt is generated every predetermined time. When this timer interrupt occurs, a timer interrupt routine is executed.
[0041]
FIG. 4 is a flowchart showing the flow of the D / A conversion control process executed in the timer interrupt routine of the microcomputer 1.
[0042]
In step S1, reads the A / D-converted value V C 'output from the A /
[0043]
In step S2, the D / A output set value VT is read.
[0044]
In step S3, the absolute value of the difference between the A / D conversion value V C ′ and the D / A output set value V T is obtained, and the result is written in the result R1 secured on the RAM of the microcomputer 1.
[0045]
In step S4, the result R1 is compared with a preset threshold value A1, and when the result R1 is smaller than the threshold value A1, this control is terminated, and the result R1 is equal to or greater than the threshold value A1. The process proceeds to step S5.
[0046]
In step S5, the A / D conversion value V C 'is compared with the D / A output setting value V T, if V T is exceeded V C proceeds to step S6, V T is less V C If so, the process proceeds to step S7.
[0047]
In step S6, a value obtained by multiplying the result R1 by a preset proportionality coefficient A2 is written in the ON time C1 secured on the RAM, and the level of the port output V A is set to “high”.
[0048]
In step S7, a value obtained by multiplying the result R1 by a preset proportionality coefficient A3 is written in the ON time C1 secured on the RAM, and the level of the port output V A is set to “low”.
[0049]
In this embodiment, the ON time C1 is set as the number of times of looping from step S8 → step S9 → step S8.
[0050]
In step S8, it is determined whether or not the ON time C1 is 0. If the ON time C1 is 0, the process proceeds to step S10. If the ON time C1 is other than 0, the process proceeds to step S9.
[0051]
In step S9, the ON time C1 is decremented.
[0052]
In step S10, the input / output direction of the port is set to input (three state), and this control is terminated.
[0053]
[D / A conversion control action]
When the D / A output set value V T is larger than the A / D converted value V C ′ and the difference is not less than the threshold value A1, step S1 → step S2 → step S3 → Step S4 → Step S5 → Step S6 → Step S8 → Step S10.
[0054]
That is, in step S6, the ON time C1 is set by multiplying the result R1 and the proportional coefficient A2, and the port output VA is set to high. In step S8 and step S9, the ON time C1 is counted down to 0, In step S10, the port output is set to the three state.
[0055]
When the D / A output set value V T is equal to or less than the A / D conversion value V C ′ and the difference is equal to or greater than the threshold A1, step S1 → step S2 → step S3 → Step S4 → Step S5 → Step S7 → Step S8 → Step S10.
[0056]
That is, in step S7, the ON time C1 is set by multiplying the result R1 and the proportional coefficient A3, and the port output VA is set to low. In steps S8 and S9, the ON time C1 is counted down to 0, In step S10, the port output is set to the three state.
[0057]
If the difference between the D / A output set value V T and the A / D conversion value V C ′ is smaller than the threshold value A1, in the flowchart of FIG. 4, go to step S1, step S2, step S3, and step S4. The control is terminated without changing the state of the port output V A.
[0058]
Next, the effect will be described.
The digital / analog conversion device of the present embodiment has the following effects.
[0059]
(1) When the output set value V T is larger than the digital signal value V C ′, the output port PC1 is set to high for the ON time C1 proportional to the result R1, and then the output port PC1 is set to the three-state (input mode On the other hand, when the output set value V T is equal to or less than the digital signal value V C ′, the output port PC1 is set to the three-state after the output port PC1 is set low for the ON time C1 proportional to the result R1. By doing so, the time constant of the low-
[0060]
(2) Since the resistor R 1 ′ and the capacitor C 1 ′ having a small time constant are used as the low-
[0061]
(3) When the result R1 is equal to or less than the threshold value A1, the A / D conversion output voltage that is always output from the A /
[0062]
(4) D / A output setting value V T is set by multiplying the the ON time C1 and result R1 and the proportionality coefficient A2 is is greater than A / D conversion value V C ', D / A output set value V When T is equal to or less than the A / D conversion value V C ′, the ON time C1 is set by multiplying the result R1 and the proportionality coefficient A3. Therefore, it is possible to increase the speed only on the side that requires responsiveness. .
[0063]
(Second embodiment)
First, the configuration will be described.
The configuration of the digital / analog conversion circuit of the second embodiment is obtained by adding one channel of a D / A output circuit to the configuration of the first embodiment.
[0064]
Another circuit is added to the low-
[0065]
The port
[0066]
Next, the operation will be described.
[D / A conversion control processing]
The D / A conversion control process of the second embodiment is obtained by adding step S21 between step S1 and step S2 and adding step S22 after step S10 in the flowchart shown in FIG. Only portions different from 4 will be described.
[0067]
In step S21, it is checked whether the channel of the A /
[0068]
In step S4, the result R1 is compared with a preset threshold value A1, and if the result R1 is smaller than the threshold value A1, the process proceeds to step S22. If the result R1 is equal to or greater than the threshold value A1, Advances to step S5.
[0069]
In step S22, the channel of the A /
[0070]
Next, the effect will be described.
(5) To output the port signal V A (V A ′) from the corresponding output port PC1 (PC2) only when the channel of the A /
[0071]
(Other examples)
[0072]
Although the embodiments of the present invention have been described based on the first and second examples, the specific configuration of the present invention is not limited to the first and second examples. The present invention includes any design changes that do not depart from the spirit of the invention.
[0073]
For example, the values of the threshold value A1 and the proportional coefficients A2 and A3 may be set in advance through experiments or after the apparatus is actually operated.
[Brief description of the drawings]
FIG. 1 is a circuit diagram of a digital / analog converter according to a first embodiment.
FIG. 2 is a diagram illustrating an output timing of a port output V A.
FIG. 3 is a diagram showing the output timing of the port output V A in a state where there is no input leakage current of the capacitor C 1 and the
FIG. 4 is a flowchart showing the flow of a D / A conversion control process executed in a timer interrupt routine of the microcomputer 1 according to the first embodiment.
FIG. 5 is a circuit diagram of a digital / analog converter according to a second embodiment.
FIG. 6 is a flowchart showing the flow of a D / A conversion control process executed in a timer interrupt routine of the microcomputer 1 according to the second embodiment.
FIG. 7 is a circuit diagram of a conventional digital / analog converter.
[Explanation of symbols]
DESCRIPTION OF SYMBOLS 1
Claims (7)
出力設定値に基づいてマイクロコンピュータの出力ポートから出力される信号をローパスフィルタに入力し、
このローパスフィルタから出力されるアナログ信号を対応するデジタル信号に変換し、
変換されたデジタル信号値と出力設定値との差の絶対値を求め、
この絶対値が予め設定されたしきい値以上のとき、前記出力設定値とデジタル信号値とを比較し、前記出力設定値がデジタル信号値よりも大きいとき、前記絶対値に比例した時間出力ポートをハイとした後、出力ポートをスリーステートとする一方、
前記出力設定値がデジタル信号値以下であるとき、前記絶対値に比例した時間出力ポートをローとした後、出力ポートをスリーステートとすることを特徴とするデジタル/アナログ変換方法。In a digital / analog conversion method that is executed when an interrupt occurs at regular intervals to a microcomputer,
Based on the output setting value, input the signal output from the microcomputer output port to the low-pass filter,
Convert the analog signal output from this low-pass filter into a corresponding digital signal,
Find the absolute value of the difference between the converted digital signal value and the output setting value,
When the absolute value is equal to or greater than a preset threshold value, the output set value is compared with the digital signal value. When the output set value is greater than the digital signal value, the time output port is proportional to the absolute value. The output port is three-stated, while
A digital / analog conversion method characterized in that, when the output set value is equal to or less than a digital signal value, the output port is set to a three-state after the time output port proportional to the absolute value is set to low.
前記ローパスフィルタのカットオフ周波数を、割り込み時間の間隔以下の周期に設定したことを特徴とするデジタル/アナログ変換方法。The digital / analog conversion method according to claim 1,
A digital / analog conversion method, wherein a cut-off frequency of the low-pass filter is set to a period equal to or less than an interrupt time interval.
このマイクロコンピュータに所定時間毎に割り込みをかけるタイマと、
前記マイクロコンピュータの出力ポートから出力される信号をアナログ信号に変換して出力するローパスフィルタと、
このローパスフィルタから出力されるアナログ信号を対応するデジタル信号に変換するアナログ/デジタル変換手段と、
を備え、
前記マイクロコンピュータは、割り込みが発生したとき、変換されたデジタル信号値と出力設定値との差の絶対値を求め、前記出力設定値とデジタル信号値とを比較し、前記出力設定値がデジタル信号値よりも大きいとき、前記絶対値に比例した時間出力ポートをハイとした後、出力ポートをスリーステートとする一方、出力設定値がデジタル信号値以下であるとき、前記絶対値に比例した時間出力ポートをローとした後、出力ポートをスリーステートとするポート出力判断部を備えることを特徴とするデジタル/アナログ変換装置。A microcomputer,
A timer for interrupting this microcomputer every predetermined time;
A low-pass filter that converts the signal output from the output port of the microcomputer into an analog signal and outputs the analog signal;
Analog / digital conversion means for converting an analog signal output from the low-pass filter into a corresponding digital signal;
With
When an interrupt occurs, the microcomputer obtains an absolute value of a difference between the converted digital signal value and the output set value, compares the output set value with the digital signal value, and the output set value is a digital signal. If the output port is three-state after the output port is set to high after the time output port is high when the output value is less than the digital signal value, the time output proportional to the absolute value is output. A digital / analog conversion apparatus comprising a port output determination unit that sets an output port to a three-state after setting the port to low.
前記ローパスフィルタのカットオフ周波数を、割り込み時間の間隔以下の周期に設定したことを特徴とするデジタル/アナログ変換装置。The digital / analog converter according to claim 3,
A digital / analog conversion apparatus characterized in that a cut-off frequency of the low-pass filter is set to a period equal to or less than an interrupt time interval.
前記ポート出力判断部は、前記絶対値と予め設定されたしきい値とを比較し、絶対値がしきい値を超えていないとき、次回の割り込み発生時まで出力ポートをスリーステートのまま保持することを特徴とするデジタル/アナログ変換装置。The digital / analog converter according to claim 3 or 4,
The port output determining unit compares the absolute value with a preset threshold value, and when the absolute value does not exceed the threshold value, holds the output port in a three-state state until the next interrupt is generated. A digital / analog converter characterized by that.
前記ポート出力判断部は、予めハイとローで別々に設定した比例係数に前記絶対値を乗じて出力ポートをハイまたはローとする時間を設定することを特徴とするデジタル/アナログ変換装置。The digital / analog converter according to any one of claims 3 to 5,
The port output determining unit sets a time for setting an output port to be high or low by multiplying a proportional coefficient set separately for high and low in advance by the absolute value.
前記マイクロコンピュータに出力ポートを複数設定するとともに、この出力ポート毎にタイマ、ローパスフィルタをそれぞれ設け、
前記アナログ/デジタル変換手段にローパスフィルタから出力されるアナログ信号の数に応じて複数のチャンネルを設定し、
前記マイクロコンピュータに、アナログ/デジタル変換手段に入力されたアナログ信号がどのチャンネルに入力されたかを検出するチャンネル検出部を設け、
検出されたチャンネルに対応する出力ポートから信号を出力することを特徴とするデジタル/アナログ変換装置。The digital / analog converter according to any one of claims 3 to 6,
A plurality of output ports are set in the microcomputer, and a timer and a low-pass filter are provided for each output port.
A plurality of channels are set according to the number of analog signals output from the low-pass filter to the analog / digital conversion means,
The microcomputer is provided with a channel detection unit that detects which channel the analog signal input to the analog / digital conversion means is input to.
A digital / analog converter which outputs a signal from an output port corresponding to a detected channel.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2002375332A JP3950793B2 (en) | 2002-12-25 | 2002-12-25 | Digital / analog conversion method and apparatus |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2002375332A JP3950793B2 (en) | 2002-12-25 | 2002-12-25 | Digital / analog conversion method and apparatus |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2004208075A JP2004208075A (en) | 2004-07-22 |
JP3950793B2 true JP3950793B2 (en) | 2007-08-01 |
Family
ID=32813109
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2002375332A Expired - Fee Related JP3950793B2 (en) | 2002-12-25 | 2002-12-25 | Digital / analog conversion method and apparatus |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP3950793B2 (en) |
-
2002
- 2002-12-25 JP JP2002375332A patent/JP3950793B2/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
JP2004208075A (en) | 2004-07-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7298212B2 (en) | Automatic level control circuit with improved attack action | |
US7484139B2 (en) | Amplifier fault detection circuit | |
US20060238253A1 (en) | Sensitivity switchable detection circuit and method | |
JP5233217B2 (en) | Output current detection method of voltage type PWM inverter device | |
JP2005150550A (en) | Solenoid driving device | |
JP3950793B2 (en) | Digital / analog conversion method and apparatus | |
JP2000009409A (en) | Circuit for detecting variation of inductance | |
JPH1070444A (en) | Digital noise filter | |
JPH0537819A (en) | Amplitude control circuit | |
JP4148077B2 (en) | Class D signal amplifier circuit | |
JP2546065B2 (en) | Knocking detection device | |
JP2006165912A (en) | Signal processor and image pickup device using the same | |
JP2836428B2 (en) | Knock sensor signal processing device | |
JP5277492B2 (en) | AD converter | |
JPH1080173A (en) | Digital filter and servomotor controller | |
JP3332634B2 (en) | Duty adjustment device | |
JPH09232956A (en) | Sensor signal processing device | |
JP3541263B2 (en) | Gain setting method | |
JP2017207382A (en) | Electronic controller | |
JPS6150242B2 (en) | ||
JP2006173928A (en) | Insulated voltage detection circuit | |
JP2555677B2 (en) | Knock detection device for internal combustion engine | |
TW202341651A (en) | Apparatus for noise reduction in audio signal processing | |
JPH0511926A (en) | Noise eliminating circuit | |
JP2022138447A (en) | Air-fuel ratio sensor controller |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20050531 |
|
RD04 | Notification of resignation of power of attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7424 Effective date: 20051114 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20070404 |
|
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: 20070417 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20070423 |
|
R150 | Certificate of patent or registration of utility model |
Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
S531 | Written request for registration of change of domicile |
Free format text: JAPANESE INTERMEDIATE CODE: R313531 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20100427 Year of fee payment: 3 |
|
R350 | Written notification of registration of transfer |
Free format text: JAPANESE INTERMEDIATE CODE: R350 |
|
LAPS | Cancellation because of no payment of annual fees |