Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 12:39709bc96e80, committed 2016-04-28
- Comitter:
- mikeb
- Date:
- Thu Apr 28 06:23:25 2016 +0000
- Parent:
- 11:8574bb5b92b0
- Child:
- 13:d221d9ef6338
- Commit message:
- corr method;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Apr 28 06:21:10 2016 +0000
+++ b/main.cpp Thu Apr 28 06:23:25 2016 +0000
@@ -3,6 +3,8 @@
#include "Phase_Finder.h"
#include "arm_math.h"
//Filter coefficients. DO NOT DELETE.
+float reference[357] = {0.500000, 0.496806, 0.487263, 0.471495, 0.449703, 0.422164, 0.389231, 0.351325, 0.308930, 0.262587, 0.212890, 0.160472, 0.106004, 0.050181, -0.006283, -0.062667, -0.118249, -0.172321, -0.224192, -0.273197, -0.318712, -0.360155, -0.396995, -0.428763, -0.455053, -0.475528, -0.489928, -0.498067, -0.499842, -0.495231, -0.484292, -0.467164, -0.444068, -0.415298, -0.381221, -0.342274, -0.298952, -0.251812, -0.201453, -0.148521, -0.093691, -0.037663, 0.018845, 0.075113, 0.130421, 0.184062, 0.235352, 0.283634, 0.328293, 0.368757, 0.404508, 0.435092, 0.460116, 0.479261, 0.492282, 0.499013, 0.499368, 0.493343, 0.481014, 0.462539, 0.438153, 0.408170, 0.372971, 0.333006, 0.288786, 0.240877, 0.189890, 0.136476, 0.081319, 0.025122, -0.031395, -0.087512, -0.142510, -0.195687, -0.246364, -0.293893, -0.337666, -0.377126, -0.411766, -0.441146, -0.464888, -0.482691, -0.494326, -0.499645, -0.498579, -0.491144, -0.477432, -0.457621, -0.431962, -0.400783, -0.364484, -0.323528, -0.278438, -0.229790, -0.178206, -0.124345, -0.068895, -0.012565, 0.043926, 0.099855, 0.154508, 0.207188, 0.257220, 0.303965, 0.346827, 0.385257, 0.418764, 0.446921, 0.469367, 0.485816, 0.496057, 0.499961, 0.497476, 0.488634, 0.473549, 0.452414, 0.425497, 0.393144, 0.355768, 0.313846, 0.267913, 0.218558, 0.166410, 0.112135, 0.056428, 0.000000, -0.056428, -0.112135, -0.166410, -0.218558, -0.267913, -0.313846, -0.355768, -0.393144, -0.425497, -0.452414, -0.473549, -0.488634, -0.497476, -0.499961, -0.496057, -0.485816, -0.469367, -0.446921, -0.418764, -0.385257, -0.346827, -0.303965, -0.257220, -0.207188, -0.154508, -0.099855, -0.043926, 0.012565, 0.068895, 0.124345, 0.178206, 0.229790, 0.278438, 0.323528, 0.364484, 0.400783, 0.431962, 0.457621, 0.477432, 0.491144, 0.498579, 0.499645, 0.494326, 0.482691, 0.464888, 0.441146, 0.411766, 0.377126, 0.337666, 0.293893, 0.246364, 0.195687, 0.142510, 0.087512, 0.031395, -0.025122, -0.081319, -0.136476, -0.189890, -0.240877, -0.288786, -0.333006, -0.372971, -0.408170, -0.438153, -0.462539, -0.481014, -0.493343, -0.499368, -0.499013, -0.492282, -0.479261, -0.460116, -0.435092, -0.404508, -0.368757, -0.328293, -0.283634, -0.235352, -0.184062, -0.130421, -0.075113, -0.018845, 0.037663, 0.093691, 0.148521, 0.201453, 0.251812, 0.298952, 0.342274, 0.381221, 0.415298, 0.444068, 0.467164, 0.484292, 0.495231, 0.499842, 0.498067, 0.489928, 0.475528, 0.455053, 0.428763, 0.396995, 0.360155, 0.318712, 0.273197, 0.224192, 0.172321, 0.118249, 0.062667, 0.006283, -0.050181, -0.106004, -0.160472, -0.212890, -0.262587, -0.308930, -0.351325, -0.389231, -0.422164, -0.449703, -0.471495, -0.487263, -0.496806, -0.500000, -0.496806, -0.487263, -0.471495, -0.449703, -0.422164, -0.389231, -0.351325, -0.308930, -0.262587, -0.212890, -0.160472, -0.106004, -0.050181, 0.006283, 0.062667, 0.118249, 0.172321, 0.224192, 0.273197, 0.318712, 0.360155, 0.396995, 0.428763, 0.455053, 0.475528, 0.489928, 0.498067, 0.499842, 0.495231, 0.484292, 0.467164, 0.444068, 0.415298, 0.381221, 0.342274, 0.298952, 0.251812, 0.201453, 0.148521, 0.093691, 0.037663, -0.018845, -0.075113, -0.130421, -0.184062, -0.235352, -0.283634, -0.328293, -0.368757, -0.404508, -0.435092, -0.460116, -0.479261, -0.492282, -0.499013, -0.499368, -0.493343, -0.481014, -0.462539, -0.438153, -0.408170, -0.372971, -0.333006, -0.288786, -0.240877, -0.189890, -0.136476, -0.081319, -0.025122, 0.031395, 0.087512, 0.142510, 0.195687, 0.246364, 0.293893, 0.337666, 0.377126, 0.411766, 0.441146, 0.464888, 0.482691, 0.494326, 0.499645, 0.498579, 0.491144, 0.477432, 0.457621, 0.431962, 0.400783, 0.364484, 0.323528, 0.278438, 0.229790, 0.178206, 0.124345, 0.068895, 0.012565, -0.043926, -0.099855, -0.154508, -0.207188, -0.257220, -0.303965, -0.346827, -0.385257, -0.418764 };
+
float b[51] = {-0.007772, -0.003741, -0.004376, -0.004861, -0.005128, -0.005108, -0.004726, -0.003925, -0.002650, -0.000867, 0.001443, 0.004277, 0.007607, 0.011379, 0.015521, 0.019940, 0.024525, 0.029149, 0.033671, 0.037953, 0.041851, 0.045248, 0.048020, 0.050070, 0.051335, 0.251747, 0.051335, 0.050070, 0.048020, 0.045248, 0.041851, 0.037953, 0.033671, 0.029149, 0.024525, 0.019940, 0.015521, 0.011379, 0.007607, 0.004277, 0.001443, -0.000867, -0.002650, -0.003925, -0.004726, -0.005108, -0.005128, -0.004861, -0.004376, -0.003741, -0.007772};
//Dummy signal to make it complile. Delete.
//float signal[350] = {-0.171926, -0.164431, -0.109017, -0.007292, 0.083098, 0.222924, 0.373266, 0.531815, 0.722060, 0.943519, 1.171436, 1.416762, 1.647820, 1.869734, 2.094165, 3.221791, 3.919746, 3.300559, 4.013104, 3.629830, 3.486193, 3.495529, 3.640264, 3.993478, 3.635194, 2.212095, 2.686072, 2.032333, 0.725234, 0.709661, -0.188523, -0.558864, -0.605799, -1.144265, -2.063190, -2.618962, -3.365376, -3.522119, -3.621998, -4.183547, -4.631551, -4.757968, -5.449490, -4.782776, -5.330020, -5.053121, -5.126057, -5.150428, -4.545297, -4.746356, -2.891791, -2.930119, -3.373582, -1.841205, -2.306663, -1.174910, -0.530784, 0.265803, 0.652884, 1.361013, 1.676977, 2.341486, 3.051038, 3.463575, 4.059581, 3.919068, 4.184487, 3.985282, 4.882868, 4.734705, 5.219888, 4.853742, 4.911346, 4.433226, 4.594856, 3.915354, 4.164072, 3.478993, 3.469309, 3.062880, 2.170758, 1.188631, 0.973389, 0.416491, 0.302067, -0.472809, -0.938098, -1.471422, -1.659218, -2.682480, -3.112274, -3.355195, -3.753629, -3.637839, -3.618635, -3.810530, -4.435617, -4.432250, -4.503820, -4.415154, -4.226244, -4.143591, -4.532533, -4.002480, -4.213850, -3.838094, -3.292588, -2.866270, -2.045566, -2.098614, -1.753220, -0.829118, -0.820524, 0.180795, 0.380893, 1.469267, 1.238872, 2.023806, 2.476717, 3.204941, 3.629909, 3.932498, 4.595968, 4.888801, 4.833841, 4.368102, 4.539508, 4.805146, 4.581446, 4.998927, 4.410131, 4.377639, 3.443010, 3.274809, 2.797714, 3.249483, 2.375086, 1.975362, 1.078000, 0.540086, 0.356897, -0.211387, -0.769486, -1.618888, -2.459778, -2.773895, -3.163354, -3.761071, -4.290114, -4.482664, -4.846559, -4.970844, -4.447797, -5.077544, -5.039585, -4.986628, -5.278021, -5.124513, -4.862664, -4.253031, -4.287352, -3.589156, -3.454390, -3.088135, -2.137847, -2.102912, -1.468011, -0.592856, -0.306698, 0.391857, 0.815387, 1.393243, 2.075283, 2.630311, 2.675572, 3.622321, 3.306180, 3.782502, 4.440816, 4.630192, 4.519812, 4.487716, 4.686595, 4.628369, 4.580376, 4.233655, 3.801272, 3.564165, 3.688830, 3.286295, 2.620788, 2.419409, 1.709356, 1.110968, 1.022952, -0.030208, -0.170681, -0.772485, -1.074350, -1.615238, -1.879486, -2.847920, -2.668092, -3.110102, -3.775532, -3.872787, -4.032065, -4.328871, -4.060052, -4.555232, -4.402229, -4.439816, -3.997897, -3.992540, -3.784796, -3.424051, -3.496234, -2.718903, -2.491277, -2.053326, -1.575908, -0.609457, -1.131810, -0.614776, 0.063980, 0.511015, 1.594910, 1.646399, 2.183805, 2.728259, 3.030428, 3.646177, 4.170161, 4.672574, 4.042578, 3.836475, 5.109740, 4.502200, 4.567188, 4.212829, 4.710209, 4.089788, 3.806692, 3.515854, 3.298185, 2.827392, 1.891928, 1.400900, 1.203533, 0.403391, -0.032541, -0.041059, -1.511060, -1.451378, -1.413470, -2.562112, -2.362005, -3.156877, -3.315784, -3.664911, -4.459824, -4.555808, -4.419097, -4.670024, -4.763353, -4.911585, -4.418733, -4.523172, -4.016395, -4.285387, -3.673176, -3.182000, -3.513826, -2.064272, -2.259835, -1.662449, -1.208372, -0.644120, -0.364028, 0.539445, 0.471142, 1.622844, 1.935751, 2.059906, 3.156104, 3.607223, 3.854957, 4.479310, 4.126830, 4.265574, 3.987360, -0.035804, -0.073435, -0.072925, -0.116558, -0.129573, -0.146679, -0.165569, -0.187004, -0.216111};
@@ -14,7 +16,7 @@
float phases = 0;
float filteredSignal[401] = {}; //this array holds the signal after filtering. Make sure the input signal is > 300 samples.
arm_conv_f32(signal, 351 , b, 51, filteredSignal ) ; //Filtering operation
- Phase_Finder phase(50000, 900); //Create phase object
+ Phase_Finder phase(50000, 900, reference); //Create phase object
//Have to delete the leading values due to the low pass filter screwing with the magnitude.
float calcSignal[251] = {};