Changeset 17028 for trunk


Ignore:
Timestamp:
08/19/13 16:38:55 (11 years ago)
Author:
tbretz
Message:
Updated to the recent changes in the feedback (still untested)
Location:
trunk/FACT++/scripts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/scripts/Main.js

    r17014 r17028  
    192192// ================================================================
    193193
    194 var service_feedback = new Subscription("FEEDBACK/DEVIATION");
     194var service_feedback = new Subscription("FEEDBACK/CALIBRATED_CURRENTS");
    195195
    196196service_feedback.onchange = function(evt)
     
    202202        return;
    203203
    204     var delta = evt.obj['DeltaBias'];
    205 
    206     // It seems this can happen when the feedback was newly started. Why?
    207     // What is the correct solution?
    208     if (!delta)
     204    var Unom = evt.obj['U_nom'];
     205    var Uov  = evt.obj['U_ov'];
     206    if (!U_ov)
    209207        return;
    210208
     209    var cnt = 0;
    211210    var avg = 0;
    212211    for (var i=0; i<320; i++)
    213         avg += delta[i];
     212    {
     213        var dU = Uov[i]-Unom;
     214
     215        // 0.022 corresponds to 1 DAC count (90V/4096)
     216        if (Math.abs(dU)>0.033)
     217            cnt++;
     218
     219        avg += dU;
     220    }
    214221    avg /= 320;
    215222
    216     if (this.previous)
    217         this.voltageStep = Math.abs(avg-this.previous);
    218 
    219     this.previous = avg;
    220 
    221     console.out("  DeltaV=%.3f".$(this.voltageStep));
     223    this.ok = cnt==0;
     224
     225    console.out("  DeltaUov=%.3f [N(>0.033V)=%d]".$(this.voltageStep, cnt));
    222226}
    223227
     
    247251        // ramping and will reject the command to switch the
    248252        // voltage off
    249         var isControl = dim.state("FEEDBACK").name=="CurrentControl";
    250         if (isControl)
    251         {
    252             //console.out("  Suspending feedback.");
    253             dim.send("FEEDBACK/ENABLE_OUTPUT", false);
    254             dim.wait("FEEDBACK", "CurrentCtrlIdle", 3000);
    255         }
     253        dim.send("FEEDBACK/STOP");
     254        dim.wait("FEEDBACK", "Calibrated", 3000);
    256255
    257256        // Switch voltage off
    258         //console.out("  "+new Date().toUTCString()+": Voltage off: switch off");
    259257        dim.send("BIAS_CONTROL/SET_ZERO_VOLTAGE");
    260 
    261         // If the feedback was enabled, re-enable it
    262         if (isControl)
    263         {
    264             //console.out("  Resuming feedback.");
    265             dim.send("FEEDBACK/ENABLE_OUTPUT", true);
    266             dim.wait("FEEDBACK", "CurrentControl", 3000);
    267         }
    268258    }
    269259
     
    307297    {
    308298        dim.log("Switching voltage on.");
    309         //console.out(JSON.stringify(dim.state("BIAS_CONTROL")));
    310 
    311         dim.send("BIAS_CONTROL/SET_GLOBAL_DAC", 1);
     299        dim.send("FEEDBACK/START", 1.1);
     300        dim.wait("FEEDBACK", "InProgress", 45000);
    312301    }
    313302
     
    315304    dim.wait("BIAS_CONTROL", "VoltageOn", 5000);
    316305
    317     // From now on the feedback waits for a valid report from the FSC
    318     // and than switchs to CurrentControl
    319     dim.wait("FEEDBACK", "CurrentControl", 60000);
    320 
    321306    if (isOff)
    322     {
    323         dim.log("Voltage on, feedback will start ramping [cnt="+this.cnt+"]");
    324 
    325         this.previous = undefined;
    326         this.cnt = this.get().counter;
    327         this.voltageStep = undefined;
    328     }
     307        this.ok = false;
    329308}
    330309
    331310service_feedback.waitForVoltageOn = function()
    332311{
    333     // waiting 45sec for the current control to stabilize...
    334     // v8.sleep(45000);
    335 
    336     // ----- Wait for at least three updates -----
    337     // The feedback is started as if the camera where at 0deg
    338     // Then after the first temp update, the temperature will be set to the
    339     // correct value (this has already happened)
    340     // So we only have to wait for the current to get stable.
    341     // This should happen after three to five current updates.
    342     // So we want one recent temperature update
    343     //  and three recent current updates
    344 
    345312    // Avoid output if condition is already fulfilled
    346     if (this.cnt && this.get().counter>this.cnt+10)
    347         return;
    348 
    349313    dim.log("Waiting for voltage to be stable.");
    350314
    351     // 0.022 corresponds to 1 DAC count (90V/4096)
    352315    function func()
    353316    {
    354         if (irq ||
    355             (this.cnt!=undefined && this.get().counter>this.cnt+10) ||
    356             (this.voltageStep && this.voltageStep<0.022))
     317        if (irq || this.ok)
    357318            return true;
    358319    }
     
    360321    var now = new Date();
    361322
    362     v8.timeout(4*60000, func, this);
     323    v8.timeout(60000, func, this);
    363324
    364325    if (irq)
    365         dim.log("Waiting for stable voltage interrupted [dU=%.3fV, cnt=%d, %.2fs]".$(this.voltageStep, this.get().counter, (new Date()-now)/1000));
     326        dim.log("Waiting for stable voltage interrupted.");
    366327    else
    367         dim.log("Voltage stable within limits [dV=%.3f, cnt=%d, %.2fs]".$(this.voltageStep, this.get().counter, (new Date()-now)/1000));
     328        dim.log("Voltage stable within limits");
    368329}
    369330
     
    411372
    412373    //dim.send("FEEDBACK/STOP");
    413     dim.send("FEEDBACK/ENABLE_OUTPUT", false);
    414374    dim.send("FTM_CONTROL/STOP_TRIGGER");
    415375    dim.send("BIAS_CONTROL/DISCONNECT");
     
    417377    dim.wait("FTM_CONTROL",  "Valid",        3000);
    418378    dim.wait("BIAS_CONTROL", "Disconnected", 3000);
    419     dim.wait("FEEDBACK",     "Connected",    3000);
     379    dim.wait("FEEDBACK",     "Calibrated",   3000);
    420380
    421381    var report = sub.get();
     
    483443         "FEEDBACK/CALIBRATED_CURRENTS",
    484444         "FEEDBACK/CALIBRATION",
    485          "FEEDBACK/DEVIATION",
     445         "FEEDBACK/CALIBRATION_R8",
     446         "FEEDBACK/CALIBRATION_STEPS",
    486447         "FEEDBACK/REFERENCE",
    487448         "FSC_CONTROL/CURRENT",
     
    582543service_feedback.get(5000);
    583544
    584 dim.send("FEEDBACK/ENABLE_OUTPUT", true);
    585 dim.send("FEEDBACK/START_CURRENT_CONTROL", 0.);
    586 
    587 v8.timeout(3000, function() { var n = dim.state("FEEDBACK").name; if (n=="CurrentCtrlIdle" || n=="CurrentControl") return true; });
     545//v8.timeout(3000, function() { var n = dim.state("FEEDBACK").name; if (n=="CurrentCtrlIdle" || n=="CurrentControl") return true; });
    588546
    589547// ----------------------------------------------------------------
     
    802760         [ "AGILENT_CONTROL", [ "VoltageOn"                ] ],
    803761         [ "BIAS_CONTROL",    [ "VoltageOff", "VoltageOn", "Ramping" ] ],
    804          [ "FEEDBACK",        [ "CurrentControl", "CurrentCtrlIdle" ] ],
     762         [ "FEEDBACK",        [ "Calibrated", "InProgress" ] ],
    805763         [ "LID_CONTROL",     [ "Open", "Closed"           ] ],
    806764         [ "DRIVE_CONTROL",   drive_states/*[ "Armed", "Tracking", "OnTrack" ]*/ ],
     
    946904        console.out("");
    947905        break; // case "RATESCAN"
     906
    948907
    949908    case "DATA":
  • trunk/FACT++/scripts/Startup.js

    r16995 r17028  
    217217function makeCurrentCalibration()
    218218{
    219      dim.send("BIAS_CONTROL/SET_GLOBAL_DAC", 1);
    220      dim.wait("BIAS_CONTROL", "VoltageOn", 3000);
    221 
    222      var now = new Date();
    223      dim.send("FEEDBACK/CALIBRATE_CURRENTS");
    224 
    225      // FIXME: Timeout!
    226      console.out("Wait for calibration to start");
    227      dim.wait("FEEDBACK", "Calibrating", 5000);
    228 
    229      console.out("Wait for calibration to end");
    230      dim.wait("FEEDBACK", "Connected", 60000);
    231 
    232      console.out("Calibration finished ["+(new Date()-now)+"ms]");
    233 
    234      console.out("Wait for voltage to be off");
    235      dim.send("BIAS_CONTROL/SET_ZERO_VOLTAGE");
    236      dim.wait("BIAS_CONTROL", "VoltageOff", 5000);
     219    dim.send("BIAS_CONTROL/SET_ZERO_VOLTAGE");
     220    dim.wait("BIAS_CONTROL", "VoltageOff", 15000);
     221
     222    var now = new Date();
     223    dim.send("FEEDBACK/CALIBRATE");
     224
     225    console.out("Wait for calibration to start");
     226    dim.wait("FEEDBACK", "Calibrating", 5000);
     227
     228    console.out("Wait for calibration to end");
     229    dim.wait("FEEDBACK", "Calibrated", 60000);
     230
     231    console.out("Calibration finished ["+(new Date()-now)+"ms]");
     232
     233    console.out("Wait for voltage to be off");
     234    dim.wait("BIAS_CONTROL", "VoltageOff", 5000);
    237235}
    238236
     
    260258
    261259service_calibration.close();
     260
     261// ================================================================
     262
     263dim.send("BIAS_CONTROL/SET_EXPERT_MODE", true);
     264dim.send("BIAS_CONTROL/EXPERT_LOAD_MAP_FILE", "/home/fact/operation/GAPDmap_with_spare_module-new.txt");
     265dim.send("BIAS_CONTROL/SET_EXPERT_MODE", false);
     266dim.send("FEEDBACK/ENABLE_OLD_ALGORITHM", false);
    262267
    263268// ================================================================
     
    279284 [ "AGILENT_CONTROL", [ "VoltageOn"                       ] ],
    280285 [ "BIAS_CONTROL",    [ "VoltageOn", "VoltageOff"         ] ],
    281  [ "FEEDBACK",        [ "Connected"                       ] ],
     286 [ "FEEDBACK",        [ "Calibrated"                      ] ],
    282287 [ "RATE_SCAN",       [ "Connected"                       ] ],
    283288 [ "RATE_CONTROL",    [ "Connected"                       ] ],
  • trunk/FACT++/scripts/handleFeedbackConnected.js

    r16857 r17028  
    1616    case "Disconnected":
    1717    case "Connecting":
    18     case "ConnectedFSC":
    19     case "ConnectedFAD":
    2018        return undefined;
    2119
    2220    case "Connected":
     21    case "Calibrated":
    2322        return "";
    2423
    25     case "FeedbackIdle":
    26     case "TempCtrlIdle":
    27     case "CurrentCtrlIdle":
    28     case "FeedbackControl":
    29     case "TempControl":
    30     case "CurrentControl":
     24    case "WaitingForData":
     25    case "InProgress":
     26        console.out("Feedback in '"+state.name+"'... sending STOP... waiting for 'Calibrated'.");
     27        dim.send("FEEDBACK/STOP");
     28        return "Calibrated";
     29
    3130    case "Calibrating":
    3231        console.out("Feedback in '"+state.name+"'... sending STOP... waiting for 'Connected'.");
Note: See TracChangeset for help on using the changeset viewer.