1 | #include "diabolo.h"
|
---|
2 | #include "bolo.h"
|
---|
3 | #include "auto.h"
|
---|
4 | #include "courbeVI.h"
|
---|
5 | #include "fenetres_diabolo.h"
|
---|
6 | #include "arcunit.h"
|
---|
7 |
|
---|
8 | int voie_bit; // octet contenant dans chaque bit le flag qui dit si on equiloibre cette voie
|
---|
9 | int bolo;
|
---|
10 | int posi=0; // valeur du courant (triangle )
|
---|
11 | int act=0;
|
---|
12 | int ref_nep=0;
|
---|
13 | double Ip=0,Vp=0;
|
---|
14 | //-------------------- fonction exec de la fenetre : courbeVI -------------------------------
|
---|
15 |
|
---|
16 | void equilibre_tout(void);
|
---|
17 |
|
---|
18 | void exec_courbeVI(int fen,int item,double valeur,...)
|
---|
19 | {
|
---|
20 | int i,j;double I,V,A,nep;int c;double x[50];
|
---|
21 | double y[nb_max_bolo+1];
|
---|
22 | def_gains
|
---|
23 | switch(item)
|
---|
24 | {
|
---|
25 | case ouverture :
|
---|
26 | graph->type_symbole=rondplein;efface(fen);
|
---|
27 | break;
|
---|
28 |
|
---|
29 | case cvi_bolo :
|
---|
30 | voie_bit=valeur; posi=0;tachedefond(fen,-1);
|
---|
31 | break;
|
---|
32 |
|
---|
33 | /* bolo=litD(fen,cvi_bolo,0L);posi=0;tachedefond(fen,-1);
|
---|
34 | if(bolo) exec_bolo(bolo,b_tri,posi);
|
---|
35 | if(bolo) exec_bolo(bolo,b_carre,0);
|
---|
36 | break;
|
---|
37 | */
|
---|
38 | /* case cvi_tous :
|
---|
39 | bolo=0;posi=0;tachedefond(fen,-1);
|
---|
40 | for(j=0;j<nb_max_bolo;j++)
|
---|
41 | {
|
---|
42 | if(fenetre(j+1) &&(!litD(j+1,b_bloq,0L)) )
|
---|
43 | {
|
---|
44 | exec_bolo(j+1,b_tri,0);
|
---|
45 | exec_bolo(j+1,b_carre,0);
|
---|
46 | }
|
---|
47 | }
|
---|
48 | break;
|
---|
49 | */
|
---|
50 |
|
---|
51 | case cvi_calc_nep :
|
---|
52 | ref_nep=ouvreD(0,0,"1e-16/Nep",0);
|
---|
53 | graph->type_symbole=rondplein;efface(ref_nep);
|
---|
54 |
|
---|
55 | position(fen,0);Ip=0;Vp=0;
|
---|
56 | while( (c=litvaleur(fen,x)) >=0)
|
---|
57 | {
|
---|
58 | // printf(" c=%d \n",c);
|
---|
59 | if (c>1)
|
---|
60 | {
|
---|
61 | I=x[0];V=x[1];
|
---|
62 | ecritD(fen,cvi_valI,"I=%g",I);
|
---|
63 | ecritD(fen,cvi_valV,"V=%g",V);
|
---|
64 | if(Ip>0)
|
---|
65 | {
|
---|
66 | A=( (V-Vp)/(I-Ip)-(V+Vp)/(I+Ip) ) / (V+Vp);
|
---|
67 | nep= 30. * A / sqrt((V+Vp)/(I+Ip));
|
---|
68 | printf(" I=%g V=%g A=%g (10^9V/W^) 1/nep=%g (10^16) \n",I,V,A,nep);
|
---|
69 | trace(ref_nep,I,nep);
|
---|
70 | }
|
---|
71 | Ip=I;Vp=V;
|
---|
72 | }
|
---|
73 | }
|
---|
74 | break;
|
---|
75 |
|
---|
76 |
|
---|
77 | case tache_de_fond :
|
---|
78 | switch(act)
|
---|
79 | {
|
---|
80 | case 0: /*pas=4;
|
---|
81 | if(posi>=20) pas=10;
|
---|
82 | if(posi>=60) pas=20;
|
---|
83 | if(posi>=100) pas=50;
|
---|
84 | if(posi>=200) pas=100;
|
---|
85 | if(posi>=600) pas=200;
|
---|
86 | if(posi>=1000) pas=500;
|
---|
87 | if(litD(fen,cvi_precis,0L)) pas=pas/2;
|
---|
88 | posi+=pas;
|
---|
89 | if(posi>4000) {posi=0;tachedefond(fen,-1);}
|
---|
90 | if(litD(fen,cvi_tous,0L))
|
---|
91 | for(j=0;j<nb_max_bolo;j++)
|
---|
92 | {
|
---|
93 | if(fenetre(j+1) &&(!litD(j+1,b_bloq,0L)) )
|
---|
94 | exec_bolo(j+1,b_tri,posi);
|
---|
95 | }
|
---|
96 | else exec_bolo(bolo,b_tri,posi);
|
---|
97 | */
|
---|
98 |
|
---|
99 | if(litD(fen,cvi_precis,0L)) posi++; else posi+=2;
|
---|
100 | printf(" posi=%d \n",posi);
|
---|
101 | if(posi>=25) {son(133);posi=0;tachedefond(fen,-1);}
|
---|
102 |
|
---|
103 | if(!fenetre(fenetre_automatismes))
|
---|
104 | ouvreD(fenetre_automatismes,automatismes_id,"automatismes",exec_automatismes);
|
---|
105 | for(i=0;i<6;i++) if((voie_bit>>i)&1)
|
---|
106 | {
|
---|
107 | long ll;
|
---|
108 | ll=(long)(&(gg->reglage.autom[i].courant))-(long)(&(gg->reglage.autom[0]));
|
---|
109 | ecritD(fenetre_automatismes,atm_courant+i,posi+1);
|
---|
110 | emission_tc_reduite(tc2_auto_bolo,ll,posi);
|
---|
111 | }
|
---|
112 | act++;
|
---|
113 | break;
|
---|
114 |
|
---|
115 | case 1: /*
|
---|
116 | if(litD(fen,cvi_tous,0L)) equilibre_tout();
|
---|
117 | else auto_control(bolo,auto_carre);
|
---|
118 | */
|
---|
119 | act++; break;
|
---|
120 |
|
---|
121 | case 2: /*
|
---|
122 | if(litD(fen,cvi_tous,0L)) equilibre_tout();
|
---|
123 | else auto_control(bolo,auto_carre);
|
---|
124 | */
|
---|
125 | act++; break;
|
---|
126 |
|
---|
127 | case 3:
|
---|
128 | j=bolo_rouge();
|
---|
129 | I=calcI(j)*1e3;ecritD(fen,cvi_valI,"I=%g",I); // nA
|
---|
130 | for(j=0;j<nb_max_bolo;j++)
|
---|
131 | {
|
---|
132 | y[j]=(calcV(j+1)-xbolbrut(j))*1e-3;
|
---|
133 | // corrigée du déséquilibre en µV puis transformé en mV
|
---|
134 | }
|
---|
135 | montracen(fen,nb_max_bolo,I,y);
|
---|
136 | act=0;
|
---|
137 | break;
|
---|
138 |
|
---|
139 |
|
---|
140 |
|
---|
141 | /*
|
---|
142 | if(litD(fen,cvi_tous,0L))
|
---|
143 | {
|
---|
144 | equilibre_tout();
|
---|
145 | for(j=nb_max_bolo-1;j>=0;j--)
|
---|
146 | if(!litD(j+1,b_bloq,0L) )
|
---|
147 | {y[j]=calcV(j+1)*1e-3; I=calcI(j+1)*1e3;}
|
---|
148 | else y[j]=0;
|
---|
149 | ecritD(fen,cvi_valI,"I=%g",I);
|
---|
150 | montracen(fen,nb_max_bolo,I,y);
|
---|
151 | }
|
---|
152 | else {
|
---|
153 | auto_control(bolo,auto_carre);
|
---|
154 | I=calcI(bolo)*1e3; // en nA
|
---|
155 | V=calcV(bolo)*1e-3; // en mV
|
---|
156 | ecritD(fen,cvi_valI,"I=%g",I);
|
---|
157 | ecritD(fen,cvi_valV,"V=%g",V);
|
---|
158 | trace(fen,I,V);
|
---|
159 | }
|
---|
160 | act=0;
|
---|
161 | break;
|
---|
162 | */
|
---|
163 |
|
---|
164 | default : act=0;
|
---|
165 | }
|
---|
166 | break;
|
---|
167 |
|
---|
168 | case cvi_mesure :
|
---|
169 |
|
---|
170 | if(!posi) style(fen);
|
---|
171 | tachedefond(fen,litD(fen,cvi_vitesse,0L)*60);act=0;
|
---|
172 | break;
|
---|
173 |
|
---|
174 | case cvi_stop :
|
---|
175 | posi=0;act=0;
|
---|
176 | tachedefond(fen,-1); break;
|
---|
177 |
|
---|
178 | default :
|
---|
179 | break;
|
---|
180 | }
|
---|
181 | }
|
---|
182 |
|
---|
183 |
|
---|
184 | void equilibre_tout(void) // fait la correction sans passer par auto_control
|
---|
185 | {
|
---|
186 | int j;
|
---|
187 | double coef[nb_max_bolo];
|
---|
188 | def_gains;
|
---|
189 | for(j=0;j<nb_max_bolo;j++)
|
---|
190 | {
|
---|
191 | coef[j]= pt_micV(j+1) * xbolbrut(j) * litD(fenetre_auto,auto_correct,0L); // correction augmentée artificiellement
|
---|
192 | coef[j]=(double)dac_V(gg->reglage.bolo[j])-coef[j];
|
---|
193 | }
|
---|
194 |
|
---|
195 | for(j=0;j<nb_max_bolo;j++) if( (parametr.bolo[j].bolo_code_util) && !litD(j+1,b_bloq,0L) ) exec_bolo(j+1,b_carre,coef[j]);
|
---|
196 | }
|
---|