Editing
Xrf spi debug
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Spi communications during System Check (Shutter Cal) == <code>CalibrateDetector</code> function is main loop that runs the shutter cal process. It does a bunch of memory allocations, close_shutter calls and it calls <code>InitShaperXL3</code>. After this the filter wheel will be moved to the correct position and the xray tube will be started. Now we start <code>SpectraView2_segger</code> and drop into the looping function <code>GetSpectra</code> which is the function that reads data from the fpga and determines when the process is done. === Setting of Shapers === <code>InitShaperXL3</code> sets up a local structure with shaper parameters based on the current detector being used. This function also calls <code>adjustDetectorShapers</code> and <code>SetShaperXL3</code>. This function then terminates. <code>adjustDetectorShapers</code> modify's some of the parameters based on a few more conditions. Why this is not included in the previous function is beyond me... All parameters are in system ram, still nothing has been updated in the actual fpga registers. <code>SetShaperXL3</code> makes some addition modifications to parameters and creates a few new ones based on other but with additional offsets (wtf), it then calls <code>SetShaperUsingSPI</code>. There is also the ability to debug output a collection of probably important parameters: <pre> sprintf(buf,"SLOW_RISE_TIME:%d\r\n",SHS.SLOW_RISE_TIME); sprintf(buf,"GATE_RECOVERY:%d\r\n",SHS.GATE_RECOVERY); sprintf(buf,"RTD_RISE_TIME:%d\r\n",SHS.RTD_RISE_TIME); sprintf(buf,"RTD_FLAT_TOP_RTM:%d\r\n",SHS.RTD_FLAT_TOP_RTM); sprintf(buf,"PEAK_TIME:%d\r\n",SHS.PEAK_TIME); sprintf(buf,"AFTER_PEAK_GUARD:%d\r\n",SHS.AFTER_PEAK_GUARD); sprintf(buf,"DT_EXTENSION:%d\r\n",SHS.DT_EXTENSION); sprintf(buf,"SLOW_EXTENSION:%d\r\n",SHS.SLOW_EXTENSION); sprintf(buf,"FAST_EXTENSION:%d\r\n",SHS.FAST_EXTENSION); sprintf(buf,"SLOW_BIN_GAIN:%d\r\n",SHS.SLOW_BIN_GAIN); sprintf(buf,"SLOW_FINE_GAIN:%d\r\n",SHS.SLOW_FINE_GAIN); </pre> <code>SetShaperUsingSPI</code>, I found something that actually writes stuff to the fpga. We start off reading <code>REG_ADDR_2</code> and clearing bit 8. <pre> usDetector = Read_Single ( (REG_ADDR_2) ); usDetector &= ~(1<<8); // First detector Write_Single( (REG_ADDR_2),usDetector ); Write_Single( (REG_ADDR_17),SHS.GATE_WIDTH_EXT); Write_Single( (REG_ADDR_18),SHS.GATE_RECOVERY); Write_Single( (REG_ADDR_16),SHS.ADC_OFFSET); Write_Single( (REG_ADDR_19),SHS.FAST_RISE_TIME +256*(SHS.FAST_RISE_TIME+SHS.FAST_FLAT_TOP)) ; if (SHS.CUSP_TRAP) { usReg7 = ((short)(SHS.SLOW_FLAT_TOP))|0x8000; } else { usReg7 = ((short)(SHS.SLOW_FLAT_TOP))&0x7FFF; } //bits 12 to 10 which have been moved to a new register Reg 31 Write_Single( (REG_ADDR_20), usReg7); Write_Single( (REG_ADDR_21) ,SHS.SLOW_RISE_TIME); Write_Single( (REG_ADDR_22) ,SHS.SLOW_EXTENSION + 256*SHS.FAST_EXTENSION);// check it with the old one and send Write_Single( (REG_ADDR_23),SHS.FAST_THRESH_LOW); Write_Single( (REG_ADDR_24),SHS.FAST_THRESH_HIGH); Write_Single( (REG_ADDR_25),SHS.SLOW_THRESH_LOW); Write_Single( (REG_ADDR_26),SHS.SLOW_THRESH_HIGH); Write_Single( (REG_ADDR_27),SHS.SLOW_BLR_TAU + 256*SHS.FAST_BLR_TAU); Write_Single( (REG_ADDR_28),SHS.AFTER_PEAK_GUARD ); Write_Single( (REG_ADDR_29),SHS.PEAK_TIME); Write_Single( (REG_ADDR_30),FPGA_GAIN); // for gain control (00->gain=1.05, 01 ->gain=2, 02 -> gain=4) Write_Single( (REG_ADDR_31),SHS.SLOW_BIN_GAIN); Write_Single( (REG_ADDR_32),SHS.SLOW_FINE_GAIN); Write_Single( (REG_ADDR_33),SHS.DT_EXTENSION); #if 1//def RTD usReg34 = SHS.RTD_RISE_TIME; Write_Single(REG_ADDR_34, usReg34);// Setting the RTD RISE TIME usReg35 = SHS.RTD_FLAT_TOP_RTM;//usReg34 + ( usReg19 & 0xFF) + ( usReg19/256 ); Write_Single(REG_ADDR_35, usReg35); #endif //Clear Spectrum is optional here ClearSpectrum_SPI ( ); usTempData = Read_Single ( (REG_ADDR_2) ); usTempData &= ~0x0002; //Disable acquisition Write_Single ( (REG_ADDR_2), usTempData ); usTempData = Read_Single ( (REG_ADDR_2) ); usTempData |= (1<<7); //Enable RTD Write_Single ( (REG_ADDR_2), usTempData | 0x0000 );// This selects Slow Shaper at the output of the DAC board - default </pre> === Getting spectra === Ok, so we start by disabling spectral acquisition <code>startSpectrum(FALSE)</code> and then call <code>InitShaperXL3</code>. We then zero out localSpecra buffer, initialize a bunch of local variables and get the current (starting) realtime and livetime values for future use.
Summary:
Please note that all contributions to SoftwareGuy may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
SoftwareGuy:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information