Changeset 11993 for trunk/FACT++
- Timestamp:
- 09/07/11 08:05:35 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/biasctrl.cc
r11982 r11993 69 69 vector<int16_t> fCurrent; // Current in ADC units (12bit = 5mA) 70 70 71 uint16_t fVoltMax; 71 uint16_t fVoltMaxAbs; 72 uint16_t fVoltMaxRel; 72 73 73 74 virtual void UpdateA() … … 82 83 bool CheckChDac(const string &cmd, uint16_t dac, uint16_t ch=0) 83 84 { 85 ostringstream str; 86 str << cmd << " - "; 87 88 if (ch>=kNumChannels) 89 { 90 str << "Channel " << ch << " out of range [0,416]."; 91 Error(str); 92 return false; 93 } 94 84 95 if (dac>kMaxDac) 85 96 { 86 Error(cmd+" - DAC value out of range."); 87 return false; 88 } 89 if (dac>fVoltMax) 90 { 91 Error(cmd+" - DAC value exceeds fVoltMax."); 92 return false; 93 } 94 95 if (ch>=kNumChannels) 96 { 97 Error(cmd+" - Channel out of range."); 97 str << "DAC value " << dac << " out of range [0,4095]."; 98 Error(str); 99 return false; 100 } 101 if (dac>fVoltMaxAbs) 102 { 103 str << "DAC value " << dac << " exceeds allowed absolute maximum of " << fVoltMaxAbs; 104 Error(str); 105 return false; 106 } 107 if (dac>fVoltGapd[ch]+fVoltMaxRel) 108 { 109 str << "DAC value " << dac << " exceeds allowed channel maximum of " << fVoltGapd[ch] << " + " << fVoltMaxRel; 110 Error(str); 98 111 return false; 99 112 } … … 152 165 const uint16_t error = (answer[2]>>4)&0xf; 153 166 const uint16_t board = answer[2]&0xf; 167 168 // 0x10 00 7f 169 // status = 0 170 // wrap = 1 171 // ddd = 0 172 // error = not present 173 // board = 15 154 174 155 175 /* … … 376 396 if (command==kCmdChannelSet && fIsRamping) 377 397 { 378 ScheduleRampStep(); 398 bool oc = false; 399 for (int ch=0; ch<kNumChannels; ch++) 400 if (fPresent[ch/kNumChannelsPerBoard] && fCurrent[ch]<0) 401 oc = true; 402 403 if (oc) 404 { 405 Warn("OverCurrent detected - ramping stopped."); 406 fIsRamping = false; 407 } 408 else 409 ScheduleRampStep(); 410 379 411 fCounter[3]++; 380 412 } … … 1025 1057 } 1026 1058 1059 uint16_t GetRampStepVolt() const 1060 { 1061 return fRampStep*90./4096; 1062 } 1063 1027 1064 bool IsRamping() const { return fIsRamping; } 1028 1065 … … 1246 1283 } 1247 1284 1248 void SetVoltMax (float max)1249 { 1250 fVoltMax = max*4096/90;1251 if (fVoltMax >4095)1252 fVoltMax = 4095;1285 void SetVoltMaxAbs(float max) 1286 { 1287 fVoltMaxAbs = max*4096/90; 1288 if (fVoltMaxAbs>4095) 1289 fVoltMaxAbs = 4095; 1253 1290 if (max<0) 1254 fVoltMax = 0; 1255 } 1256 1291 fVoltMaxAbs = 0; 1292 } 1293 1294 void SetVoltMaxRel(float max) 1295 { 1296 fVoltMaxRel = max*4096/90; 1297 if (fVoltMaxRel>4095) 1298 fVoltMaxRel = 4095; 1299 if (max<0) 1300 fVoltMaxRel = 0; 1301 } 1302 1303 uint16_t GetVoltMaxAbs() const 1304 { 1305 return fVoltMaxAbs * 90./4096; 1306 } 1307 1308 uint16_t GetVoltMaxRel() const 1309 { 1310 return fVoltMaxRel * 90./4096; 1311 } 1257 1312 1258 1313 /* … … 1846 1901 fBias.SetSyncDelay(conf.Get<uint16_t>("sync-delay")); 1847 1902 1848 const float maxv = conf.Get<float>("volt-max"); 1849 if (maxv>90) 1903 ostringstream str; 1904 str << "Ramping in effective steps of " << fBias.GetRampStepVolt() << "V with a cyle time of " << time << "ms"; 1905 T::Message(str); 1906 1907 // -------------------------------------------------------------------------- 1908 1909 const float maxabsv = conf.Get<float>("volt-max-abs"); 1910 const float maxrelv = conf.Get<float>("volt-max-rel"); 1911 if (maxabsv>90) 1850 1912 { 1851 1913 T::Error("volt-max exceeds 90V."); 1852 1914 return 2; 1853 1915 } 1854 if (max v>75)1916 if (maxabsv>75) 1855 1917 T::Warn("volt-max exceeds 75V."); 1856 if (max v<70)1918 if (maxabsv<70) 1857 1919 T::Warn("volt-max below 70V."); 1858 if (max v<0)1920 if (maxabsv<0) 1859 1921 { 1860 1922 T::Error("volt-max negative."); … … 1862 1924 } 1863 1925 1864 fBias.SetVoltMax(maxv); 1926 fBias.SetVoltMaxAbs(maxabsv); 1927 fBias.SetVoltMaxRel(maxrelv); 1928 1929 ostringstream str1, str2; 1930 str1 << "Effective maximum allowed absolute voltage " << fBias.GetVoltMaxAbs() << "V"; 1931 str2 << "Effective maximum allowed relative voltage " << fBias.GetVoltMaxAbs() << "V w.r.t to G-APD reference voltage"; 1932 T::Message(str1); 1933 T::Message(str2); 1865 1934 1866 1935 // -------------------------------------------------------------------------- … … 1908 1977 ("update-interval", var<uint16_t>(3000), "Interval between two current requests in milliseconds") 1909 1978 ("sync-delay", var<uint16_t>(333), "Delay between sending the inital 0's after a newly established connection to synchronize the output stream in milliseconds") 1910 ("volt-max", var<float>(75), "Upper limit for the voltage which can be applied in Volts") 1979 ("volt-max-abs", var<float>(75), "Absolte upper limit for the voltage (in Volts)") 1980 ("volt-max-rel", var<float>(2.5), "Relative upper limit for the voltage w.r.t. the G-APD reference voltage (in Volts)") 1911 1981 ; 1912 1982 // FIXME: Add a bit for OC... there is no -0
Note:
See TracChangeset
for help on using the changeset viewer.