4 directional EMG control of the XY table. Made during my bachelor end assignment.
Dependencies: C12832_lcd HIDScope mbed-dsp mbed
Diff: main.cpp
- Revision:
- 25:144eb5822aa7
- Parent:
- 24:c4c5d30a3938
- Child:
- 26:b88ff19ff5dc
--- a/main.cpp Fri May 08 13:35:41 2015 +0000 +++ b/main.cpp Fri May 08 15:01:30 2015 +0000 @@ -21,8 +21,9 @@ //Potmeter and EMG AnalogIn Pot1(p19); -AnalogIn emg0(p20); +AnalogIn emg0(p17); //HIDScope scope(2); + //lcd C12832_LCD lcd; @@ -66,12 +67,12 @@ void looper_emg() { /*variable to store value in*/ - //uint16_t emg_value1; + volatile uint16_t emg_value1; float emg_value1_f32; /*put raw emg value both in red and in emg_value*/ - //emg_value1 = emg0.read_u16(); // read direct ADC result, converted to 16 bit integer (0..2^16 = 0..65536 = 0..3.3V) + emg_value1 = emg0.read_u16(); // read direct ADC result, converted to 16 bit integer (0..2^16 = 0..65536 = 0..3.3V) emg_value1_f32 = emg0.read(); //process emg biceps @@ -110,15 +111,15 @@ } int main() { - Ticker log_timer; + /*Ticker log_timer; //set up filters. Use external array for constants arm_biquad_cascade_df1_init_f32(&lowpass_pot, 1 , lowpass_const, lowpass_pot_states); - log_timer.attach(looper_pot, 0.01); + log_timer.attach(looper_pot, 0.01);*/ - /*Ticker emgtimer; - arm_biquad_cascade_df1_init_f32(&lowpass_biceps,1 , lowpass_const, lowpass_biceps_states); - arm_biquad_cascade_df1_init_f32(&highnotch_biceps,2 ,highnotch_const,highnotch_biceps_states); - emgtimer.attach(looper_emg, 0.002);*/ + Ticker emgtimer; + arm_biquad_cascade_df1_init_f32(&lowpass_biceps, 1 , lowpass_const, lowpass_biceps_states); + arm_biquad_cascade_df1_init_f32(&highnotch_biceps, 2 , highnotch_const, highnotch_biceps_states); + emgtimer.attach(looper_emg, 0.01); Ticker looptimer; arm_biquad_cascade_df1_init_f32(&lowpass_step, 1, lowpass1_const, lowpass1_step_states); @@ -138,10 +139,11 @@ Dir = 1; } - lcd.printf("Spd %.0f Hz p1 %.4f \n", step_freq, pot_value1_f32); //snelheid meting op lcd - pc.printf("filt %f \n", filtered_biceps); - // pc.printf("Spd %.0f Hz p1 %.4f \n", step_freq, pot_value1_f32); //snelheid meting op lcd - wait(0.01); + //lcd.printf("Spd %.0f Hz p1 %.4f \n", step_freq, pot_value1_f32); //snelheid meting op lcd + pc.printf("filt %.3f raw %.3f \n", filtered_biceps, emg0.read()); + lcd.printf("filt %.3f raw %.3f \n", filtered_biceps, emg0.read()); + //pc.printf("Spd %.0f Hz p1 %.4f \n", step_freq, pot_value1_f32); //snelheid meting op lcd + wait(0.1); }