![](/media/cache/group/9e3cc099b3b04bca937a1cca1da81b19.jpg.50x50_q85.jpg)
Dit is alleen het EMG gedeelte
Dependencies: mbed HIDScope biquadFilter MODSERIAL FXOS8700Q
Diff: main.cpp
- Revision:
- 3:c0ece64850db
- Parent:
- 2:d3e9788ab1b3
- Child:
- 4:09a01d2db8f7
--- a/main.cpp Sun Oct 20 18:45:13 2019 +0000 +++ b/main.cpp Sun Oct 20 19:01:21 2019 +0000 @@ -34,40 +34,23 @@ double rectify2; double rectify3; -// Notch filter coefficients (iirnotch Q factor 35 @50Hz) from MATLAB: 0.995636295063941 -1.89829218816065 0.995636295063941 1 -1.89829218816065 0.991272590127882 -const double n_b0 = 0.995636295063941; -const double n_b1 = -1.89829218816065; -const double n_b2 = 0.995636295063941; -const double n_a0 = 1; -const double n_a1 = -1.89829218816065; -const double n_a2 = 0.991272590127882; - -// Highpass filter coefficients (butter 4th order @10Hz cutoff) from MATLAB: 0.922946103200875 -1.84589220640175 0.922946103200875 1 -1.88920703055163 0.892769008131025 -const double h_b0 = 0.922946103200875; -const double h_b1 = -1.84589220640175; -const double h_b2 = 0.922946103200875; -const double h_a0 = 1; -const double h_a1 = -1.88920703055163; -const double h_02 = 0.892769008131025; +// Notch filter coefficients (iirnotch Q factor 35 @50Hz) from MATLAB in the following form: +// b01 b11 b21 a01 a11 a21 +BiQuad bq_notch(0.995636295063941, -1.89829218816065, 0.995636295063941, 1, -1.89829218816065, 0.991272590127882); -// Lowpass filter coefficients (butter 4th order @5Hz cutoff) from MATLAB: 5.32116245737504e-08 1.06423249147501e-07 5.32116245737504e-08 1 -1.94396715039462 0.944882378004138 -const double l_b0 = 5.32116245737504e-08; -const double l_b1 = 1.06423249147501e-07; -const double l_b2 = 5.32116245737504e-08; -const double l_a0 = 1; -const double l_a1 = -1.94396715039462; -const double l_a2 = 0.944882378004138; - +// Highpass filter coefficients (butter 4th order @10Hz cutoff) from MATLAB in the following form: +// b01 b11 b21 a01 a11 a21 +// b02 b12 b22 a02 a12 a22 +BiQuad bq_H1(0.922946103200875, -1.84589220640175, 0.922946103200875, 1, -1.88920703055163, 0.892769008131025); +BiQuad bq_H2(1, -2, 1, 1, -1.95046575793011, 0.954143234875078); +BiQuadChain bqc_high; // Used to chain two 2nd other filters into a 4th order filter -//BiQuad filters intialization -BiQuadChain notch; -BiQuad bq_notch( n_b0, n_b1, n_b2, n_a0, n_a1, n_a2); - -BiQuadChain highpass; -BiQuad bq_high( h_b0, h_b1, h_b2, h_a0, h_a1, h_a2); - -BiQuadChain lowpass; -BiQuad bq_notch( l_b0, l_b1, l_b2, l_a0, l_a1, l_a2); +// Lowpass filter coefficients (butter 4th order @5Hz cutoff) from MATLAB in the following form: +// b01 b11 b21 a01 a11 a21 +// b02 b12 b22 a02 a12 a22 +BiQuad bq_L1(5.32116245737504e-08, 1.06423249147501e-07, 5.32116245737504e-08, 1, -1.94396715039462, 0.944882378004138); +BiQuad bq_L2(1, 2, 1, 1, -1.97586467534468, 0.976794920438162); +BiQuadChain bqc_low; // Used to chain two 2nd other filters into a 4th order filter void sample() {