Changeset 12994 for trunk/FACT++/src/feedback.cc
- Timestamp:
- 03/07/12 10:17:48 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/feedback.cc
r12991 r12994 504 504 fPV[2] = valarray<double>(&avg, 1); 505 505 506 const double T21 = 1; // feedback is 1s507 const double T10 = 1; // feedback is 20s508 509 506 // => Kp = 0.01 * gain = 0.00005 510 507 // => Ki = 0.8 * gain/20s = 0.00025 … … 518 515 519 516 // correction = (fSP[0]-fPV[2])*fKi 517 /* 518 const double T21 = 1; // feedback is 1s 519 const double T10 = 1; // feedback is 20s 520 520 521 const valarray<double> correction = 1./fGain/1000* 521 522 ( … … 523 524 + fKi*T21*(fSP[0]-fPV[2]) 524 525 + 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)) 525 534 ); 526 535 … … 679 688 } 680 689 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 685 694 fCursor = 0; 686 695 fStartTime = Time(); … … 700 709 } 701 710 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()); 705 717 706 718 fControlType = kFeedback; … … 709 721 } 710 722 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()); 715 729 716 730 fControlType = kFeedbackGlobal; … … 970 984 "Calibrating current offsets."); 971 985 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"); 979 995 980 996 AddEvent("START_TEMP_CONTROL", "F:1", kStateConnectedFSC, kStateConnected) … … 1054 1070 fKp = 0; 1055 1071 fKd = 0; 1056 fKi = 0. 66;1072 fKi = 0.75; 1057 1073 fT = 1; 1058 1074
Note:
See TracChangeset
for help on using the changeset viewer.