Biorobotics
/
piano_robot
newest version,
Embed:
(wiki syntax)
Show/hide line numbers
read_filter_emg.h
00001 /* 00002 * read_filter_emg.h 00003 * 00004 * Created on: Oct 14, 2015 00005 * Author: User 00006 */ 00007 00008 #ifndef READ_FILTER_EMG_H_ 00009 #define READ_FILTER_EMG_H_ 00010 00011 class EMG { 00012 public: 00013 //create instance of the EMG class 00014 EMG(AnalogIn &aI_, double &v1_, double &v2_); 00015 AnalogIn aI(pinName); 00016 double v1; 00017 double v2; 00018 double input_sample; 00019 double filtered_sample; 00020 00021 //reads emg value and saves as input_sample 00022 void sample(); 00023 00024 /*general biquad function to be used in the filtering 00025 biquad coefficients are in the filter functions */ 00026 double biquad(double u, double &v1, double &v2, const double a1, 00027 const double a2, const double b0, const double b1, const double b2); 00028 00029 //20 hz highpass filter contains 3 biquads. Returns filtered value 00030 double highpass_filter(double hpInput); 00031 00032 //Rectify the input (take absolute value). Input is output of highpass 00033 double rectify(double rcInput); 00034 00035 //6 hz low pass filter, contains 3 biquads, input output of rectify 00036 double lowpass_filter(double lpInput); 00037 00038 //function containing all three filter steps. Input raw signal value, output is filtered envelope value 00039 double filter(double input); 00040 }; 00041 00042 #endif /* READ_FILTER_EMG_H_ */ 00043
Generated on Thu Aug 4 2022 19:30:43 by 1.7.2