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: Encoder HIDScope MODSERIAL mbed QEI biquadFilter
Diff: main.cpp
- Revision:
- 26:1090acf98efc
- Parent:
- 25:38ab6dd19d9b
- Child:
- 27:85e5d36bb6c5
--- a/main.cpp Fri Oct 09 10:21:39 2015 +0000
+++ b/main.cpp Fri Oct 09 11:05:05 2015 +0000
@@ -3,25 +3,26 @@
#include "MODSERIAL.h"
#include "biquadFilter.h" //Filter direct form II
-//Define inputs
+// [DEFINE INPUTS] //
AnalogIn emgL(A0); //Analog input left arm
//AnalogIn emgR(PTB1); //Analog input right arm
DigitalOut led1(LED_GREEN);
+// [DEFINE CONSTANTS] //
+float emgL_L, emgL_LH, emgLeft, emgL_H, emgL_Notch;
+double B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, MOVAVG;
+HIDScope scope(4); // Aantal HIDScope kanalen
MODSERIAL pc(USBTX,USBRX);
volatile bool control_go = false;
Ticker control_tick;
-//Define constants
-float emgL_L, emgL_LH, emgLeft, emgL_H, emgL_Notch;
-double B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, MOVAVG;
-
+// [BIQUAD FILTERS] //
const float la1 = 0.29358435979;
const float la2 = 0.71930322156;
const float lb0 = 1.00000000000;
const float lb1 = 0.01516472727;
const float lb2 = 1.00000000000; // Waarde van biquads via groep 1 2014
-biquadFilter Lowpassfilter (la1, la2, lb0, lb1, lb2);
+biquadFilter Lowpassfilter1 (la1, la2, lb0, lb1, lb2);
const float ha1 = -0.29358436761;
const float ha2 = 0.71930322175;
@@ -30,14 +31,15 @@
const float hb2 = 1.000000000000; // Waarde van biquads via groep 1 2014
biquadFilter Highpassfilter (ha1, ha2, hb0, hb1, hb2);
-HIDScope scope(4); // Aantal HIDScope kanalen
-
+// [FUNCTIONS] //
void ControlGo() //Control flag
{
control_go = true;
led1 = 0;
}
+
+// [MAIN FUNCTION] //
int main()
{
control_tick.attach(&ControlGo, 0.005);
@@ -54,7 +56,7 @@
emgL_H = Highpassfilter.step(emgLeft); //emgL_L met Highpassfilter
emgL_Notch = Highpassfilter.step(emgL_L); //Highpass filter over de lowpass filter = Notch
- // [MOVING AVERAGE]// Mov avg van lowpass filter
+ // [MOVING AVERAGE] // Mov avg van lowpass filter
B0 = emgL_L;
MOVAVG=B0*0.1+B1*0.1+B2*0.1+B3*0.1+B4*0.1+B5*0.1+B6*0.1+B7*0.1+B8*0.1+B9*0.1;
B9=B8;
