Table of Contents Previous Chapter
The fepSciTimed module, executing in the FEP, implements timed-exposure science processing, comprising either raw mode, event detection mode, or raw histogramming mode. It is called from fepCtl with a single argument, fp, a pointer to the fepParm
structure. Before invoking fepSciTimed, the FEP must be commanded to (a) load a timed-exposure FEPparmBlock
into fp->tp, and (b) perform a bias calibration.
The fepSciTimed function operates in one of the following modes, according to the value of fp->tp.type:
FIGURE 171. fepSciTimed subroutines and their calling hierarchy
All interactions with the BEP and with FEP hardware are made through fepio library functions described in Section 38.0. The data structures that are passed between FEP and BEP are defined in that document and in Section 4.10. fepSciTimed makes use of the following functions which call each other in the manner shown in Figure 171:
FEPparmBlock
, fp->tp, and performs all necessary mode-dependent initialization, e.g. in event-finding modes, it checks that the bias map has been initialized.
FEPeventRecHist
records.FEPeventRecRaw
records without any thresholdingFEPtestEvenPixel---processes a threshold-crossing event possessing an even bit-offset relative to the start of the T-Plane buffer. If the center pixel is a local maximum, FIOappendData is called to copy a FEPeventRec3x3
record (or, in 5x5 mode, a
F
EPeventRec5x5
record) to the ring buffer.
FEPeventRec3x3
record (or, in 5x5 mode, a
F
EPeventRec5x5
record) to the ring buffer.
inline
function (and therefore not shown in Figure 171) that is called several times within FEPtestEvenPixel and FEPtestOddPixel to determine whether the central pixel is less than (or equal to) one of its neighbors.
FEPeventRec3x3
structure before it is copied to the ring buffer by FEPtestEvenPixel or FEPtestOddPixel, and (b) change its type
to FEP_EVENT_REC_5x5
, thereby transforming it into a FEPeventRec5x5
structure.
FEPerrorRec
record to the ring buffer, and returns to the caller the corrected value of the bias map pair.
The following FEPparm fields, defined in fepCtl.h and invariably addressed by the fp pointer parameter, are used by all timed exposure modes:
FEPexpRec
record
FEPexpEndRec
record
FP_EDGE_ROW
FP_SUSPEND
F
P_PAST_EOR
FP_TERMINATE
colshft
fidpix[]
The following FEPparm fields are only used by fepSciTimedHist:
[4]
[4][2]
[4][2]
FEPeventRecHist
structure
The following paragraphs describe the basic functions performed in timed exposure mode. All Timed Exposure modes wait until an image frame is processed and copied to the ring buffer before commanding the hardware thresholder to read the next frame, thereby ensuring that no partially processed frames are generated.
FEP_TIMED_PARM_3x3
. After checking that the bias array contains appropriate values, FEPsciTimedInit calls fioWriteImPulseReg to start the hardware thresholder, and waits for the first frame (exposure number one) to arrive.
FEPexpRec
structure and calls FIOappendData to copy it to the ring buffer. It then calls FEPsciTimedEvent to process the frame.
[]
, indexed by their DEA output nodes. It then inspects the T-plane buffer and calls either FEPtestEvenPixel or FEPtestOddPixel whenever a non-zero bit is found, indicating that the thresholder has located a pixel that exceeds its bias value by fp->tp.thresh[nn]
, where nn
is the index of the appropriate DEA output node. Since the 12-bit pixel and bias values are only accessible two at a time via 32-bit CPU instructions, the logic required to inspect even-indexed pixels differs considerably from that needed for odd-indexed pixels, hence the two separate routines.
FIGURE 173. The Relation Between Image Pixels and FEP Register Values.
FIGURE 174. The Relation Between the Bias Map and FEP Register Values.
BEP_FEP_CMD_FIDPIX
command to the FEP, which calls the fepCreateFidPix routine (in fepCtl). This sets the corresponding parity plane bits to incorrect values, which will cause the FEP thresholder to mark them in the T-plane. They will therefore always generate calls to FEPtestEvenPixel and it is the responsibility of FEPsciTimedFixBias to determine that they do not represent a genuine parity error, but to report them to the BEP by appending FEPfidPixRec records to the ring buffer.
[]
values and calls FIOsetThresholdRegister to update the hardware threshold registers.
FEPexpEndRec
(end-of-frame) record to the ring buffer.
FEP_TIMED_PARM_5x5
. It is identical to the 3x3 mode described in the preceding section except that, prior to copying an event record to the ring buffer, FEPtestEvenPixel and FEPtestOddPixel call the FEPappend5x5 function to transform the FEPeventRec3x3
record into a FEPeventRec5x5
record by setting its type
to FEP_EVENT_REC_5x5
and adding the 16 additional edge pixels and bias values.
FEP_TIMED_PARM_RAW
. It begins in an identical manner to the event-finding modes described in the previous sections, except that fepSciTimed calls FEPsciTimedRaw to process each frame.
FEPeventRecRaw
record and thence to the ring buffer.
FEP_TIMED_PARM_HIST
. Processing commences in the manner described in the preceding sections, except that fepSciTimed calls FEPsciTimedHist to process each frame.
[][0]+BIGNUM*fp->osum
[][1]
), where BIGNUM
, a constant defined in fepCtl.h, does not exceed 2321.
FEPeventRecHist
structure.
This section describes the functions that are local to the fepSciTimed unit. The only external is fepSciTimed itself which is called from fepCtl. The FEPparm
structure is defined in fepCtl.h, along with several pixel access macros. The interface to the FEP I/O library is described in Section 38.0, and data and messages exchanged between FEP and BEP are described in Section 4.10.
FEPparm *fp
fepSciTimed is called from fepCtl with a single argument: the pointer fp to the fepParm structure. It is responsible for all FEP actions associated with a timed exposure science run, except for bias calibration. It performs the following actions:
FEP_CMD_NOERR
, fepSciTimed calls fepAckCmd and continues. Otherwise, it calls fepNackCmd to pass the error code to the BEP, indicating that the command has failed, and fepSciTimed then returns to fepCtl.
IPULSE_ARMNXTACQ
(write-enable) flag.
fp->nextexpnum
is encountered (or exceeded). During this loop, calls are made to FIOgetNextCmd to handle any incoming BEP commands, and to FIOtouchWatchdog to prevent the Watchdog Timer from expiring while waiting for that particular frame.
FEPexpRec
record to the ring buffer and then calls either FEPsciTimedEvent, FEPsciTimedRaw, or FEPsciTimedHist to process the frame.
BEP_FEP_CMD_STOP
command is received from the BEP, which sets the FP_TERMINATE
bit in fp->flags. When this occurs, fepSciTimed will finish processing the current frame before returning to fepCtl.
FEPparm *fp
This function is called from fepSciTimed to verify the contents of the FEPparmBlock, fp->tp, and to check whether a bias calibration has been per formed. It also performs any necessary mode-dependent initialization. If an error is detected, FEPsciTimedInit returns a fepCmdRetCode code as defined in fepBep.h; otherwise it returns FEP_CMD_NOERR.
FEPparm *fp
This function is called from fepSciTimed to process a single timed exposure frame. It initializes the following pointers to the addresses of data structures used by the hardware thresholder:
unsigned irow unsigned icol FEPparm *fp
This function is called from FEPsciTimedEvent for every bit set in the T-plane whose bit offset is even. This pixel is located in row irow, column icol, and fp->image points to the first pair of pixels in that row. The corresponding pair of bias values are to be found in fp->image[BIAS_OFFSET]. FEPtestEvenPixel first loads the 32-bit pixel and bias fields that contain the cen tral pixel. Since the FEP is a little-endian processor, and the central pixel is stored in the lower address pair of bytes, pixel and bias will be loaded into the least-sig nificant 16 bits of each 32-bit variable. (The most significant 16 bits of these vari ables will contain the pixel and bias for row irow and column icol+1.) The pair of bias values is now validated---the bias parity flags (bits 15 and 31) are tested to determine whether a parity error has occurred in either of those locations in the bias map. If so, a call is made to FEPsciTimedFixBias to handle the problem. Since this may instead be a fiducial pixel, the corrected 32-bit bias pair is examined; if it still contains a BIAS_PARITY flag, the central pixel is not fidu cial---the pair of values is written back to the bias map, and the central pixel is ig nored. Otherwise, processing continues. Next, a test is made to determine whether this central pixel lies on the boundary of the CCD, or if its bias value is either BIAS_BAD (indicating that it had previously been found to have a parity error) or PIXEL_BAD (indication that the pixel is a member of the bad-pixel list). In any of these situations, the pixel is ignored. The 12-bit value of the central pixel is saved in ev.p[1][1] and the correspond ing 12-bit bias value in ev.b[1][1]. Two threshold values are loaded from the fp->ex.dOclk[] array---dql and dq---the former referring to the 3 pixels at a lower column number than the central pixel, the latter to the remaining 6 (which may belong to a different DEA output node). To assist in later FEPsciPixTest calls, the variable val is set equal to the difference between the center pixel value and the sum of its bias and threshold values, as discussed in Section 41.6.6. The center pixel is now compared to those lying to its left, to its right, and to those on the preceding row, using FEPsciPixTest, which also saves the pixel and bias values in the appropriate elements of the ev.p and ev.b arrays. If a test fails, i.e. if the central pixel isn't a local maximum, the function returns. Before testing the row that follows the center pixel, FEPtestEvenPixel calls FIOgetExpInfo to see whether the hardware is still processing the same frame as the software. If so, it loops over calls to FIOgetImageMapRowPtr until the hardware has finished processing the current row. Then the three pixels in the fol lowing row are also tested against the center pixel using FEPsciPixTest. This time, however, it is also necessary to check each pair of bias values for a possible parity error. If discovered, FEPsciTimedFixBias is called to log the occur rence, and the fixed bias value pair is stored back in the bias map. If all 8 pixels that surround the central pixel survive the FEPsciPixTest crite ria, the 3x3 pixel and bias arrays in the ev structure will have been loaded. If 5x5 mode has been selected, FEPtestEvenPixel calls FEPappend5x5 to append the 16 bordering pixels and their corresponding bias values to the FEPeventRec3x3, transforming it into a FEPeventRec5x5 record. Finally, FEPtestEvenPixel calls FIOappendData to write the FEPeventRec3x3 record or FEPeventRec5x5 record to the FEP-BEP ring buffer.
unsigned irow unsigned icol FEPparm *fp
This function is called from FEPsciTimedEvent for every bit set in the T-plane whose bit offset is odd. This pixel is located in row irow, column icol, and fp>image points to the first pair of pixels in that row. The corresponding pair of bias values are to be found in fp->image[BIAS_OFFSET] FEPtestOddPixel first loads the 32-bit pixel and bias fields that contain the central pixel. Since the FEP is a little-endian processor, and the central pixel is stored in the upper address pair of bytes, pixel and bias will be loaded into the most -significant 16 bits of each 32-bit variable. (The least significant 16 bits of these variables will contain the pixel and bias for row irow and column icol--1.) The pair of bias values is now validated---the bias parity flags (bits 15 and 31) are tested to determine whether a parity error has occurred in either of those locations in the bias map. If so, a call is made to FEPsciTimedFixBias to handle the problem, the corrected 32-bit bias pair is written back to the bias map, and the cen tral pixel is ignored. Note that pixels from odd numbered columns cannot be fidu cial (cf. FEPtestEvenPixel). Next, a test is made to determine whether this central pixel lies on the boundary of the CCD, or if its bias value is either BIAS_BAD (indicating that it had previously been found to have a parity error) or PIXEL_BAD (indication that the pixel is a member of the bad-pixel list). In any of these situations, the pixel is ignored. The 12-bit value of the central pixel is saved in ev.p[1][1] and the correspond ing 12-bit bias value in ev.b[1][1]. Two threshold values are loaded from the fp->ex.dOclk[] array---dqr and dq---the former referring to the 3 pixels at a higher column number than the central pixel, the latter to the remaining 6 (which may belong to a different DEA output node). To assist in later FEPsciPixTest calls, the variable val is set equal to the difference between the center pixel value and the sum of its bias and threshold values, as discussed in Section 41.6.6. The center pixel is now compared to those lying to its left, to its right, and to those on the preceding row, using FEPsciPixTest, which also saves the pixel and bias values in the appropriate elements of the ev.p and ev.b arrays. If a test fails, i.e. if the central pixel isn't a local maximum, the function returns. Before testing the row that follows the center pixel, FEPtestOddPixel calls FIOgetExpInfo to see whether the hardware is still processing the same frame as the software. If it is, it loops over calls to FIOgetImageMapRowPtr until the hardware has finished processing the current row. Then the three pixels in the fol lowing row are also tested against the center pixel using FEPsciPixTest. This time, however, it is also necessary to check each pair of bias values for a possible parity error. If discovered, FEPsciTimedFixBias is called to log the occur rence, and the fixed bias value pair is stored back in the bias map. If all 8 pixels that surround the central pixel survive the FEPsciPixTest crite ria, the 3x3 pixel and bias arrays in the ev structure will have been loaded. If 5x5 mode has been selected, FEPtestOddPixel calls FEPappend5x5 to append the 16 bordering pixels and their corresponding bias values to the FEPeventRec3x3, transforming it into a FEPeventRec5x5 record. Finally, FEPtestOddPixel calls FIOappendData to write the FEPeventRec3x3 record or FEPeventRec5x5 record to the FEP-BEP ring buffer.
FEPeventRec5x5 *ev unsigned drow unsigned dcol unsigned val unsigned pixel unsigned code unsigned bias
This is an inline function that is invoked several times within the FEPtestEv enPixel and FEPtestOddPixel functions. It masks the 12 low-order bits of pixel and bias and stores them in p[drow][dcol] and b[drow][dcol] in the ev structure. It then compares the value of (pixel - bias) against val, the corresponding value derived for the central pixel, val = ev.p[1][1] - ev.b[1][1] - doclk; where doclk represents an adjustment, quadrant by quadrant and frame by frame, for changes in average overclock. The averages from the first frame that was used in bias calibration are stored in fp->br.bias0[] and reported in FEPexpRec records, and all subsequent thresholds must be corrected by the difference between those bias0 values and the current overclock averages. This difference is report ed in the dOclk array in FEPexpRec records. FEPsciPixTest evaluates to TRUE when the value of the pixel at (drow,dcol) is inconsistent with a legal event, or FALSE when it isn't. When the code argument is TRUE (non-zero), the comparison is "less-than-or-equal", i.e. return val <= (pixel - bias); This test is used for the 3 pixels whose drow index is greater than that of the cen tral pixel, and for the pixel whose drow index is the same but whose dcol index is greater than the central pixel; for the remaining pixels, code should be set to FALSE (zero) and the comparison will be "less than", i.e. return val < (pixel - bias); FEPsciPixTest also returns FALSE when the bias value is either PIXEL_BAD or BIAS_BAD, i.e. when a parity error has previously been detected in the bias value, or when the corresponding pixel is a member of the bad pixel list. drow and dcol must be in the range 0-2; the "center" pixel has drow=dcol=1; drow=0 refers to the row before the center pixel, drow=2 to the row after; dcol=0 to the column before, dcol=2 to the column after. Constants PIXEL_MASK, PIXEL_BAD, and BIAS_BAD are defined within fepCtl.h, and val and ev are local variables. NOTE: In 3x3 mode, only that part of the FEPeventRec5x5 structure which is identical to a FEPeventRec3x3 will be accessed by FEPtestEvenPixel and FEPtestOddPixel.
FEPeventRec5x5 *ev unsigned *pImage FEPparm *fp
This function is called from FEPtestEvenPixel and from FEPtestOd dPixel to copy the 16 edge pixels and their corresponding bias values to the ev- >pe[] and ev->be[] arrays. In entry, pImage points to the 32-bit word in the pixel map that contains the central pixel of the event. Since the calling routines will not have determined whether the last of the 5 rows has yet been processed by the FEP hardware, FEPappend5x5 first calls FIOgetExpInfo to see whether the hardware is still processing the same frame as the software. If so, it loops over calls to FIOgetImageMapRowPtr until the 5th row (ev->row+2) is available. The edge pixels and their bias values are then loaded, masked, and copied to ev>pe[] and ev->be[], taking care to detect and fix any bias parity violations via a call to FEPsciTimedFixBias.
unsigned bias unsigned irow unsigned icol FEPparm *fp
This function is called from FEPtestEvenPixel or FEPtestOddPixel, (or FEPappend5x5) when a parity error or fiducial pixel is encountered in either or both of the halves of a 32-bit bias word. FEPsciTimedFixBias first determines whether fiducial pixels have been de fined (fp->nfidpix > 0), and also whether the parity flag is set for the even- column bias value. If both are true, the fp->fidpix array is scanned to see if it contains the current irow,icol address. If so, e.g. in fp->fidpix[ii], FEPsciTimedFixBias writes to the ring buffer a FEPfidPixRec record containing the index ii and the pair of pixel values, and it then removes the even pixel's parity error flag from the bias variable. Fiducial pixels excepted, each parity-corrupted 12-bit value in bias is replaced by BIAS_BAD (defined in fepCtl.h) and FEPsciTimedError is called (twice if both 12-bit values are bad) to reset the appropriate bits in the Bias Parity Plane and T-plane. It then calls FIOappendData to send a message of type FEP_ERROR_REC to the BEP containing irow, icol, the uncorrected bias val ue, and the current exposure number in fp->ex.expnum. Finally, FEPsci TimedFixBias returns the fixed-up 32-bit bias word to the caller, which has the responsibility for saving it back in the appropriate location in the bias map. The returned value consists of the pair of input pixels and their parity error flags. If the even-column pixel was fiducial, the corresponding error flag is cleared in the returned value.
unsigned irow unsigned icol FEPparm *fp
This function is called from FEPsciTimedFixBias when a parity error is de tected in row irow, column icol of the bias map. It resets the relevant bit in the Bias Parity Plane, turns off the corresponding bit in the T-plane, and increments the bias error count, fp->exend.parityerrs.
FEPparm *fp
This function is called from fepSciTimed to process a single raw CCD image frame. It initializes the following pointers to the addresses of data structures used by the hardware thresholder:
FEPparm *fp
This function is called from fepSciTimed to extract raw pixel histogram data from a single image frame. It initializes the following pointers to the addresses of data structures used by the hardware thresholder: