Project

General

Profile

tromb_coefs.txt

Kyle Hazelwood, 01/15/2015 12:01 PM

 
1

    
2
/* trombone program by solving the equations using SVD -Meiqin*/
3

    
4
/*  tromb_id = 0 for Trombone 60x,  1 for Trombone 30x */
5

    
6
int trombone(int tromb_id,TROMB_STRUCT *tune_set)
7
{  
8
  int sts;
9
/*  float b[9],u[9][9],w[9],v[9][9],x[9];*/
10

    
11
  //float   value;
12
  //char    numstr[9];
13

    
14

    
15
  int i,j,ii;
16
  float wmax,wmin;
17

    
18
    float **u;
19
    float **v;
20
    float *w;
21
    float *b;
22
    float *x;
23

    
24

    
25
  u=create_matrix(1,N, 1,N);
26
  
27
  if (tromb_id == GRP_QT_60X) {
28

    
29
     /* Meiqin's Coefficients for trombone 60x */
30
     
31
     u[1][1]= -122.497; 
32
     u[1][2]= 1615.65 ;
33
     u[1][3]=  135.61; 
34
     u[1][4]=-1588.11;
35
     u[1][5]=  -65.9322;
36
     u[1][6]= 1704.44;
37
     u[1][7]=   47.0098;
38
     u[1][8]= -1651.3;
39
     u[1][9]= -49.7233;
40

    
41
     u[2][1]=  34.1466;
42
     u[2][2]=  59.8896 ;
43
     u[2][3]= -36.2102;
44
     u[2][4]= -52.1996;
45
     u[2][5]=  35.2765;
46
     u[2][6]=  27.7801;
47
     u[2][7]= -38.4453;
48
     u[2][8]= -26.4248; 
49
     u[2][9]=  35.546;
50

    
51
     u[3][1]=  5480.38;
52
     u[3][2]= -1461.7 ;
53
     u[3][3]= -3851.28;
54
     u[3][4]=  1761.54;
55
     u[3][5]=  2908.44;
56
     u[3][6]= -1692.79;
57
     u[3][7]= -1313.27;
58
     u[3][8]=  1788.4;
59
     u[3][9]=   280.657;
60

    
61
     u[4][1]= -167.666;
62
     u[4][2]=  -21.7508;
63
     u[4][3]=  162.204;
64
     u[4][4]=    9.72964;
65
     u[4][5]= -191.958;
66
     u[4][6]=  -13.9525;
67
     u[4][7]=  177.936;
68
     u[4][8]=    4.82235;
69
     u[4][9]=  -200.808;
70

    
71
     u[5][1]=     2.87133 ; 
72
     u[5][2]=    15.4478; 
73
     u[5][3]=     3.06023 ; 
74
     u[5][4]=    14.9975; 
75
     u[5][5]=     2.84258; 
76
     u[5][6]=    15.4768; 
77
     u[5][7]=     3.06936; 
78
     u[5][8]=    14.9874; 
79
     u[5][9]=     2.84597; 
80

    
81
     u[6][1]=   -15.9904; 
82
     u[6][2]=    -2.88911; 
83
     u[6][3]=   -14.3305; 
84
     u[6][4]=    -2.90138; 
85
     u[6][5]=   -16.001; 
86
     u[6][6]=    -2.90307; 
87
     u[6][7]=   -14.3319; 
88
     u[6][8]=    -2.86806;
89
     u[6][9]=   -15.9923; 
90

    
91
     u[7][1]=0.;
92
     u[7][2]=0.;
93
     u[7][3]=0.;
94
     u[7][4]=0.;
95
     u[7][5]=0.;
96
     u[7][6]=0.;
97
     u[7][7]=0.;
98
     u[7][8]=0.;
99
     u[7][9]=0.;
100

    
101
     u[8][1]=0.;
102
     u[8][2]=0.;
103
     u[8][3]=0.;
104
     u[8][4]=0.;
105
     u[8][5]=0.;
106
     u[8][6]=0.;
107
     u[8][7]=0.;
108
     u[8][8]=0.;
109
     u[8][9]=0.;
110

    
111
     u[9][1]=0.;
112
     u[9][2]=0.;
113
     u[9][3]=0.;
114
     u[9][4]=0.;
115
     u[9][5]=0.;
116
     u[9][6]=0.;
117
     u[9][7]=0.;
118
     u[9][8]=0.;
119
     u[9][9]=0.;
120
  }
121
  else if (tromb_id == GRP_QT_30X) {
122

    
123
      /* Meiqin's Coefficients for trombone 30x */
124
     
125
     u[1][1]= -122.497; 
126
     u[1][2]= 1615.65 ;
127
     u[1][3]=  135.61; 
128
     u[1][4]=-1588.11;
129
     u[1][5]=  -65.9322;
130
     u[1][6]= 1704.44;
131
     u[1][7]=   47.0098;
132
     u[1][8]= -1651.3;
133
     u[1][9]= -49.7233;
134

    
135
     u[2][1]=  34.1466;
136
     u[2][2]=  59.8896 ;
137
     u[2][3]= -36.2102;
138
     u[2][4]= -52.1996;
139
     u[2][5]=  35.2765;
140
     u[2][6]=  27.7801;
141
     u[2][7]= -38.4453;
142
     u[2][8]= -26.4248; 
143
     u[2][9]=  35.546;
144

    
145
     u[3][1]=  5480.38;
146
     u[3][2]= -1461.7 ;
147
     u[3][3]= -3851.28;
148
     u[3][4]=  1761.54;
149
     u[3][5]=  2908.44;
150
     u[3][6]= -1692.79;
151
     u[3][7]= -1313.27;
152
     u[3][8]=  1788.4;
153
     u[3][9]=   280.657;
154

    
155
     u[4][1]= -167.666;
156
     u[4][2]=  -21.7508;
157
     u[4][3]=  162.204;
158
     u[4][4]=    9.72964;
159
     u[4][5]= -191.958;
160
     u[4][6]=  -13.9525;
161
     u[4][7]=  177.936;
162
     u[4][8]=    4.82235;
163
     u[4][9]=  -200.808;
164

    
165
     u[5][1]=     2.87133 ; 
166
     u[5][2]=    15.4478; 
167
     u[5][3]=     3.06023 ; 
168
     u[5][4]=    14.9975; 
169
     u[5][5]=     2.84258; 
170
     u[5][6]=    15.4768; 
171
     u[5][7]=     3.06936; 
172
     u[5][8]=    14.9874; 
173
     u[5][9]=     2.84597; 
174

    
175
     u[6][1]=   -15.9904; 
176
     u[6][2]=    -2.88911; 
177
     u[6][3]=   -14.3305; 
178
     u[6][4]=    -2.90138; 
179
     u[6][5]=   -16.001; 
180
     u[6][6]=    -2.90307; 
181
     u[6][7]=   -14.3319; 
182
     u[6][8]=    -2.86806;
183
     u[6][9]=   -15.9923; 
184

    
185
     u[7][1]=0.;
186
     u[7][2]=0.;
187
     u[7][3]=0.;
188
     u[7][4]=0.;
189
     u[7][5]=0.;
190
     u[7][6]=0.;
191
     u[7][7]=0.;
192
     u[7][8]=0.;
193
     u[7][9]=0.;
194

    
195
     u[8][1]=0.;
196
     u[8][2]=0.;
197
     u[8][3]=0.;
198
     u[8][4]=0.;
199
     u[8][5]=0.;
200
     u[8][6]=0.;
201
     u[8][7]=0.;
202
     u[8][8]=0.;
203
     u[8][9]=0.;
204

    
205
     u[9][1]=0.;
206
     u[9][2]=0.;
207
     u[9][3]=0.;
208
     u[9][4]=0.;
209
     u[9][5]=0.;
210
     u[9][6]=0.;
211
     u[9][7]=0.;
212
     u[9][8]=0.;
213
     u[9][9]=0.;
214

    
215
  }
216

    
217
  else {
218
     error_message_c("Err: Invalid trombone id passed!",ERR_SIMPLE_DISPLAY,RED);
219
     return TRUE;
220
  }   
221
  
222
/* Copy a into u if you don't want it to be destroyed.*/
223
/*        for (i=1;i<=N;i++)    
224
	 for (j=1;j<=N;j++)
225
	   u[i][j]=a[i][j];*/
226
  sts = 1;
227
  
228
  v=create_matrix(1,N, 1,N);
229
  w=vector( 1,N);
230
  b=vector( 1,N);
231
  x=vector( 1,N);
232

    
233
/* The following were for the old trombone section with 2 trim quads in a group
234
 *
235
 *      b[1]=-0.00203665;
236
 *      b[2]=0.000291693;
237
 *      b[3]=-0.156029;
238
 *      b[4]=-0.000528379;
239
 *      b[5]=tune_set->delta_q[0];
240
 *      b[6]=tune_set->delta_q[1];
241
 *      b[7]=0;
242
 *      b[8]=0;
243
 *      b[9]=0;
244
 * assign value to b vector*/
245

    
246
/* assign value to b vector, 11/17/2009, Meiqin Xiao*/
247
 
248
       b[1]= 0.00258321;
249
       b[2]= 0.000059317;
250
       b[3]=-0.000148048;
251
       b[4]= 0.000377263;
252
       b[5]=tune_set->delta_q[0];
253
       b[6]=tune_set->delta_q[1];
254
       b[7]=0;
255
       b[8]=0;
256
       b[9]=0;
257

    
258
/*SVD the square matrix a.*/
259
       svdcmp(u,N,N,w,v);
260
       wmax=0.0;   /* will be the maximum singular value obtained.*/
261
       for (j=1;j<=N;j++) if (w[j]>wmax) wmax=w[j];
262
       wmin=wmax*10e-6;
263
/*This is where we set the threshold for singular values allowed to be nonzero. The constant is typical , but not universal. You have to experiment with your own application.*/
264
       for (j=1;j<=N;j++) if (w[j]<wmin) w[j]=0.;
265
       svbksb(u,w,v,N,N,b,x);
266

    
267
       for (i=0;i< NKNOB;i++){
268
	 ii=i+1;
269
	 tune_set->amps[i]=x[ii]/0.3048/0.00297;
270
	 if ( tune_set->amps[i] > 6.5 ) {
271
         error_message_c("Err: Maximum current exceed 6.5 Amps!",
272
                       ERR_SIMPLE_DISPLAY,RED);
273

    
274
	 tune_set->amps[i] = 6.5;
275
	 error_message_c("Caution: The current is repalced by 6.5 Amps!",
276
                       ERR_SIMPLE_DISPLAY,RED);
277
       }
278
	 if ( tune_set->amps[i] < -6.5 ) {
279
         error_message_c("Err: Maximum current exceed -6.5 Amps!",
280
                       ERR_SIMPLE_DISPLAY,RED);
281

    
282
	 tune_set->amps[i] = -6.5;
283
	 error_message_c("Caution: The current is repalced by -6.5 Amps!",
284
                       ERR_SIMPLE_DISPLAY,RED);
285
       }
286
       }
287
    sts = 0;
288
    //error_message_c("GOOD SOLUTION!",ERR_SIMPLE_DISPLAY,BLUE);
289

    
290
 /*
291
  for (i = 0; i < 5; i++) { 
292
    value = tune_set->amps[i];
293
    sprintf(numstr,"%8.3f",value);
294
    window_tvm_c(win_dis_id,i+12,10,numstr,8,GREEN);
295
  }
296
    for (i = 5; i <9; i++) { 
297
    value = tune_set->amps[i];
298
     sprintf(numstr,"%8.3f",value);
299
    window_tvm_c(win_dis_id,20-i,27,numstr,8,GREEN);
300
    
301
  }
302
  */
303
   
304
  //memcpy(q_amps,tune_set->amps,NKNOB*sizeof(float));
305

    
306
 return (sts);
307
}
308