Changeset 16965 for trunk/FACT++


Ignore:
Timestamp:
07/19/13 12:49:59 (11 years ago)
Author:
tbretz
Message:
Added the slope to the channel calibration (conversion from dac counts to voltage and vice versa); added slope to dim service; round the dac counts instead of cutting the remainder
File:
1 edited

Legend:

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

    r16941 r16965  
    8585    vector<float> fBreakdownVoltage;      // Breakdown voltage of GAPDs
    8686    vector<float> fOvervoltage;           // Requested overvoltage of GAPDs
    87     vector<float> fChannelCalibration;    // Bias crate channel offset
    8887    vector<float> fChannelOffset;         // User defined channel offset
     88
     89    vector<float> fCalibrationOffset;     // Bias crate channel offset
     90    vector<float> fCalibrationSlope;      // Bias crate channel slope
    8991
    9092    float fVoltageMaxAbs;  // Maximum voltage
     
    840842        fBreakdownVoltage(kNumChannels, 0),
    841843        fOvervoltage(kNumChannels),
    842         fChannelCalibration(kNumChannels),
    843844        fChannelOffset(kNumChannels),
     845        fCalibrationOffset(kNumChannels),
     846        fCalibrationSlope(kNumChannels, 90./4096),
    844847        fVoltageMaxAbs(75),
    845848        fVoltageMaxRel(2),
     
    942945    uint16_t ConvertVoltToDac(uint16_t ch, double volt)
    943946    {
    944         volt += fChannelCalibration[ch];
     947        volt -= fCalibrationOffset[ch];
     948        volt /= fCalibrationSlope[ch];
    945949        if (volt<0)
    946950            volt = 0;
    947951
    948         return volt*4096/90;
     952        return nearbyint(volt);
    949953    }
    950954
    951955    double ConvertDacToVolt(uint16_t ch, uint16_t dac)
    952956    {
    953         return dac*90./4096 - fChannelCalibration[ch];
     957        return dac*fCalibrationSlope[ch] + fCalibrationOffset[ch];
    954958    }
    955959
     
    11101114    }
    11111115
    1112     bool SetReferences(const vector<float> &volt, const vector<float> &offset)
     1116    bool SetReferences(const vector<float> &volt, const vector<float> &offset, const vector<float> &slope)
    11131117    {
    11141118        if (volt.size()!=kNumChannels)
     
    11221126        {
    11231127            ostringstream out;
    1124             out << "SetReferences - Given vector has " << volt.size() << " elements - expected " << kNumChannels << endl;
     1128            out << "SetReferences - Given vector has " << offset.size() << " elements - expected " << kNumChannels << endl;
    11251129            Error(out);
    11261130            return false;
    11271131        }
    1128 
    1129         fBreakdownVoltage   = volt;
    1130         fChannelCalibration = offset;
     1132        if (slope.size()!=kNumChannels)
     1133        {
     1134            ostringstream out;
     1135            out << "SetReferences - Given vector has " << slope.size() << " elements - expected " << kNumChannels << endl;
     1136            Error(out);
     1137            return false;
     1138        }
     1139
     1140        fBreakdownVoltage  = volt;
     1141        fCalibrationOffset = offset;
     1142        fCalibrationSlope  = slope;
    11311143        fOvervoltage.assign(kNumChannels, 0);
    11321144
     
    15281540        volt.insert(volt.end(), fBreakdownVoltage.begin(),   fBreakdownVoltage.end());
    15291541        volt.insert(volt.end(), fOvervoltage.begin(),        fOvervoltage.end());
    1530         volt.insert(volt.end(), fChannelCalibration.begin(), fChannelCalibration.end());
     1542        volt.insert(volt.end(), fCalibrationOffset.begin(),  fCalibrationOffset.end());
     1543        volt.insert(volt.end(), fCalibrationSlope.begin(),   fCalibrationSlope.end());
    15311544        fDimGapd.Update(volt);
    15321545    }
     
    15421555        fDimVolt("BIAS_CONTROL/VOLTAGE", "F:416",
    15431556                 "|Uout[V]:Output voltage"),
    1544         fDimGapd("BIAS_CONTROL/NOMINAL", "F:416;F:416;F:416",
     1557        fDimGapd("BIAS_CONTROL/NOMINAL", "F:416;F:416;F:416;F:416",
    15451558                 "|Ubr[V]:Nominal breakdown voltage at 25deg C"
    15461559                 "|Uov[V]:Nominal overvoltage"
    1547                  "|Uoff[V]:Bias crate channel offsets")
     1560                 "|Uoff[V]:Bias crate channel calibration offsets"
     1561                 "|Uslope[V/dac]:Bias crate channel calibration slope")
    15481562    {
    15491563    }
     
    21402154        }
    21412155
    2142         if (!fBias.SetReferences(map.Vgapd(), map.Voffset()))
     2156        if (!fBias.SetReferences(map.Vgapd(), map.Voffset(), map.Vslope()))
    21432157        {
    21442158            T::Error("Setting reference voltages failed.");
Note: See TracChangeset for help on using the changeset viewer.