Ignore:
Timestamp:
03/07/12 10:17:48 (13 years ago)
Author:
tbretz
Message:
Added the number of events to interpolate to the feedback commands; implemented an exponent of 1./1.6 for the global feedback
File:
1 edited

Legend:

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

    r12991 r12994  
    504504        fPV[2] = valarray<double>(&avg, 1);
    505505
    506         const double T21 = 1; // feedback is  1s
    507         const double T10 = 1; // feedback is 20s
    508 
    509506        // => Kp = 0.01 * gain     = 0.00005
    510507        // => Ki = 0.8  * gain/20s = 0.00025
     
    518515
    519516        // correction = (fSP[0]-fPV[2])*fKi
     517        /*
     518        const double T21 = 1; // feedback is  1s
     519        const double T10 = 1; // feedback is 20s
     520
    520521        const valarray<double> correction = 1./fGain/1000*
    521522            (
     
    523524             +  fKi*T21*(fSP[0]-fPV[2])
    524525             +  fKd/T10*(fPV[1]-fPV[0])
     526            );
     527        */
     528
     529        // pow of 1.6 comes from the non-linearity of the
     530        // amplitude vs bias voltage
     531        const valarray<double> correction = 1./fGain/1000*
     532            (
     533             fKi*(pow(fSP[0], 1./1.6)-pow(fPV[2], 1./1.6))
    525534            );
    526535
     
    679688    }
    680689
    681     void ResetData()
    682     {
    683         fData.clear();
    684         fData.resize(500);
     690    void ResetData(int16_t n=-1)
     691    {
     692        fData.assign(n>0 ? n : fData.size(), vector<float>(0));
     693
    685694        fCursor = 0;
    686695        fStartTime = Time();
     
    700709    }
    701710
    702     int StartFeedback()
    703     {
    704         ResetData();
     711    int StartFeedback(const EventImp &evt)
     712    {
     713        if (!CheckEventSize(evt.GetSize(), "StartFeedback", 2))
     714            return kSM_FatalError;
     715
     716        ResetData(evt.GetShort());
    705717
    706718        fControlType = kFeedback;
     
    709721    }
    710722
    711     int StartFeedbackGlobal()
    712     {
    713         ResetData();
    714         fData.resize(5);
     723    int StartFeedbackGlobal(const EventImp &evt)
     724    {
     725        if (!CheckEventSize(evt.GetSize(), "StartFeedbackGlobal", 2))
     726            return kSM_FatalError;
     727
     728        ResetData(evt.GetShort());
    715729
    716730        fControlType = kFeedbackGlobal;
     
    970984                     "Calibrating current offsets.");
    971985
    972         AddEvent("START_FEEDBACK_CONTROL", kStateConnectedFAD, kStateConnected)
    973             (bind(&StateMachineFeedback::StartFeedback, this))
    974             ("Start the feedback control loop");
    975 
    976         AddEvent("START_GLOBAL_FEEDBACK", kStateConnectedFAD, kStateConnected)
    977             (bind(&StateMachineFeedback::StartFeedbackGlobal, this))
    978             ("Start the global feedback control loop");
     986        AddEvent("START_FEEDBACK_CONTROL", "S:1", kStateConnectedFAD, kStateConnected)
     987            (bind(&StateMachineFeedback::StartFeedback, this, placeholders::_1))
     988            ("Start the feedback control loop"
     989             "|Num[short]:Number of events 'medianed' to calculate the correction value");
     990
     991        AddEvent("START_GLOBAL_FEEDBACK", "S:1", kStateConnectedFAD, kStateConnected)
     992            (bind(&StateMachineFeedback::StartFeedbackGlobal, this, placeholders::_1))
     993            ("Start the global feedback control loop"
     994             "Num[short]:Number of events averaged to calculate the correction value");
    979995
    980996        AddEvent("START_TEMP_CONTROL", "F:1", kStateConnectedFSC, kStateConnected)
     
    10541070        fKp = 0;
    10551071        fKd = 0;
    1056         fKi = 0.66;
     1072        fKi = 0.75;
    10571073        fT  = 1;
    10581074
Note: See TracChangeset for help on using the changeset viewer.