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: biquadFilter mbed HIDScope
main.cpp
- Committer:
- s1604554
- Date:
- 2016-10-31
- Revision:
- 11:50ef30ca2b59
- Parent:
- 10:bc2c13508fe5
- Child:
- 12:b7025b3a111b
File content as of revision 11:50ef30ca2b59:
#include "mbed.h"
#include "BiQuad.h"
#include "stdlib.h"
#include <iostream>
#include <cmath>
#include <string>
#include "HIDScope.h"
AnalogIn emg0(A0);
AnalogIn emg1(A1);
DigitalOut led1(LED1);
HIDScope scope( 2 );
Ticker emgticker;
BiQuadChain bqc;
BiQuad bq1( 8.17310e-01, 0.00000e+00, -8.17310e-01, -1.57627e-01, -6.34619e-01 ); //bandpass
BiQuad bq2( 6.68124e-01, -1.27085e+00, 6.68124e-01, -1.27085e+00, 3.36249e-01 ); //notchnotch
//there is a rectifier between these two bqc's
//gives you new highfrequency noise, so lowpass afterwards
BiQuadChain bqc2;
BiQuad bq3( 2.00834e-02, 4.01667e-02, 2.00834e-02, -1.56102e+00, 6.41352e-01 ); //lowpass
void Sample ()
{
double emgSignal = emg0.read();
double emgFiltered1 = bqc.step(emgSignal);
double emgFiltered2 = fabs(emgFiltered1);
double emgFiltered3 = bqc2.step(emgFiltered2);
scope.set(0, emgSignal);
scope.set(1, emgFiltered3);
scope.send();
if (emgFiltered3 >= 0.1)
{
led1 = !led1;
emgFiltered3 = true;
}
}
int main()
{
led1 = 1;
bqc.add( &bq1 ).add( &bq2 );
bqc2.add( &bq3 );
emgticker.attach(&Sample, 0.001);
while (true) {
}
}