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

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

4 bit pour bolo on-of/bolo transmis

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 {
[657]135 if(param_pt->bolo[j].bolo_code_util&bolo_thermo_simplifie)
[651]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
[652]151
[651]152double temperature_service(param_bolo* param_pt, reglage_bolo* reglage_pt, block_type_dilution* blk, int indice_tempe)
153{
154double I,V,R,T,llR;
155int j,k;
156def_gains;
157k=0;
158
159for(j=0;(j<nb_max_bolo) && (k<4);j++)
160 {
[657]161 if(param_pt->bolo[j].bolo_code_util&bolo_thermo_simplifie)
[651]162 {
163 if(k==indice_tempe)
164 {
165 I = 1e-3 * (double)dac_V(reglage_pt->bolo[j]) * 2441. / param_pt->bolo[j].bolo_capa; // I en µA
166 V=0.001*bol_micro_volt(blk->temperature[k],(double)param_pt->bolo[j].bolo_gain*gain_ampli(reglage_pt->bolo[j]));
167 if(I>0.0000001) R=V/I; else R=0; // R en ‡
168 //------ calcul de l'etalonnage en temperature des cartes temperature simplifiées
169 // j=numero de bebo T[k] = R[k+4] en Kelvin
170 if ((R-c(j,6))>1.)
171 {if((log(R-c(j,6))-c(j,0))>0.001) llR= log(log(R-c(j,6))-c(j,0)) ; else llR=0;
172// printf("\nk=%d j=%d R=%g c2=%g c3=%g llR=%g",k,j,R[k],c(j,2),c(j,3),llR);
173 }
174 else llR=0;
175 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) ;
176 if(T>9999) T=9999;
177 return(T);
178 }
179 k++;
180 }
181 }
182return(0);
183}
184
185#undef c
186
187
188
189/********** coefficients pour les mesures bolo **********************************/
190/* toutes les puissances en pW */
191/* -1- loi de reponse thermique des bolos avec R en ohms et T en Kelvin */
192/* */
193/* T = coef2 * ( ln ( R / coef1) ** ( -1 / coef0 ) */
194/* */
195/* -2- fuite thermique du bolo coef 3,4 */
196/* */
197/* Ptot = coef3 * ( (10*Tb) ** coef4 - (10*Tcryo) ** coef4 ) */
198/* */
199/* -3- calcul empirique de Pciel et de tau coef 5,6 */
200/* */
201/* Pciel = coef5 - Pelec coef5= I * Ai (tables xavier) */
202/* tau = - ln ( 1 + Pciel / coef6 ) coef6= I * Bi (tables xavier) */
203/* */
204/* Pour les thermometres 1 à 4 (germanium et carbone Allan-Bradley) */
205/* les coefficients sont utilisés differemment, ils permettent de convertir */
206/* R vers T ( c(6) est un offset sur la mesure de R par rapport aux mesures 4 fils)*/
207/* llR= log(log(R - c(6))-c(0)) */
208/* T = exp(c(1) + c(2)* llR + c(3)* llR* llR + c(4)* llR* llR* llR + */
209/* c(5)* llR* llR* llR* llR) */
210/* */
211/* version vol Trapani */
212/* on corrige le biais de temperature coef2=1.1 old, coef3=old/1.1^coef4 */
213/* */
214/* */
215/* */
216/* */
217/* */
218/****************************************************************************************/
219
220
221
222
223/* ------------------------------------ corps des fonctions ------------------------------ */
224/* -------------------------------------------------------------------------------------------- */
225
226
227
228
229double DAC_muV (param_bolo* param_pt, reglage_bolo* reglage_pt, int indice_bolo)
230{
231double div,car;
232car= (double)dac_V(reglage_pt->bolo[indice_bolo]) ;
233div=(double)param_pt->bolo[indice_bolo].bolo_diviseur;
234if(div) return (car *2441. / div );
235else return(0);
236}
237
238
239
240double DAC_muA (param_bolo* param_pt, reglage_bolo* reglage_pt, int indice_bolo)
241{
242double capa,tri;
243tri= (double)dac_I(reglage_pt->bolo[indice_bolo]) ;
244capa=((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);
245 /* capa en pF */
246return (tri * capa / (4096. * 22. * 20.) );
247}
248
249
250double bolo_muV (param_bolo* param_pt, reglage_bolo* reglage_pt, int valbrut,int indice_bolo)
251{
252double x;
253int nb_coups;
254int aa;
255def_gains
256
257nb_coups= reglage_pt->horloge.nb_mesures/2 - reglage_pt->horloge.temp_mort;
258
259aa = (nb_coups<<14) + (nb_coups*190) ;
260x=((double)((valbrut-aa)<<1))/(double)nb_coups;
261x= bol_micro_volt(x,(double)param_pt->bolo[indice_bolo].bolo_gain*gain_ampli(reglage_pt->bolo[indice_bolo]));
262return(x);
263}
264
265
266
267
268#define c(i) (1e-4*(double)param_pt->nom_coef[param_pt->bolo[indice_bolo].numero_nom_coef].coef[i])
269
270double bolo_temp (param_bolo* param_pt, reglage_bolo* reglage_pt, double R,int indice_bolo)
271{
272double a,T;
273a=1; if( (R>0) && (c(1) >0.01) ) a= log ( R / c(1) );
274T=0; if( (a>0) && (c(0)>0.01) ) T= c(2) * pow( a , -1 / c(0) );
275return(T);
276}
277
278#undef c
279
280
281
282
283/* ------------------------------------------------------------- */
284
285
286unsigned int4 val_long(char x)
287{
288unsigned long a,xl;
289char aa;
290aa=x-2;
291a=aa;
292if(x<3) xl=x; else xl=((a&1) + 2)<<(a>>1);
293return(xl);
294}
295
296
297double val_double(char x)
298{
299unsigned long a,xl;
300if(x<0) x=-x; a=x; if(!a) xl=0; else xl=((a&1) + 2)<<(a>>1);
301if(x>0) return(1e-4*(double)xl); else return(-1e-4*(double)xl);
302}
303
304int new_val_dac(int a,char code)
305{
306if(code&0x80) a=(code&0x7f) <<5 ;
307else {
308 if(code&0x40) a+=code&0x3f;
309 else a-=code&0x3f;
310 }
311return(a);
312}
313
Note: See TracBrowser for help on using the repository browser.