JP2004208075A - Method and device for digital/analog conversion - Google Patents
Method and device for digital/analog conversion Download PDFInfo
- Publication number
- JP2004208075A JP2004208075A JP2002375332A JP2002375332A JP2004208075A JP 2004208075 A JP2004208075 A JP 2004208075A JP 2002375332 A JP2002375332 A JP 2002375332A JP 2002375332 A JP2002375332 A JP 2002375332A JP 2004208075 A JP2004208075 A JP 2004208075A
- Authority
- JP
- Japan
- Prior art keywords
- output
- value
- digital
- analog
- port
- 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.)
- Granted
Links
Images
Landscapes
- Analogue/Digital Conversion (AREA)
Abstract
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]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a digital / analog conversion method and a digital / analog conversion device for controlling a port output of a microcomputer to obtain a predetermined analog signal.
[0002]
[Prior art]
As a circuit configuration of a conventional digital / analog (D / A) conversion device, one shown in FIG. 7 is known (for example, see Patent Document 1).
[0003]
The
[0004]
In this manner, by setting desired data in the
[0005]
The V A is integrated by constructed low pass filter 06 from the resistor R 1 and capacitor C 1 Tokyo, it is converted into an analog waveform shown in V B. The V B is V C are obtained are input to the non-inverting amplifier 07. Note that this V C, by passing through the low pass filter 08 composed of the resistor R 4 and the capacitor C 2 Prefecture, after being reduce voltage ripple, is outputted as V D from the voltage follower 09, A / It is also input to the
[0006]
The
[0007]
As described above, in the conventional D / A converter, the PWM signal VA output from the
[0008]
[Patent Document 1]
JP-A-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]
SUMMARY OF THE INVENTION The present invention has been made in view of the above problems, and has as its object to provide a digital / analog conversion method and a digital / analog conversion device capable of achieving both suppression of ripples and high responsiveness. 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 when an interruption to the microcomputer occurs at regular time intervals, the digital / analog conversion method is performed based on the output set value. The signal output from the output port of the computer is input to a low-pass filter, the analog signal output from the low-pass filter is converted into a corresponding digital signal, and the absolute value of the difference between the converted digital signal value and the output set value When the absolute value is equal to or greater than a predetermined threshold value, the output set value is compared with a digital signal value, and when the output set value is larger than the digital signal value, the output set value is proportional to the absolute value. After the time output port is set to high, the output port is three-stated while the output set value is a digital signal. 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-to-analog conversion method according to the first aspect, the cutoff frequency of the low-pass filter is set to a cycle equal to or less than an interval of an interruption time.
[0014]
In the digital / analog converter according to the third aspect, a microcomputer, a timer for interrupting the microcomputer every predetermined time, and a signal output from an output port of the microcomputer are converted into analog signals and output. A low-pass filter, and analog / digital conversion means for converting an analog signal output from the low-pass filter into a corresponding digital signal, wherein the microcomputer converts the converted digital signal value when an interrupt occurs. Obtain the absolute value of the difference from the output set value, compare the output set value and the digital signal value, and when the output set value is greater than the digital signal value, set the output port to high for a time proportional to the absolute value. Output port is three-stated while the output When issue value or less, after the low time output port proportional to the absolute value, characterized in that it comprises a port output determining section for the output port and three-state.
[0015]
According to a fourth aspect of the present invention, in the digital-to-analog converter according to the third aspect, the cutoff frequency of the low-pass filter is set to a period equal to or less than an interval of an interruption time.
[0016]
According to a fifth aspect of the present invention, in the digital / analog conversion apparatus 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 kept in a three-state state until the next interrupt occurs.
[0017]
According to a sixth aspect of the present invention, in the digital-to-analog conversion apparatus according to any one of the third to fifth aspects, the port output determination unit is configured to determine a proportional coefficient which is separately set for high and low in advance. A time for setting the output port to high or low by multiplying the absolute value is set.
[0018]
According to a seventh aspect of the present invention, in the digital-to-analog converter 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 of the output ports. A plurality of channels are set in the analog / digital conversion means in accordance with the number of analog signals output from the low-pass filter, and the microcomputer inputs the analog signal input to the analog / digital conversion means to any channel. A channel detection unit for detecting whether the signal is output, and outputting a signal from an output port corresponding to the detected channel.
[0019]
【The invention's effect】
In the digital / analog conversion method according to the first aspect, at the time of a timer interrupt, 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, and this absolute value is determined in advance. When the value is equal to or larger than the set threshold, the output set value is compared with the digital signal value.
[0020]
If the output set value is larger than the digital signal value, the output port is set to high for a time proportional to the absolute value, 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 output port is set to low for a time proportional to the absolute value, and then the output port is set to three-state.
[0021]
That is, in the present invention, theoretically, a signal is output from the output port only for a moment when the level is changed, so that the time constant of the low-pass filter can be set small, and both high responsiveness and suppression of ripple can be achieved. Can be achieved.
[0022]
In the digital / analog conversion method according to the second aspect, the response can be further improved by setting the cutoff 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 the third aspect, the port output determination unit obtains the absolute value of the difference between the digital signal value output from the analog / digital conversion means and the output set value at the time of timer interruption, and further outputs Compare the set value with the digital signal value.
[0024]
If the output set value is larger than the digital signal value, the output port is set to high for a time proportional to the absolute value, and then the output port is set to three-state (input mode). On the other hand, if the output setting is equal to or less than the digital signal value, the output port is set to low for a time proportional to the absolute value, 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 responsiveness and suppression of ripple can be achieved.
[0026]
Further, by increasing the resolution of the analog / digital conversion means, the resolution of the obtained analog signal can be improved.
[0027]
In the digital / analog converter according to the fourth aspect, the response can be further improved by setting the cutoff frequency of the low-pass filter to be equal to or shorter than the interval of the interruption time.
[0028]
In the digital / analog conversion apparatus according to the fifth aspect, when the absolute value does not exceed the threshold value, the output port is kept in the three-state until the next interrupt occurs, so that the analog / digital conversion is always performed due to noise or the like. When the digital signal value output from the digital conversion means does not match the output set value, the output port goes high or low for a time proportional to the absolute value of the difference between the digital signal value and the output set value for each timer interrupt As a result, the analog value can be prevented from becoming unstable.
[0029]
In the digital / analog converter according to the sixth aspect, by setting different proportional coefficients for high and low, it is possible to speed up only the side where responsiveness is required.
[0030]
In the digital / analog conversion device according to the seventh aspect, it is detected which channel the analog signal input to the analog / digital conversion means has been input, and a signal is output from an output port corresponding to the detected channel. Thus, a plurality of desired analog signals can be output.
[0031]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, embodiments for realizing the digital / analog conversion device of the present invention will be described based on a first embodiment and a second embodiment.
[0032]
(First embodiment)
First, the configuration will be described.
FIG. 1 is a circuit diagram of the digital / analog converter of the first embodiment.
[0033]
The microcomputer 1 includes a port
[0034]
FIG. 2 shows the output timing of VA . As shown in the figure, the port output VA is output as digital data of “low level (low)”, “high level (high)”, and “high impedance state (three state)”. The V A is integrated through composed low pass filter 4 by a resistor R 1 and capacitor C 1, after becoming a analog signal V B, is amplified by the
[0035]
The gain (amplification rate) of the
[0036]
Note that in the pulse P 1 to P 3 in Figure 2, despite the D / A output setting value V T has not changed, the pulse is being output, the capacitor C 1 or
[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 the configuration 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, as the low-pass filter 4, a resistor R 1 ′ and a capacitor C 1 ′ having a smaller time constant than the resistor R 1 and the capacitor C 1 in the low-pass filter 06 of FIG. 7 are used. The cut-off frequency of the low-pass filter 4 is set to a cycle shorter than the interval of the interruption time of the timer.
[0040]
Next, the operation will be described.
[D / A conversion control processing]
In the microcomputer 1, in addition to the predetermined control as the main, subroutine for setting the D / A output setting value V T is performed. In this subroutine, a target value determined by another routine or the like, that is, a D / A output set value VT is set. When the timer interrupt time is set, a timer interrupt occurs 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, the A / D conversion 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 D / A output setting value V T, and writes the result to the result R1 secured on the microcomputer 1 RAM.
[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, the present control is terminated, and when the result R1 is equal to or more than the threshold value A1. 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 In this case, the process proceeds to step S7.
[0047]
In step S6, a value obtained by multiplying the result R1 by a preset proportional coefficient A2 is written in the ON time C1 secured on the RAM, and the level of the port output VA is set to "high".
[0048]
In step S7, a value obtained by multiplying the result R1 by a preset proportional coefficient A3 is written in the ON time C1 secured on the RAM, and the level of the port output VA 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 the ON time C1 is 0. If the ON time C1 is 0, the process proceeds to step S10, and 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 the control ends.
[0053]
[D / A conversion control action]
D / A output setting value V T is greater than the A / D conversion value V C ', when the difference is the threshold value A1 or more, in the flowchart of FIG. 4, step S1 → step S2 → step S3 → The flow proceeds to 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 by the proportional coefficient A2, and the port output VA is set high. In steps S8 and S9, the countdown is performed until the ON time C1 becomes 0, In step S10, the port output is set to a three-state.
[0055]
When the D / A output set value VT is equal to or less than the A / D conversion value V C ′ and the difference is equal to or greater than the threshold value A1, in the flowchart of FIG. The flow proceeds to 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 by the proportional coefficient A3, and the port output VA is set to low. In steps S8 and S9, the countdown is performed until the ON time C1 becomes zero. In step S10, the port output is set to a three-state.
[0057]
When the difference between the D / A output set value VT 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 → step S4. And the control ends without changing the state of the port output VA .
[0058]
Next, effects will be described.
The digital / analog conversion device according to the present embodiment has the following effects.
[0059]
(1) when the output setting value V T is greater than the digital signal value V C ', after between output port PC1 ON-time C1 in proportion to result R1 to the high, three-state output port PC1 (input mode ) to one, when the output setting value V T is equal to or less than the digital signal value V C ', after between output port PC1 oN-time C1 in proportion to result R1 low, the output port PC1 and three-state By doing so, the time constant of the low-pass filter 4 can be set small, and both high responsiveness and suppression of ripples can be achieved.
[0060]
(2) Since the low-pass filter 4 uses a resistor R 1 ′ and a capacitor C 1 ′ having a small time constant and the cutoff frequency is set to a cycle shorter than the interval of the timer interrupt time, high responsiveness can be ensured. it can.
[0061]
(3) When the result R1 is equal to or less than the threshold value A1, the output port PC1 is kept in the three-state, so that the A / D conversion output voltage 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 by the proportional coefficient A3, so that it is possible to speed up only 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 such that one channel of a D / A output circuit is added to the configuration of the first embodiment.
[0064]
Another circuit is added to the low-pass filter 4 and the
[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 the parts different from 4 will be described.
[0067]
In step S21, it is checked whether the channel of the A /
If 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, and if the result R1 is equal to or larger than the threshold value A1, Goes to step S5.
[0069]
In step S22, the channel of the A /
[0070]
Next, effects will be described.
(5) In order to output the port signal VA ( VA ′) from the corresponding output port PC1 (PC2) only when the channel of the A /
[0071]
(Other Examples)
[0072]
Although the embodiment of the present invention has been described based on the first and second embodiments, the specific configuration of the present invention is not limited to the first and second embodiments. In addition, the present invention includes any design changes that do not depart from the gist 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 by experiments or the like, or may be set after the apparatus is actually operated.
[Brief description of the drawings]
FIG. 1 is a circuit diagram of a digital / analog conversion device according to a first embodiment.
FIG. 2 is a diagram showing the output timing of a port output VA .
3 is a diagram showing the output timing of the port output V A of a state input leakage current or the like is not of the capacitor C 1 and a
FIG. 4 is a flowchart illustrating a 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 conversion device according to a second embodiment.
FIG. 6 is a flowchart illustrating a 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 which is executed when an interrupt occurs at regular intervals for a microcomputer,
Input the signal output from the output port of the microcomputer to the low-pass filter based on the output setting value,
Convert the analog signal output from this low-pass filter to a corresponding digital signal,
Find the absolute value of the difference between the converted digital signal value and the output set value,
When the absolute value is equal to or greater than a predetermined threshold value, the output set value is compared with a digital signal value. When the output set value is larger than the digital signal value, a time output port proportional to the absolute value is output. And then set the output port to three-state,
When the output set value is equal to or less than the digital signal value, the output port is set to a low state for a time proportional to the absolute value, and then the output port is set to a three-state.
前記ローパスフィルタのカットオフ周波数を、割り込み時間の間隔以下の周期に設定したことを特徴とするデジタル/アナログ変換方法。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 cycle equal to or less than an interval of an interruption time.
このマイクロコンピュータに所定時間毎に割り込みをかけるタイマと、
前記マイクロコンピュータの出力ポートから出力される信号をアナログ信号に変換して出力するローパスフィルタと、
このローパスフィルタから出力されるアナログ信号を対応するデジタル信号に変換するアナログ/デジタル変換手段と、
を備え、
前記マイクロコンピュータは、割り込みが発生したとき、変換されたデジタル信号値と出力設定値との差の絶対値を求め、前記出力設定値とデジタル信号値とを比較し、前記出力設定値がデジタル信号値よりも大きいとき、前記絶対値に比例した時間出力ポートをハイとした後、出力ポートをスリーステートとする一方、出力設定値がデジタル信号値以下であるとき、前記絶対値に比例した時間出力ポートをローとした後、出力ポートをスリーステートとするポート出力判断部を備えることを特徴とするデジタル/アナログ変換装置。A microcomputer,
A timer for interrupting the microcomputer at predetermined time intervals,
A low-pass filter that converts a signal output from an 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 the absolute value of the difference between the converted digital signal value and the output set value, compares the output set value with the digital signal value, and sets the output set value to a digital signal. When the output value is greater than the digital signal value, the output port is set to three-state after the output port is set to high for a time proportional to the absolute value, and when the output set value is equal to or less than the digital signal value, the time output is proportional to the absolute value. A digital / analog conversion device comprising: a port output determination unit that sets an output port to three-state after setting a port to low.
前記ローパスフィルタのカットオフ周波数を、割り込み時間の間隔以下の周期に設定したことを特徴とするデジタル/アナログ変換装置。The digital / analog converter according to claim 3,
A digital / analog conversion device, wherein a cutoff frequency of the low-pass filter is set to a cycle equal to or less than an interval of an interruption time.
前記ポート出力判断部は、前記絶対値と予め設定されたしきい値とを比較し、絶対値がしきい値を超えていないとき、次回の割り込み発生時まで出力ポートをスリーステートのまま保持することを特徴とするデジタル/アナログ変換装置。The digital / analog converter according to claim 3 or 4,
The port output determination 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 occurs. A digital / analog conversion device characterized by the above-mentioned.
前記ポート出力判断部は、予めハイとローで別々に設定した比例係数に前記絶対値を乗じて出力ポートをハイまたはローとする時間を設定することを特徴とするデジタル/アナログ変換装置。The digital / analog converter according to claim 3, wherein:
The digital / analog conversion device according to claim 1, wherein the port output determining unit multiplies the proportional coefficient separately set in advance by a high value and a low value by the absolute value to set a time for setting the output port to high or low.
前記マイクロコンピュータに出力ポートを複数設定するとともに、この出力ポート毎にタイマ、ローパスフィルタをそれぞれ設け、
前記アナログ/デジタル変換手段にローパスフィルタから出力されるアナログ信号の数に応じて複数のチャンネルを設定し、
前記マイクロコンピュータに、アナログ/デジタル変換手段に入力されたアナログ信号がどのチャンネルに入力されたかを検出するチャンネル検出部を設け、検出されたチャンネルに対応する出力ポートから信号を出力することを特徴とするデジタル/アナログ変換装置。The digital / analog conversion device according to claim 3, wherein:
A plurality of output ports are set in the microcomputer, and a timer and a low-pass filter are provided for each of the output ports,
Setting a plurality of channels 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 for detecting which channel the analog signal input to the analog / digital conversion unit is input, and outputs a signal from an output port corresponding to the detected channel. Digital / analog converter.
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 true JP2004208075A (en) | 2004-07-22 |
JP3950793B2 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 |
---|---|
JP3950793B2 (en) | 2007-08-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
TWI605722B (en) | DC impedance detection method and circuit for speaker | |
JP2005150550A (en) | Solenoid driving device | |
JP2000009409A (en) | Circuit for detecting variation of inductance | |
JP2004208075A (en) | Method and device for digital/analog conversion | |
JP4148077B2 (en) | Class D signal amplifier circuit | |
US5910743A (en) | High efficiency pulse width modulator | |
JPH0537819A (en) | Amplitude control circuit | |
TW201636633A (en) | Magnetic sensor circuit | |
US9577853B1 (en) | Current balance method and current balance circuit thereof | |
US20070165428A1 (en) | Digital pulse width modulation controlling system and method | |
JP2006173928A (en) | Insulated voltage detection circuit | |
JP2003032054A (en) | Low distortion power amplification method and its system | |
JPS6150242B2 (en) | ||
JP6789727B2 (en) | Analog-digital mixed circuit | |
JPS6331224A (en) | Accuracy improving system for a/d conversion sample value | |
JP2905212B2 (en) | Digital level detector | |
JPH05219406A (en) | Level adjustment circuit for video signal | |
JPH08297501A (en) | Control method for electric motor | |
JPH0898515A (en) | Control system of switching power supply | |
JPH0718179Y2 (en) | Automatic gain adjustment circuit | |
JP2000134637A (en) | Signal processing circuit | |
JP2003122401A (en) | Controller | |
JP2022138447A (en) | Air-fuel ratio sensor controller | |
JP2000003204A (en) | Control method and device | |
JP4890144B2 (en) | Brushless motor drive circuit and motor provided with the same |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Effective date: 20050531 Free format text: JAPANESE INTERMEDIATE CODE: A621 |
|
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 (=grant) 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 (prs date is renewal date of database) |
Year of fee payment: 3 Free format text: PAYMENT UNTIL: 20100427 |
|
R350 | Written notification of registration of transfer |
Free format text: JAPANESE INTERMEDIATE CODE: R350 |
|
LAPS | Cancellation because of no payment of annual fees |