弄了个迷你电桥,硬件调通。数据采集上来了。软件方面可以先用pc机先写,然后移植到stm32中去。算法目标:避免浮点数计算,stm32f103c8t6没有fpu,用软件浮点速度慢。如果算法快,可以多测几次求平均值,降低方差。
试着算了一下。v1=[2714, 2698, 2690, 2661, 2635, 2603, 2578, 2527, 2486, 2437, 2385, 2333, 2277, 2214, 2144, 2062, 1984, 1942, 1870, 1794, 1743, 1745, 1569, 1494, 1411, 1340, 1247, 1180, 1110, 1039, 978, 911, 835, 759, 710, 648, 586, 550, 494, 458, 415, 384, 351, 333, 312, 290, 276, 270, 267, 268, 275, 278, 302, 320, 356, 364, 423, 453, 495, 541, 590, 651, 703, 777, 823, 899, 964, 1042, 1121, 1184, 1264, 1356, 1301, 1499, 1577, 1655, 1719, 1756, 1882, 1953, 2027, 2152, 2166, 2230, 2295, 2348, 2387, 2450, 2500, 2543, 2582, 2610, 2647, 2670, 2694, 2709, 2720, 2722, 2724, 2722,2712, 2698, 2679, 2653, 2634, 2600, 2560, 2518, 2487, 2432, 2373, 2323, 2264, 2198, 2140, 2070, 2005, 1937, 1861, 1785, 1709, 1626, 1559, 1471, 1404, 1328, 1258, 1172, 1099, 1027, 954, 890, 831, 676, 691, 637, 586, 550, 475, 449, 409, 374, 353, 335, 301, 284, 272, 267, 268, 264, 278, 285, 301, 328, 358, 381, 411, 450, 494, 544, 608, 670, 713, 778, 839, 909, 978, 1051, 1123, 1198, 1280, 1355, 1433, 1511, 1590, 1668, 1744, 1815, 1892, 1968, 2047, 2105, 2171, 2237, 2306, 2354, 2410, 2460, 2514, 2521, 2586, 2622, 2646, 2712, 2682, 2707, 2720, 2725, 2769, 2744]
v2=[1578, 1594, 1642, 1677, 1715, 1750, 1779, 1809, 1850, 1881, 1905, 1935, 1957, 1986, 2001, 2007, 2004, 2048, 2068, 2078, 2107, 2149, 2100, 2086, 2093, 2092, 2088, 2072, 2067, 2039, 2034, 2020, 1997, 1976, 1958, 1931, 1900, 1878, 1845, 1805, 1782, 1747, 1710, 1690, 1657, 1607, 1573, 1533, 1505, 1466, 1426, 1390, 1354, 1302, 1281, 1230, 1207, 1166, 1147, 1113, 1068, 1048, 1031, 1002, 977, 963, 935, 932, 919, 894, 887, 885, 778, 887, 894, 890, 889, 878, 916, 917, 945, 984, 984, 1008, 1028, 1052, 1080, 1096, 1144, 1169, 1204, 1242, 1279, 1304, 1350, 1389, 1436, 1463, 1505, 1540,1578, 1615, 1649, 1686, 1723, 1759, 1784, 1816, 1845, 1885, 1907, 1930, 1962, 1972, 2009, 2020, 2036, 2053, 2075, 2082, 2092, 2093, 2097, 2087, 2096, 2083, 2092, 2072, 2066, 2047, 2035, 2023, 2002, 1935, 1951, 1925, 1908, 1890, 1826, 1814, 1770, 1746, 1696, 1685, 1644, 1600, 1563, 1529, 1497, 1443, 1422, 1382, 1338, 1311, 1277, 1240, 1199, 1168, 1134, 1105, 1082, 1051, 1029, 1002, 977, 962, 946, 912, 913, 902, 890, 884, 887, 883, 893, 893, 895, 901, 918, 933, 941, 961, 987, 1019, 1029, 1062, 1085, 1119, 1148, 1168, 1212, 1250, 1283, 1338, 1372, 1400, 1436, 1476, 1520, 1562]
matlabclear all;
clc;
format long
v1=[2714, 2698, 2690, 2661, 2635, 2603, 2578, 2527, 2486, 2437, 2385, 2333, 2277, 2214, 2144, 2062, 1984, 1942, 1870, 1794, 1743, 1745, 1569, 1494, 1411, 1340, 1247, 1180, 1110, 1039, 978, 911, 835, 759, 710, 648, 586, 550, 494, 458, 415, 384, 351, 333, 312, 290, 276, 270, 267, 268, 275, 278, 302, 320, 356, 364, 423, 453, 495, 541, 590, 651, 703, 777, 823, 899, 964, 1042, 1121, 1184, 1264, 1356, 1301, 1499, 1577, 1655, 1719, 1756, 1882, 1953, 2027, 2152, 2166, 2230, 2295, 2348, 2387, 2450, 2500, 2543, 2582, 2610, 2647, 2670, 2694, 2709, 2720, 2722, 2724, 2722,2712, 2698, 2679, 2653, 2634, 2600, 2560, 2518, 2487, 2432, 2373, 2323, 2264, 2198, 2140, 2070, 2005, 1937, 1861, 1785, 1709, 1626, 1559, 1471, 1404, 1328, 1258, 1172, 1099, 1027, 954, 890, 831, 676, 691, 637, 586, 550, 475, 449, 409, 374, 353, 335, 301, 284, 272, 267, 268, 264, 278, 285, 301, 328, 358, 381, 411, 450, 494, 544, 608, 670, 713, 778, 839, 909, 978, 1051, 1123, 1198, 1280, 1355, 1433, 1511, 1590, 1668, 1744, 1815, 1892, 1968, 2047, 2105, 2171, 2237, 2306, 2354, 2410, 2460, 2514, 2521, 2586, 2622, 2646, 2712, 2682, 2707, 2720, 2725, 2769, 2744]
v2=[1578, 1594, 1642, 1677, 1715, 1750, 1779, 1809, 1850, 1881, 1905, 1935, 1957, 1986, 2001, 2007, 2004, 2048, 2068, 2078, 2107, 2149, 2100, 2086, 2093, 2092, 2088, 2072, 2067, 2039, 2034, 2020, 1997, 1976, 1958, 1931, 1900, 1878, 1845, 1805, 1782, 1747, 1710, 1690, 1657, 1607, 1573, 1533, 1505, 1466, 1426, 1390, 1354, 1302, 1281, 1230, 1207, 1166, 1147, 1113, 1068, 1048, 1031, 1002, 977, 963, 935, 932, 919, 894, 887, 885, 778, 887, 894, 890, 889, 878, 916, 917, 945, 984, 984, 1008, 1028, 1052, 1080, 1096, 1144, 1169, 1204, 1242, 1279, 1304, 1350, 1389, 1436, 1463, 1505, 1540,1578, 1615, 1649, 1686, 1723, 1759, 1784, 1816, 1845, 1885, 1907, 1930, 1962, 1972, 2009, 2020, 2036, 2053, 2075, 2082, 2092, 2093, 2097, 2087, 2096, 2083, 2092, 2072, 2066, 2047, 2035, 2023, 2002, 1935, 1951, 1925, 1908, 1890, 1826, 1814, 1770, 1746, 1696, 1685, 1644, 1600, 1563, 1529, 1497, 1443, 1422, 1382, 1338, 1311, 1277, 1240, 1199, 1168, 1134, 1105, 1082, 1051, 1029, 1002, 977, 962, 946, 912, 913, 902, 890, 884, 887, 883, 893, 893, 895, 901, 918, 933, 941, 961, 987, 1019, 1029, 1062, 1085, 1119, 1148, 1168, 1212, 1250, 1283, 1338, 1372, 1400, 1436, 1476, 1520, 1562]
F1=fft(v1)
F2=fft(v2)
F1(1)=0
F2(1)=0
V=max(F1)
I=max(F2)/1800
Y=abs(I/V)
Cx=Y/(2*pi*1e3)*1e9
程序输出结果:
Cx = 43.347718537423894 nf
|