Poep Hoofd / Mbed 2 deprecated PoolRobot_Code

Dependencies:   HIDScope mbed MODSERIAL QEI

Committer:
john111222333
Date:
Tue Oct 17 06:29:42 2017 +0000
Revision:
7:c17f5473f4e1
Parent:
6:452e301a105a
Child:
11:dd1976534a03
unknown changes;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Alex_Kyrl 6:452e301a105a 1 #include "EMG.h"
john111222333 7:c17f5473f4e1 2
Alex_Kyrl 6:452e301a105a 3
john111222333 7:c17f5473f4e1 4 EMG::EMG(PinName data) : _data(data) , MainsReject(0.940809296, -1.525271192, 0.940809296, 1.000000000, -1.525271192, 0.881618592) ,
john111222333 7:c17f5473f4e1 5 Low_pass( 0.145323884, 0.290647768, 0.145323884, 1.000000000, -0.671029091, 0.252324626) ,
john111222333 7:c17f5473f4e1 6 HiPass(0.914969144, -1.829938288, 0.914969144, 1.000000000, -1.822694925, 0.837181651) ,
john111222333 7:c17f5473f4e1 7 LoPass( 0.003621682, 0.007243363, 0.003621682, 1.000000000, -1.822694925, 0.837181651)
Alex_Kyrl 6:452e301a105a 8 {
Alex_Kyrl 6:452e301a105a 9 cntr = 0;
john111222333 7:c17f5473f4e1 10
Alex_Kyrl 6:452e301a105a 11
Alex_Kyrl 6:452e301a105a 12
john111222333 7:c17f5473f4e1 13 }
Alex_Kyrl 6:452e301a105a 14 double EMG::get_notch(double data){
Alex_Kyrl 6:452e301a105a 15
john111222333 7:c17f5473f4e1 16
Alex_Kyrl 6:452e301a105a 17
Alex_Kyrl 6:452e301a105a 18 return MainsReject.step(data);
Alex_Kyrl 6:452e301a105a 19
Alex_Kyrl 6:452e301a105a 20 }
Alex_Kyrl 6:452e301a105a 21
Alex_Kyrl 6:452e301a105a 22
john111222333 7:c17f5473f4e1 23 double EMG::get_noise(){
john111222333 7:c17f5473f4e1 24
Alex_Kyrl 6:452e301a105a 25
Alex_Kyrl 6:452e301a105a 26
john111222333 7:c17f5473f4e1 27 return Low_pass.step(_data);
Alex_Kyrl 6:452e301a105a 28 }
Alex_Kyrl 6:452e301a105a 29
Alex_Kyrl 6:452e301a105a 30
Alex_Kyrl 6:452e301a105a 31 double EMG::get_DC(double data){
Alex_Kyrl 6:452e301a105a 32
john111222333 7:c17f5473f4e1 33
Alex_Kyrl 6:452e301a105a 34
Alex_Kyrl 6:452e301a105a 35 return HiPass.step(data);
Alex_Kyrl 6:452e301a105a 36
Alex_Kyrl 6:452e301a105a 37 }
Alex_Kyrl 6:452e301a105a 38
Alex_Kyrl 6:452e301a105a 39
Alex_Kyrl 6:452e301a105a 40 double EMG::get_absolute(double data){
Alex_Kyrl 6:452e301a105a 41
Alex_Kyrl 6:452e301a105a 42 return abs(data);
Alex_Kyrl 6:452e301a105a 43
Alex_Kyrl 6:452e301a105a 44
Alex_Kyrl 6:452e301a105a 45 }
Alex_Kyrl 6:452e301a105a 46
Alex_Kyrl 6:452e301a105a 47
Alex_Kyrl 6:452e301a105a 48 double EMG::get_envelope(double data){
Alex_Kyrl 6:452e301a105a 49
john111222333 7:c17f5473f4e1 50
Alex_Kyrl 6:452e301a105a 51
Alex_Kyrl 6:452e301a105a 52 return LoPass.step(data);
Alex_Kyrl 6:452e301a105a 53 }
Alex_Kyrl 6:452e301a105a 54
Alex_Kyrl 6:452e301a105a 55 double EMG::filter(){
Alex_Kyrl 6:452e301a105a 56
Alex_Kyrl 6:452e301a105a 57 if(cntr<=500)
Alex_Kyrl 6:452e301a105a 58 {
Alex_Kyrl 6:452e301a105a 59 cntr++;
Alex_Kyrl 6:452e301a105a 60 return 0;
Alex_Kyrl 6:452e301a105a 61 }
Alex_Kyrl 6:452e301a105a 62 else
Alex_Kyrl 6:452e301a105a 63 {
john111222333 7:c17f5473f4e1 64 return get_envelope(get_absolute(get_DC(get_notch(get_noise()))));
Alex_Kyrl 6:452e301a105a 65 }
Alex_Kyrl 6:452e301a105a 66
Alex_Kyrl 6:452e301a105a 67 }