source: Sophya/trunk/Poubelle/archediab.old/archediab.sources/c/arcunit.c@ 651

Last change on this file since 651 was 651, checked in by ansari, 26 years ago

archediab 29

File size: 10.9 KB
RevLine 
[651]1
2#include "manip.h"
3#include "archeops.h"
4#include "arcunit.h"
5
6/**************************************************************************************/
7/* */
8/* programme contenant les conversions en mesure physique */
9/* */
10/* */
11/* */
12/**************************************************************************************/
13
14
15/* ---------------- block dilution --------------------------------------------- */
16
17
18int voyant_EVO(block_type_dilution* blk) {return((blk->switch_dil&switch_EVO)?0:1);}
19int voyant_EVF(block_type_dilution* blk) {return((blk->switch_dil&switch_EVF)?0:1);}
20int commande_EVO(block_type_dilution* blk) {return((blk->switch_dil&vanne_EVO)?0:1);}
21int commande_EVF(block_type_dilution* blk) {return((blk->switch_dil&vanne_EVF)?0:1);}
22int commande_EVB(block_type_dilution* blk) {return((blk->switch_dil&vanne_EVB)?0:1);}
23int commande_EVV(block_type_dilution* blk) {return((blk->switch_dil&vanne_EVV)?0:1);}
24
25
26// les pressions et debits metres des injections de la dilution
27double pression_entree_3He(block_type_dilution* blk)
28 {return(40. * val_multiplex(blk->ADC_dil[ p_R3]) -1.6);} // 200 bars pour 5V et 1.6 bar d'offset
29
30double debit_3He(block_type_dilution* blk)
31 {return(2. * val_multiplex(blk->ADC_dil[ d_3He]) );} // 10 MICRO MOLES pour 5V
32
33double pression_sortie_3He(block_type_dilution* blk)
34 {return(20. * val_multiplex(blk->ADC_dil[ p_C3]) );} // 100 bars pour 5V
35
36double pression_entree_4He(block_type_dilution* blk)
37 {return(40. * val_multiplex(blk->ADC_dil[ p_R4])) ;} // 200 bars pour 5V
38
39double debit_4He(block_type_dilution* blk)
40 {return(8. * val_multiplex(blk->ADC_dil[ d_4He])) ;} // 40 MICRO MOLES pour 5V
41// ,4. * val_multiplex(blk->ADC_dil[ d_4He]) // 20 MICRO MOLES pour 5V
42
43double pression_sortie_4He(block_type_dilution* blk)
44 {return(20. * val_multiplex(blk->ADC_dil[ p_C4]) );} // 100 bars pour 5V
45
46
47
48double pression_air_vanne(block_type_dilution* blk)
49 {return(20.*val_multiplex(blk->ADC_dil[ p_air]));}
50
51double pression_pompe_charbon(block_type_dilution* blk)
52 {return(20.*val_multiplex(blk->ADC_dil[ p_charb]));}
53
54
55double pression_membranne(block_type_dilution* blk)
56 {return(0.2*val_multiplex(blk->ADC_dil[ p_memb]));}
57
58
59double pression_externe(block_type_dilution* blk)
60 {return(0.2*val_multiplex(blk->ADC_dil[ p_haut]));}
61
62
63
64double tension_pile_10T(block_type_dilution* blk)
65 {return(2.03*val_multiplex(blk->ADC_dil[ p_10T]));}
66
67double tension_pile_p18D(block_type_dilution* blk)
68 {return(3.90*val_multiplex(blk->ADC_dil[ p_p18D]));}
69
70double tension_pile_m18D(block_type_dilution* blk)
71 {return(3.90*val_multiplex(blk->ADC_dil[ p_m18D]));}
72
73double tension_pile_10B(block_type_dilution* blk)
74 {return(2.03*val_multiplex(blk->ADC_dil[ p_10B]));}
75
76double tension_pile_p18B(block_type_dilution* blk)
77 {return(3.90*val_multiplex(blk->ADC_dil[ p_p18B]));}
78
79double tension_pile_m18B(block_type_dilution* blk)
80 {return(3.90*val_multiplex(blk->ADC_dil[ p_m18B]));}
81
82double tension_pile_Ch(block_type_dilution* blk)
83 {return(3.8*val_multiplex(blk->ADC_dil[ p_Ch]));}
84
85
86
87int switch_pile_5(block_type_dilution* blk)
88 {return((blk->switch_dil&switch_pile_par_5)?1:0);}
89int switch_pile_15(block_type_dilution* blk)
90 {return((blk->switch_dil&switch_pile_par_15)?1:0);}
91
92
93double temperature_caisson_haut1(block_type_dilution* blk)
94 {return(val_temperature(blk->ADC_dil[ t_h2]));}
95
96double temperature_caisson_haut2(block_type_dilution* blk)
97 {return(val_temperature(blk->ADC_dil[ t_h4]));}
98
99double temperature_caisson_bas1(block_type_dilution* blk)
100 {return(val_temperature(blk->ADC_dil[ t_b1]));}
101
102double temperature_caisson_bas2(block_type_dilution* blk)
103 {return(val_temperature(blk->ADC_dil[ t_b2]));}
104
105double temperature_caisson_tube_helium(block_type_dilution* blk)
106 {return(val_temperature(blk->ADC_dil[ t_b3]));}
107
108double temperature_caisson_piles(block_type_dilution* blk)
109 {return(val_temperature(blk->ADC_dil[ t_pile]));}
110
111double temperature_caisson_driver_moteur(block_type_dilution* blk)
112 {return(val_temperature(blk->ADC_dil[ t_a1]));}
113
114double pression_helium_bain(block_type_dilution* blk)
115 {return( 0.2*val_multiplex(blk->ADC_dil[ RP_He]));}
116
117double pression_pirani(block_type_dilution* blk)
118 {return(val_multiplex(blk->ADC_dil[ pirani]));}
119
120
121
122#define c(j,i) (1e-4*(double)param_pt->nom_coef[param_pt->bolo[j].numero_nom_coef].coef[i])
123
124// les temperatures sur les cartes modifiées
125
126double resistance_service(param_bolo* param_pt, reglage_bolo* reglage_pt, block_type_dilution* blk, int indice_tempe)
127{
128double I,V,R;
129int j,k;
130def_gains;
131k=0;
132
133for(j=0;(j<nb_max_bolo) && (k<4);j++)
134 {
135 if(param_pt->bolo[j].bolo_code_util==bolo_thermo_simplifie)
136 {
137 if(k==indice_tempe)
138 {
139 I = 1e-3 * (double)dac_V(reglage_pt->bolo[j]) * 2441. / param_pt->bolo[j].bolo_capa; // I en µA
140 V=0.001*bol_micro_volt(blk->temperature[k],(double)param_pt->bolo[j].bolo_gain*gain_ampli(reglage_pt->bolo[j]));
141 if(I>0.0000001) R=V/I; else R=0; // R en ‡
142 return(R);
143 }
144 k++;
145 }
146 }
147return(0);
148}
149
150
151double temperature_service(param_bolo* param_pt, reglage_bolo* reglage_pt, block_type_dilution* blk, int indice_tempe)
152{
153double I,V,R,T,llR;
154int j,k;
155def_gains;
156k=0;
157
158for(j=0;(j<nb_max_bolo) && (k<4);j++)
159 {
160 if(param_pt->bolo[j].bolo_code_util==bolo_thermo_simplifie)
161 {
162 if(k==indice_tempe)
163 {
164 I = 1e-3 * (double)dac_V(reglage_pt->bolo[j]) * 2441. / param_pt->bolo[j].bolo_capa; // I en µA
165 V=0.001*bol_micro_volt(blk->temperature[k],(double)param_pt->bolo[j].bolo_gain*gain_ampli(reglage_pt->bolo[j]));
166 if(I>0.0000001) R=V/I; else R=0; // R en ‡
167 //------ calcul de l'etalonnage en temperature des cartes temperature simplifiées
168 // j=numero de bebo T[k] = R[k+4] en Kelvin
169 if ((R-c(j,6))>1.)
170 {if((log(R-c(j,6))-c(j,0))>0.001) llR= log(log(R-c(j,6))-c(j,0)) ; else llR=0;
171// printf("\nk=%d j=%d R=%g c2=%g c3=%g llR=%g",k,j,R[k],c(j,2),c(j,3),llR);
172 }
173 else llR=0;
174 T = exp( c(j,1) + c(j,2)* llR + c(j,3)* llR* llR + c(j,4)* llR* llR* llR + c(j,5)* llR* llR* llR* llR) ;
175 if(T>9999) T=9999;
176 return(T);
177 }
178 k++;
179 }
180 }
181return(0);
182}
183
184#undef c
185
186
187
188/********** coefficients pour les mesures bolo **********************************/
189/* toutes les puissances en pW */
190/* -1- loi de reponse thermique des bolos avec R en ohms et T en Kelvin */
191/* */
192/* T = coef2 * ( ln ( R / coef1) ** ( -1 / coef0 ) */
193/* */
194/* -2- fuite thermique du bolo coef 3,4 */
195/* */
196/* Ptot = coef3 * ( (10*Tb) ** coef4 - (10*Tcryo) ** coef4 ) */
197/* */
198/* -3- calcul empirique de Pciel et de tau coef 5,6 */
199/* */
200/* Pciel = coef5 - Pelec coef5= I * Ai (tables xavier) */
201/* tau = - ln ( 1 + Pciel / coef6 ) coef6= I * Bi (tables xavier) */
202/* */
203/* Pour les thermometres 1 à 4 (germanium et carbone Allan-Bradley) */
204/* les coefficients sont utilisés differemment, ils permettent de convertir */
205/* R vers T ( c(6) est un offset sur la mesure de R par rapport aux mesures 4 fils)*/
206/* llR= log(log(R - c(6))-c(0)) */
207/* T = exp(c(1) + c(2)* llR + c(3)* llR* llR + c(4)* llR* llR* llR + */
208/* c(5)* llR* llR* llR* llR) */
209/* */
210/* version vol Trapani */
211/* on corrige le biais de temperature coef2=1.1 old, coef3=old/1.1^coef4 */
212/* */
213/* */
214/* */
215/* */
216/* */
217/****************************************************************************************/
218
219
220
221
222/* ------------------------------------ corps des fonctions ------------------------------ */
223/* -------------------------------------------------------------------------------------------- */
224
225
226
227
228double DAC_muV (param_bolo* param_pt, reglage_bolo* reglage_pt, int indice_bolo)
229{
230double div,car;
231car= (double)dac_V(reglage_pt->bolo[indice_bolo]) ;
232div=(double)param_pt->bolo[indice_bolo].bolo_diviseur;
233if(div) return (car *2441. / div );
234else return(0);
235}
236
237
238
239double DAC_muA (param_bolo* param_pt, reglage_bolo* reglage_pt, int indice_bolo)
240{
241double capa,tri;
242tri= (double)dac_I(reglage_pt->bolo[indice_bolo]) ;
243capa=((param_pt->bolo[indice_bolo].bolo_bebo==10)?0.000868 * (double)param_pt->bolo[indice_bolo].bolo_capa:0.001 * (double)param_pt->bolo[indice_bolo].bolo_capa);
244 /* capa en pF */
245return (tri * capa / (4096. * 22. * 20.) );
246}
247
248
249double bolo_muV (param_bolo* param_pt, reglage_bolo* reglage_pt, int valbrut,int indice_bolo)
250{
251double x;
252int nb_coups;
253int aa;
254def_gains
255
256nb_coups= reglage_pt->horloge.nb_mesures/2 - reglage_pt->horloge.temp_mort;
257
258aa = (nb_coups<<14) + (nb_coups*190) ;
259x=((double)((valbrut-aa)<<1))/(double)nb_coups;
260x= bol_micro_volt(x,(double)param_pt->bolo[indice_bolo].bolo_gain*gain_ampli(reglage_pt->bolo[indice_bolo]));
261return(x);
262}
263
264
265
266
267#define c(i) (1e-4*(double)param_pt->nom_coef[param_pt->bolo[indice_bolo].numero_nom_coef].coef[i])
268
269double bolo_temp (param_bolo* param_pt, reglage_bolo* reglage_pt, double R,int indice_bolo)
270{
271double a,T;
272a=1; if( (R>0) && (c(1) >0.01) ) a= log ( R / c(1) );
273T=0; if( (a>0) && (c(0)>0.01) ) T= c(2) * pow( a , -1 / c(0) );
274return(T);
275}
276
277#undef c
278
279
280
281
282/* ------------------------------------------------------------- */
283
284
285unsigned int4 val_long(char x)
286{
287unsigned long a,xl;
288char aa;
289aa=x-2;
290a=aa;
291if(x<3) xl=x; else xl=((a&1) + 2)<<(a>>1);
292return(xl);
293}
294
295
296double val_double(char x)
297{
298unsigned long a,xl;
299if(x<0) x=-x; a=x; if(!a) xl=0; else xl=((a&1) + 2)<<(a>>1);
300if(x>0) return(1e-4*(double)xl); else return(-1e-4*(double)xl);
301}
302
303int new_val_dac(int a,char code)
304{
305if(code&0x80) a=(code&0x7f) <<5 ;
306else {
307 if(code&0x40) a+=code&0x3f;
308 else a-=code&0x3f;
309 }
310return(a);
311}
312
Note: See TracBrowser for help on using the repository browser.