testcode pid
Dependencies: HIDScope MODSERIAL QEI biquadFilter mbed
Fork of testPID by
Diff: main.cpp
- Revision:
- 22:1ba637601dc3
- Parent:
- 21:d6a46315d5f5
- Child:
- 23:e9b1b426cde6
--- a/main.cpp Tue Oct 13 10:02:48 2015 +0000 +++ b/main.cpp Tue Oct 13 12:55:33 2015 +0000 @@ -138,6 +138,7 @@ double emg_extens = emg4.read(); //Extensor //Filter: high-pass -> notch -> rectify -> lowpass or moving average + // Can we use same biquadFilter (eg. highpass) for other muscles or does each muscle need its own biquad? biceps_power = highpass.step(emg_biceps); triceps_power = highpass.step(emg_triceps); flexor_power = highpass.step(emg_flexor); extens_power = highpass.step(emg_extens); biceps_power = notch1.step(biceps_power); triceps_power = notch1.step(triceps_power); flexor_power = notch1.step(flexor_power); extens_power = notch1.step(extens_power); biceps_power = notch2.step(biceps_power); triceps_power = notch2.step(triceps_power); flexor_power = notch2.step(flexor_power); extens_power = notch2.step(extens_power); @@ -163,6 +164,12 @@ //Send arm to mechanical limits, and set encoder to 0. Then send arm to starting position. void calibrate_arm(void) { + dir_motor1=1; //ccw + dir_motor2=1; //ccw + while(limitswitch != hit){ + pwm_motor1.write(0.4); + pwm_motor2.write(0.4); + } } //EMG Maximum Voluntary Contraction measurement @@ -170,6 +177,7 @@ { if(muscle==1){ start_sampling(); + wait(1); for(int index=0; index<2500;index++){ //measure 5 seconds@500hz = 2500 samples if(biceps_power>bicepsMVC){ @@ -181,6 +189,7 @@ if(muscle==2){ start_sampling(); + wait(1); for(int index=0; index<2500;index++){ //measure 5 seconds@500hz = 2500 samples if(triceps_power>tricepsMVC){