Werkcollege opgave 23 september BMT K9

Dependencies:   Encoder HIDScope MODSERIAL mbed QEI biquadFilter

Committer:
bscheltinga
Date:
Wed Oct 07 15:42:23 2015 +0000
Revision:
16:ca457fa8257f
Parent:
15:7870f7912904
EMG filter High and Lowpass with Hidscope

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bscheltinga 0:fe3896c6eeb0 1 #include "mbed.h"
bscheltinga 12:0a079e86348e 2 #include "HIDScope.h"
bscheltinga 0:fe3896c6eeb0 3 #include "MODSERIAL.h"
bscheltinga 13:04e10692e239 4 #include "biquadFilter.h" //Filter direct form II
bscheltinga 0:fe3896c6eeb0 5
bscheltinga 15:7870f7912904 6 //Define inputs
bscheltinga 14:57d38789bff2 7 AnalogIn emgL(PTB0); //Analog input left arm
bscheltinga 14:57d38789bff2 8 AnalogIn emgR(PTB1); //Analog input right arm
bscheltinga 4:96e47998d495 9
bscheltinga 15:7870f7912904 10 //Define constants
bscheltinga 15:7870f7912904 11 float emgL_L;
bscheltinga 16:ca457fa8257f 12 float emgL_LH;
bscheltinga 15:7870f7912904 13
bscheltinga 13:04e10692e239 14 Ticker looptimer;
bscheltinga 14:57d38789bff2 15 volatile bool looptimerflag;
bscheltinga 15:7870f7912904 16
bscheltinga 16:ca457fa8257f 17 const float la1 = 0;
bscheltinga 16:ca457fa8257f 18 const float la2 = 0.17156822136;
bscheltinga 16:ca457fa8257f 19 const float lb0 = 0.2928920553;
bscheltinga 16:ca457fa8257f 20 const float lb1 = 0.5857841107;
bscheltinga 16:ca457fa8257f 21 const float lb2 = 0.2928920554; // Waarde van biquads via groep 1 2014
bscheltinga 16:ca457fa8257f 22 biquadFilter Lowpassfilter (la1, la2, lb0, lb1, lb2);
bscheltinga 15:7870f7912904 23
bscheltinga 16:ca457fa8257f 24 const float ha1 = -1.5610153913;
bscheltinga 16:ca457fa8257f 25 const float ha2 = 0.6413487154;
bscheltinga 16:ca457fa8257f 26 const float hb0 = 0.8005910267;
bscheltinga 16:ca457fa8257f 27 const float hb1 = -1.6011820533;
bscheltinga 16:ca457fa8257f 28 const float hb2 = 0.8005910267; // Waarde van biquads via groep 1 2014
bscheltinga 16:ca457fa8257f 29 biquadFilter Highpassfilter (ha1, ha2, hb0, hb1, hb2);
bscheltinga 16:ca457fa8257f 30
bscheltinga 16:ca457fa8257f 31 HIDScope scope(3);
bscheltinga 0:fe3896c6eeb0 32
bscheltinga 13:04e10692e239 33 void setlooptimerflag(void)
bscheltinga 13:04e10692e239 34 {
bscheltinga 14:57d38789bff2 35 looptimerflag = true;
bscheltinga 13:04e10692e239 36 }
bscheltinga 11:73817c9df1e5 37
bscheltinga 13:04e10692e239 38 int main()
bscheltinga 13:04e10692e239 39 {
bscheltinga 16:ca457fa8257f 40 looptimer.attach(setlooptimerflag, 0.01);
bscheltinga 15:7870f7912904 41 while(true) {
bscheltinga 12:0a079e86348e 42
bscheltinga 15:7870f7912904 43 while (looptimerflag !=true) {
bscheltinga 15:7870f7912904 44 looptimerflag = false;
bscheltinga 15:7870f7912904 45 emgL_L = Lowpassfilter.step(emgL); //emgL_L Linker bicep met lowpass filter
bscheltinga 16:ca457fa8257f 46 emgL_LH = Highpassfilter.step(emgL_L);
bscheltinga 13:04e10692e239 47 }
bscheltinga 16:ca457fa8257f 48 scope.set(0,emgL);
bscheltinga 16:ca457fa8257f 49 scope.set(1,emgL_L);
bscheltinga 16:ca457fa8257f 50 scope.set(2,emgL_LH);
bscheltinga 15:7870f7912904 51 scope.send();
bscheltinga 14:57d38789bff2 52 }
bscheltinga 14:57d38789bff2 53 }