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