Home

Documentation

Project Support

Changes in Version 5 of GraspSwControllerCmdReadcal

Author:
isani
Timestamp:
Wed Dec 25 19:16:44 2019

Legend:

Unmodified
Added
Removed
Modified
  • GraspSwControllerCmdReadcal

    v4 v5
    1 1  '''[wiki:GraspSwControllerCmd readcal]''' 
    2 2  [[TracNav(GraspContents)]] 
    3 3  ||Command:||'''readcal'''|| 
    4 4  ||Contexts:||Network socket, serial console, stage2 only|| 
    5 5  ||Function:||Calibrate signal chain to bring in range of the ADCs.|| 
    6 6  ||Required Parameters:||None.|| 
    7 7  ||Optional Parameters:||If '''adulevel''' omitted, readcal just measures pedestal.|| 
    8 8  ||'''adulevel='''||A number of counts, like '''5000'''|| 
    9 9  ||'''channel='''||[r] Select between '''r'''ed '''g'''reen and '''b'''lue ADC channel|| 
    10 10  ||'''cellrow='''||(Use [wiki:GraspSwControllerCmdOtacal otacal] command instead of readcal, for OTAs)|| 
    11 11  ||'''dev='''||[current] Select dev '''0''' or '''1''' (>= r5696 stage2 ONLY)|| 
    12 12  == Usage == 
    13 13  {{{ 
    14 14  dev 0 
    15 15  readcal 5000 
    16 16  dev 1 
    17 17  readcal 5000 
    18 18  }}} 
    19 19  For most STARGRASP camera systems, the higher camera-level [wiki:GraspSwDemoCal "cal" script] is used to call readcal, and even then, it is typically not necessary to use readcal every time a system is powered on unless a boardset has been moved around or clock timings have been adjusted.  Temperature changes and some detector-specific effects may also require readcal to be redone, but typically the values determined once are usable until hardware is changed.  All of the readcal values are stored in the FITS header by tools like [wiki:GraspSwToolkitSaveOta grasp_save_ota] and restored automatically by tools like [wiki:GraspSwToolkitPonOta grasp_pon_ota] meaning if this save/pon model is being used to restore state, it is advisable to create a new set of so called PONFITS reference files with which to power on your camera any time when clocking, voltages, operating temperatures, or boardset positions have been changed. 
    20 20  Alternatively, a camera-specific setup script could be used to restore the dacs which get set by readcal, which is preferable to re-running readcal each time the camera is powered on.  The reason for this is that "readcal" is sensitive to many factors, and has the following prerequisites: 
    21 21   * clocking timings ([wiki:GraspSwControllerCmdClvset clvset]) must be set up first or the results are invalid. 
    22 22   * clocking voltages set by some kind of [wiki:GraspSwDemoPon pon] or any sequence of necessary [wiki:GraspSwControllerCmdDac dac] commands 
    23 23   * geometry parameters ([wiki:GraspSwControllerCmdDetsize detsize]) must be set or else readcal may fail trying to calibrate non-connected channels 
    24 24   * detector must be cold, or it could get so swamped with charge that reset levels are not reached 
    25 25   * detector must be [wiki:GraspSwDemoClean cleaned] properly first, and without major light leaks (to avoid same problem as previous item.) 
    26 26  A bad readcal operating point could result in an entire night or run of bad/noisy/dynamic-range-limited data.  A warm or supersaturated detector, overwhelming the reset so it cannot get back down to a proper pedestal level, is the most common cause of readcal failure.  Even if the readcal command does not fail, the result should be checked on a full image readout, as explained below. 
    27 27  Each pixel in the image has a pedestal, which should be around 5000 ADU once "readcal 5000" has been run, but there are always low level effects in the pedestal (tilt, negative or positive image leaking in) and so the best way to determine if the operating point resulting from readcal is good would be to [wiki:GraspSwDemoReadout readout] and [wiki:GraspSwDemoSave save] an image with 32 bpp mode, which saves a cube where the first layer is the image, and the second is the pedestal, intended to be subtracted off.  '''No pixels anywhere in this pedestal image should be at or near zero.'''  Any FITS image viewer can be used to verify this. 
    28 28  [[Image(Offsetting_CAL_STARGRASP_CCD_case.png)]] 
    29 29  == What Does "readcal" Do? == 
    30 30  Each pixel value generated by the STARGRASP controller is the 
    31 31  result of multiple individual digital samples of the channel's 
    32 32  internal Analog to Digital Converter (ADC) 0 to 4V range, shown above.  The process used 
    33 33  is known as Digital Correlated Double Sampling (DCDS).  Although a variety of 
    34 34  multi-sampling readout parameters are configurable at runtime with the '''cestlavie''' program and the '''[wiki:GraspSwControllerCmdClvset clvset]''' command, most STARGRASP CCD 
    35 35  readouts sample the reference pedestal level (ped) for each pixel 
    36 36  four times, and the video signal level (sig) four times.  All eight of these 
    37 37  samples must be within the 0-4V limits of the 16-bit ADC (0..65535). 
    38 38  The difference between the average (arithmetic mean) of the 
    39 39  four reference pedestal values is subtracted from the average 
    40 40  of the video to produce the pixel value found in the FITS file (unless saving in "3d" or bpp=32 mode for diagnostics.) 
    41 41  All four of the reference pedestal samples must always be above 
    42 42  the floor that the A/D can measure, and an internal offset voltage 
    43 43  (per channel) must be used to "steer" the value to something 
    44 44  above zero, but not too high.  The side effect of being too 
    45 45  high would be reduced dynamic range.  Steering the pedestal in to around 5000 ADU already means that the highest measurable value is around 65535 - 5000 or 60535.  Going higher would further reduce the maximum signal that can be measured (assuming detector full well is not reached first.) 
    46 46  In order to converge more quickly, the starting point for the readcal algorithm is the last known 
    47 47  calibration value.  If it fails to converge, that offset voltage 
    48 48  (and next starting point) is set to 0 Volts.  For this reason, 
    49 49  ''sometimes readcal must be run twice to succeed'', especially if 
    50 50  incorrect values (from a different boardset or preamp, for example) 
    51 51  were used as the starting point. 
    52 52  If readcal is taking a long time to complete, or of it is failing to converge, it is often because a new 
    53 53  starting point should be recorded.  The other common cause of failure can be super-saturation of the CCD. 
    54 54  The CCD should always be dark (shutter closed, no major light leaks) and be cleaned multiple times 
    55 55  before attempting readcal. 
    56 56  == Restoring readcal Without grasp_pon == 
    57 57  The preferred method of restoring the entire operating point of the detectors is to use a tool like [wiki:GraspSwToolkitSaveOta grasp_pon_ota] or other '''grasp_pon_<detectortype>''' C program, which reads a FITS file and communicates directly with the controllers to restore everything.  The keywords which specifically control readcal levels are named DAC_CAL* and appear in a space-delimited list in a header keyword. 
    58 58  If this method is not being used (it is only fully implemented for OTA CCDs), then correct "readcal" levels can be extracted from a previous stargrasp log message history and converted into the right "dac 2 ..." commands, sent from a script.  The appearance of the readcal parameters in the log will be similar to this: 
    59 59  {{{ 
    60 60  > dev 1 
    61 61  > readcal 5000 
    62 62  + ch 0 offset   -39mv mean= 5100.8, 7082.7, 1981.8 rms=33.1,35.4, 8.0 
    63 63  + ch 1 offset   -19mv mean= 5013.2, 6885.6, 1872.4 rms=32.1,34.3, 7.2 
    64 64  + ch 2 offset   -18mv mean= 5197.3, 7253.9, 2056.5 rms=35.1,37.8, 7.1 
    65 65  + ch 3 offset    -5mv mean= 53.... 
    66 66  }}} 
    67 67  with up to 8 channels per "dev".  If the current dev was dev 0, channel 0 starts at '''dac 2 7 ...''' and counts backwards.  For '''dev 1''' as shown above, the 8 dac "dac 2 15" through "dac 2 8" adjust the offset.  Note the reversal here, on both sets of dacs.  For example, to restore the -39, -19, -18, and -5mV calibration shown above, send commands: 
    68 68  {{{ 
    69 69  dac 2 15 -39 
    70 70  dac 2 14 -19 
    71 71  dac 2 13 -18 
    72 72  dac 2 12 -5 
    73 73  }}} 
      74   
      75  It is also possible to issue the following command after a "readcal" result that has been verified: 
      76  {{{ 
      77  dac 2 
      78  }}} 
      79  which will print all of the values in dac 2, the first 16 of which need to be restored to get back to the same readcal operating point. 
      80   
    74 81  '''CAUTION!'''  It is relatively harmless to adjust "dac 2 0" through "dac 2 15" but use extreme caution when manually sending dac commands since stray voltages on other channels could harm the detector.  See the [wiki:GraspSwControllerCmdDac manual page for dac] for more information.