
Transistor Gijutsu, October 2014, Special Features Chapter 8,Software of the thermistor thermometer of 0.001 ° resolution, トランジスタ技術2014年10月号 特集第8章のソフトウェア 0.001℃分解能で気配もキャッチ「超敏感肌温度計」
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月号の記事および上記ファイル中のコメントを参照してください。
main.cpp@0:de885a6da962, 2014-08-29 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
Dance | 0:de885a6da962 | 1 | #include "mbed.h" |
Dance | 0:de885a6da962 | 2 | #include "USBSerial.h" |
Dance | 0:de885a6da962 | 3 | #include "AD7714.h" |
Dance | 0:de885a6da962 | 4 | #include "Thermistor.h" |
Dance | 0:de885a6da962 | 5 | #include "ExpAvr.h" |
Dance | 0:de885a6da962 | 6 | |
Dance | 0:de885a6da962 | 7 | |
Dance | 0:de885a6da962 | 8 | int main() { |
Dance | 0:de885a6da962 | 9 | |
Dance | 0:de885a6da962 | 10 | int fsample = 5; // AD7714サンプリング周波数 |
Dance | 0:de885a6da962 | 11 | float LPFcut = 0.01; // LPFカットオフ周波数 |
Dance | 0:de885a6da962 | 12 | |
Dance | 0:de885a6da962 | 13 | USBSerial serial; // PCとの通信ポート |
Dance | 0:de885a6da962 | 14 | |
Dance | 0:de885a6da962 | 15 | // AD7714によるレシオメトリック測定オブジェクト |
Dance | 0:de885a6da962 | 16 | // (+)入力Vdd側抵抗値、(-)入力Vdd側抵抗値、同GND側抵抗値、リファレンス入力Vdd側抵抗値、同GND側抵抗値 |
Dance | 0:de885a6da962 | 17 | RatioMetric7714 resistorAdc(9988, 9976, 9942, 9956, 9830); |
Dance | 0:de885a6da962 | 18 | // フィルタノッチ周波数(出力更新レート)の設定 |
Dance | 0:de885a6da962 | 19 | resistorAdc.setFilter(fsample); |
Dance | 0:de885a6da962 | 20 | |
Dance | 0:de885a6da962 | 21 | // サーミスタオブジェクト |
Dance | 0:de885a6da962 | 22 | // B定数、基準温度、基準温度でのサーミスタ抵抗値 |
Dance | 0:de885a6da962 | 23 | Thermistor tsensor(3480.0, 25.0, 5369.0); |
Dance | 0:de885a6da962 | 24 | // 2次式による補正のための設定 |
Dance | 0:de885a6da962 | 25 | tsensor.adjust(1.7, 0.5, 58.9, 57.0, 77.0, 73.0); |
Dance | 0:de885a6da962 | 26 | |
Dance | 0:de885a6da962 | 27 | // 指数平均によるLPFオブジェクト、4次フィルタ |
Dance | 0:de885a6da962 | 28 | ExpAvr LPF(4, LPFcut, fsample); |
Dance | 0:de885a6da962 | 29 | |
Dance | 0:de885a6da962 | 30 | serial.printf("self cal finished. OK!\r\n"); |
Dance | 0:de885a6da962 | 31 | serial.printf("Rs Temp LPF\r\n"); |
Dance | 0:de885a6da962 | 32 | |
Dance | 0:de885a6da962 | 33 | int cnt = 0; |
Dance | 0:de885a6da962 | 34 | while(1){ |
Dance | 0:de885a6da962 | 35 | // 変換終了を待つ |
Dance | 0:de885a6da962 | 36 | while(resistorAdc.isBusy()){ |
Dance | 0:de885a6da962 | 37 | } |
Dance | 0:de885a6da962 | 38 | // サーミスタの抵抗値を得る |
Dance | 0:de885a6da962 | 39 | double r = resistorAdc.getResistorValue(); |
Dance | 0:de885a6da962 | 40 | // 抵抗値を温度値に変換 |
Dance | 0:de885a6da962 | 41 | double t = tsensor.toTempValue(r); |
Dance | 0:de885a6da962 | 42 | // LPF処理 |
Dance | 0:de885a6da962 | 43 | double v = LPF.getOutput(t); |
Dance | 0:de885a6da962 | 44 | // 出力更新レートに関わらず1Hz毎に測定結果を出力 |
Dance | 0:de885a6da962 | 45 | if(cnt++ == fsample){ |
Dance | 0:de885a6da962 | 46 | cnt = 0; |
Dance | 0:de885a6da962 | 47 | serial.printf("%7.2f, %6.4f, %6.4f\n\r", r, t, v); |
Dance | 0:de885a6da962 | 48 | } |
Dance | 0:de885a6da962 | 49 | } |
Dance | 0:de885a6da962 | 50 | } |