Transistor Gijutsu, October 2014, Special Features Chapter 8,Software of the thermistor thermometer of 0.001 ° resolution, トランジスタ技術2014年10月号 特集第8章のソフトウェア 0.001℃分解能で気配もキャッチ「超敏感肌温度計」
AD7714.h
00001 #ifndef AD7714_H 00002 #define AD7714_H 00003 #include "mbed.h" 00004 00005 /** 00006 * AD7714クラス 00007 * 00008 * AD7714の設定し運用する 00009 * サーミスタ温度計に必要な機能を実装したものなので 00010 * AD7714のすべての機能を制御することはできない 00011 */ 00012 class AD7714{ 00013 private: 00014 00015 static const int CmdRead = 0x08; 00016 static const int CmdWrite = 0x00; 00017 00018 int channel; 00019 int data; 00020 00021 SPI *spi; ///< SPI通信のインスタンス 00022 00023 00024 public: 00025 static const int FclkIn = 1000000; ///< AD7714へのクロック 1MHz 00026 static const int bits = 24; ///< 変換ビット長 00027 /// 内部レジスタを選択するための数値 00028 static struct CRegister { 00029 static const int Comun = 0x00; ///< コミュニケーションレジスタ 00030 static const int Mode = 0x10; ///< モードレジスタ 00031 static const int FltHi = 0x20; ///< フィルタ上位レジスタ 00032 static const int FltLo = 0x30; ///< フィルタ下位レジスタ 00033 static const int Test = 0x40; ///< 動作テスト、使用禁止 00034 static const int Data = 0x50; ///< データレジスタ 00035 static const int ZeroCal = 0x60; ///< ゼロキャリブレーションレジスタ 00036 static const int FullCal = 0x70; ///< フルスケールキャリブレーションレジスタ 00037 } Reg; ///< レジスタを指定するための構造体 00038 /// 入力チャネルの指定 00039 static struct CCh { 00040 static const int A1A6 = 0; ///< 擬似差動入力 ch1 - ch6 00041 static const int A2A6 = 1; ///< 擬似差動入力 ch2 - ch6 00042 static const int A3A6 = 2; ///< 擬似差動入力 ch3 - ch6 00043 static const int A4A6 = 3; ///< 擬似差動入力 ch4 - ch6 00044 static const int A1A2 = 4; ///< 差動入力 ch1 - ch2 00045 static const int A3A4 = 5; ///< 差動入力 ch3 - ch4 00046 static const int A5A6 = 6; ///< 差動入力 ch5 - ch6 00047 static const int A6A6 = 7; ///< テスト入力 ch6 - ch6 00048 } Ch; ///< 入力チャネルを指定するための構造体 00049 00050 00051 /// 内部レジスタに値を書き込む 00052 void write(int reg, int data); 00053 /// レジスタを読む 00054 int read(int reg); 00055 /// バイトデータを書き込む 00056 int writeByte(int txd); 00057 00058 /// コンストラクタ 00059 AD7714(); 00060 /// リセット 00061 void reset(void); 00062 /// ゼロとフルスケールのキャリブレーション 00063 void calib(void); 00064 /// 変換中かどうかの判定 @return ture 変換中 00065 bool isBusy(); 00066 /// 入力チャネルを指定する 00067 void setCh(int ch){channel = ch;}; 00068 /// デジタルフィルタを設定する 00069 void setFilter(int filter); 00070 /// 変換値を読み出す 00071 int getValue(){return read(CRegister::Data);}; 00072 }; 00073 00074 /// AD7714によるレシオメトリックにより抵抗値を測定するADCクラス 00075 /// AD7714クラスから派生 00076 class RatioMetric7714 : public AD7714 { 00077 private: 00078 double af; 00079 double rpu; 00080 double rmu; 00081 double rml; 00082 double rru; 00083 double rrl; 00084 public: 00085 /** 00086 * コンストラクタ 00087 */ 00088 RatioMetric7714(double Rpu, double Rmu, double Rml, double Rru, double Rrl); 00089 /// 指定されたAD値を抵抗値に変換 00090 double toResistorValue(int adcVal); 00091 /// 現在のAD値を抵抗値に変換して返す 00092 double getResistorValue(void); 00093 }; 00094 00095 00096 00097 00098 #endif
Generated on Tue Jul 12 2022 19:08:10 by 1.7.2