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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ExpAvr.cpp Source File

ExpAvr.cpp

00001 #include "ExpAvr.h"
00002 
00003 /// 指数平均を行い最新の値を返す
00004 /// @param double val 入力値
00005 /// @return double 移動平均後の値
00006 double ExpAvr::getOutput(double val)
00007 {
00008     int a;
00009     // 入力値で初期化
00010     if(first){
00011         first = false;
00012         for(a = 0; a < order; a++){
00013             acc[a] = val;
00014         }
00015         return val;
00016     }
00017     // 各段の値を計算
00018     for(a = 0; a < order; a++){
00019         acc[a] = tc * acc[a] + (1.0 - tc) * val;
00020         val = acc[a];
00021     }
00022     return val;
00023 }