Changeset 17203 for trunk/FACT++/src/feedback.cc
- Timestamp:
- 10/08/13 15:35:24 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/feedback.cc
r17173 r17203 43 43 DimDescribedService fDimCalibrationR8; 44 44 DimDescribedService fDimCurrents; 45 DimDescribedService fDimOffsets; 45 46 46 47 vector<float> fCalibCurrentMes[6]; // Measured calibration current at six different levels … … 70 71 double fTempCoefficient; 71 72 double fTemp; 73 74 vector<double> fVoltOffset; 72 75 73 76 uint16_t fCurrentRequestInterval; … … 399 402 } __attribute__((__packed__)); 400 403 404 int Ndev[3] = { 0, 0, 0 }; 405 401 406 dim_data data; 402 407 … … 507 512 508 513 // Current in R4/R5 branch 509 const double Iout = I8 >I9 ? I8 - I9 : 0;514 const double Iout = I8 - I9;//I8>I9 ? I8 - I9 : 0; 510 515 511 516 // Applied voltage at calibration resistors, according to biasctrl … … 547 552 548 553 // Nominal breakdown voltage with correction for temperature dependence 549 const double Ubd = fVoltGapd[i] + f TempOffset[i];554 const double Ubd = fVoltGapd[i] + fVoltOffset[i] + fTempOffset[i]; 550 555 551 556 // Current overvoltage (at a G-APD with the correct 3900 Ohm resistor) 552 const double Uov = U9-Udrp-Ubd>0 ? U9-Udrp-Ubd : 0; 557 //const double Uov = U9-Udrp-Ubd>0 ? U9-Udrp-Ubd : 0; 558 const double Uov = U9-Udrp-Ubd>-0.34 ? U9-Udrp-Ubd : -0.34; 553 559 554 560 // Iout linear with U9 above Ubd … … 591 597 // Estimate set point for over-voltage (voltage drop at the target point) 592 598 //const double Uset = Ubd + overvoltage + R*Iov*N; 593 const double Uset = Uov<0.3 ? Ubd + overvoltage + Udrp : Ubd + overvoltage + Udrp*pow(overvoltage/Uov, 1.66); 599 //const double Uset = Uov<0.3 ? Ubd + overvoltage + Udrp : Ubd + overvoltage + Udrp*pow(overvoltage/Uov, 1.66); 600 const double Uset = Uov<0 ? 601 Ubd + overvoltage + Udrp*pow(overvoltage/0.34+1, 1.66) : 602 Ubd + overvoltage + Udrp*pow((overvoltage+0.34)/(Uov+0.34), 1.66); 603 604 if (fabs(overvoltage-Uov)>0.033) 605 Ndev[0]++; 606 if (fabs(overvoltage-Uov)>0.022) 607 Ndev[1]++; 608 if (fabs(overvoltage-Uov)>0.011) 609 Ndev[2]++; 594 610 595 611 // Voltage set point … … 638 654 639 655 ostringstream msg; 640 msg << setprecision(4) << "Sending new absolute offset: dU(" << fTemp << "degC)=" << fTempOffsetAvg << "V+-" << fTempOffsetRms << ", Unom=" << overvoltage << "V, Uov=" << (num[0]+num[1]>0?(avg[0]+avg[1])/(num[0]+num[1]):0) ;656 msg << setprecision(4) << "Sending new absolute offset: dU(" << fTemp << "degC)=" << fTempOffsetAvg << "V+-" << fTempOffsetRms << ", Unom=" << overvoltage << "V, Uov=" << (num[0]+num[1]>0?(avg[0]+avg[1])/(num[0]+num[1]):0) << " [N=" << Ndev[0] << "/" << Ndev[1] << "/" << Ndev[2] << "]"; 641 657 Info(msg); 642 658 } … … 647 663 { 648 664 ostringstream msg; 649 msg << setprecision(4) << "Current status: dU(" << fTemp << "degC)=" << fTempOffsetAvg << "V+-" << fTempOffsetRms << ", Unom=" << overvoltage << "V, Uov=" << (num[0]+num[1]>0?(avg[0]+avg[1])/(num[0]+num[1]):0) ;665 msg << setprecision(4) << "Current status: dU(" << fTemp << "degC)=" << fTempOffsetAvg << "V+-" << fTempOffsetRms << ", Unom=" << overvoltage << "V, Uov=" << (num[0]+num[1]>0?(avg[0]+avg[1])/(num[0]+num[1]):0) << " [N=" << Ndev[0] << "/" << Ndev[1] << "/" << Ndev[2] << "]"; 650 666 Info(msg); 651 667 } … … 850 866 return GetCurrentState(); 851 867 } 868 869 bool LoadOffsets(const string &file) 870 { 871 vector<double> data(416); 872 873 ifstream fin(file); 874 875 int cnt = 0; 876 while (fin && cnt<320) 877 fin >> data[cnt++]; 878 879 if (cnt!=320) 880 { 881 Error("Reading offsets from "+file+" failed [N="+to_string(cnt-1)+"]"); 882 return false; 883 } 884 885 fVoltOffset = data; 886 887 fDimOffsets.Update(fVoltOffset); 888 889 Info("New voltage offsets loaded from "+file); 890 return true; 891 892 } 893 894 int LoadOffset(const EventImp &evt) 895 { 896 LoadOffsets(evt.GetText()); 897 return GetCurrentState(); 898 } 899 900 int ResetOffset() 901 { 902 fVoltOffset.assign(416, 0); 903 904 fDimOffsets.Update(fVoltOffset); 905 906 Info("Voltage offsets resetted."); 907 return GetCurrentState(); 908 } 909 852 910 853 911 int Execute() … … 926 984 "|dU_temp[V]:Correction calculated from temperature" 927 985 ), 986 fDimOffsets("FEEDBACK/OFFSETS", "F:416", 987 "Offsets operation voltages" 988 "|U[V]:Offset per bias channels"), 989 fVoltOffset(416), 928 990 fCurrentRequestInterval(0), 929 991 fNumCalibIgnore(30), … … 988 1050 ("Stop any control loop"); 989 1051 1052 AddEvent("LOAD_OFFSETS", "C", Feedback::State::kConnected, Feedback::State::kCalibrated) 1053 (bind(&StateMachineFeedback::LoadOffset, this, placeholders::_1)) 1054 (""); 1055 AddEvent("RESET_OFFSETS", Feedback::State::kConnected, Feedback::State::kCalibrated) 1056 (bind(&StateMachineFeedback::ResetOffset, this)) 1057 (""); 1058 990 1059 991 1060 AddEvent("PRINT") … … 1017 1086 fNumCalibRequests = conf.Get<uint16_t>("num-calib-average"); 1018 1087 fTempCoefficient = conf.Get<double>("temp-coefficient"); 1088 1089 if (conf.Has("offset-file")) 1090 LoadOffsets(conf.Get<string>("offset-file")); 1019 1091 1020 1092 return -1; … … 1042 1114 ("num-calib-average", var<uint16_t>(300), "Number of current requests to be averaged") 1043 1115 ("temp-coefficient", var<double>()->required(), "Temp. coefficient [V/K]") 1116 ("offset-file", var<string>(), "File with operation voltage offsets") 1044 1117 ; 1045 1118
Note:
See TracChangeset
for help on using the changeset viewer.