Changeset 16967


Ignore:
Timestamp:
07/19/13 12:55:20 (11 years ago)
Author:
tbretz
Message:
Updated new feedback algorithm.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/feedback.cc

    r16781 r16967  
    149149        med[1].resize(416);
    150150
    151         const float *Ravg = fCalibration.data()+BIAS::kNumChannels*2; // Measured resistance
     151        //const float *Ravg = fCalibration.data()+BIAS::kNumChannels*2; // Measured resistance
    152152
    153153        vector<float> vec(2*BIAS::kNumChannels+2);
     
    171171                return GetCurrentState();
    172172
     173            vector<double> dI;
     174            vector<double> R8;
     175            vector<double> R9;
     176
    173177            for (int i=0; i<BIAS::kNumChannels; i++)
    174178            {
     
    189193                const int N = hv.group() ? 5 : 4;
    190194
    191                 // 100 Ohm measurement resistor for current measurement
    192                 const double R2 = 100;
     195                // Average measured ADC value for this channel
     196                const double adc = double(fCurrentsAvg[i])/fCursorCur * (5000/4096.); // [uA]
     197
     198                // Current through ~100Ohm measurement resistor
     199                const double I8 = (adc-dI[i])*100/R8[i];
    193200
    194201                // Serial resistors (one 1kOhm at the output of the bias crate, one 1kOhm in the camera)
     
    205212
    206213                // Total resistance of branch with diode
    207                 const double R3 = R4+R5;
    208 
    209                 // Measured calibration resistor
    210                 const double R1 = Ravg[i] - R2;
    211 
    212                 // Voltage output of bias crate
    213                 const double Uout = fBiasVolt[i];
    214 
    215                 // Average current measured for this channel
    216                 const double Imes = double(fCurrentsAvg[i])/fCursorCur * (5000/4096.); // [uA]
    217 
    218                 // Voltage drop at measurement resistor R2 is define
    219                 // bythe measured current and the resistor
    220                 const double U2 = R2*Imes;
    221 
    222                 // The voltage seen by the calibration resistor R1 is defined by the
    223                 // bias crate output voltage minus the drop at the measurement resistor R2
    224                 const double U1 = Uout - U2;
    225 
    226                 // The current through the resistor R1 is defined
    227                 // by the applied voltage and the resistor
    228                 const double I1 = U1/R1;
    229 
    230                 // The current through the diode branch is the measured current
    231                 // minus the current through the calibration resistor R1
    232                 const double I3 = Imes - I1;
    233 
    234                 // The voltage drop in the diode branch (without the diode) is defined by the
    235                 // resistor and the current. It is 0 below the breakdown voltage of the G-APD
    236                 // is reached at the G-APD. This is the case when the output voltage minus
    237                 // the voltage drop at the calibration resistor reaches the breakdown voltage.
    238                 const double U3 = Uout-U2<Ubd ? 0 : R3*I3;
    239 
    240                 // Voltage drop at measurement resistor R2 and
    241                 // the total serial resistor R3 in the diode branch
    242                 const double Udrp = U2 + U3;
    243 
    244                 // Voltage finally at each G-APD (bias crate output voltage minus voltage drop)
    245                 const double Uapd = Uout - Udrp;
    246 
    247                 // The over-voltage seen by the G-APD (the voltage above the breakdown voltage) is
    248                 const double Uov = Uapd<Ubd ? 0 : Uapd - Ubd;
     214                const double R = R4+R5;
     215
     216                // Applied voltage at calibration resistors, according to
     217                // biasctrl
     218                const double U9 = fBiasVolt[i];
     219
     220                // Current through calibration resistors
     221                // FIXME: Get that from biasctrl!!!
     222                const double I9 = U9/R9[i];
     223
     224                // Current in R4/R5 branch
     225                const double Iout = I8>I9 ? I8 - I9 : 0;
     226
     227                // Voltage drop in R4/R5 branch
     228                const double Udrp = R*Iout;
     229
     230                // Current overvoltage
     231                const double Uov = U9-Udrp-Ubd>0 ? U9-Udrp-Ubd : 0;
    249232
    250233                // The current through one G-APD is the sum divided by the number of G-APDs
    251234                // (assuming identical serial resistors)
    252                 double Iapd = I3/N;
     235                double Iapd = Iout/N;
    253236
    254237                // This is assuming that the broken pixels have a 390 Ohm instead of 3900 Ohm serial resistor
     
    267250                // If the G-APD voltage is above the breakdown voltage we have the current through the
    268251                // G-APD and the over-voltage applied to the G-APD to calculate its differential resistor.
    269                 if (Uapd>Ubd)
     252                if (Iapd>0)
    270253                {
    271254                    // The differential resistance of the G-APD, i.e. the dependence of the
     
    276259                    const double Iov = (1.1+fBiasOffset)/Rapd;
    277260
    278                     // This gives us an ohmic resistance Rov of the G-APD at the set-point
    279                     const double Rest = (Ubd+1.1+fBiasOffset)/Iov;
    280 
    281                     // This lets us estimate the total resistance Rtot of the circuit at the set-point
    282                     const double R3b  = R4 + (R5+Rest)/N;
    283                     const double Rtot = R2 + 1/(1/R1 + 1/R3b);
    284 
    285                     // From this we can estimate the output voltage we need to get the
    286                     // over-voltage at the G-APD as anticipated
    287                     const double r    = 1 + R3/R1 - (R2 + R3 + R3*R2/R1)/Rtot;
    288                     const double Uset = (Ubd+1.1+fBiasOffset)/r;
    289 
    290                     Uoff[i] = Uset - fVoltGapd[i];
     261                    // Estimate set point for over-voltage
     262                    const double Uset = (1.1+fBiasOffset) + Ubd + R*Iov*N;
     263
     264                    // Voltage set point as a difference between breakdown voltage and set point
     265                    Uoff[i] = Uset - fBiasVolt[i];
    291266                }
    292267
Note: See TracChangeset for help on using the changeset viewer.