diff --git a/App/Src/anemometer_dev.c b/App/Src/anemometer_dev.c index bd56d62..8144542 100644 --- a/App/Src/anemometer_dev.c +++ b/App/Src/anemometer_dev.c @@ -6,6 +6,7 @@ #include "fdacoefs.h" #include "sht30.h" #include "hp203b.h" +#include "FIR.h" #define AVE_TIME 600 //滑动平均时间,秒,最大600 @@ -93,6 +94,17 @@ float32_t find_maxValPosition_by_sinInterpolation(float32_t a,float32_t b,float3 float32_t RSSI; +/*****************测试滤波器函数**********/ +int16_t firFilterTestData[1024]={ +2041,2047,2047,2045,2044,2045,2048,2050,2052,2049,2047,2046,2048,2050,2049,2048,2047,2045,2046,2045,2046,2045,2045,2043,2042,2044,2044,2044,2042,2042,2043,2042,2043,2042,2041,2040,2041,2043,2043,2042,2040,2041,2041,2042,2041,2041,2041,2041,2041,2041,2041,2043,2041,2039,2040,2042,2042,2041,2040,2042,2112,2097,1898,2011,2062,2081,2090,2010,1993,2055,2042,2012,2044,2051,2049,2062,2054,2038,2039,2027,2023,2054,2095,2070,1965,1966,2107,2125,2031,1971,2009,2076,2070,2017,2023,2065,2058,2033,2035,2048,2045,2035,2029,2041,2053,2048,2040,2047,2048,2031,2026,2039,2050,2054,2044,2035,2039,2041,2038,2037,2039,2044,2045,2045,2044,2038,2032,2038,2049,2051,2041,2032,2033,2043,2049,2048,2042,2039,2038,2040,2040,2039,2039,2043,2045,2044,2042,2039,2036,2039,2044,2048,2041,2036,2036,2039,2045,2046,2043,2040,2039,2038,2041,2043,2043,2042,2041,2039,2040,2039,2039,2042,2045,2045,2040,2036,2038,2043,2043,2043,2039,2038,2040,2042,2042,2043,2040,2040,2042,2043,2042,2038,2038,2042,2043,2040,2035,2033,2036,2041,2051,2060,2066,2067,2061,2046,2018,1987,1967,1966,1992,2039,2102,2163,2202,2199,2144,2041,1916,1807,1752,1778,1883,2051,2245,2412,2497,2457,2285,2015,1723,1492,1397,1478,1723,2081,2465,2765,2884,2769,2436,1968,1491,1145,1035,1199,1601,2143,2685,3069,3180,2975,2508,1895,1310,919,829,1067,1575,2220,2830,3227,3299,3023,2480,1814,1212,838,790,1082,1634,2213,2849,3460,3311,2814,2336,1803,1272,859,765,1159,1794,2352,2851,3207,3212,2868,2319,1701,1192,912,752,1280,2049,2424,2711,3073,3207,2907,2238,1551,1189,1031,998,1296,1885,2480,2906,3100,3019,2686,2153,1573,1163,1025,1132,1465,1979,2519,2904,3027,2875,2522,2051,1577,1234,1124,1264,1608,2062,2506,2811,2902,2763,2432,1996,1577,1293,1229,1396,1727,2120,2483,2723,2783,2640,2331,1947,1606,1395,1365,1512,1794,2141,2455,2649,2675,2529,2247,1913,1633,1479,1482,1627,1873,2161,2413,2558,2562,2423,2181,1906,1680,1561,1578,1717,1936,2176,2375,2477,2456,2323,2122,1911,1740,1654,1672,1791,1977,2172,2323,2392,2366,2254,2091,1921,1789,1727,1754,1858,2008,2159,2268,2313,2289,2202,2074,1938,1836,1795,1824,1911,2028,2141,2221,2251,2227,2154,2052,1951,1880,1859,1890,1957,2039,2118,2177,2198,2176,2116,2038,1966,1920,1912,1938,1987,2047,2104,2142,2152,2130,2087,2034,1985,1956,1950,1969,2006,2050,2091,2116,2119,2101,2068,2031,1999,1980,1978,1992,2020,2053,2080,2096,2096,2081,2056,2031,2009,1998,1997,2008,2031,2055,2074,2080,2075,2063,2047,2031,2017,2009,2099,2054,1896,2039,2085,2107,2106,2016,1999,2047,2017,1991,2031,2042,2053,2074,2069,2055,2054,2033,2024,2049,2080,2048,1944,1974,2120,2129,2036,1984,2029,2086,2061,2002,2011,2052,2045,2028,2041,2059,2058,2049,2041,2045,2046,2033,2025,2035,2039,2030,2034,2053,2067,2067,2051,2036,2032,2027,2023,2026,2035,2047,2055,2059,2058,2048,2037,2037,2041,2038,2028,2021,2030,2046,2058,2059,2055,2049,2043,2039,2033,2029,2028,2034,2041,2045,2048,2050,2050,2051,2051,2045,2034,2024,2024,2032,2041,2047,2049,2052,2051,2048,2045,2041,2036,2033,2030,2032,2037,2042,2048,2054,2056,2053,2043,2035,2032,2034,2034,2034,2036,2041,2048,2052,2052,2049,2044,2039,2037,2036,2032,2031,2036,2045,2050,2050,2047,2046,2044,2042,2037,2035,2033,2035,2038,2043,2045,2047,2048,2048,2045,2041,2036,2034,2035,2038,2042,2043,2044,2045,2046,2046,2045,2041,2038,2037,2038,2040,2040,2041,2043,2045,2045,2044,2042,2041,2041,2040,2039,2039,2040,2041,2042,2044,2043,2042,2041,2042,2041,2040,2040,2041,2041,2041,2040,2042,2042,2042,2042,2042,2042,2042,2043,2041,2039,2040,2041,2041,2040,2040,2041,1944,2038,2255,2036,1891,1992,2101,2125,2033,1959,2050,2117,2026,1990,2041,2058,2040,2040,2042,2056,2055,1872,2109,2287,2028,1843,1969,2146,2166,2019,1940,2064,2119,2012,1977,2039,2061,2045,2038,2050,2067,2048,2009,2018,2052,2044,2019,2035,2065,2071,2050,2024,2028,2040,2042,2042,2045,2045,2040,2040,2043,2040,2042,2047,2051,2047,2035,2024,2031,2048,2055,2047,2036,2034,2043,2050,2046,2037,2036,2040,2043,2040,2036,2038,2043,2047,2050,2051,2043,2030,2030,2037,2048,2048,2041,2037,2039,2042,2048,2050,2047,2037,2033,2033,2037,2043,2044,2043,2045,2046,2045,2039,2039,2041,2041,2039,2037,2038,2042,2044,2044,2045,2045,2043,2041,2039,2038,2037,2038,2041,2045,2044,2042,2040,2044,2047,2044,2038,2036,2037,2040,2043,2043,2042,2042,2045,2046,2044,2040,2036,2036,2039,2043,2041,2039,2039,2043,2046,2046,2044,2039,2037,2038,2038,2040,2040,2041,2043,2045,2045,2042,2041,2041,2041,2039,2038,2038,2041,2043,2044,2045,2044,2041,2041,2042,2041,2039,2038,2039,2041,2044,2042,2043,2042,2041,2042,2043,2041,2038,2037,2038,2042,2044,2043,2041,2040,2043,2045,2043,2041,2037,2114,2093,1893,1999,2066,2106,2091,1996,1990,2062,2047,2006,2037,2054,2057,2058,2048,2039,2044,2029,2025,2058,2098,2063,1949,1983,2122,2114,2017,1971,2022,2084,2062,2011,2031,2069,2052,2029,2035,2048,2045,2035,2031,2045,2053,2047,2042,2049,2045,2027,2024,2039,2053,2056,2043,2036,2040,2042,2039,2037,2038,2043,2044,2046,2044,2038,2034,2040,2052,2052,2040,2030,2032,2043,2048,2048,2043,2039,2039,2040,2040,2041,2041,2044,2044,2039,2039,2039,2037,2040,2046,2048,2043,2036,2036,2041,2046,2043,2039,2039,2039,2039,2041,2043,2044,2043,2041,2040,2039,2037,2039,2043,2047,2046,2041,2037,2039,2044,2044,2042}; + +int16_t firFilterTestOutData[1024]; + +float32_t buf[1024]; +float32_t buf2[1024]; + +/*****************测试滤波器函数**********/ + float32_t cal_tof(q15_t* x,uint32_t len) { q15_t max_val,dc_offset; @@ -107,6 +119,30 @@ float32_t cal_tof(q15_t* x,uint32_t len) // 信号减去直流分量 arm_offset_q15(x,-dc_offset,x,len); + /*****************测试滤波器函数**********/ + + arm_mean_q15(firFilterTestData,50,&dc_offset); + // 信号减去直流分量 + arm_offset_q15(firFilterTestData,-dc_offset,firFilterTestData,len); + // 转换成浮点数 + // arm_q15_to_float(firFilterTestData,buf,len); + + for(i= 0 ;i