The final program for the #include AIR robot

Dependencies:   Biquad HIDScope QEI angleandposition controlandadjust mbed

Fork of includeair by BioRobotics

Committer:
Gerth
Date:
Mon Oct 12 14:27:42 2015 +0000
Revision:
1:917c07a4f3ec
Child:
39:ebcf0a60f58b
Added the biquad filter;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gerth 1:917c07a4f3ec 1 //////////////////////////////////////////////CONSTANTS
Gerth 1:917c07a4f3ec 2 ///////////////////Biquad #1
Gerth 1:917c07a4f3ec 3 const double gain_f1 = 9.6508098634474382e-01;
Gerth 1:917c07a4f3ec 4 const double A_f1[] = { 1.0000000000000000e+00 , -1.5685816307006708e+00 , 9.6424138386900704e-01};
Gerth 1:917c07a4f3ec 5 const double B_f1[] = { 9.6508098634474382e-01 ,-1.5620271748674457e+00 , 9.6508103356874642e-01};
Gerth 1:917c07a4f3ec 6
Gerth 1:917c07a4f3ec 7 ///////////////////Biquad #2
Gerth 1:917c07a4f3ec 8 const double gain_f2 = 1.0000000000000000e+00;
Gerth 1:917c07a4f3ec 9 const double A_f2[] = { 1.0000000000000000e+00 , -1.6110035772715345e+00 , 9.6592170561041857e-01};
Gerth 1:917c07a4f3ec 10 const double B_f2[] = { 1.0000000000000000e+00 ,-1.6185451093340690e+00 , 9.9999995106731920e-01};
Gerth 1:917c07a4f3ec 11
Gerth 1:917c07a4f3ec 12 ///////////////////Biquad #3
Gerth 1:917c07a4f3ec 13 const double gain_f3 = 9.6508098634473305e-01;
Gerth 1:917c07a4f3ec 14 const double A_f3[] = {1.0000000000000000e+00, -5.7396521780998500e-01 , 9.6488297638274156e-01};
Gerth 1:917c07a4f3ec 15 const double B_f3[] = { 9.6508098634473305e-01 ,-5.9664124427116272e-01 , 9.6508097692557404e-01};
Gerth 1:917c07a4f3ec 16
Gerth 1:917c07a4f3ec 17 ///////////////////Biquad #4
Gerth 1:917c07a4f3ec 18 const double gain_f4 = 1.0000000000000000e+00;
Gerth 1:917c07a4f3ec 19 const double A_f4[] = { 1.0000000000000000e+00 ,-6.4052826150899422e-01 , 9.6527942240059728e-01};
Gerth 1:917c07a4f3ec 20 const double B_f4[] = {1.0000000000000000e+00, -6.1822926625254149e-01 , 1.0000000097599706e+00};
Gerth 1:917c07a4f3ec 21 ///////////////////Biquad #5
Gerth 1:917c07a4f3ec 22 const double gain_f5 = 6.9977431651797473e-01;
Gerth 1:917c07a4f3ec 23 const double A_f5[] = { 1.0000000000000000e+00 ,-1.3072850288493236e+00 , 4.9181223722257517e-01};
Gerth 1:917c07a4f3ec 24 const double B_f5[] = { 6.9977431651797473e-01, -1.3995486330359495e+00 , 6.9977431651797473e-01};
Gerth 1:917c07a4f3ec 25
Gerth 1:917c07a4f3ec 26 ///////////////////Biquad #6
Gerth 1:917c07a4f3ec 27 const double gain_f6 = 2.4136223124304745e-08;
Gerth 1:917c07a4f3ec 28 const double A_f6[] = {1.0000000000000000e+00 ,-1.9540019616345168e+00 , 9.5461925134316061e-01};
Gerth 1:917c07a4f3ec 29 const double B_f6[] = { 2.4136223124304745e-08 , 4.8272447728835386e-08 , 2.4136223466598214e-08};
Gerth 1:917c07a4f3ec 30
Gerth 1:917c07a4f3ec 31 ///////////////////Biquad #7
Gerth 1:917c07a4f3ec 32 const double gain_f7 = 1.0000000000000000e+00;
Gerth 1:917c07a4f3ec 33 const double A_f7[] = { 1.0000000000000000e+00 , -1.9803238591642129e+00 , 9.8094946423345442e-01};
Gerth 1:917c07a4f3ec 34 const double B_f7[] = { 1.0000000000000000e+00 , 1.9999999386720257e+00 , 9.9999998581827421e-01};
Gerth 1:917c07a4f3ec 35
Gerth 1:917c07a4f3ec 36
Gerth 1:917c07a4f3ec 37 ////////////////////////////////////////////ARRAYS TO VARIABLES
Gerth 1:917c07a4f3ec 38 /////////////////Biquad #1
Gerth 1:917c07a4f3ec 39 const double a1_f1 = gain_f1*A_f1[1],
Gerth 1:917c07a4f3ec 40 a2_f1 = gain_f1*A_f1[2],
Gerth 1:917c07a4f3ec 41 b0_f1 = gain_f1*B_f1[0],
Gerth 1:917c07a4f3ec 42 b1_f1 = gain_f1*B_f1[1],
Gerth 1:917c07a4f3ec 43 b2_f1 = gain_f1*B_f1[2]; //filter coefficients filter 1
Gerth 1:917c07a4f3ec 44 double v1_f1_emg1=0 ,
Gerth 1:917c07a4f3ec 45 v2_f1_emg1=0 ,
Gerth 1:917c07a4f3ec 46 v1_f1_emg2=0 ,
Gerth 1:917c07a4f3ec 47 v2_f1_emg2=0;//storage variables filter 1
Gerth 1:917c07a4f3ec 48
Gerth 1:917c07a4f3ec 49 /////////////////Biquad #2
Gerth 1:917c07a4f3ec 50 const double a1_f2 = gain_f2*A_f2[1],
Gerth 1:917c07a4f3ec 51 a2_f2 = gain_f2*A_f2[2],
Gerth 1:917c07a4f3ec 52 b0_f2 = gain_f2*B_f2[0],
Gerth 1:917c07a4f3ec 53 b1_f2 = gain_f2*B_f2[1],
Gerth 1:917c07a4f3ec 54 b2_f2 = gain_f2*B_f2[2]; //filter coefficients filter 2
Gerth 1:917c07a4f3ec 55 double v1_f2_emg1=0 ,
Gerth 1:917c07a4f3ec 56 v2_f2_emg1=0 ,
Gerth 1:917c07a4f3ec 57 v1_f2_emg2=0 ,
Gerth 1:917c07a4f3ec 58 v2_f2_emg2=0;//storage variables filter 2
Gerth 1:917c07a4f3ec 59
Gerth 1:917c07a4f3ec 60 /////////////////Biquad #3
Gerth 1:917c07a4f3ec 61 const double a1_f3 = gain_f3*A_f3[1],
Gerth 1:917c07a4f3ec 62 a2_f3 = gain_f3*A_f3[2],
Gerth 1:917c07a4f3ec 63 b0_f3 = gain_f3*B_f3[0],
Gerth 1:917c07a4f3ec 64 b1_f3 = gain_f3*B_f3[1],
Gerth 1:917c07a4f3ec 65 b2_f3 = gain_f3*B_f3[2]; //filter coefficients filter 3
Gerth 1:917c07a4f3ec 66 double v1_f3_emg1=0 ,
Gerth 1:917c07a4f3ec 67 v2_f3_emg1=0 ,
Gerth 1:917c07a4f3ec 68 v1_f3_emg2=0 ,
Gerth 1:917c07a4f3ec 69 v2_f3_emg2=0;//storage variables filter 3
Gerth 1:917c07a4f3ec 70
Gerth 1:917c07a4f3ec 71 /////////////////Biquad #4
Gerth 1:917c07a4f3ec 72 const double a1_f4 = gain_f4*A_f4[1],
Gerth 1:917c07a4f3ec 73 a2_f4 = gain_f4*A_f4[2],
Gerth 1:917c07a4f3ec 74 b0_f4 = gain_f4*B_f4[0],
Gerth 1:917c07a4f3ec 75 b1_f4 = gain_f4*B_f4[1],
Gerth 1:917c07a4f3ec 76 b2_f4 = gain_f4*B_f4[2]; //filter coefficients filter 4
Gerth 1:917c07a4f3ec 77 double v1_f4_emg1=0 ,
Gerth 1:917c07a4f3ec 78 v2_f4_emg1=0 ,
Gerth 1:917c07a4f3ec 79 v1_f4_emg2=0 ,
Gerth 1:917c07a4f3ec 80 v2_f4_emg2=0;//storage variables filter 4
Gerth 1:917c07a4f3ec 81
Gerth 1:917c07a4f3ec 82 /////////////////Biquad #5
Gerth 1:917c07a4f3ec 83 const double a1_f5 = gain_f5*A_f5[1],
Gerth 1:917c07a4f3ec 84 a2_f5 = gain_f5*A_f5[2],
Gerth 1:917c07a4f3ec 85 b0_f5 = gain_f5*B_f5[0],
Gerth 1:917c07a4f3ec 86 b1_f5 = gain_f5*B_f5[1],
Gerth 1:917c07a4f3ec 87 b2_f5 = gain_f5*B_f5[2]; //filter coefficients filter 5
Gerth 1:917c07a4f3ec 88 double v1_f5_emg1=0 ,
Gerth 1:917c07a4f3ec 89 v2_f5_emg1=0 ,
Gerth 1:917c07a4f3ec 90 v1_f5_emg2=0 ,
Gerth 1:917c07a4f3ec 91 v2_f5_emg2=0;//storage variables filter 5
Gerth 1:917c07a4f3ec 92
Gerth 1:917c07a4f3ec 93 /////////////////Biquad #6
Gerth 1:917c07a4f3ec 94 const double a1_f6 = gain_f6*A_f6[1],
Gerth 1:917c07a4f3ec 95 a2_f6 = gain_f6*A_f6[2],
Gerth 1:917c07a4f3ec 96 b0_f6 = gain_f6*B_f6[0],
Gerth 1:917c07a4f3ec 97 b1_f6 = gain_f6*B_f6[1],
Gerth 1:917c07a4f3ec 98 b2_f6 = gain_f6*B_f6[2]; //filter coefficients filter 6
Gerth 1:917c07a4f3ec 99 double v1_f6_emg1=0 ,
Gerth 1:917c07a4f3ec 100 v2_f6_emg1=0 ,
Gerth 1:917c07a4f3ec 101 v1_f6_emg2=0 ,
Gerth 1:917c07a4f3ec 102 v2_f6_emg2=0;//storage variables filter 6
Gerth 1:917c07a4f3ec 103
Gerth 1:917c07a4f3ec 104 /////////////////Biquad #7
Gerth 1:917c07a4f3ec 105 const double a1_f7 = gain_f7*A_f7[1],
Gerth 1:917c07a4f3ec 106 a2_f7 = gain_f7*A_f7[2],
Gerth 1:917c07a4f3ec 107 b0_f7 = gain_f7*B_f7[0],
Gerth 1:917c07a4f3ec 108 b1_f7 = gain_f7*B_f7[1],
Gerth 1:917c07a4f3ec 109 b2_f7 = gain_f7*B_f7[2]; //filter coefficients filter 7
Gerth 1:917c07a4f3ec 110 double v1_f7_emg1=0 ,
Gerth 1:917c07a4f3ec 111 v2_f7_emg1=0 ,
Gerth 1:917c07a4f3ec 112 v1_f7_emg2=0 ,
Gerth 1:917c07a4f3ec 113 v2_f7_emg2=0;//storage variables filter 7
Gerth 1:917c07a4f3ec 114
Gerth 1:917c07a4f3ec 115 /////////////MEAN VALUE