| 1 | #include "manip.h"
 | 
|---|
| 2 | #include "choix_acquisition.h"
 | 
|---|
| 3 | #include "archeops.h"
 | 
|---|
| 4 | #include "choix_param.h"
 | 
|---|
| 5 | #include "structure.h"
 | 
|---|
| 6 | #include "carte_acqui.h"
 | 
|---|
| 7 | #include "carte_pci.h"
 | 
|---|
| 8 | #include "tm.h"
 | 
|---|
| 9 | #include "tache.h"
 | 
|---|
| 10 | #include "bolo.h"
 | 
|---|
| 11 | 
 | 
|---|
| 12 | 
 | 
|---|
| 13 | //*****************************************************************************************
 | 
|---|
| 14 | //                                                                                      ***
 | 
|---|
| 15 | #ifdef _diabolo //---------   pour  Diabolo    ------------------------------   ***
 | 
|---|
| 16 | //                                                                                      ***
 | 
|---|
| 17 | //*****************************************************************************************
 | 
|---|
| 18 | 
 | 
|---|
| 19 | 
 | 
|---|
| 20 | 
 | 
|---|
| 21 | 
 | 
|---|
| 22 | 
 | 
|---|
| 23 | double  deglitch_regul(double x);
 | 
|---|
| 24 | double  deglitch_regul(double x)
 | 
|---|
| 25 | {
 | 
|---|
| 26 | double dx;
 | 
|---|
| 27 | static int debut=1;
 | 
|---|
| 28 | static double X,DX;
 | 
|---|
| 29 | //return(x);                    //  ligne a retirer pour deglitcher
 | 
|---|
| 30 | 
 | 
|---|
| 31 | if(debut) {     X=0;DX=1000;    debut=0;        }
 | 
|---|
| 32 | 
 | 
|---|
| 33 | dx=x-X; if(dx<0)  dx=-dx;
 | 
|---|
| 34 | if( dx > DX ) 
 | 
|---|
| 35 |                 {
 | 
|---|
| 36 |                 x=X;
 | 
|---|
| 37 |                 DX *=1.1;
 | 
|---|
| 38 |                 }
 | 
|---|
| 39 | else    {
 | 
|---|
| 40 |                 DX=0.9 * DX + 0.5 * dx +1 ; 
 | 
|---|
| 41 |                 X=x;
 | 
|---|
| 42 |                 }               // en moyenne, 5 fois l'interval moyen
 | 
|---|
| 43 | return(x);
 | 
|---|
| 44 | }
 | 
|---|
| 45 | 
 | 
|---|
| 46 | 
 | 
|---|
| 47 | void  tache_regul(tmtc* tt)
 | 
|---|
| 48 | {
 | 
|---|
| 49 | block_tc  btc;
 | 
|---|
| 50 | btc=tt->tc.btc[tt->tc.pos_lit];
 | 
|---|
| 51 | tt->vi.reg.pid=* ( (regul_p_i_d*)    &btc );
 | 
|---|
| 52 | }
 | 
|---|
| 53 | 
 | 
|---|
| 54 | 
 | 
|---|
| 55 | void    regul(tmtc* tt)
 | 
