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.
Dependencies: Biquad HIDScope biquadFilter mbed BiQuad4th_order
Revision 2:5b3c939b4a8b, committed 2018-10-19
- Comitter:
- Mirjam
- Date:
- Fri Oct 19 14:49:54 2018 +0000
- Parent:
- 1:eeb1cd328267
- Child:
- 3:19aec41b416a
- Commit message:
- Totaal met vier filters (notch op 50 Hz, highpass 10 Hz, abs() en lowpass 1.5Hz)
Changed in this revision
| Filter/FilterDesign.cpp | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Filter/FilterDesign.cpp Fri Oct 19 11:26:00 2018 +0000
+++ b/Filter/FilterDesign.cpp Fri Oct 19 14:49:54 2018 +0000
@@ -1,49 +1,37 @@
#include "FilterDesign.h"
#include "BiQuad.h"
-BiQuadChain bqc1; // Maak een ketting van de verschillende soorten filters achter elkaar
-BiQuadChain bqc2;
-/*
-// Notch 50 Hz
-double a0 = 0.753836635129499;
-double a1 = -1.2197332976043829;
-double a2 = 0.753836635129499;
-double b1 = -1.2197332976043829;
-double b2 = 0.5076732702589982;
-/**/
+
+// Notch filter op 50 Hz
+double n_a0 = 0.9137620113472577;
+double n_a1 = -1.742189689727076;
+double n_a2 = 0.9137620113472577;
+double n_b1 = -1.742189689727076;
+double n_b2 = 0.8275240226945152;
+
// High pass 10 Hz
-double h_a0 = 0.9571359964201929;
-double h_a1 = -1.9142719928403857;
-double h_a2 = 0.9571359964201929;
-double h_b1 = -1.9124690745115471;
-double h_b2 = 0.9160749111692243;
-
- /*
-// Low pass 300 Hz
-double l_a0 = 0.3751196837396032;
-double l_a1 = 0.7502393674792064;
-double l_a2 = 0.3751196837396032;
-double l_b1 = 0.31593336261250676;
-double l_b2 = 0.1845453723459059;
+double hp_a0 = 0.9802743241577302;
+double hp_a1 = -1.9605486483154604;
+double hp_a2 = 0.9802743241577302;
+double hp_b1 = -1.9587021452553688;
+double hp_b2 = 0.9623951513755521;
-// Low pass 100 Hz
-double a0 = 0.6439437667747981;
-double a1 = -1.2878875335495963;
-double a2 = 0.6439437667747981;
-double b1 = -1.158633457826527;
-double b2 = 0.4171416092726655;
-/**/
-
+// Low pass 1.5 Hz
+double lp_a0 = 0.000021116987899827544;
+double lp_a1 = 0.00004223397579965509;
+double lp_a2 = 0.000021116987899827544;
+double lp_b1 = -1.9941796826070277;
+double lp_b2 = 0.9942641505586269;
+
double FilterDesign(double u)
{
- //BiQuad notch50(a0,a1,a2,b1,b2);
- BiQuad highpass10(h_a0,h_a1,h_a2,h_b1,h_b2);
- //BiQuad lowpass300(l_a0,l_a1,l_a2,l_b1,l_b2);
- // BiQuad lowpass100(a0,a1,a2,b1,b2);
- //ouble y1 = notch50.step(u);
- double y2 = highpass10.step(u);
- // double y3 = lowpass100.step(u);
- //bqc1.add(¬ch50).add(&highpass10);
- //double y = bqc1.step(u);
+ BiQuad notch50(n_a0,n_a1,n_a2,n_b1,n_b2);
+ BiQuad highpass10(hp_a0,hp_a1,hp_a2,hp_b1,hp_b2);
+ BiQuad lowpass15(lp_a0,lp_a1,lp_a2,lp_b1,lp_b2);
- return y2;
+ double y_n = notch50.step(u);
+ double y_hp = highpass10.step(y_n);
+ double y_abs = abs(y_hp);
+ double y_lp = lowpass15.step(y_abs);
+
+ return y_lp;
}
\ No newline at end of file
--- a/main.cpp Fri Oct 19 11:26:00 2018 +0000 +++ b/main.cpp Fri Oct 19 14:49:54 2018 +0000 @@ -3,15 +3,12 @@ #include "BiQuad.h" #include "FilterDesign.h" -// Dit deel van de code wordt gebruikt voor het filteren van een EMG signaal en het gebruiken van de switch voor de beweging. -// Input zijn de twee EMGs en 2 switches. +// Dit deel van de code wordt gebruikt voor het filteren van een EMG signaal //Define objects AnalogIn emg1_raw( A0 ); AnalogIn emg2_raw( A1 ); DigitalOut led(LED_GREEN); -//DigitalIn switch1(??); -//DigitalIn switch2(??); Ticker sample_timer; //Used to send to hidscope HIDScope scope(2); //Number of channels which needs to be send to the HIDScope