- Timestamp:
- 08/19/13 16:38:55 (11 years ago)
- Location:
- trunk/FACT++/scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/scripts/Main.js
r17014 r17028 192 192 // ================================================================ 193 193 194 var service_feedback = new Subscription("FEEDBACK/ DEVIATION");194 var service_feedback = new Subscription("FEEDBACK/CALIBRATED_CURRENTS"); 195 195 196 196 service_feedback.onchange = function(evt) … … 202 202 return; 203 203 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) 209 207 return; 210 208 209 var cnt = 0; 211 210 var avg = 0; 212 211 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 } 214 221 avg /= 320; 215 222 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)); 222 226 } 223 227 … … 247 251 // ramping and will reject the command to switch the 248 252 // 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); 256 255 257 256 // Switch voltage off 258 //console.out(" "+new Date().toUTCString()+": Voltage off: switch off");259 257 dim.send("BIAS_CONTROL/SET_ZERO_VOLTAGE"); 260 261 // If the feedback was enabled, re-enable it262 if (isControl)263 {264 //console.out(" Resuming feedback.");265 dim.send("FEEDBACK/ENABLE_OUTPUT", true);266 dim.wait("FEEDBACK", "CurrentControl", 3000);267 }268 258 } 269 259 … … 307 297 { 308 298 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); 312 301 } 313 302 … … 315 304 dim.wait("BIAS_CONTROL", "VoltageOn", 5000); 316 305 317 // From now on the feedback waits for a valid report from the FSC318 // and than switchs to CurrentControl319 dim.wait("FEEDBACK", "CurrentControl", 60000);320 321 306 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; 329 308 } 330 309 331 310 service_feedback.waitForVoltageOn = function() 332 311 { 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 0deg338 // Then after the first temp update, the temperature will be set to the339 // 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 update343 // and three recent current updates344 345 312 // Avoid output if condition is already fulfilled 346 if (this.cnt && this.get().counter>this.cnt+10)347 return;348 349 313 dim.log("Waiting for voltage to be stable."); 350 314 351 // 0.022 corresponds to 1 DAC count (90V/4096)352 315 function func() 353 316 { 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) 357 318 return true; 358 319 } … … 360 321 var now = new Date(); 361 322 362 v8.timeout( 4*60000, func, this);323 v8.timeout(60000, func, this); 363 324 364 325 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."); 366 327 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"); 368 329 } 369 330 … … 411 372 412 373 //dim.send("FEEDBACK/STOP"); 413 dim.send("FEEDBACK/ENABLE_OUTPUT", false);414 374 dim.send("FTM_CONTROL/STOP_TRIGGER"); 415 375 dim.send("BIAS_CONTROL/DISCONNECT"); … … 417 377 dim.wait("FTM_CONTROL", "Valid", 3000); 418 378 dim.wait("BIAS_CONTROL", "Disconnected", 3000); 419 dim.wait("FEEDBACK", "C onnected",3000);379 dim.wait("FEEDBACK", "Calibrated", 3000); 420 380 421 381 var report = sub.get(); … … 483 443 "FEEDBACK/CALIBRATED_CURRENTS", 484 444 "FEEDBACK/CALIBRATION", 485 "FEEDBACK/DEVIATION", 445 "FEEDBACK/CALIBRATION_R8", 446 "FEEDBACK/CALIBRATION_STEPS", 486 447 "FEEDBACK/REFERENCE", 487 448 "FSC_CONTROL/CURRENT", … … 582 543 service_feedback.get(5000); 583 544 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; }); 588 546 589 547 // ---------------------------------------------------------------- … … 802 760 [ "AGILENT_CONTROL", [ "VoltageOn" ] ], 803 761 [ "BIAS_CONTROL", [ "VoltageOff", "VoltageOn", "Ramping" ] ], 804 [ "FEEDBACK", [ "C urrentControl", "CurrentCtrlIdle" ] ],762 [ "FEEDBACK", [ "Calibrated", "InProgress" ] ], 805 763 [ "LID_CONTROL", [ "Open", "Closed" ] ], 806 764 [ "DRIVE_CONTROL", drive_states/*[ "Armed", "Tracking", "OnTrack" ]*/ ], … … 946 904 console.out(""); 947 905 break; // case "RATESCAN" 906 948 907 949 908 case "DATA": -
trunk/FACT++/scripts/Startup.js
r16995 r17028 217 217 function makeCurrentCalibration() 218 218 { 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); 237 235 } 238 236 … … 260 258 261 259 service_calibration.close(); 260 261 // ================================================================ 262 263 dim.send("BIAS_CONTROL/SET_EXPERT_MODE", true); 264 dim.send("BIAS_CONTROL/EXPERT_LOAD_MAP_FILE", "/home/fact/operation/GAPDmap_with_spare_module-new.txt"); 265 dim.send("BIAS_CONTROL/SET_EXPERT_MODE", false); 266 dim.send("FEEDBACK/ENABLE_OLD_ALGORITHM", false); 262 267 263 268 // ================================================================ … … 279 284 [ "AGILENT_CONTROL", [ "VoltageOn" ] ], 280 285 [ "BIAS_CONTROL", [ "VoltageOn", "VoltageOff" ] ], 281 [ "FEEDBACK", [ "C onnected"] ],286 [ "FEEDBACK", [ "Calibrated" ] ], 282 287 [ "RATE_SCAN", [ "Connected" ] ], 283 288 [ "RATE_CONTROL", [ "Connected" ] ], -
trunk/FACT++/scripts/handleFeedbackConnected.js
r16857 r17028 16 16 case "Disconnected": 17 17 case "Connecting": 18 case "ConnectedFSC":19 case "ConnectedFAD":20 18 return undefined; 21 19 22 20 case "Connected": 21 case "Calibrated": 23 22 return ""; 24 23 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 31 30 case "Calibrating": 32 31 console.out("Feedback in '"+state.name+"'... sending STOP... waiting for 'Connected'.");
Note:
See TracChangeset
for help on using the changeset viewer.