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: HIDScope mbed MODSERIAL QEI
EMG.cpp
- Committer:
- john111222333
- Date:
- 2017-10-17
- Revision:
- 7:c17f5473f4e1
- Parent:
- 6:452e301a105a
- Child:
- 11:dd1976534a03
File content as of revision 7:c17f5473f4e1:
#include "EMG.h"
EMG::EMG(PinName data) : _data(data) , MainsReject(0.940809296, -1.525271192, 0.940809296, 1.000000000, -1.525271192, 0.881618592) ,
Low_pass( 0.145323884, 0.290647768, 0.145323884, 1.000000000, -0.671029091, 0.252324626) ,
HiPass(0.914969144, -1.829938288, 0.914969144, 1.000000000, -1.822694925, 0.837181651) ,
LoPass( 0.003621682, 0.007243363, 0.003621682, 1.000000000, -1.822694925, 0.837181651)
{
cntr = 0;
}
double EMG::get_notch(double data){
return MainsReject.step(data);
}
double EMG::get_noise(){
return Low_pass.step(_data);
}
double EMG::get_DC(double data){
return HiPass.step(data);
}
double EMG::get_absolute(double data){
return abs(data);
}
double EMG::get_envelope(double data){
return LoPass.step(data);
}
double EMG::filter(){
if(cntr<=500)
{
cntr++;
return 0;
}
else
{
return get_envelope(get_absolute(get_DC(get_notch(get_noise()))));
}
}