|---|
| 56 | {
 | 
|---|
| 57 | int j,cc;
 | 
|---|
| 58 | double i,ecart;
 | 
|---|
| 59 | 
 | 
|---|
| 60 | 
 | 
|---|
| 61 | if(tt->vi.reg.pid.nb_mes<1) return;             // pas de regul si repetition <1
 | 
|---|
| 62 | tt->vi.reg.compteur++;
 | 
|---|
| 63 | if( (tt->vi.reg.compteur>0) && (tt->vi.reg.compteur< (tt->vi.reg.pid.nb_mes*4+4) ) )    return;
 | 
|---|
| 64 | 
 | 
|---|
| 65 | ecart=-deglitch_regul(tt->vi.reg.valeur);
 | 
|---|
| 66 | ecart/=4*tt->vi.reg.pid.nb_mes;         //  valeur mesurée et moyennée apres repetition
 | 
|---|
| 67 | ecart=ecart/(long)tt->ds.dsnorme;
 | 
|---|
| 68 | ecart=((1e5*(double)ecart)/(65536.*tt->reglage.gain[tt->vi.reg.pid.num_bolo-1]));
 | 
|---|
| 69 | tt->vi.reg.valeur=(long)ecart;
 | 
|---|
| 70 | i=tt->vi.reg.tint;                                                      
 | 
|---|
| 71 | i=i+ecart*tt->vi.reg.pid.i;                                     //      terme intergral
 | 
|---|
| 72 | if(i>4000) i=4000;
 | 
|---|
| 73 | if(i<0) i=0;
 | 
|---|
| 74 | cc=tt->vi.reg.pid.p*ecart+i+(ecart-tt->vi.reg.anc_ecart)*tt->vi.reg.pid.d;      //      calcul de la commande
 | 
|---|
| 75 | if(cc>4000) cc=4000;
 | 
|---|
| 76 | if(cc<0) cc=0;
 | 
|---|
| 77 | if(!tt->vi.reg.pid.chauf) cc=0; 
 | 
|---|
| 78 | //cc=tt->vi.reg.pid.p;
 | 
|---|
| 79 | tt->vi.reg.cc=cc;
 | 
|---|
| 80 | cc=( 0x0fff - cc ) & 0x0fff;            //  12 bits  avec inverser la polarité 
 | 
|---|
| 81 | if( (acquisition_PCI) && ( tt->vi.flag_ecriture_data>2 ) )              //    rien en attente d'ecriture: j'ecris direct en interruption                
 | 
|---|
| 82 |         {
 | 
|---|
| 83 |         ecrit_carte(tc_regul );                 // ecrit bolo 251  -->  ecrit regulation
 | 
|---|
| 84 |         ecrit_carte( ( (tt->vi.reg.pid.chauf&3 ) <<6 ) |  (cc>>6)  );           // ecrit relais (2 bits) + 6 bits de data 
 | 
|---|
| 85 |         ecrit_carte( (cc<<2) |  2  );                                                           // ecrit  6 bits de data + 1  +  0      
 | 
|---|
| 86 |         for(j=0;j<7;j++)        ecrit_carte(0);                         // reste 7 mots à ecrire 
 | 
|---|
| 87 |         tt->vi.flag_ecriture_data=0;
 | 
|---|
| 88 |         }
 | 
|---|
| 89 |                 
 | 
|---|
| 90 | tt->vi.reg.compteur=0;
 | 
|---|
| 91 | tt->vi.reg.valeur=0;
 | 
|---|
| 92 | tt->vi.reg.anc_ecart=(int)ecart;
 | 
|---|
| 93 | tt->vi.reg.tint=i;
 | 
|---|
| 94 | }
 | 
|---|
| 95 | 
 | 
|---|
| 96 | void    raz_periodique(tmtc* tt)
 | 
|---|
| 97 | {
 | 
|---|
| 98 | /*****************************  ne  fait  rien  !!!!!!!!
 | 
|---|
| 99 | int j;
 | 
|---|
| 100 | if(tt->reg.per_raz<1) return;           // pas de raz si periode demandee = 0
 | 
|---|
| 101 | tt->reg.nb_raz++;
 | 
|---|
| 102 | if( (tt->reg.nb_raz>0) && (tt->reg.nb_raz< (tt->reg.per_raz) ) )        return;
 | 
|---|
| 103 | 
 | 
|---|
| 104 | 
 | 
|---|
| 105 | if( tt->vi.flag_ecriture_data>2 )       //   j'ecris direct en interruption sans regrader si autre chose est en cours d'ecriture                
 | 
|---|
| 106 |         {
 | 
|---|
| 107 |         ecrit_carte(23 );                       // ecrit bolo 23  -->  bebo A
 | 
|---|
| 108 |         ecrit_carte( 16);                       // ecrit a 
 | 
|---|
| 109 |         for(j=0;j<8;j++)        ecrit_carte(0);                         // reste 8 mots à ecrire 
 | 
|---|
| 110 |         }
 | 
|---|
| 111 | 
 | 
|---|
| 112 | tt->tb.synchro[2][tt->tb.pos_ecrit]=999;                
 | 
|---|
| 113 | tt->reg.nb_raz=0;
 | 
|---|
| 114 | */
 | 
|---|
| 115 | }
 | 
|---|
| 116 | 
 | 
|---|
| 117 | 
 | 
|---|
| 118 | //*****************************************************************************************
 | 
|---|
| 119 | //                                                                                      ***
 | 
|---|
| 120 | #endif          //--------------------------------------------------------------------  ***
 | 
|---|
| 121 | //                                                                                      ***
 | 
|---|
| 122 | //*****************************************************************************************
 | 
|---|
| 123 | 
 | 
|---|
| 124 | 
 | 
|---|