Index: /trunk/Poubelle/archTOI.old/arcunit.c
===================================================================
--- /trunk/Poubelle/archTOI.old/arcunit.c	(revision 434)
+++ /trunk/Poubelle/archTOI.old/arcunit.c	(revision 434)
@@ -0,0 +1,248 @@
+
+#include "manip.h"      
+#include "archeops.h"
+#include "arcunit.h"
+
+/**************************************************************************************/
+/*                                                                                    */
+/*          programme  contenant les conversions en mesure physique                   */
+/*                                                                                    */
+/*                                                                                    */
+/*                                                                                    */
+/**************************************************************************************/
+
+
+/* ----------------   block  dilution     ---------------------------------------------  */
+
+
+int	voyant_EVO(block_type_dilution*	blk)	{return((blk->switch_dil&switch_EVO)?0:1);}
+int	voyant_EVF(block_type_dilution*	blk)	{return((blk->switch_dil&switch_EVF)?0:1);}
+int	commande_EVO(block_type_dilution*	blk)	{return((blk->switch_dil&vanne_EVO)?0:1);}
+int	commande_EVF(block_type_dilution*	blk)	{return((blk->switch_dil&vanne_EVF)?0:1);}
+int	commande_EVB(block_type_dilution*	blk)	{return((blk->switch_dil&vanne_EVB)?0:1);}
+int	commande_EVV(block_type_dilution*	blk)	{return((blk->switch_dil&vanne_EVV)?0:1);}
+
+
+// les pressions et debits metres des injections de la dilution
+double pression_entree_3He(block_type_dilution*	blk)	
+		{return(40. *	val_multiplex(blk->ADC_dil[ p_R3])  -1.6);}	//	200 bars pour 5V et 1.6 bar d'offset
+
+double debit_3He(block_type_dilution*	blk)	
+		{return(2. 	* 	val_multiplex(blk->ADC_dil[ d_3He]) );}		//  10 MICRO MOLES  pour  5V
+
+double pression_sortie_3He(block_type_dilution*	blk)	
+		{return(20. 	*	val_multiplex(blk->ADC_dil[ p_C3]) );}		//	100 bars pour 5V
+	
+double pression_entree_4He(block_type_dilution*	blk)	
+		{return(40. 	*	val_multiplex(blk->ADC_dil[ p_R4])) ;}		//	200 bars pour 5V
+
+double debit_4He(block_type_dilution*	blk)	
+		{return(8. 	* 	val_multiplex(blk->ADC_dil[ d_4He]))	 ;}	//  40 MICRO MOLES  pour  5V
+//	,4. 	* 	val_multiplex(blk->ADC_dil[ d_4He])		//  20 MICRO MOLES  pour  5V
+
+double pression_sortie_4He(block_type_dilution*	blk)	
+		{return(20. 	*	val_multiplex(blk->ADC_dil[ p_C4]) );}		//	100 bars pour 5V
+	
+
+
+double pression_air_vanne(block_type_dilution*	blk)	
+		{return(20.*val_multiplex(blk->ADC_dil[ p_air]));}
+		
+double pression_pompe_charbon(block_type_dilution*	blk)	
+		{return(20.*val_multiplex(blk->ADC_dil[ p_charb]));}
+		
+
+double pression_membranne(block_type_dilution*	blk)	
+		{return(0.2*val_multiplex(blk->ADC_dil[ p_memb]));}
+		
+		
+double pression_externe(block_type_dilution*	blk)	
+		{return(0.2*val_multiplex(blk->ADC_dil[ p_haut]));}
+
+			
+		
+double tension_pile_10T(block_type_dilution*	blk)	
+		{return(2.03*val_multiplex(blk->ADC_dil[ p_10T]));}
+				
+double tension_pile_p18D(block_type_dilution*	blk)	
+		{return(3.90*val_multiplex(blk->ADC_dil[ p_p18D]));}
+				
+double tension_pile_m18D(block_type_dilution*	blk)	
+		{return(3.90*val_multiplex(blk->ADC_dil[ p_m18D]));}
+				
+double tension_pile_10B(block_type_dilution*	blk)	
+		{return(2.03*val_multiplex(blk->ADC_dil[ p_10B]));}
+				
+double tension_pile_p18B(block_type_dilution*	blk)	
+		{return(3.90*val_multiplex(blk->ADC_dil[ p_p18B]));}
+				
+double tension_pile_m18B(block_type_dilution*	blk)	
+		{return(3.90*val_multiplex(blk->ADC_dil[ p_m18B]));}
+				
+double tension_pile_Ch(block_type_dilution*	blk)	
+		{return(3.8*val_multiplex(blk->ADC_dil[ p_Ch]));}
+
+
+				
+int switch_pile_5(block_type_dilution*	blk)	
+		{return((blk->switch_dil&switch_pile_par_5)?1:0);}
+int switch_pile_15(block_type_dilution*	blk)	
+		{return((blk->switch_dil&switch_pile_par_15)?1:0);}
+
+
+double	temperature_caisson_haut1(block_type_dilution*	blk)
+		{return(val_temperature(blk->ADC_dil[ t_h2]));}
+		
+double	temperature_caisson_haut2(block_type_dilution*	blk)
+		{return(val_temperature(blk->ADC_dil[ t_h4]));}
+		
+double	temperature_caisson_bas1(block_type_dilution*	blk)
+		{return(val_temperature(blk->ADC_dil[ t_b1]));}
+		
+double	temperature_caisson_bas2(block_type_dilution*	blk)
+		{return(val_temperature(blk->ADC_dil[ t_b2]));}
+		
+double	temperature_caisson_tube_helium(block_type_dilution*	blk)
+		{return(val_temperature(blk->ADC_dil[ t_b3]));}
+		
+double	temperature_caisson_piles(block_type_dilution*	blk)
+		{return(val_temperature(blk->ADC_dil[ t_pile]));}
+		
+double	temperature_caisson_driver_moteur(block_type_dilution*	blk)
+		{return(val_temperature(blk->ADC_dil[ t_a1]));}
+		
+double	pression_helium_bain(block_type_dilution*	blk)
+		{return( 0.2*val_multiplex(blk->ADC_dil[ RP_He]));}
+		
+double	pression_pirani(block_type_dilution*	blk)
+		{return(val_multiplex(blk->ADC_dil[ pirani]));}
+
+
+
+
+
+/**********  coefficients  pour  les  mesures  bolo    **********************************/
+/*                         toutes les puissances en pW                                  */
+/*	-1-	loi de reponse thermique des bolos  avec R en ohms et T en Kelvin               */
+/*                                                                                      */
+/* 	T =  coef2  *   (   ln (  R / coef1) **  ( -1 / coef0 )                             */
+/*                                                                                      */
+/*	-2-	fuite thermique du bolo   coef 3,4                                              */
+/*                                                                                      */
+/*	Ptot =  coef3  *  ( (10*Tb) ** coef4    -    (10*Tcryo)  **  coef4 )                */
+/*                                                                                      */
+/*	-3-	calcul empirique de Pciel et de  tau	  coef  5,6                             */
+/*                                                                                      */
+/*	Pciel	=	coef5	- Pelec		coef5= I * Ai (tables xavier) 	                    */
+/*	tau	=	- ln ( 1 +  Pciel / coef6 )	coef6= I * Bi (tables xavier)                   */
+/*   										                                            */
+/* Pour les thermometres 1 à 4 (germanium et carbone Allan-Bradley) 		            */
+/* les coefficients sont utilisés differemment, ils permettent de convertir	            */
+/* R vers T		( c(6) est un offset sur la mesure de R par rapport  aux mesures 4 fils)*/
+/*   llR= log(log(R - c(6))-c(0))  						                                */
+/*    T	= exp(c(1) + c(2)* llR + c(3)* llR* llR + c(4)* llR* llR* llR +                 */
+/*            c(5)* llR* llR* llR* llR)                                                 */
+/*										                                                */
+/*	version vol Trapani									                                */
+/*	on corrige le biais de temperature coef2=1.1 old,  coef3=old/1.1^coef4	            */
+/*										                                                */
+/*										                                                */
+/*										                                                */
+/*										                                                */
+/*										                                                */
+/****************************************************************************************/
+
+
+
+
+/* ------------------------------------   corps  des fonctions	 ------------------------------ */
+/* -------------------------------------------------------------------------------------------- */
+
+
+
+
+double		DAC_muV		(param_bolo*	param_pt,	reglage_bolo*	reglage_pt, int indice_bolo)
+{
+double div,car;
+car= (double)dac_V(reglage_pt->bolo[indice_bolo])  ;
+div=(double)param_pt->bolo[indice_bolo].bolo_diviseur;
+if(div) return (car *2441. /  div );					
+else	return(0);
+}
+
+
+
+double		DAC_muA		(param_bolo*	param_pt,	reglage_bolo*	reglage_pt, int indice_bolo)
+{
+double capa,tri;
+tri= (double)dac_I(reglage_pt->bolo[indice_bolo])  ;
+capa=((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);
+		/* capa en pF	*/
+return (tri * capa / (4096. * 22. * 20.) );					
+}
+
+
+double		bolo_muV	(param_bolo*	param_pt,	reglage_bolo*	reglage_pt, int valbrut,int indice_bolo)										
+{
+double x;
+int nb_coups;
+int aa;
+def_gains
+
+nb_coups= reglage_pt->horloge.nb_mesures/2 - reglage_pt->horloge.temp_mort;
+
+aa = (nb_coups<<14) + (nb_coups*190) ;
+x=((double)((valbrut-aa)<<1))/(double)nb_coups;
+x=	bol_micro_volt(x,(double)param_pt->bolo[indice_bolo].bolo_gain*gain_ampli(reglage_pt->bolo[indice_bolo]));
+return(x);
+}
+
+
+
+
+#define	c(i)		(1e-4*(double)param_pt->nom_coef[param_pt->bolo[indice_bolo].numero_nom_coef].coef[i])	
+
+double		bolo_temp	(param_bolo*	param_pt,	reglage_bolo*	reglage_pt, double R,int indice_bolo)
+{
+double a,T;
+a=1;	if( (R>0) && (c(1) >0.01) )		a= log ( R / c(1) );
+T=0;	if( (a>0) && (c(0)>0.01) )		T= c(2) * pow( a , -1 / c(0) );
+return(T);
+}
+
+#undef c
+
+
+
+
+/* -------------------------------------------------------------  */
+
+
+unsigned int4	val_long(char x)
+{
+unsigned long a,xl;
+char aa;
+aa=x-2;
+a=aa;
+if(x<3)  xl=x;	else	xl=((a&1) + 2)<<(a>>1);
+return(xl);
+}
+
+
+double	val_double(char x)
+{
+unsigned long a,xl;
+if(x<0) x=-x;	a=x;	if(!a)  xl=0;	else	xl=((a&1) + 2)<<(a>>1);
+if(x>0)	return(1e-4*(double)xl);	else	return(-1e-4*(double)xl);
+}
+
+int	new_val_dac(int a,char  code)
+{
+if(code&0x80)	a=(code&0x7f) <<5 ;
+else	{
+	if(code&0x40)	a+=code&0x3f;	
+	else		a-=code&0x3f;	
+	}
+return(a);
+}
+
Index: /trunk/Poubelle/archTOI.old/arcunit.h
===================================================================
--- /trunk/Poubelle/archTOI.old/arcunit.h	(revision 434)
+++ /trunk/Poubelle/archTOI.old/arcunit.h	(revision 434)
@@ -0,0 +1,137 @@
+
+/*======================================================================*/
+/*                                                                      */
+/* 		 arcunit.h  :	conversion en mesure physique               	*/
+/*                                                                      */
+/*======================================================================*/
+
+
+
+/* ----------------------------   prototypes des fonctions	 ------------------------------ */
+/* -------------------------------------------------------------------------------------------- */
+
+
+double		bolo_muV	(param_bolo*	param_pt,	reglage_bolo*	reglage_pt, int valbrut,int indice_bolo);											
+double		bolo_temp	(param_bolo*	param_pt,	reglage_bolo*	reglage_pt, double R,int indice_bolo);
+
+double		DAC_muV		(param_bolo*	param_pt,	reglage_bolo*	reglage_pt, int indice_bolo);
+double		DAC_muA		(param_bolo*	param_pt,	reglage_bolo*	reglage_pt, int indice_bolo);
+
+int	voyant_EVO(block_type_dilution*	blk);
+int	voyant_EVF(block_type_dilution*	blk);
+int	commande_EVO(block_type_dilution*	blk);
+int	commande_EVF(block_type_dilution*	blk);
+int	commande_EVB(block_type_dilution*	blk);
+int	commande_EVV(block_type_dilution*	blk);
+
+
+double pression_entree_3He(block_type_dilution*	blk);	
+double debit_3He(block_type_dilution*	blk)	;
+double pression_sortie_3He(block_type_dilution*	blk)	;
+double pression_entree_4He(block_type_dilution*	blk)	;
+double debit_4He(block_type_dilution*	blk)	;
+double pression_sortie_4He(block_type_dilution*	blk)	;
+double pression_air_vanne(block_type_dilution*	blk)	;
+double pression_pompe_charbon(block_type_dilution*	blk);	
+double pression_membranne(block_type_dilution*	blk)	;
+double pression_externe(block_type_dilution*	blk)	;
+double tension_pile_10T(block_type_dilution*	blk)	;
+double tension_pile_p18D(block_type_dilution*	blk)	;
+double tension_pile_m18D(block_type_dilution*	blk)	;
+double tension_pile_10B(block_type_dilution*	blk)	;
+double tension_pile_p18B(block_type_dilution*	blk)	;
+double tension_pile_m18B(block_type_dilution*	blk)	;
+double tension_pile_Ch(block_type_dilution*	blk)	;
+int switch_pile_5(block_type_dilution*	blk)	;
+int switch_pile_15(block_type_dilution*	blk)	;
+double	temperature_caisson_haut1(block_type_dilution*	blk)	;
+double	temperature_caisson_haut2(block_type_dilution*	blk)	;
+double	temperature_caisson_bas1(block_type_dilution*	blk)	;
+double	temperature_caisson_bas2(block_type_dilution*	blk)	;
+double	temperature_caisson_tube_helium(block_type_dilution*	blk)	;
+double	temperature_caisson_piles(block_type_dilution*	blk)	;
+double	temperature_caisson_driver_moteur(block_type_dilution*	blk)	;
+double	pression_helium_bain(block_type_dilution*	blk)	;
+double	pression_pirani(block_type_dilution*	blk)	;
+
+
+
+
+/* 	cette fonction transforme un char (sur 8 bit) en double avec une echelle logarythmique	*/
+/*	elle est en particulier utilisée pour calculer les coef de la regul			*/
+
+double		val_double(char x);
+
+/* 	cette fonction transforme un char (sur 8 bit) en entier int4 (echelle logarythmique)	*/
+/*	elle est en particulier utilisée pour fixer le courant sur les bolometres		*/
+
+unsigned 	int4	val_long(char x);
+
+int			new_val_dac(int a,char  code); 
+
+
+
+/* ----------------------------   define utilise pour les calculs	 ------------------------------ */
+
+
+#define	bol_micro_volt(val,gain)	((1e7*(double)val)/(65536.*gain))
+/*  avec  gain = (double)parametr.bolo[bolo].bolo_gain*gain_ampli(reglage.bolo[bolo])				*/
+		
+
+/* gains 0 .. 15 pour MLPA  ///   gain 16..19  pour BEBO   ///   gain 20..22  pour BEDIF	*/		
+#define	def_gains	double gains_reels[32]={1,2,4,8,10,20,40,80,100,200,400,800,1000,2000,4000,8000,0.5,2.5,10,50,0.93,3.777,18.974};
+		/*			gain bediff    10->9.3    40->37.77     200->189.74		*/
+
+#define		gain_ampli(aa)	gains_reels[gainbrut(aa)]		
+
+
+
+#define bit_piles_5V	1
+#define bit_piles_15V	2
+#define bit_piles_auto	4
+
+
+/*      signification des bit lus dans switch_dil	*/
+#define	switch_EVF		0x00000080	/*	contact fin de course vanne fermee	*/
+#define	switch_EVO		0x00000040	/*	contact fin de course vanne ouverte	*/
+
+/* les bit suivants sont envoyés par telecommande et relus dans switch_dil	*/
+#define	switch_helium		0x00200000	/*  13: commande sond niveau helium	*/
+#define switch_pile_par_5	0x00100000	/*  12: mise en parallele des piles pour le 5V	*/
+#define switch_pile_par_15	0x00080000	/*  11: mise en parallele des piles pour le 15V	*/
+#define vanne_EVB		0x00008000	/*  7: commande vanne brooks	*/
+#define vanne_EVO		0x00010000	/*  8: commande vanne EVO	*/
+#define vanne_EVV		0x00020000	/*  9: commande vanne EVV	*/
+#define vanne_EVF		0x00040000	/*  10: commande vanne EVF	*/
+#define chauffage1		0x00004000	/*  6: chauffage 1	*/
+#define chauffage2		0x00002000	/*  5: chauffage 1	*/
+#define chauffage3		0x00001000	/*  4: chauffage 1	*/
+#define chauffage4		0x00000800	/*  3: chauffage 1	*/
+#define chauffage5		0x00000400	/*  2: chauffage 1	*/
+#define chauffage6		0x00000200	/*  1: chauffage 1	*/
+#define chauffage7		0x00000100	/*  0: chauffage 7	*/
+
+enum{nbit_chauffage7,nbit_chauffage6,nbit_chauffage5,nbit_chauffage4,nbit_chauffage3
+	,nbit_chauffage2,nbit_chauffage1,nbit_vanne_EVB,nbit_vanne_EVO
+	,nbit_vanne_EVV,nbit_vanne_EVF,nbit_switch_pile_par_15,nbit_switch_pile_par_5,nbit_switch_helium};
+
+/*  position des mesures sur les multiplexeurs		*/
+/* J10A  ->  temperatures basses t_b1 t_b2,t_b3 t_b4 36 37 41 35	*/ 
+/* J10B  ->  temperatures basses t_a1 t_a2,t_a3 t_a4 38 11 34 28	*/ 
+/* J1??	 ->  temperatures hautes t_h1 t_h2,t_h3 t_h4	*/ 
+
+enum{
+/* multiplex11..18:*/	t_a2	,mul12_	,p_haut	,p_memb	,t_h1	,t_h4	,t_h3	,t_h2	
+/* multiplex21..28:*/,	mul21_	,mul22	,p_charb,p_R4	,mul25_	,p_C3	,p_R3	,t_a4	
+/* multiplex31..38:*/,	mul31_	,p_C4	,p_air	,t_a3	,t_b4	,t_b1	,t_b2	,t_a1	
+/* multiplex41..48:*/,	t_b3	,d_4He	,RP_He	,t_pile	,d_3He	,j_he3	,j_he7	,j_he4	
+/* multiplex51..58:*/,	j_he5	,j_he1	,j_he8	,j_he2	,j_he6	,pirani	,mul57	,mul58	
+/* multiplex61..68:*/,	p_m18B	,p_10B	,p_m18D	,mul64	,p_p18B	,p_10T	,p_Ch	,p_p18D		
+	};
+/* reste libres :  mul   12 - 21 - 22 - 25 -  31 - 44 - 57 - 58 - 64	*/
+/* T_A1 EST AUSSI LE DRIVER DU MOTEUR DE PIVOT   */
+
+#define  val_multiplex(qq)	(0.0003052*(double)((qq)-0x8000))	
+#define  val_temperature(qq)	((val_multiplex(qq)<0.2)?-99:((1146.3/(val_multiplex(qq)-0.1)) - 245.13))
+
+
