Transistor Gijutsu, October 2014, Special Features Chapter 8,Software of the thermistor thermometer of 0.001 ° resolution, トランジスタ技術2014年10月号 特集第8章のソフトウェア 0.001℃分解能で気配もキャッチ「超敏感肌温度計」

Dependencies:   USBDevice mbed

Information

tg_201410s8_AD7714 トランジスタ技術 2014年 10月号 第8章のソフトウェア

Program for Section 8 in October. 2014 issue of the Transistor Gijutsu
(Japanese electronics magazine)

概要

このプログラムは、サーミスタの抵抗値変化をAD7714(24bitADC)で測定し、抵抗値を温度値に変換することで、0.001℃程度の分解能で温度変化を測定します。

ファイル

このソフトウエアは、次のファイルから構成されています。

  • AD7714.cpp - AD7714の内部レジスタを設定
  • Thermistor.cpp - サーミスタの抵抗値から温度値に変換
  • ExpAvr.cpp - 指数平均によるソフトウエアLPF
  • main.cpp - main()関数

詳細については、10月号の記事および上記ファイル中のコメントを参照してください。

Committer:
Dance
Date:
Fri Aug 29 08:38:36 2014 +0000
Revision:
0:de885a6da962
Transistor Gijutsu, October 2014, Special Features Chapter 8; ????????2014?10??????8????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Dance 0:de885a6da962 1 #ifndef EXPAVR_H
Dance 0:de885a6da962 2 #define EXPAVR_H
Dance 0:de885a6da962 3
Dance 0:de885a6da962 4 #include <math.h>
Dance 0:de885a6da962 5
Dance 0:de885a6da962 6 #define MathPi (3.1415926535897932384626433832795)
Dance 0:de885a6da962 7 /// 指数平均を計算する(実質的なローパスフィルタ)
Dance 0:de885a6da962 8 class ExpAvr {
Dance 0:de885a6da962 9 private:
Dance 0:de885a6da962 10 int order; ///< ローパスフィルタの次数に相当
Dance 0:de885a6da962 11 double tc; ///< 指数平均への増分、CR時定数に相当
Dance 0:de885a6da962 12 double *acc; ///< 中間値を保存
Dance 0:de885a6da962 13 bool first; ///< 初期化が必要かどうかのフラグ
Dance 0:de885a6da962 14 public:
Dance 0:de885a6da962 15 /// コンストラクタ
Dance 0:de885a6da962 16 /// @param order 次数(フィルタの段数)
Dance 0:de885a6da962 17 /// @param fcutoff カットオフ周波数[Hz]、fsampleより十分小さいこと。1/10以下を推奨。
Dance 0:de885a6da962 18 /// @param fsample サンプリング周波数[Hz]
Dance 0:de885a6da962 19 ExpAvr(int order, double fcutoff, double fsample){
Dance 0:de885a6da962 20 this->order = order;
Dance 0:de885a6da962 21 this->tc = exp((-2*fcutoff*MathPi)/fsample);
Dance 0:de885a6da962 22 acc = new double[order];
Dance 0:de885a6da962 23 first = true;
Dance 0:de885a6da962 24 };
Dance 0:de885a6da962 25 /// 指数平均計算
Dance 0:de885a6da962 26 /// @param d フィルタの入力値
Dance 0:de885a6da962 27 /// @return フィルタの出力値
Dance 0:de885a6da962 28 double getOutput(double d);
Dance 0:de885a6da962 29 };
Dance 0:de885a6da962 30
Dance 0:de885a6da962 31
Dance 0:de885a6da962 32 #endif