Changeset 11993 for trunk


Ignore:
Timestamp:
09/07/11 08:05:35 (13 years ago)
Author:
tbretz
Message:
Added voltage limit relative to G-APD reference voltage.
File:
1 edited

Legend:

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

    r11982 r11993  
    6969    vector<int16_t>  fCurrent;     // Current in ADC units (12bit = 5mA)
    7070
    71     uint16_t fVoltMax;
     71    uint16_t fVoltMaxAbs;
     72    uint16_t fVoltMaxRel;
    7273
    7374    virtual void UpdateA()
     
    8283    bool CheckChDac(const string &cmd, uint16_t dac, uint16_t ch=0)
    8384    {
     85        ostringstream str;
     86        str << cmd << " - ";
     87
     88        if (ch>=kNumChannels)
     89        {
     90            str << "Channel " << ch << " out of range [0,416].";
     91            Error(str);
     92            return false;
     93        }
     94
    8495        if (dac>kMaxDac)
    8596        {
    86             Error(cmd+" - DAC value out of range.");
    87             return false;
    88         }
    89         if (dac>fVoltMax)
    90         {
    91             Error(cmd+" - DAC value exceeds fVoltMax.");
    92             return false;
    93         }
    94 
    95         if (ch>=kNumChannels)
    96         {
    97             Error(cmd+" - Channel out of range.");
     97            str << "DAC value " << dac << " out of range [0,4095].";
     98            Error(str);
     99            return false;
     100        }
     101        if (dac>fVoltMaxAbs)
     102        {
     103            str << "DAC value " << dac << " exceeds allowed absolute maximum of " << fVoltMaxAbs;
     104            Error(str);
     105            return false;
     106        }
     107        if (dac>fVoltGapd[ch]+fVoltMaxRel)
     108        {
     109            str << "DAC value " << dac << " exceeds allowed channel maximum of " << fVoltGapd[ch] << " + " << fVoltMaxRel;
     110            Error(str);
    98111            return false;
    99112        }
     
    152165        const uint16_t error  = (answer[2]>>4)&0xf;
    153166        const uint16_t board  =  answer[2]&0xf;
     167
     168        // 0x10 00 7f
     169        //   status = 0
     170        //   wrap   = 1
     171        //   ddd    = 0
     172        //   error  = not present
     173        //   board  = 15
    154174
    155175        /*
     
    376396        if (command==kCmdChannelSet && fIsRamping)
    377397        {
    378             ScheduleRampStep();
     398            bool oc = false;
     399            for (int ch=0; ch<kNumChannels; ch++)
     400                if (fPresent[ch/kNumChannelsPerBoard] && fCurrent[ch]<0)
     401                    oc = true;
     402
     403            if (oc)
     404            {
     405                Warn("OverCurrent detected - ramping stopped.");
     406                fIsRamping = false;
     407            }
     408            else
     409                ScheduleRampStep();
     410
    379411            fCounter[3]++;
    380412        }
     
    10251057    }
    10261058
     1059    uint16_t GetRampStepVolt() const
     1060    {
     1061        return fRampStep*90./4096;
     1062    }
     1063
    10271064    bool IsRamping() const { return fIsRamping; }
    10281065
     
    12461283    }
    12471284
    1248     void SetVoltMax(float max)
    1249     {
    1250         fVoltMax = max*4096/90;
    1251         if (fVoltMax>4095)
    1252             fVoltMax = 4095;
     1285    void SetVoltMaxAbs(float max)
     1286    {
     1287        fVoltMaxAbs = max*4096/90;
     1288        if (fVoltMaxAbs>4095)
     1289            fVoltMaxAbs = 4095;
    12531290        if (max<0)
    1254             fVoltMax = 0;
    1255     }
    1256 
     1291            fVoltMaxAbs = 0;
     1292    }
     1293
     1294    void SetVoltMaxRel(float max)
     1295    {
     1296        fVoltMaxRel = max*4096/90;
     1297        if (fVoltMaxRel>4095)
     1298            fVoltMaxRel = 4095;
     1299        if (max<0)
     1300            fVoltMaxRel = 0;
     1301    }
     1302
     1303    uint16_t GetVoltMaxAbs() const
     1304    {
     1305        return fVoltMaxAbs * 90./4096;
     1306    }
     1307
     1308    uint16_t GetVoltMaxRel() const
     1309    {
     1310        return fVoltMaxRel * 90./4096;
     1311    }
    12571312
    12581313/*
     
    18461901        fBias.SetSyncDelay(conf.Get<uint16_t>("sync-delay"));
    18471902
    1848         const float maxv = conf.Get<float>("volt-max");
    1849         if (maxv>90)
     1903        ostringstream str;
     1904        str << "Ramping in effective steps of " << fBias.GetRampStepVolt() << "V with a cyle time of " << time << "ms";
     1905        T::Message(str);
     1906
     1907        // --------------------------------------------------------------------------
     1908
     1909        const float maxabsv = conf.Get<float>("volt-max-abs");
     1910        const float maxrelv = conf.Get<float>("volt-max-rel");
     1911        if (maxabsv>90)
    18501912        {
    18511913            T::Error("volt-max exceeds 90V.");
    18521914            return 2;
    18531915        }
    1854         if (maxv>75)
     1916        if (maxabsv>75)
    18551917            T::Warn("volt-max exceeds 75V.");
    1856         if (maxv<70)
     1918        if (maxabsv<70)
    18571919            T::Warn("volt-max below 70V.");
    1858         if (maxv<0)
     1920        if (maxabsv<0)
    18591921        {
    18601922            T::Error("volt-max negative.");
     
    18621924        }
    18631925
    1864         fBias.SetVoltMax(maxv);
     1926        fBias.SetVoltMaxAbs(maxabsv);
     1927        fBias.SetVoltMaxRel(maxrelv);
     1928
     1929        ostringstream str1, str2;
     1930        str1 << "Effective maximum allowed absolute voltage " << fBias.GetVoltMaxAbs() << "V";
     1931        str2 << "Effective maximum allowed relative voltage " << fBias.GetVoltMaxAbs() << "V w.r.t to G-APD reference voltage";
     1932        T::Message(str1);
     1933        T::Message(str2);
    18651934
    18661935        // --------------------------------------------------------------------------
     
    19081977        ("update-interval", var<uint16_t>(3000), "Interval between two current requests in milliseconds")
    19091978        ("sync-delay",      var<uint16_t>(333),  "Delay between sending the inital 0's after a newly established connection to synchronize the output stream in milliseconds")
    1910         ("volt-max",        var<float>(75),      "Upper limit for the voltage which can be applied in Volts")
     1979        ("volt-max-abs",    var<float>(75),      "Absolte upper limit for the voltage (in Volts)")
     1980        ("volt-max-rel",    var<float>(2.5),     "Relative upper limit for the voltage w.r.t. the G-APD reference voltage (in Volts)")
    19111981        ;
    19121982    // FIXME: Add a bit for OC... there is no -0
Note: See TracChangeset for help on using the changeset viewer.