Changeset 17030
- Timestamp:
- 08/20/13 08:05:05 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/feedback.cc
r17027 r17030 194 194 int HandleCalibration(const EventImp &evt) 195 195 { 196 if (fDimBias.state()!=BIAS::State::kVoltageOn) 197 return GetCurrentState(); 198 196 199 const uint16_t dac = 256+512*fCalibStep; // Command value 197 200 … … 312 315 } 313 316 314 vector<float> v(BIAS::kNumChannels*2); 317 vector<float> v; 318 v.reserve(BIAS::kNumChannels*2); 315 319 v.insert(v.end(), fCalibDeltaI.begin(), fCalibDeltaI.end()); 316 320 v.insert(v.end(), fCalibR8.begin(), fCalibR8.end()); … … 333 337 334 338 if (GetCurrentState()<Feedback::State::kCalibrating) 335 return GetCurrentState();336 337 // FIXME? Allow for calibrated currents also during ramping?338 if ((GetCurrentState()!=Feedback::State::kWaitingForData || fDimBias.state()!=BIAS::State::kVoltageOff) &&339 fDimBias.state()!=BIAS::State::kVoltageOn)340 339 return GetCurrentState(); 341 340 … … 362 361 // ---------------------- Calibrated, WaitingForData, InProgress ----------------------- 363 362 364 const vector<float> &Imes = AverageCurrents(evt.Ptr<int16_t>(), 3).first; 363 const int Navg = fDimBias.state()!=BIAS::State::kVoltageOn ? 1 : 3; 364 365 const vector<float> &Imes = AverageCurrents(evt.Ptr<int16_t>(), Navg).first; 365 366 if (Imes.size()==0) 366 367 return GetCurrentState(); … … 408 409 vector<float> vec(416); 409 410 410 cout << setprecision(4) << endl;411 412 411 if (fEnableOldAlgorithm) 413 412 { … … 458 457 459 458 if (i==2) 460 cout << dU << endl;;459 cout << setprecision(4)<< dU << endl;; 461 460 462 461 vec[i] = Ubd + overvoltage + dU; … … 523 522 524 523 // Serial resistor of the individual G-APDs 525 double R5 = 3900 /N;524 double R5 = 3900./N; 526 525 527 526 // This is assuming that the broken pixels have a 390 Ohm instead of 3900 Ohm serial resistor … … 581 580 // resistor is large enough that the increase of the overvoltage does not dramatically 582 581 // increase the current flow as compared to the total current flow. 583 if (i==66) 584 Iapd /= 1.3; 585 if (i==191 || i==193) 586 Iapd /= 1.4; 582 if (i==66 || i==191 || i==193) 583 Iapd = Iout/(N+9); // Iapd = R5*Iout/3900; 587 584 588 585 // The differential resistance of the G-APD, i.e. the dependence of the … … 590 587 //const double Rapd = Uov/Iapd; 591 588 // This allows us to estimate the current Iov at the overvoltage we want to apply 592 //const double Iov = pow(overvoltage, 1)/Rapd;589 //const double Iov = overvoltage/Rapd; 593 590 594 591 // Estimate set point for over-voltage (voltage drop at the target point) 595 592 //const double Uset = Ubd + overvoltage + R*Iov*N; 596 double Uset = Uov<0.3 ? Ubd + overvoltage + Udrp : Ubd + overvoltage + Udrp*pow(overvoltage/Uov, 1.66);593 const double Uset = Uov<0.3 ? Ubd + overvoltage + Udrp : Ubd + overvoltage + Udrp*pow(overvoltage/Uov, 1.66); 597 594 598 595 // Voltage set point 599 596 vec[i] = Uset; 597 598 if (fDimBias.state()==BIAS::State::kVoltageOn && GetCurrentState()==Feedback::State::kInProgress && 599 fabs(Uov-overvoltage)>0.033) 600 cout << setprecision(4) << setw(3) << i << ": Uov=" << Uov << " Udrp=" << Udrp << " Iapd=" << Iapd*1e6 << endl; 601 600 602 601 603 // Calculate statistics only for channels with a valid calibration … … 628 630 // ------------------------------- Update voltages ------------------------------------ 629 631 630 if (GetCurrentState()!=Feedback::State::kCalibrated) 631 { 632 DimClient::sendCommandNB("BIAS_CONTROL/SET_ALL_CHANNELS_VOLTAGE", 633 vec.data(), BIAS::kNumChannels*sizeof(float)); 634 635 ostringstream msg; 636 msg << setprecision(4) << "Sending new absolute offset: dU(" << fTemp << "degC)=" << fTempOffset << "V, Unom=" << overvoltage << "V, Uov=" << (num[0]+num[1]>0?(avg[0]+avg[1])/(num[0]+num[1]):0); 637 Info(msg); 632 if (GetCurrentState()!=Feedback::State::kCalibrated) // WaitingForData, InProgress 633 { 634 if (fDimBias.state()!=BIAS::State::kRamping) 635 { 636 DimClient::sendCommandNB("BIAS_CONTROL/SET_ALL_CHANNELS_VOLTAGE", 637 vec.data(), BIAS::kNumChannels*sizeof(float)); 638 639 ostringstream msg; 640 msg << setprecision(4) << "Sending new absolute offset: dU(" << fTemp << "degC)=" << fTempOffset << "V, Unom=" << overvoltage << "V, Uov=" << (num[0]+num[1]>0?(avg[0]+avg[1])/(num[0]+num[1]):0); 641 Info(msg); 642 } 638 643 } 639 644 else 640 645 { 641 ostringstream msg; 642 msg << setprecision(4) << "Current status: dU(" << fTemp << "degC)=" << fTempOffset << "V, Unom=" << overvoltage << "V, Uov=" << (num[0]+num[1]>0?(avg[0]+avg[1])/(num[0]+num[1]):0); 643 Info(msg); 644 645 } 646 if (fDimBias.state()==BIAS::State::kVoltageOn) 647 { 648 ostringstream msg; 649 msg << setprecision(4) << "Current status: dU(" << fTemp << "degC)=" << fTempOffset << "V, Unom=" << overvoltage << "V, Uov=" << (num[0]+num[1]>0?(avg[0]+avg[1])/(num[0]+num[1]):0); 650 Info(msg); 651 } 652 653 } 654 655 if (GetCurrentState()==Feedback::State::kInProgress && 656 fDimBias.state()==BIAS::State::kRamping) 657 return GetCurrentState(); 646 658 647 659 // --------------------------------- Console out -------------------------------------- 648 660 649 if (num[0]>0 && num[1]>0 && fIsVerbose )661 if (num[0]>0 && num[1]>0 && fIsVerbose && !fDimBias.state()==BIAS::State::kRamping) 650 662 { 651 663 sort(med[0].begin(), med[0].begin()+num[0]); … … 816 828 if (!CheckEventSize(evt.GetSize(), "Start", 4)) 817 829 return kSM_FatalError; 830 831 if (fDimBias.state()==BIAS::State::kRamping) 832 { 833 Warn("Feedback can not be started when biasctrl is in state Ramping."); 834 return GetCurrentState(); 835 } 818 836 819 837 fUserOffset = evt.GetFloat();
Note:
See TracChangeset
for help on using the changeset viewer.