2017年度の製作を開始します。

Dependencies:   BufferedSoftSerial2 SDFileSystem-RTOS mbed mbed-rtos INA226_ver1

Fork of keiki2016ver5 by albatross

Committer:
tsumagari
Date:
Sat Nov 26 01:12:10 2016 +0000
Branch:
fusokukei
Revision:
15:6966299bea4c
Parent:
13:09e05e7cfca1
Child:
27:d2955f29a3aa
?????????????????????????????????????????13?????????;?????????soudaDatas???????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
taurin 0:085b2c5e3254 1 #ifndef FUSOKUKEI_H
taurin 0:085b2c5e3254 2 #define FUSOKUKEI_H
taurin 0:085b2c5e3254 3
taurin 0:085b2c5e3254 4 #include "mbed.h"
taurin 0:085b2c5e3254 5
taurin 7:9415448ae9ca 6
tsumagari 13:09e05e7cfca1 7 #define AIR_K 4.70581884 //0.14737
taurin 7:9415448ae9ca 8 #define AIR_N 1.12
taurin 0:085b2c5e3254 9 #define AIR_A 1.4314
taurin 0:085b2c5e3254 10 #define AIR_B 0.209
taurin 0:085b2c5e3254 11 #define AIR_SUM_NUM 20
taurin 0:085b2c5e3254 12 #define AIR_BUFFER 30
taurin 0:085b2c5e3254 13
taurin 0:085b2c5e3254 14 float airSpeed = 0.0;
taurin 0:085b2c5e3254 15 float airSpeed_ave = 0.0;
taurin 0:085b2c5e3254 16 float airSpeed_max = 0.0;
taurin 0:085b2c5e3254 17 int air_counter = 0;
taurin 0:085b2c5e3254 18 float air_sum[AIR_SUM_NUM] = {0.0};
taurin 0:085b2c5e3254 19
taurin 0:085b2c5e3254 20 class Fusokukei{
tsumagari 15:6966299bea4c 21 double air_r;
taurin 0:085b2c5e3254 22 protected:
taurin 0:085b2c5e3254 23
taurin 0:085b2c5e3254 24 public:
taurin 0:085b2c5e3254 25 float make_ave(float s[], int n){
taurin 0:085b2c5e3254 26 float p = 0;
taurin 0:085b2c5e3254 27 int i;
taurin 0:085b2c5e3254 28 for(i = 0; i < n; i++){
taurin 0:085b2c5e3254 29 p += s[i];
taurin 0:085b2c5e3254 30 }
taurin 0:085b2c5e3254 31 if(n != 0)
taurin 0:085b2c5e3254 32 return p / n;
taurin 0:085b2c5e3254 33 else
taurin 0:085b2c5e3254 34 return 0;
taurin 0:085b2c5e3254 35 }
taurin 0:085b2c5e3254 36
taurin 0:085b2c5e3254 37 void calcAirSpeed(float x){
tsumagari 15:6966299bea4c 38 air_r = x/150;
tsumagari 15:6966299bea4c 39 air_sum[air_counter % AIR_SUM_NUM] = (float)AIR_K * (float)pow(air_r, 1 / AIR_N);
taurin 0:085b2c5e3254 40 if(air_counter % AIR_SUM_NUM == 0)
taurin 0:085b2c5e3254 41 air_counter = 0;
taurin 0:085b2c5e3254 42 airSpeed_ave = make_ave(air_sum, AIR_SUM_NUM);
taurin 7:9415448ae9ca 43 //airSpeed = airSpeed_ave*AIR_A+AIR_B;
taurin 7:9415448ae9ca 44 airSpeed=airSpeed_ave;
taurin 0:085b2c5e3254 45 if(airSpeed > airSpeed_max)
taurin 0:085b2c5e3254 46 airSpeed_max = airSpeed;
taurin 0:085b2c5e3254 47 air_counter++;
taurin 0:085b2c5e3254 48 }
taurin 0:085b2c5e3254 49 };
taurin 0:085b2c5e3254 50 #endif