Login| Sign Up| Help| Contact|

Patent Searching and Data


Title:
METHOD AND APPARATUS FOR DIGITALLY BASED HIGH SPEED X-RAY SPECTROMETER
Document Type and Number:
WIPO Patent Application WO/1997/007591
Kind Code:
A1
Abstract:
A high speed signal processing system accepts input data from a detector-preamplifier (20) and produces a spectral analysis of the x-rays illuminating the detector. The system achieves high throughputs at low cost by dividing the required digital processing steps between a "hardwired" processor implemented in combinatorial digital logic (25), which detects the presence of x-ray signals in the digitized data stream and extracts filtered estimates of their amplitudes, and a programmable digital signal processing computer (28), which refines the filtered amplitude estimates and binds them to produce the desired spectral analysis. The hardwired processor has two parallel processing channels: a slow channel, which filters the data stream with a long time constant triangular filter for good energy resolution; and a fast channel which filters the data stream with a short time constant triangular filter, detects x-ray events, inspects for pileups, and captures peak values from the slow channel for good events.

Inventors:
WARBURTON WILLIAM K (US)
ZHOU CARL
HUBBARD BRADLEY
Application Number:
PCT/US1996/013082
Publication Date:
February 27, 1997
Filing Date:
August 09, 1996
Export Citation:
Click for automatic bibliography generation   Help
Assignee:
WARBURTON WILLIAM K (US)
International Classes:
G01T1/17; G01T1/36; G06F17/40; (IPC1-7): H03F1/26; G05B23/02; G06G7/12; H04B15/00
Foreign References:
US5349193A1994-09-20
US5005146A1991-04-02
US4658216A1987-04-14
US3872287A1975-03-18
Other References:
IEEE TRANSACTIONS ON NUCLEAR SCIENCE, Vol. 40, No. 4, August 1993, TAKAHASHI et al., "A New Pulse Height Analysis System Based on Fast ADC Digitizing Technique", pages 626-629.
REV. SCI. INSTRUM., Vol. 66, No. 2, February 1995, R. FARROW et al., "X-ray Signal Processing Electronics for Solid State Detectors", pages 2307-2309.
IEEE TRANSACTION ON NUCLEAR SCIENCE, Vol. 42, No. 4, August 1995, V.T. JORDANOV et al., "Digital Pulse-Shape Analyzer Based on Fast Sampling of an Integrated Charge Pulse", pages 683-687.
IEEE TRANSACTIONS ON NUCLEAR SCIENCE, Vol. 41, No. 4, August 1994, A. GEORGIEV et al., "An Analog-to-Digital Conversion Based on a Moving Window Deconvolution", pages 1116-1124.
IEEE TRANSACTIONS ON NUCLEAR SCIENCE, Vol. 41, No. 5, October 1994, M.N. AL-HADDAD et al., "Development and Testing of a Flash Analog-to-Digital Converter Based System for Pulse Shape Discrimination of Nuclear Radiation Pulses", pages 1765-1769.
See also references of EP 0880821A4
Download PDF:
Claims:
WHAT IS CLAIMED IS:
1. A high speed, digitally based method for analyzing an electronic signal containing steplike pulses, which arrive at an average rate R, to estimate the amplitudes of at least some of said steplike pulses, the method comprising the steps of: digitizing the electronic signal with an analog to digital converter (ADC) , operating at a sampling frequency S which is greater than R, to produce a digital representation of the electronic signal, the representation being referred to as the digitized input signal; providing digital combinatorial logic, referred to as the FiPPI, clocked at frequency S or a multiple thereof; providing a programmable digital computing device (DSP) coupled to the FiPPI; applying a digital shaping filter to the digitized input signal, using the FiPPI; detecting the presence of the pulse signals in the digitized input signal, using the FiPPI; extracting estimates of amplitudes of the pulse signals from the output of the digital filter, using the FiPPI; transferring the estimates from the FiPPI to the DSP; and compensating the estimates for errors resulting from applying the digital filter to waveforms which are not ideal steps, using the DSP.
2. The method of claim 1, and further comprising the step, carried out using the DSP, of binning the estimates, so compensated, to produce a spectral representation of the amplitudes of the detected pulses.
3. The method of claim 1, and further comprising the step, carried out using the DSP, of correcting the pulse amplitude estimates for manipulations of the electronic signal between its source and the input of the ADC.
4. The method of claim 3, and further including the step, carried out before said digitizing step, of conditioning the electronic signal according to a set of parameters to reduce the dynamic range of the input signal.
5. The method of claim 4, and further comprising the steps of: communicating the set of parameters to the DSP; and using the values of the parameters in the set in said correcting step.
6. The method of claim 4, and further comprising the steps of: sensing whether the input signal exceeds the input range of the ADC; and, if so, performing at least one of the following steps: signaling the DSP to avoid capturing possibly spurious filtered amplitude estimates; and signaling the DSP to adjust the set of parameters to return the input signal to the ADC input range.
7. The method of claim 1, wherein said electronic signal is composed of a parametrically describable (PD) fraction having a high dynamic range and a signalofinterest (SOI) fraction having a significantly smaller dynamic range, and said conditioning step comprises the steps of: generating a replica of the PD fraction according to the values of said set of parameters; subtracting said replica from said electronic signal to form a difference signal; and, optionally, using a gain stage to adjust the amplitude of the difference signal; or using a filter to remove frequency components in the difference signal above the Nyquist frequency of the ADC; or doing both.
8. A method for applying a shaping filter, described by a set of one or more parameters, to a noisy input signal containing steplike pulses with exponential decays, described by a time constant 7, between them to extract estimates of the step amplitudes of said pulses which are substantially independent of the slope values of the exponentially decaying components in the vicinity of the pulses, by the steps of: applying said shaping filter to said input signal to generate a filtered signal; generating a first weighted signal by weighting said filtered signal by a first constant that depends upon the values of the set of shaping filter parameters and upon T; generating a second weighted signal by weighting said input signal by a second constant that depends upon the values of the set of shaping filter parameters and upon T; and forming a compensated signal by combining the first and second weighted signals, the compensated signal representing the filtered signal compensated for the exponentially decaying components' slope values in the vicinity of said steplike pulses.
9. The method of claim 8 wherein the first and second constants are determined for a particular shaping filter by the steps of: mathematically expressing said filter's output amplitude in terms of said steplike pulse's amplitude and the exponentially decaying components' slope values in the vicinity of said steplike pulses; using the proportionality between the slope of a decaying exponential and its instantaneous amplitude to express said slopes in terms of said input signal amplitudes; and solving said expression for the pulse step amplitude in terms of the filter's output amplitude and the input signal's amplitude.
10. The method of claim 8 and further comprising the step, performed before said step of generating a second weighted signal, of applying a different filter to the input signal, so that said second weighted signal includes the effect of said different filter.
11. The method of claim 8 wherein only discrete measurements of said input and filtered signals are used to produce each steplike pulse amplitude estimate, by the additional steps, prior to said steps of generating first and second weighted signals, of: capturing said filtered signal at an instant which is separated from the occurrence of the steplike pulse by a first time interval; capturing said input signal at an instant which is separated from the occurrence of the steplike pulse by a second time interval; and including the values of said first and second time intervals in determining the values of said first and second weighting constants; and replacing said filtered and input signals by said captured values of the same in all subsequent steps in the method.
12. A method for analyzing a noisy input electronic signal containing steplike pulses with exponential decays, described by a time constant T, between them to extract estimates of the step amplitudes of said pulses which are substantially independent of the slope values of the exponentially decaying component in the vicinity of the pulses by the steps of: applying a filter, described by a set of one or more parameters, to said input signal to reduce its noise components; generating a first weighted signal by weighting said filtered signal by a first constant; and generating a second weighted signal by weighting a time delayed version of said filtered signal by a second constant, wherein said first and second constants depend upon the values of the set of filter parameters, upon T, and upon the value Δ of said time delay; and combining the first and second weighted signals to form an output signal which has a maximum for each steplike pulse, the value of said maximum being proportional to the amplitude of said pulse and , substantially independent of the slope values of the exponentially decaying component in the vicinity of the pulse.
13. The method of claim 12 wherein the first and second constants are determined for a particular filter by the steps of: mathematically expressing the difference between the value of said steplike pulse amplitude and the result of a simple subtraction of the value of said time delayed filtered signal from the value of the filtered signal itself in terms of the values of said set of filter parameters, decay constant T, time delay Δ, and slopes of the exponentially decaying components' slope values in the vicinity of said steplike pulses; applying the principle that the slope of a decaying exponential is directly proportional to its amplitude to express said slopes in terms of said filtered signal values; and solving said expression for the pulse step amplitude in terms of the filter output amplitude and the time delayed filter output amplitude.
14. A digital combinatorial logic circuit for analyzing a digital representation of an electronic signal containing steplike pulses, which arrive at an average input rate R, to provide estimates of the amplitudes of at least some of said steplike pulses, said representation having been created by digitizing the electronic signal with an analogto digital converter (ADC) operating at a sampling frequency S which is greater than R, the representation being referred to as the digitized input signal, the circuit being clocked at frequency S or a multiple thereof, the circuit comprising: a digital shaping filter receiving the digitized input signal and providing an output signal referred to as the filtered signal; a pulse detector receiving the digitized input signal and providing an output signal representing the detection of a pulse in the digitized input signal; an output buffer coupled to said digital shaping filter and operable to capture a value of said filtered signal in response to a trigger signal; and a timing circuit coupled to said pulse detector and to said output buffer, said timing circuit providing a trigger signal in response to the detection of a pulse, said trigger signal being delayed relative to said output signal from said pulse detector by an amount that depends on at least one characteristic of said digital shaping filter.
15. The circuit of claim 14 wherein the electronic signal containing steplike pulses is from a preamplifier whose input is a photon or particle detector and wherein the amplitudes of the steplike pulses represent the energies of the photons or particles absorbed in the detector.
16. The circuit of claim 14 wherein: said digital shaping filter, referred to as the first shaping filter, is characterized by at least one time constant rs; and said pulse detector comprises a second digital shaping filter characterized by at least one time constant Tf , where T is significantly shorter than τg.
17. The circuit of claim 14 wherein said output buffer includes a FIFO memory.
18. The circuit of claim 14 wherein said pulse detector comprises: an additional shaping filter to produce an additional filtered signal; and a peak detector coupled to said additional shaping filter.
19. The circuit of claim 14, and further comprising: a "slow" pileup inspector, coupled between said pulse detector and said timing circuit, which measures intervals between successive pairs of signals output from said pulse detector, and prevents said timing circuit from generating said trigger signal when a measured interval is inadequate to allow said digital shaping filter to produce valid estimates of the amplitudes of the associated pulses.
20. The circuit of claim 14, and further comprising: a "fast" pileup inspector coupled between said pulse detector and said timing circuit, which determines from the output signal of said pulse detector that a pair of pulses arrived so close together that they could not be resolved as separate pulses by said pulse detector, and prevents said timing circuit from generating said trigger signal.
21. The circuit of claim 20 wherein: said pulse detector includes a fast digital filter to generate an additional filtered signal and a peak detector receiving the additional filtered signal; and said fast pileup inspector counts the number of clock cycles until the detected peak falls back below a preset threshold and labels as "piled up" any detected peak for which the number of counted clock cycles exceeds a preset value, where the preset value is a predetermined, adjustable parameter based on both the parameters of the fast digital filter and the input signal risetime.
22. The circuit of claim 20 wherein: said pulse detector includes a fast digital filter to generate an additional filtered signal and a peak detector receiving the additional filtered signal; and said fast pileup inspector includes a digital delay element to produce a delayed copy of the additional filtered signal, means for capturing the maximum amplitude of each detected peak, taking a fixed fraction of the maximum amplitude, means for counting the number of clock cycles the delayed copy of the detected peak exceeds the fixed fraction of its own maximum amplitude, and means for labeling as "piled up" any peaks for which the number of counted clock cycles exceeds a preset value, where the preset value is also a predetermined, adjustable parameter based on both the parameters of the fast digital filter and the input signal risetime.
23. The circuit of claim 14 wherein said output buffer is coupled to an external device, and further comprising: a counter for measuring system "livetime" by counting clock cycles when said external device is available to accept amplitude estimates captured by said output buffer.
Description:
METHOD AND APPARATUS FOR DIGITALLY BASED HIGH SPEED X-RAY SPECTROMETER

GOVERNMENT RIGHTS

The United States Government has rights in this invention pursuant to Contract No. DE-FG03-92ER81311 awarded by the Department of Energy.

BACKGROUND OF THE INVENTION

The present invention relates generally to systems for digitally processing the pulses generated in detector systems in response to absorbed radiation and, more particularly, to processing such pulses in low cost, high resolution, high rate spectrometers for x-rays or gamma rays .

There is a need, particularly in synchrotron radiation research, for low cost, high speed arrays of x-ray spectrometers. In order to optimize data acquisition, such spectrometers should have good energy resolution, high counting rate capability with pileup rejection, and low enough cost so that arrays of 30 or more detectors can be contemplated. Full multichannel analysis (MCA) capability would extend the range of application considerably. Full computer control of all spectrometer functions is also very important since otherwise the setup and calibration of the detector array becomes very burdensome as the array size becomes large. The spectrometer's physical size would be preferably compact as well.

Present electronics do not meet these goals, costing about $6,000 per detector to implement without multichannel analysis, and filling a full rack for a 13 element detector. Thus 30 element detectors are impractical to instrument and 100 element arrays are essentially impossible. Multichannel analysis is rarely employed with detector arrays because low cost MCAs are not fast enough and high speed MCAs are too expensive for most applications. Pileup inspection is sporadically implemented, but is typically effective only for energies above 8 keV. A few modules allow partial computer control of spectrometer functions, but typically cost about twice as much as modules without computer interfaces . This is significant because while tuning a single spectrometer channel requires only a few minutes, the effort must be multiplied by the number of elements in an array and becomes burdensome for arrays of 10 elements or more.

For these synchrotron applications, and many others as well, it would thus be advantageous to have a low cost, small volume spectrometry device capable of providing full energy analysis with good

energy resolution at high count rates and be further capable of being interfaced to a computer system so that necessary tuning operations could be accomplished automatically by an appropriate program.

SUMMARY OF THE INVENTION

The present invention provides a method and apparatus for processing pulse signals from a detector-preamplifier system and analyzing the energy of the x-rays or γ-rays absorbed .in the detector. In specific embodiments, it is compact, low cost, high speed, performs pileup inspection, has a digital interface so that it can be easily connected to a computer, and can operate effectively with most common preamplifiers.

The invention employs digital signal processing techniques to analyze the detector-preamplifier input pulses. In this way it uses the low cost, high speed analog-to-digital converters (ADCs) and digital signal processors (DSPs) to meet the desired performance criteria. The invention duplicates the energy resolution and exceeds the pileup rejection performance of state of the art analog spectrometers and produces complete output spectra at very high count rates which were previously typical only of SCA systems. Digital processing allows overall costs and physical volume to be reduced by factors of about 4 and 10, respectively, compared to commercial analog circuitry. All spectrometry tuning functions are digitally implemented and may be handled automatically under external computer control.

For the intended application, high data throughput at low cost is more important than optimum energy resolution. To achieve these goals, the invention carries out the digital pulse processing in two stages. The first stage uses "hardwired" digital combinatorial logic to implement time invariant filtering, while the second stage uses a programmable DSP to adjust and correct the first stage's output, based on time dependent parameters. This division of labor is critical to the invention's success.

In a specific embodiment, the hardwired logic stage avoids the adaptive filtering, cusp-like weighting, or deconvolution schemes typical of the art to date. Such schemes require complex data operations including: multiplication; lookup tables for weighting functions; data set buffering for both time variant processing and interprocess synchronization; and the like. Instead, the invention implements only a simple shaping filter (preferably trapezoidal) in both a slow and a fast channel, using an algorithm requiring only addition and subtraction. As commonly practiced in the art, the fast channel's output is used for pileup inspection and slow peak capture, while slow channel filtering provides the noise reduction required to achieve good energy resolution. See, for example, the analog spectrometer design of Goulding and Landis, (U.S. Pat. No. 4,658,216) . Processing all pulses identically and eliminating all complex data operations so simplifies the first stage design that it can be readily implemented in a single medium sized field

programmable gate array (FPGA) and still process over 500,000 counts/second (cps) . For comparison, the adaptive digital filtering spectrometer shown by Mott et al. (U.S. Pat. No. 5,349,193) requires a similar sized FPGA simply to implement the state machine required to control data flow.

Used alone, however, such a simple filter, does not produce acceptable spectroscopic performance, compared to existing analog devices, which is why the more complex schemes found in the art have been developed. The present invention therefore applies a second processing stage, using a programmable computer to apply the time variant corrections which are required to achieve competitive performance. Because these corrections are not carried out at the system's sampling speed, which can easily be 10's of mega-Hertz, but only at the average signal pulse rate, which will be 10 to 100 times slower, relatively complex corrections can be implemented using an inexpensive DSP. Moreover, not all possible corrections must be implemented simultaneously. In contrast to hardware solutions, only those corrections required by a particular detector- preamplifier combination are downloaded to the DSP at system startup. In a specific implementation, for instance, the 500,000 cps data rate noted above is processed by only a $40 DSP chip.

Thus the present invention is to distinguished from the two classes of solutions previously devised to digitally process pulses in x and gamma ray spectrometers: the "hard-wired" class where all the computations required to identify pulses in the data stream and extract their amplitudes with time dependent corrections and optimizations are performed using hardwired logic; and the "computer analysis" class where all these operations are performed under software control. The former class includes the devices of Koeman (US Pat. No. 3,872,287), akatos et al. (US Pat. No. 5,005,146), Georgiev et al. (IEEE Trans. Nucl. Sci. 41(1994) 1116-1124, Mott et al. , Jordanov and Knoll (IEEE. Trans. Nucl. Sci. 42 (1995) 683-685, and Farrow et al. (Rev. Sci. Instr. 66 (1995) 2307-2309. Commercialization of the Georgiev, Mott and Jordanov devices has been attempted by the companies Target, Inc., Princeton Gamma-Tech, Inc., and Amptek, Inc., respectively. Examples of the latter class have been reported by Takahashi et al. (IEEE Trans. Nucl. Sci. 40 (1993) 626- 629, Al-Haddad et al. (IEEE Trans. Nucl. Sci. 41(1994) 1765-1769. The latter class has not been commercialized to date, presumably due to the extreme cost of a processor fast enough to process useful data rates. The present invention thus defines a new, "hybrid" class, which distributes digital filtering between a hardwired preprocessor and a programmed signal corrector.

The corrective use of the DSP in the second stage of the spectroscopic filtering process should not be confused with the MCA step used to produce a spectrum of the photon energies seen by the detector. While the sorting and binning of the filtered pulse amplitudes is also commonly handled by a dedicated digital computer, these functions are not

conceptually a part of the filtering process. Therefore, although many systems found in the art may have a similar physical topology, with a DSP providing MCA following a digital filtering stage, the innovative use of the DSP in the present invention, as described both above and in the specification below, is entirely different.

In a specific implementation, a single DSP is actually used to implement four logically separate functions: the inventive filtering functions; the MCA function; controlling the analog conditioning front end; and handling data input/output to a system control computer. In this same specific implementation, the invention is used with an analog signal conditioning (ASC) front end to remove ramp-like components from the input data stream in order to reduce the number of bits of accuracy required in the system's ADC. This ASC's input control parameters are set digitally by the DSP and adjusted as required to maintain the conditioned signal within the ADC's input range. After digitization, the pulse stream is processed by the hardwired logic unit discussed above, which detects pulses, implements triangular filtering, and performs pileup inspection. It further captures both good peak and baseline values which it passes to the DSP for further processing. The DSP performs the computations and corrections which convert peak values into accurate energy values and then bins the results to produce MCA spectra. Although the ASC's action introduces distortions into the hardwired filtering procedure, the DSP can make appropriate corrections using both its values of the ASC control parameters and unfiltered signal values as appropriate. By capturing baseline values between peaks, the

DSP can also correct the peak heights for less systematic variations which occur for a variety of reasons.

In the invention, the hardwired digital processing stage is designated as the FiPPI because it implements filtering, peak detection, and pileup inspection. The FiPPI processes every data sample, but performs only the small set of filtering and inspection functions which are required to detect and accurately capture the local amplitudes of x-ray pulses in the input data stream. More complex DSP computations are required to process these captured peak amplitudes to produce accurate x-ray energy values, but are only executed as often as actual events are detected. This division is beneficial because it minimizes both the amount of expensive fast logic required and the speed (and hence cost) of the DSP required. The result is lower cost and higher performance than if either approach were used singly. The FiPPI functions which occur in one or another specific implementation comprise a decimator, a slow trapezoidal filter, a fast trapezoidal filter, a peak detector, a pileup checker, an output buffer, and an input count rate (ICR) counter. The FiPPI operation is controlled by several digital parameters which are loaded into the FiPPI before the spectrometer system commences operation.

The decimate by N function breaks up the input from the ADC into successive blocks of N values and outputs the average value of each block at 1/N th the frequency of the input data stream. The adjustable parameter N is a power of 2, taking the values 1, 2, 4, 8, etc. The decimator's primary function is to reduce the amount of First-In-First-Out (FIFO) memory required to implement long filtering times in the FiPPI's slow filter.

Both the slow and fast filters are symmetrical trapezoids whose peaking times τ p and flattop lengths τ„ are externally loaded parameters. The trapezoid's peak values constitute measurements of the detected x-ray's energies. These functions are formed by a running average of the difference of two delayed offset differences, which are implemented using FIFO functions. The fast filter is much shorter than the slow filter and normally runs at full clock speed. The slow filter works with the decimator output at 1/N clock speed and can have peaking times of several microseconds or more using FIFOs which are only 32 words deep.

A peak detection circuit inspects the fast filter's output for signal pulses by looking for M or more consecutive values above some threshold level T and, finding such a set of values, captures the arrival time of the maximum signal value within the set, which is thereafter defined as the associated signal pulse's arrival time. The externally loaded parameters T and M may be adjusted to optimize sensitivity to low signal levels while maintaining adequate immunity to triggering by noise. The pileup inspector assures that the slow filter trapezoids are sampled in the middle of their flattops and that this sampling occurs only for "good peaks. " A good peak results from a pulse which is separated from both its predecessor and successor by acceptable time intervals. Pileup inspection comprises several tests. Two of these are for "fast pileup" pulses, which are too close together to resolve as separate fast filter output peaks. Because a pair of piled-up fast pulses separated by time d extends the fast filter's single pulse output duration D to D + d, a first fast pileup test compares fast pulse widths at a threshold T to a parameter W, which is set to a value slightly longer than D.

Whereas the first fast pileup test compares the fast peak's width at threshold to a test value, a second fast pileup test compares its width at half amplitude to a test value set to be slightly greater than the half width of an ideal fast pulse. This test is pulse amplitude independent, and, while more complex to implement, has increased accuracy for very low amplitude fast pulses which may not exceed the threshold by very much and whose durations above a fixed amplitude threshold are therefore strongly amplitude dependent. Pileup in the slow channel is inspected using a counter which is reset each time a fast pulse is detected. If this counter reaches the

value S of an external parameter without being reset, the slow filter's output value is captured to an output buffer at that instant, as is the FiPPI's unfiltered input value. If the counter continues on to reach the value N of a second external parameter, then this pulse has no trailing edge pileup. If a stored flag value shows that it also has no leading edge pileup, then the peak value is "good" and a DSP interrupt flag is raised to signal its capture. The value of N is typically equal to τ sp plus τ s „/2 plus a small margin interval. The value of S is N adjusted for timing offsets. After a good event value is captured, a second attempt is made to count to N. If successful, this means that the slow filter output has returned to its baseline level, allowing a value to be captured on DSP request for use in normalization corrections.

The ICR counter is incremented whenever an x-ray is detected, whether it is piled up or not. This value is read and zeroed from time to time, allowing statistics on the fractional pileup rate to be collected and accurate deadtime corrections to be made when quantitatively precise results are required.

In this same embodiment, the DSP is a commercial digital signal processing circuit with all of its functions implemented in software. These functions fall into four general categories: controlling the ASC; correcting captured FiPPI data values to optimize peak height estimation accuracy; performing multichannel analysis to produce spectra; and input/output (I/O) transfers of data and parameters between the system and the outside world. The I/P circuits and software are readily accomplished by one skilled in the art.

The DSP controls the ASC by first setting initial values to the offset and slope DACs in the ASC's ramp generator and then resetting the ramp generator as required. Initial DAC settings are estimated when operation starts. The slope DAC setting estimate is updated from time to time to compensate for variations in the rate of arrival of x-rays to the detector. If the ASC output goes out of the ADC's input range, then the offset DAC is adjusted to restore it.

The DSP retrieves captured peak values from the FiPPI under interrupt control, as noted above, reading FiPPI registers containing this value, the ICR counter value, an unfiltered FiPPI input value, and any other values characterizing the captured event. By design the DSP's interrupt response is less than the minimum slow filter peaking time, so this read does not add any paralyzable dead time to the overall system response. The good peak value is converted into an energy value and such corrections are made as may be required to achieve acceptable accuracy. Then, if it lies within a selected spectral energy range, MCA is performed by binning the result to the spectrum being collected.

From time to time the DSP also captures FiPPI baseline values, which are read the same way as good peak values are. A "set baseline" flag distinguishes the two cases. Baseline values correspond by

definition to events with zero energy and are used to establish the FiPPI's zero offset. Baseline statistics can also be collected and used for diagnostic purposes such as monitoring the spectrometer's energy resolution. If uncorrected, the ASC's subtraction of a ramp waveform from the preamplifier input signal would produce spectral distortions. Because the DSP controls the ASC ramp generator, it can compute the original signal's amplitude, allowing algorithms to be implemented which make the appropriate corrections. The DSP monitors the average baseline value after these corrections and, if it is not zero, subtracts this value from good peak energies to compensate for any residual errors arising from, for example, detector leakage current.

A further understanding of the nature and advantages of the present invention may be realized by reference to the remaining portions of the specification and the drawings.

BRIEF DESCRIPTION OF THE DRAWINGS PIG. IA is a circuit schematic of a representative detector- preamplifier system which supplies pulses to the present invention; FIG. IB is the trace of a typical detector-preamplifier output signal resulting from the absorption of a single x-ray in the detector; FIG. IC shows a typical output from a continuous discharge detector-preamplifier over the course of multiple x-rays;

FIG. ID shows a typical output from a periodic reset detector- preamplifier over the course of multiple x-rays;

FIG. IE shows three common x-ray pulse arrival patterns after the ASC has removed the reset-ramp portion of the signal;

FIG. 2 is a block diagram of the invention showing its major parts and its connections to other equipment; FIG. 3 is a block diagram of the Analog Signal Conditioning

(ASC) and A to D hardware blocks of FIG. 2;

FIG. 4 is a circuit schematic of a representative embodiment of several blocks of FIG. 3;

FIG. 5 is a block diagram of the Hardwired Digital Signal Processor hardware block of FIG. 2;

FIG. 6A is a circuit schematic of a representative embodiment of the Decimator hardware block of FIG. 5;

FIG. 6B is a timing diagram illustrating the operation of the circuitry of FIG. 6A; FIG. 7A is a circuit schematic of a representative embodiment of the Slow Filter hardware block of Fig. 5;

FIG. 7B is a timing diagram illustrating the operation of the circuitry of FIG. 7A;

FIG. 8A is a circuit schematic of a representative embodiment of the FIFO 10 hardware block of FIG. 6A;

FIG. 8B is a timing diagram illustrating the operation of the circuitry of FIG. 8A;

FIGS. 9A-9G are a series of timing diagrams demonstrating the relationship between corresponding pulses output by the Fast and Slow Filters of FIG. 5 and illustrating functions of the Peak Detector and Pileup Checker blocks of FIG. 5;

FIG. IOA is a circuit schematic of a representative embodiment of the Peak Detector hardware block of FIG. 5;

FIG. 10B is a timing diagram illustrating the operation of the circuitry of FIG. IOA;

FIG. IIA is a circuit schematic of a representative embodiment of the Pileup Checker hardware block of FIG. 5;

FIG. IIB is a timing diagram illustrating the operation of the circuitry of FIG. IIA; FIG. 12A is a circuit schematic of a representative embodiment of the Input Count Rate (ICR) Counter hardware block of FIG. 5;

FIG. 12B is a timing diagram illustrating the operation of the circuitry of FIG. 12A;

FIG. 13 is a circuit schematic of a representative embodiment of the livetime counter hardware block of FIG. 5;

FIG. 14A is a circuit schematic of a representative embodiment of a Pileup Inspector which measures fast peak widths at their half heights;

FIG. 14B is a timing diagram illustrating the operation of the circuitry of FIG. 14A;

FIG. 15 is a flow diagram showing the major features of the DSP's control program;

FIG. 16 is flow diagram of the Data Acquisition Task feature of the DSP's control program; and FIGS. 17A-17D are oscilloscope traces of the output of a specific embodiment of the invention ASC showing the effects of time fluctuations in the arrival rate of x-rays;

FIG. 18 is a block diagram of a control procedure used to keep the ASC's output within the ADC's input range; FIGS. 19A-19B are sketches showing the need for pulse height correction terms for two types of preamplifiers.

FIG. 20 is a sketch defining the terms used in the derivation of the pulse height correction term for the continuous discharge type preamplifier. FIG. 21A is a circuit schematic of an alternate embodiment of the Slow Filter hardware block of Fig. 4;

FIG. 21B is a timing diagram illustrating the operation of the circuitry of FIG. 21A; and

FIG. 22 shows an alternate Slow Filter embodiment using analog filtering.

DESCRIPTION OF SPECIFIC EMBODIMENTS 1; System Overview 1.1. Preamplifier Input Signals

The description of specific embodiments will be clarified by a brief discussion of the electrical pulses, corresponding to detected x-rays, which we will process. FIG. IA shows a common x-ray detector/preamplifier circuit comprising a semiconductor detector diode 10, a voltage supply 12, a charge integrating preamplifier 13 with feedback capacitor C f 15 and feedback element 17. An x-ray of energy E x absorbed in diode 10 releases a charge Q x equal to E x /e, where e depends on the diode material. Q x is integrated on C f 15, producing an output voltage step V χ equal to Q x /C f or E χ /(eC f ), as shown in FIG. IB. The present invention uses digital filtering to accurately estimate E χ by reducing the noise σ in the measurement of V χ . Functionally, there are two basic types of preamplifiers. In the first type, element 17 continuously discharges capacitor 15 (the "CD" case),as by a resistor. FIG. IC shows a typical CD preamplifier output, comprising a series of signal steps (as per FIG. IB) with exponential decays between. The average output voltage, V avq , equals the input diode current I j _ n times element 17's resistance.

In the second preamplifier type, element 17 is a switch which closes periodically when the output voltage of preamplifier 13 approaches an upper reset value VU and opens again when the preset lower limit VI is reached. This is the periodic reset ("PR") case FIG. ID shows a typical output, comprising a ramp of voltage steps which rise to VU, where reset occurs, returning the voltage VL, whence the process begins anew. The ramp's average slope S avg equals Ii n /C f . Typical signal fluctuations about the average slope are shown in FIG. IE.

1.2. Dynamic Range and Digitization Rate Issues

ADC selection is critical in implementing a digital spectrometer with both good pileup rejection and good energy resolution. Regarding pileup: at least 20 megasamples/second (MSA) is required to achieve 200 ns pulse pileup inspection times. Regarding energy resolution: experience shows that to get good energy resolution, the noise range σ (see FIG. IB) must be about 4 times the ADC's least significant bit ΔV- ^ . This sets the gain (volts/bit) of the amplifier stages preceding the ADC:

4 ΔV-L ≤ 0 (1) Given ΔV 1# the ADC must then have enough bits N B to fully cover the range 0 to V maχ :

N B = log(V maχ /ΔV 1 )/log(2). (2)

A typical value of N B is 14.

14 bit ADCs operating at 20 MSA exist, but are expensive compared to the cost of the analog electronics which we want to replace. Fast 8 to 10 bit ADCs, however, are inexpensive due to their wide use in

digital communications. In the present invention, we reduce the dynamic range of the preamplifier signal sufficiently to allow the use of these cheaper devices. The reduction from 14-15 bits to 8-10 bits is also advantageous both because shorter words require less electronics to process and because they require less power to process at a given data rate.

1.3. Functional Organization

FIG. 2 shows the basic structure of the invention digital spectrometer. Input from a conventional detector-preamplifier 20, as in FIG. IA, feeds into a digital spectrometer 22 comprising three functional blocks: an analog signal conditioning (ASC) and analog to digital converter (ADC) block 23; a hardwired digital filter, peak detector, and pileup inspector (FiPPI) block 25; and a programmable digital computer block 27, which in a specific embodiment is a digital signal processor (DSP), for signal refinement, multichannel signal analysis, ASC control and input/output (I/O) functions. The digital spectrometer 22 connects to a general purpose control computer and interface 28, from which it receives parameter values and control signals and to which it sends collected spectra. The function of ASC 23 is not required for the operation of the digital spectrometer blocks 25 and 27, but is our preferred embodiment. The functions of blocks 25 and 27 can be implemented using various circuitry, but in our preferred embodiment are implemented according to the specification presented below. The general purpose control computer and interface 28 are conventional and may include any of a variety of common personal or laboratory computers and interface standards. The details of interfacing a computer to a DSP are well known to those skilled in the art.

2; ASC: Analog Signal Conditioning and A to D Conversion Block 2.1. ASC Functional Philosophy

The ASC 23 has two primary functions: reducing the input signal's dynamic range and to adjusting its gain to satisfy Eqn. 1. Dynamic range reduction is accomplished by decomposing the preamplifier signal into two components: a "low frequency" signal fraction (LFF) , of large dynamic range; and a "higher frequency" signal fraction (HFF) , of much smaller dynamic range, carrying the signal of interest (SOI; compare FIG. ID to FIG. IE) . The terms "low frequency" and "high frequency" are descriptive since, in this application, the LFF's fundamental frequency is much lower than the frequency bandwidth carrying the HFF SOI. The important concept is that a reasonable replica of the LFF signal fraction can be described by a relatively small number of parameters, allowing it to be readily generated and subtracted from the input signal. The remainder signal fraction then closely approximates the original HFF carrying the SOI and has a significantly reduced dynamic range, allowing

it to be digitized using an ADC with a significantly reduced number of bits.

Under parametric control by DSP 27, ASC 23 therefore generates a LFF replica, subtracts it from the input signal, and adjusts the remaining HFF replica's amplitude to meet Eqn. 1. Besides requiring fewer ADC bits, this approach has three additional advantages. First, the DSP 27 knows the ASC's control parameters and can use them to refine the energy spectrum it is collecting. Second, since x-ray pulses in the HFF fraction will fall nearly randomly (dithered) across the ADC's input range, the spectrometer 22's accuracy and linearity are relatively insensitive to the ADC's differential and integral non-linearity and completely insensitive to any DC offset voltages. Third, different types of preamplifier input can be accommodated merely by parametric adjustments. For CD preamplifiers, the LFF is merely a constant set to the value V avc ,, as shown in FIG. IC; for PR preamplifiers it is a sawtooth function, consisting of alternating ramps of slope S avq and resets, as shown in FIG. ID.

2.2. ASC High Level Description FIG. 3 is a functional block diagram of ASC and conversion block 23. An amplifier 30 amplifies the difference between the input signal from the detector-preamplifier 20 and a voltage level set by a digital-to-analog converter (DAC) Bias DAC 32 which allows the preamplifier signal to be centered about zero in the rest of the circuit. A subtracter 33 subtracts the output of a LFF generator 35 from amplifier 30's output. LFF generator 35's output waveform is controlled by inputs from an Offset DAC 37, a Slope DAC 38, and a reset line 40 from DSP 27. Subtracter 33's output feeds an amplifier 42, whose variable gain is controlled by a Gain DAC 43. A comparator 44 examines the signal and alerts the DSP 27 on interrupt line 45 if it passes outside the ADC's input limits. A low pass filter 47 removes any signal frequencies above the ADC's Nyquist limit before it reaches an ADC 48.

The ADC output connects both directly to FiPPI block 25 via a digital ADC output bus 50, and indirectly to DSP block 27 via the bus buffers 52. The buffers 52 attach to the bidirectional DSP data bus 53, the DSP address lines 54, and the reset line 40 and allow DSP 27 to load digital input values to the DACs 32, 37, 38, and 43. and sample the ADC output data stream on ADC output bus 50 as desired. Thus DSP 27 both directly controls all the ASC 23's functions and can also directly measure their effects on the ADC output 50. With appropriate control software, this allows DSP 27 first to initially set preferred operating values for the ASC 23 and then to dynamically control the LFF generator 35's operation as well. The details of using interface buffers are well known to those skilled in the art of digital electronics and will not be described further.

2.3. ASC Block Output Signal

Under DSP 27's control, LFF generator 35 generates a resetting ramp function with a DC offset. For a CR preamplifier only a DC offset of value a is used (see FIG. IC) . For a PR preamplifier, the DC offset is set to the value VL and the ramp's slope is adjusted to match the average slope S av _ (see FIG. ID) . Three PR output signal samples, after ramp subtraction, gain adjustment and filtering, are indicated in FIG. IE. After removal of the quasi-periodic ramp structure, the individual x-ray pulses appear as vertical steps with fluctuations in their arrival times. Trace A shows an average rate of arrival case. Traces B and C show temporary fluctuations from the average. Ramp subtraction leaves a negative slope between steps, but their amplitudes are not appreciably modified by this procedure and are to be recovered by the digital spectrometer. For CR preamplifiers, the ASC output would look much like

FIG. IC, except that the vertical scale would be adjusted to fill the ADC's entire input range. In this case the regions between the x-ray pulses have the same exponentially decaying slopes as the preamplifier.

2.4. ASC Specific Embodiment

FIG. 4 is a circuit schematic of the amplifier 30, subtractor 33, LFF generator 35, and variable gain amplifier 42 blocks of ASC 20. The circuit will be self explanatory to those skilled in analog electronics and needs little further discussion beyond a few design comments. Circuit details which are well known to those skilled in the art, such as power supply filtering or op-amp compensation, are not shown. The implementation are not unique and many other suitable arrangements can be readily devised.

Beyond centering the input signal in the ASC circuit's range, the primary function of amplifier 30 is to buffer the ASC from the input and ease noise requirements in the rest of the circuit by amplifying the input by a factor of about 3. It should therefore be implemented using a very low noise op-amp of adequate bandwidth.

The LFF generator 35 is a resettable current integrator, with offset voltage of £, designed to generate low noise, high accuracy ramps with settling times of less than 5 μs on reset. Resistor 68 converts a current from DAC 37 into voltage Q ££. Capacitor 72 integrates a current from DAC 38 until reset by switch 75. Resistor 77 assures that the slew rate of FET op-amp 65 is not exceeded. Op-amp 78 and switch 85 allow the amplitude and sign of LFF generator 35's output to be matched to the input. DAC 37 is usually adjusted so that the LFF generator 35's output and the signal from amplifier 30 match immediately after preamplifier resets.

The variable gain stage 42 comprises a switch 88 and resistors 90 for coarse gain into the 100 ohm fixed input impedance Analog Devices AD603 92, a voltage controlled, variable gain op-amp for fine gain. To

minimize noise, the fixed output noise op-amp 92 is only used for fine gain adjustments of about 12 dB.

The remaining blocks in the ASC section 20, a comparator 44 and a low pass filter 47, are straightforward to implement. The comparator is required to detect any occasions, see FIG. IE, when fluctuations cause the ASC output signal to exceed the range LL to UL which is mapped onto the ADC's input range.

The low pass filter 47 limits the ASC output signal's bandwidth to less than the Nyquist frequency, f N , which is half of ADC 48's sampling frequency, because all noise at higher frequencies will be "aliased" into the digitized output signal, unnecessarily increasing its noise. In this specific embodiment, the ADC operates at 20 MHz so f N is 10 MHz. While various filter designs could be employed, a 4-pole Butterworth filter is used in the specific embodiment because it has fast rolloff in frequency, minimum peaking in time and requires only four passive components. We have experimentally verified that, when the Nyquist criterion is met, spectrometer energy resolution is independent of sampling rate: embodiments operating at 2, 5, 10 or 25 MSA, with lowpass filters of 1, 2.5, 5 and 12.5 MHz respectively, all produced identical energy resolution for triangular filtering with 2 μs peaking time, even though the number of data samples collected in these cases varied from 8 at 2 MSA to 100 at 25 MSA. The several authors who have reported improvements in energy resolution with increased sampling rates have clearly failed to satisfy the Nyquist criterion. Selecting a sampling rate is therefore primarily a tradeoff between raising sampling rate to achieve good pulse pair resolution and lowering sampling rates to lower digital processing costs.

3. FiPPI; Filter, Peak Detection, and Pileup Inspection Circuit 3.1. FiPPI Design Philosophy

As discussed in the summary, the invention spectrometer carries out digital filtering in two stages. The first stage, designated the FiPPI, uses combinatorial logic to implement Filtering, Peak detection and Pileup .Inspection. In order to minimize filtering circuitry and maximize processing speed, no more complex operations than addition and subtraction are allowed in this stage. To optimize speed, all operations are pipelined to process input data at one point per clock cycle. Thus, if 0{n,j) is the jth operation required by data sample n, then at time step i, we simultaneously execute operations 0(n,l), 0(n-l,2), OJn-2 , 3) , etc.

This approach has significant limitations because compensatory adjustments cannot be made based on pulse-specific conditions and filters using only addition or subtraction are not accurate enough to meet our spectroscopic performance goals. Thus, as noted in the summary, in the second filtering stage a DSP is employed to make the specific corrections

(based upon preamp type, local operating conditions, etc.) required to achieve the desired accuracy.

This approach is advantageous for several reasons. First, the FiPPI can be both very cheap and very fast. For example, in the preferred embodiment, it is implemented in a single FPGA while running with a 20 MSA ADC. Second, the functions in the second step are only executed at the x-ray signal events' average arrival rate, which is much slower than the ADC sampling rate (e.g., 500,000 cps compared to 20 MSA). Because the required corrections are typically simple formulae, applying them only to captured peak values is both simpler and faster than making them on the data stream itself (through preconditioning or deconvolution) , as practiced in existing art. In the same embodiment, only a 20 MIP DSP is needed for second stage processing.

The FiPPI in the specific embodiment therefore implements only trapezoidal filtering, including triangular filtering as a subset. This choice does not degrade the spectrometer's energy resolution in the high count rate regime contemplated because, as Gatti and Manfredi showed in their paper entitled "Processing the Signals from Solid State Detectors in Elementary-Particle Physics" published in Revista del Nuovo Cimento (1986) Vol. 9(1), pp. 1-146, triangular filtering is actually the ideal fixed shaping form in the short shaping time regime where series white noise dominates. Even at longer shaping times the triangular shape is still very effective: Radeka showed in his paper entitled "Low Noise Techniques in Detectors", published in Annual Reviews of Nuclear Particle Science 38 (1988) , pp. 217-277, that even for maximum energy resolution a triangular filter's resolution is only 8% worse than an ideal cusp filter.

3.2. Specific Embodiment of the FiPPI, High Level View

In one specific embodiment, the FiPPI logic is implemented using a field programmable gate array (FPGA) . This allows a high logic density in a small space. Further, because the FiPPI's logic is downloaded from a file prior to operation, it can be readily modified, either to meet new conditions or to incorporate design improvements. In other embodiments, where lower costs or higher operating speeds are desired, the FiPPI can be implemented with an application specific integrated circuit (ASIC) or other logic circuitry.

The topology of the FiPPI 25 in a specific implementation is indicated in FIG. 5. The data stream enters on ADC output bus 50 and feeds into both a slow and a fast signal channel. The first slow channel circuit, a decimator 97, reduces the incoming signal's data rate by a preset factor. Its output is processed by a slow filter 98 which digitally implements trapezoidal filtering. Peak maxima in slow filter 98's signal output correspond to the energies of detected x-rays and can be captured by an output buffer 100. The operation of the slow channel is controlled by three parameters loaded into FiPPI 25 from DSP 27: a decimation factor 102 and the slow filter's length and gap values 103.

The fast signal channel's principal function is to inspect the data input stream 50 and trigger output buffer 100 to capture appropriate values from the slow filter 98. The first fast channel circuit is a fast filter 105, which also digitally implements trapezoidal filtering, but with a much shorter time constant than in the slow channel. A peak detector 107 inspects its output for peaks which exceed a preset threshold value for at least a preset number of consecutive samples and then captures the arrival times of these peaks' maxima. These arrival times define the associated x-ray events' arrival times and are used to time the trigger to the output buffer 100. Output pulses from the peak detector are inspected by a pileup checker 108 which rejects events whose maxima would overlap (pile-up) in the slow filter 98. Each time the pileup checker 108 detects a good peak it triggers output buffer 100 to capture the slow filter's 98 output value for export to the DSP 27 for second stage processing. Each peak detector 107 output pulse also increments an input count rate (ICR) counter 110. As in the slow channel, the fast channel's operation is controlled by parameters loaded from the DSP 27: the fast filter length and gap 112, the peak detector's threshold and minimum peak width test values 113, and the interpeak interval, fast peak maximum width, and timing offset values 115 required by the pileup checker.

Each time output buffer 100 is triggered it also captures two other values: the value in ICR counter 110 and a flag to denote what type of slow filter value was captured. The buffer therefore outputs four values to the DSP 27: two captured slow filter values PKVA 117 and UFVA 118, the number of x-rays PLOUT 119 since the last output, and a flag BLFLG 120 indicating whether PKVAL 117 is an x-ray amplitude value or a baseline value for normalization purposes.

The FiPPI's final circuit is a livetime counter 121, which measures the actual time TIME 122 the digital spectrometer spends collecting data. This is useful for two reasons. First, it is otherwise difficult to precisely time data collection processes started under software control by control computer 28. Second, in a multiple detector system it is important for each spectrometer to be able to accurately measure its own livetime so that its count rates can be accurately determined.

3.3. Operation of the Subcircuits in the FiPPI Specific Embodiment

The implementation and operation of the subcircuits in the FiPPI preferred embodiment are shown by the circuit schematics in Figures 6 through 13 with their accompanying representative signal traces. These circuits and traces will be largely self explanatory to those skilled in the art of digital electronics. In the following paragraphs we will primarily relate their functions and indicate any design issues which are not obvious

3.3.1. Decimator

Fig. 6A is a circuit schematic of the decimator 97, with representative signals shown in FIG. 6B, of a specific embodiment hardwired to decimate by 4. It comprises a clock divider 123 and an N value summer 125, which adds four consecutive values from 10 bit input line ADCBUS 50 and outputs their sum on the 10 bit line CS 147. If more accuracy is desired, more bits may be retained in CS. Using similar techniques, circuits which decimate by any arbitrary parameter D_Factor 102, may be readily built.

3.3.2. Slow Filter Module

The trapezoidal filter function values {T j _} of a stream of data values {d j _} at times {i} are given by the equation

I-L-G 1

Ti = " ∑ d k + ∑ d k (3) k=i-2L-G+l k=i-L+l

Here L and G are the slow filter interval length L s and gap interval G s and enter the module as Parameters 103. When the G s is zero, a triangular filter function is obtained. Both forms have been extensively discussed in the analog spectrometer literature. The trapezoidal function's amplitude can be made independent of charge collection time if the gap G s is adequately long, thus avoiding the phenomenon of ballistic deficit. Its signal to noise ratio for short shaping times is not as good as the triangular function's, however. In the present case the choice is set by the parameters S_Length and S_Gap 103.

To avoid long summations which consume excessive FPGA real estate and also operate slowly, Bqn. 3 can be recast as:

T i " T i-1 + d i " d i-L - d i-L-G + d i-2L-G (4)

Since the partial sum (d _L_ Q + --i-2l.-G^ s 3 ust the partial sum (dj_ - c*i-ιJ evaluated L g +G s timesteps earlier, we discover that it is possible to create T^ according to Bqn. 4 using only two first-in-first-out (FIFO) memories: one L g bits deep to hold values for making the terms (d j _ - d^. L ) and one L s +G s bits deep to hold values to implement Eqn. 4.

The circuit schematic in FIG. 7A and the waveforms in FIG. 7B describe an implementation of the slow filter module 98.that creates T^ values according to Eqn. 4 for a 10 bit input. The width of all the components in the filter would expand by 1 bit for each bit of decimation. The input CS[9:0] 147, from the decimator 97, has a slight slope both before and after a typical pulse to represent the effects of detector leakage current and/or the operation of the ASC 23.

FIFO memory 148 and subtracter 150 create the terms (d^ - d i- ^ ' wnere L is set by parameter PA[4:0] 152. FIFO memory 158 and

subtracter 160 create the terms (d^ - d^. j - (di_ L _ G + d i _ 2jJ _ ( 5) , where L+G is set by parameter PB[4:0] 162. Accumulator 168 then creates the values T^ of Eqn. 4 on line FS[ll,0l 173. Pipeline delays of 3 clock cycles are produced. The use of 12 bits in accumulator 168 is just an engineering tradeoff for XAS applications where only a narrow range of x-ray energies is expected and the ASC gain can be optimally set so one x-ray step is about 5% of the ADC input range. In a more general design an increased number of accumulator bits would be advantageous.

Thus a step function in C[9:0]) F[11:0] becomes a trapezoidal pulse whose rising and falling times 175 and 177 both equal the "peaking time" TPK, which equals L. Its flattop 178 has duration TGP, the "gap time," which equals G the difference between PA 152 and PB 162. The black dot on trace FS[11:0] in FIG. 7B shows the time t m when the pileup checker captures FS[11:0] to output buffer 100 if the peak is not piled- up. When CS[9:0] is also captured, this happens 3 clock cycles earlier to account for pipeline delays.

The output FS[11:0] 173 has a non-zero baseline which is proportional to the slope in signal CS[9:0] 147. Thus, peak amplitudes must be measured with respect to the baseline, which must therefore also be determined accurately. Also, when the slope in CS[9:0] is not constant in time (as for a DC preamplifier) , then the baseline will have to be measured locally for each detected x-ray pulse.

The combination of decimator 97 and slow filter 98 allows peaking times of up to 400 samples (20 μs for a 20 MSA ADC) using FIFOs which are only 32 deep and a 12 bit accumulator, whereas a direct implementation would require 400 deep FIFOs and an 18 bit accumulator. Not only does this require fewer FPGA gates, but shorter word lengths allow the circuit to run fast enough using a cheaper grade FPGA than would otherwise be the case.

3.3.3. FIFO Specific Implementation

FIGS. 8A and 8B show a circuit and waveforms of a specific implementation of FIFO 148, using a Xilinx 4000 series FPGA for g equal to 3. The other FIFOs in the design are implemented similarly. Ten 32 bit deep memories (one per data bit) are cyclically addressed by a cyclical address counter 185, whose output QC is out of phase with the clock 128. The Xilinx memories therefore display their stored data O[9,0], which are captured by buffers 188, when first addressed by QC. These values are then overwritten by new values of C 147 as the clock goes positive. Thus a read and a write are accomplished in a single clock cycle, with the output values delayed from the input by PA 152 counts.

3.3.4. Fast Filter

The fast filter 105 is implemented in exactly the same way as the slow filter except that it has its own control parameters F_Length and F_Gap 112 and works directly with the 10 bit output 50 of the ADC 48. Its

peaking time and gap length, from Eqn. 4 are written as L f and G f , the subscript f signifying "fast."

3.3.5. Pileup Inspection 3.3.5.1. The Meaning of Pileup

To understand pileup inspection, one must understand how the slow filter 98 and fast filter 105 pulse outputs change as a function of the time interval between consecutive input pulses FIGS. 9A-9G present this information, showing superimposed fast filter 192 and slow filter 193 output traces as the time between two input pulses decreases. Provided the two peaks are adequately separated (FIGS. 9A-9C) the amplitudes of the slow filter peaks remain valid measured of the x-ray energies. At shorter times these peaks merge and must be rejected. The minimum allowed separation is when the second pulse begins (corrected for pipeline delay) one clock cycle after the first peak is sampled. Otherwise the two pulses are piled up. As the interval between the pulses continues to decrease, the fast pulses will also eventually overlap, and pile up as well (FIGS. 9E-9F) .

3.3.5.2. Peak Detection

The first issue is to detect pulses which is the function of the peak detector 107. The preferred implementation offers improved performance over classical discriminators which have timing jitter and do not operate well for pulse amplituded close to the noise floor. Here, as shown by the circuit and traces in FIGS. 10A-10B, a threshold level 195 is set by a parameter PC 207. However, signal values FF 205 are only recognized as a peak when they exceed the threshold at least a minimum number min_width 113 (set by parameter PD 208) times in a row. Under this condition the signals RFP 223 and SFP 225 are generated. RFP lasts as long as FF continues to exceed the threshold. The values of both the threshold 195 and min_width 113 may be adjusted to increase noise immunity when working with soft x-ray pulses which do not rise far above the noise floor.

3.3.5.3. Arrival Time Determination

The second issue is to determine pulse arrival times, which is the function of Block 240 of Pileup Checker 108, as shown by the circuit and traces in FIGS. 11A-11B. Here the fast peak's location is determined not by its crossing of threshold 195, but by the time T3 196 of its maximum value. Whenever RFP 223 is high, this block compares FF 173 to previously captured maximum values in buffer 250, setting FTOP 255 high each time a new maximum is found. Arrival time locations TS 196 are now essentially amplitude independent, greatly reducing time jitter and removing any energy dependent skewing of slow channel peaks amplitude determinations.

3.3.5.4. Slow Peak Amplitude Capture

Once a peak is detected, the FiPPI must determine if it is free of pileup and, if so, capture its amplitude in the slow channel. The actual capture is carried out by the Output Buffer 100, which is shown in more detail in FIG. IIA and is triggered by the signal PSAM 298.The timing of slow peak amplitude capture is conceptually straightforward, as shown in FIG. 9A. The desired capture time T4 198 is at the trapezoid's flattop midpoint. Because the digital processing operations in both fast and slow channels are fixed in number, T4 198 is separated from the fast peak's arrival time T3 196 by a constant time TS 194, which depends only on such FiPPI control parameters as D_Factor 102, S_ ength and S_Gap 103, and F_Length and F_Gap 112. Thus, following fast peak detection, a counter can measure time TS 194 and transfer the slow filter 98 output transferred to buffer 100.

3.3.5.5. Slow Channel Pileup Inspection

The pileup inspection implemented digitally in the FiPPI is conceptually similar to that commonly found in analog spectroscopy circuits: requiring that successive pulses must be separated by some multiple of the slow channel peaking time. In the case of analog triangular filtering, a multiple of 1.5 - 2.5 is commonly used. As FIG. 9A shows, for truly trapezoidal filtering, successive pulses need only be separated by a single slow filter peaking time plus half the flattop time. The fact that analog "triangular" pulses have tails that extend significantly beyond one peaking time on the decaying side of the peaks is the source of their extended inspection times. Digitally generated pulses terminate cleanly, as shown in FIG. 7B, allowing shorter pileup inspection times to be used. Resulting increases in count rate capability of 2 or more have been demonstrated. The trailing edge pileup inspection is carried out by block

243 in the circuit shown in FIG. IIA with traces shown in FIG IIB, which measures the time intervals between adjacent terminations of the signal FTOP 255. A falling FTOP signal, which marks a fast peak maximum and thus its arrival time, starts the Interval_l Counter 260, which is loaded with the parameter PF 268, the pileup inspection period. If the counter overflows successfully and the value stored in FF16 265 shows that the pulse does not have leading edge pileup, then a signal is issued to a second interval counter block 245 which finishes counting the time TS 194 at which the slow channel peak should be captured. The Interval_2 counter is required to accommodate pipeline delays in the slow filter, which may be running with a decimated clock.

When Interval_l counter 260 overflows, it is restarted and Pass_Cnt counter 261 is incremented. If Interval_l counter 260 overflows a second time, it means that the interpulse period has been long enough for the slow filter output to return to baseline. Under this condition, if the DSP 27 has set the flag BLCOL 315, then Interval_2 counter 245 will

be triggered to initiate a baseline capture. The bit BL 278 is captured by buffers 100 as the output value BLFLG 120 to signify this condition.

Whether or not a peak is free of leading edge pileup is determined by flipflop FF16 265, which stores the value of Pass_Cnt counter 261 each time a new fast pulse is detected, as signaled by the signal SFP 228. If this value is 1, then a time of at least PF 268 has passed since the last pulse.

When the unfiltered output CS (see FIG. 7B) is required, it must be captured 3 slow clock cycles before time T4 198, which is before Interval_l counter has actually determined if the peak will be valid.

This time is therefore determined by comparator CMP23 262, which causes the appropriate value of CS to be captured to an intermediate buffer 307, where it can be transferred to Output Buffer 100 if the peak is valid.

3.3.5.6. Fast Pileup Test

A first fast pileup test is implemented by block 242 in FIG. IIA, which measures the width of the fast pulse a the threshold value 195. As FIGS. 9E-9F show, if this value TW is more than a maximum value TM 200, then there must be pileup in the fast channel and the slow channel peak value will be invalid. This result, when detected, is stored in flipflop FF16 265, which prevents the slow peak capture. Because both the parameter TM and the threshold can be adjusted on a case by case basis, this is a very effective test when coupled with our fast peak detection circuit. With quasi-monochromatic x-rays, as in XAS, the parameters can be tuned to achieve pileup rates which can be up to 3 orders of magnitude lower than with conventional analog tests.

3.3.5.7. Input Countrate Counter and Timer

The circuit and traces in FIGS. 12A - 12B show an embodiment of the FiPPI 15 input count rate counter 110 (see FIG. 5) . This circuit uses the fast pulse arrival signal SFP 228 and the output Q10[0] 270 of Pass_Cnt counter 261 to record the total number of x-ray pulses detected for each valid x-ray pulse detected. Its output NSFP 340, can be read by DSP 27 at the same time as it reads buffers 100. The circuit in FIG. 13 shows an embodiment of the FiPPI 15 live time counter 121 (see FIG. 5) . This circuit counts a divided clock signal at all times that the DSP 27 signals, via C_Enable 373, that it is in data collecting mode.

3.3.5.8. Optional Fast Pileup Test

A second fast pileup test can be additionally implemented according to the circuit and traces shown in FIGS. 14A - 14B. This circuit measures the width of the fast peak at one half of its maximum. Other ratios could be readily substituted. The Inspect_l counter sets the inspection period PL 362 while the Half_Width counter 357 compares the peak width to the maximum allowed value PK. The fast pulse signal FF

173 is delayed PJ 358 counts by FIFO10 353 until Q7 251 has a chance to attain its maximum value. If the fast peak is piled up according to this test, output MWIDl 367 can be used to set flipflop FF16 265 to prevent the slow peak capture. This test works particularly well when pulses with a wide range of amplitudes are present, preventing the fast pulse and pileup tests to be optimized for low amplitude pulses where the threshold may be a sizable fraction of peak amplitude. In this case there may be quite a wide range of times over which two low amplitude pulses can pile up and still have the sum of their two widths be less than the base width pileup test value.

3.3.6. Optional Output Buffering

Although the circuitry is not shown in this specific implementation, we have found it to be advantageous, in systems designed for the highest counting rates, to replace the three output buffers 100 by three short FIFOs, each capable of storing several captured values. This modification allows the DSP 27 more flexibility in how it collects captured peak values from the FiPPI. In the preferred implementation shown, the DSP operates under interrupt control, pausing in its computations to fetch a captured value in less that 0.5 μs each time one is signaled. While this system uses fewer FiPPI circuit resources, it requires more, and on average slower, DSP code to service the interrupt routines. With the optional FIFO output, the DSP can poll the FiPPI for data at a fixed point in its processing routine and never be interrupted, which increases its average processing speed. This implementation is therefore preferred when the very highest data rates must be accommodated.

We have modeled this operation and found that, if the DSP 27 polls DSPFLAG 302 at least once per event it processes, and is fast enough to process events at their average rate, then this buffer need only be about 4 events deep to capture the vast majority of all events.

4. DSP; Digital Signal Processing Computer and Logic 4.1. DSP Overview In accordance with our design philosophy, the DSP carries out those tasks, procedures, and computations which are required either on a "per event" basis or less often, to maintain system level operations. As shown in FIG. 2, the DSP 27's major tasks include interacting with the general purpose control computer and interface 28, adjusting and controlling the ASC 23, and collecting, correcting and histogramming data values from the FiPPI 25. In the general practice of the invention, these functions could be met by a wide variety of combinations of processor and memory, the choice in any particular embodiment being primarily an engineering decision based on such considerations as cost, speed, size, and so forth.

4.2 . DSP Hardware Implementation

An NEC μPD77016 processor is used in the specific embodiment. It was selected because it is a fast, low cost, 16 bit DSP with enough internal memory to hold both its control program and the spectra produced by its MCA function. Its 2.0 K X-data memory is dedicated to MCA spectra, allowing spectra to be histogrammed into up to 1024 bins, each 32 bits (or more than 4 billion counts) deep. Its 2.0 K Y-data memory stores the variables and constants required to control system operation; data to monitor system performance; and a circular buffer to temporarily store FiPPI events for MCA processing. Internal memory is not necessary for the invention but reduces total package count and cost and may allow higher speed operation. Executing instructions at one half its externally applied clock frequency, the DSP is clocked at exactly twice the rate of the ADC and FiPPI, to produce synchronous operation of one instruction per ADC sample. It has 4 external interrupt lines, which allow it to respond to the ASC 23, FiPPI 25, and external control computer 28.

The general issues associated with programming and interrupting microprocessors and DSPs are well known to those skilled in the art and will not be described in any detail. General flow charts of the control programs will be shown and attention will concentrate on the specific algorithms which have been invented to produce the desired instrument function.

4.3. DSP High Level Software Descriptions 4.3.1. Supervisory Control Program

FIG. 15 shows a high level flow chart of the supervisory control program used in the specific embodiment. Bold arrows trace the flow of program control through a single data collection cycle. Operation begins by downloading the DSP's program and Initialization 380, including setting up registers and initializing constants in Y-data memory. The program then proceeds to its primary control loop, the CAMAC Monitoring Task 382. in the specific embodiment the control computer interface was implemented using the CAMAC interface standard, IEEE Standard 583-1975, but this choice is not critical to the invention's function. In the CAMAC Monitoring Task 382 the DSP is essentially in a loop, waiting to be interrupted.

Data transfers to and from the DSP are initiated by the control computer 28 through its interface to the digital spectrometer 22. The details of implementing such interfaces are well known to those skilled in the art. These requests for data transfer cause the interface to generate a Transfer Interrupt 383 to the DSP. When such a Transfer Interrupt 383 is received, the DSP moves to Transfer Data To/From DSP 385. Here it reads two status registers in the interface 28 and uses their contents to determine whether it should transfer a data word to a DSP memory location from an interface register or vice versa. It makes the requested transfer and then to the CAMAC Monitoring Task 382. Multiple

word data transfers are similarly implemented using the DSP's block data transfer mode at rates up to 2 MBytes/second.

Before the digital spectrometer 22 can be controlled effectively, it requires the values of various constants and control parameters which must either be downloaded from the control computer 28

(e.g., the FiPPI 25 filter lengths) or be determined experimentally (e.g., a Slope DAC 38 estimate) by calibrating the system. Of particular note is the control word RUNTASKS, which is a set of flags to control DSP program flow. When an Acquisition Interrupt 387 is received, Acquisition Type 388 is determined by testing RUNTASKS.

4.3.1.1. Test/Calibrate Routines

If Acquisition Type is Test/Calibrate 390, the DSP executes Test/Calibrate Routines 392, which are used to verify correct system operation and calibrate the DAC controls to the ASC. They include:

1) Write to Bias 32, Offset 37, Slope 38, and Gain 43 DACs to set the operating point of the ASC 23.

2) Measure overall system gain by first disconnecting the input to spectrometer 22 and then recording the output of ADC 48 for a series of voltage values applied to Op Amp 30 using Bias DAC 32. A fit to the results yields ADC units per Volt input, which is just the digital spectrometer's gain. This can be multiplied by the preamplifier gain in Volts per eV of x-ray energy to obtain overall system gain in ADC steps per eV. If the preamplifier gain is not known, a measurement of a known x-ray energy can be made to provide this constant.

3) Calibrate Offset DAC 37 in ADC units, by the same process as in routine 2) above, to obtain the normalization constant DACperADC, the number of Offset DAC steps required to change the ADC output by one step. 4) Calibrate the slope generator by setting known values into the Slope DAC 38 and measuring the time required for the generated signal to go out of the ADC input range. Slope depends only on the current input from Slope DAC 38 and the size of the integration capacitor 72, thereby providing a good secondary test of the DACperADC value. 5) Test ADC differential and integral non-linearity using the ASC's slope generator as a controlled input waveform.

6) Monitor ASC interrupts without acquiring spectrum data.

7) Capture ADC output signal traces with DSP. This mode, in which the ADC-DSP combination essentially operates as a simple digital oscilloscope, can be particularly useful for debugging detector problems by allowing representative signal traces to be captured.

8) Capture FiPPI Decimator output values C[9:0] 147. This has the same utility as routine No. 7, but works with the slower Decimator outpu . 9) Verify correct operation of the entire spectrometer by first disconnecting the spectrometer's 22 input and then collecting a

spectrum using voltage steps output by Bias DAC 32 to simulate input x-ray signals. The output spectrum should be a single narrow peak whose location is a direct measure of the overall system gain and whose width measures the spectrometer's noise. This test is a valuable diagnostic that the complete instrument is operating correctly for the selected digital filter parameters.

These tests allow the invention digital spectrometer to be both self testing and self calibrating and are also useful for quality control tests in manufacturing. In normal operation, the control computer 28 runs a test suite of these programs to assure that the spectrometer is operating correctly prior to attempting to collect data.

4.3.1.2. Data Acquisition

When the Acquisition Interrupt Type is Data 393, then the DSP moves to the Start Data Acquisition Routine 395 and executes the following tasks to prepare for data acquisition (assuming a reset type preamplifier) .

1) Set the ASC's Bias DAC 32, Offset DAC 37, Slope DAC 38, and Gain DAC 43 to specified values determined by the x-ray energy range, characteristics of the preamplifier, and initial rate estimates.

2) Reset the MCA data and statistics to zero.

3) Write control parameters Decimation Factor 102, Slow Filter Length and Gap values 103, Fast Filter Length and Gap 112, Peak Detector Test Values 113, and Pileup Checker Values 115 to the FiPPI and restart FiPPI operation.

4) Initiate ASC monitoring by observing ADC values versus time, with the slope generator disabled. Estimate ramp slope in the preamplifier signal and compute a Slope DAC 38 value to match it. Then load the reset value into Offset DAC 37 and enable the slope generator 35. 5) Enable the ASC Comparator Interrupt to interrupt the DSP if the ASC's 28 output signal exceeds the ADC's 48 input range.

6) Collect an initial set of slow filter baseline values and compute baseline mean and variance.

7) Set up pointer values to a circular event loop buffer in DSP Y-data memory to prepare for receipt of FiPPI data.

8) Enable FiPPI interrupt signal DSPFLAG 302 allowing the FiPPI to signal the DSP when it captures a valid peak amplitude.

4.3.1.3. Data Acquisition Task If any of these procedures fail, the program aborts, otherwise it proceeds to Data Acquisition Task 402. This task is designed to accommodate bursts in data arrival rate up to 2,000,000 cps (which is the inverse of the minimum 0.5 /xsec slow channel peaking time) while processing data at average rates of up to 500,000 cps. This is accomplished by storing incoming data in a circular buffer, which is a fast process under interrupt control, and processing them at a steady rate

in the intervals between interrupts. This reduces the average processing rate by a factor of about 4 and allows the use of a much less expensive DSP.

Capture FiPPI Data Routine 405 carries out the data capture step. Here the DSP reads two 16 bit words from the FiPPI containing the values PKVAL 117, UFVAL 118, BLFLG 120, and PLOUT 119. It then writes these two words onto the circular buffer, and increments the pointer to their address. These operations require only 5 or 6 clock cycles. Control then returns to the Data Acquisition Task 402 to processes any data remaining in the circular buffer. This continues until either a preset maximum number of events are processed or until a Stop Data Acquisition 407 occurs. In either case, the program proceeds to Finish Data Acquisition 408, whose primary functions are to disable the ASC Comparator Interrupt 45, disable the FiPPI interrupt 302, finish processing any remaining data in the circular buffer, and record the value in the livetime counter 121. The program then returns to the CAMAC Monitoring Task 382, where the collected data can be unloaded.

The Data Acquisition Task 402 can also be interrupted by ASC Interrupt 410 at any time the ASC 23 output exceeds the input range to ADC 48, forcing a branch to the Fix ADC Out of Range Condition 412 routine, as described below. Once correct ASC operation is restored, the program returns to processing data in the circular buffer.

4.3.2. Data Acquisition Task Software FIG. 16 shows a flow chart of a specific embodiment of the

Data Acquisition Task 402. For the most part, this chart will be self explanatory to those skilled in control computer programming. Beyond general comments, our discussion will center on the steps which are unique to the invention spectrometer function. The program is essentially a loop which processes date from the circular buffer until it is halted either because test NEVENTS = MAX? 463 is true or until an appropriate value of RUNTASKS is found in the test RUN ENDED? 440. Once every 256 times around the loop and independent test of the ADC condition is performed and a baseline estimate is collected from the slow filter to UPDATE BASELINE ESTIMATE 438, which will be discussed further below. The number 256 is not critical and was selected so that the baseline would be updated often enough to track changing experimental conditions but not so often that it represents a substantial computation burden within the Data Acquisition Task 402. In the processing loop, once data from a good event have been read from the buffer 452, the total number of events is incremented 453 using the value PLOUT 119. Total counts can be divided by the recorded livetime to obtain a true Incoming Count Rate estimate. Statistics on PLOUT values can also be collected and used to monitor for incorrect experimental conditions such as excessive flux. The DSP then performs the computations and corrections, for distortions from the ASC 23 and

otherwise, required to compute an accurate x-ray energy 455 from the captured slow filter values PKVAL 117 and UFVAL 118. The algorithms selected must be appropriate for the detector-preamplifier combination to which the invention spectrometer is connected. This is an inventive step and will be described further below. Once the energy has been found, it can be scaled to compute a multichannel analysis (MCA) bin 458 and that bin incremented 460 to generate a histogram of the detected x-rays' spectrum using techniques well known to those skilled in the field.

4.4. Spectrometer Control and Computation Algorithms

Because the present invention digital spectrometer system comprises three linked modules: the ASC 23, FiPPI 25 and DSP 27; several novel algorithms are required to control them effectively. These will be described in the following sections.

4.4.1. Fixing ADC Out of Range Condition

The essence of this problem is that fluctuations in input counting rate can cause the output of the ASC analog subsection 23, which is the amplified difference between the preamplifier input and the LFF function generator 35, to temporarily fall outside the input voltage range to ADC 48 (i.e., the range LL to UL in FIG. IE) . This is illustrated by FIGS. 17A and 17B. FIG. 17A shows the most common cases, where temporarily high rate (trace B) or low rate (trace C) return to the average rate (trace A) . Because x-ray arrivals are truly random, however, some small fraction of cases will appear as in FIG. 17B, where high

(trace D) or low (trace E) arrival rates persist long enough to exceed the ADC's input range LL to UL. This invalidates the FiPPI's 25 data stream, requiring the DSP 27 to take corrective action. It does so by adjusting the signals to LFF generator 35 control DACs 37 and 38 until the ASC's output signal returns to the ADC's input range. FIGS. 17C and 17D show two examples where DAC 37 is adjusted. The types of fluctuations which are commonly encountered include preamplifier resets, cosmic ray events in the detector, and statistical fluctuations in the rate of arrival of x-rays to the detector. The algorithm shown in FIG. 18 is designed to deal with these situations in a rapid and efficient manner and, in the preferred implementation, typically restores proper operation in less than about 2 μs. With the following few comments, this algorithm will be clear to those skilled in computer programming. The action boxes "Move Down l" 495 and "Move Up 1" 504 refer to adjustments by DAC 37, where a "unit" step is the number of DAC bits required to move half way across the ADC input range, as shown in FIGS. 17C and 17D. The box "Reset" 498 means that a preamplifier reset has been detected and requires the LFF generator 35 to be reset as well, using switch 75 and returning DAC 37 to its standard value. The box "If ABS(FLAG) = 1, Update Tracker" 511 means that a simple

drift out of range was detected, as shown in FIG. 17B, and the slope tracking algorithm described in the next section should be invoked.

4.4.2. updating the Slope DAC 38 Setting Estimate When Slope DAC 38 is set correctly, then, on average, out-of- range excursions should be equally likely in the Hi and Low directions. But if the incoming x-ray rate changes, then the Slope DAC will need to be adjusted. Therefore, each time the program calls the Fix ADC Out-of-Range Condition 412 routine it notes whether the excursion was in fact Hi or Low and determines whether the Slope DAC setting needs to be adjusted.

Thus, each time "Update Tracker" 511 is called, a weight W is updated which, in the specific implementation, has an exponentially decaying memory of past Out-of-Range conditions, according to the formula

Wi = ((N-lJ NJWi.i + V ± /N (5)

where V^ equals +1 for Hi and -1 for Low Out-of-Ranges. j _ is then tested and, if it exceeds a test value V, it is zeroed and the Slope DAC 38 is adjusted by one bit in the appropriate direction. Otherwise nothing is done and the program moves on. Other equations, such as running averages, could be used to compute W j _, but equation 5 is efficient in that require only minimal storage and computations.

4.4.3. Computing Energy From Pulse Height Amplitudes 4.4.3.1. Periodic Reset Preamplifier Case

Some computation is required to convert the FiPPI 25 output value PKVAL 117 to an x-ray energy without introducing systematic errors, primarily because the regions just before and just after the x-ray step in the ASC's 23 output are not flat, as in FIG. IB, but are tilted, as in FIG. IE. There are two contributions to this tilt for periodic reset preamplifier: .first, because the ASC 23 has subtracted off the ramp generated by the LFF generator 35; second, because of leakage currents from either the detector or the preamplifier's first FET.

The FiPPI's 25 response to this sloped signal is indicated in FIG. 19A (for the PR preamplifier case) . While the amplitude A is desired, the FiPPI produces the value H, which is the difference between the two shaded regions above and below the edge. Computation is therefore required to recover A from the measured value H. FIG. 19A shows that, for a slow filter length L s with a gap time of G g :

H = V 2 - V T = A - S(L S +G S ) (6)

where V 1 and V 2 are the average voltages over the shaded filter regions and S is the difference slope between the generated slope S g and the leakage slope S-^. Thus:

A = V 2 - V j, = A - (Sg-S i ) (L s +G s ) (7)

We thus wish to obtain a precise estimate of the second term, which would otherwise degrade the spectrometer's energy resolution. L g and G g are parameters and are known exactly, as is the generated slope S σ . Si must be measured, which can be done using measurements according to Eqn. 7 when A equals 0, i.e., when no x-ray events are present anywhere within the filter. Now H equals - (S g - S-^) (L g +G s ) and is the "baseline" between triangular pulses. By making many measurements, we can estimate the mean baseline value B to arbitrary precision:

B = <S 1 (L S +G S ) > = <PKVALB + S g (L s +G s ) > (8 )

where PKVALg are values of PKVAL 117 obtained from the FiPPI when the flag BKCOL 315 set to 1 , as described earlier . Given B, we can compute an x-ray' s energy from:

E = G (PKVALN + S g (L s +G s ) - B) (9)

where G is the system gain and these are normal values of PKVAL, i.e., with flag BKCOL 315 set to 0.

The baseline B must be determined with sufficient accuracy so that it does not affect the spectrometer's resolution. Since, in Eqn. 9, the variances σ p and σ B of PKVAL and B add in quadrature, σ B should thus be of order l/io σ p and B should be determined from an average of approximately 100 measurements of PKVALg, assuming Gaussian distributed errors.

The determination of B in the preferred embodiment proceeds in two steps. First, in task no. 6 of the Start Data Acquisition Routine 395, 100 measurements of PKVALg are made and then their average B and variance σ B are computed. This provides an accurate starting value of B. Second, in Data Acquisition Task 402 (FIG. 16) B is updated once every 256 loops in procedure Update Baseline Estimate 438. While various running averages of B could be computed, in the specific embodiment

Bi = ((N-D/NJBi.- t + bi/N (10)

is implemented to provide an exponentially decaying past history, where b is the currently measured value of PKVAL B + S B (L g +G s ) . This is efficient because only the current value of B has to be stored and it can be carried out very rapidly on a fixed point DSP using shift instructions if the

ratios are powers of 2. Experience shows that even fairly rapid changes in B can be accurately tracked by this technique. If B is expected to change very rapidly, the NLOOP Modulo 256 = 0 Test 428 value 256 can be reduced to sample the baseline more often.

4.4.3.2. Continuous Discharge Preamplifier Case

For a CD preamplifier, the signals on both sides of the x-ray step event are decaying exponentials with different average slopes, as shown in FIGS. 19B and 20. The situation is therefore more complex than for a PR preamplifier and requires a modified algorithm to replace Eqn.9. No changes in either spectrometer hardware or FiPPI firmware are required, however.

FIG. 20 shows the situation. We desire amplitude A, but capture value H, the difference between the running averages <V 2 >, captured 0.5(L g +G s ) after the pulse, and <V 1 >, captured 0.5(L g +G s ) before the pulse. S 2 and S^ are the signal slope at the two measurement points, V e its value at time t e instantaneously before the x-ray event, and V Q the value to which it decays exponentially. We define the constant K by K = (L s + G g )/2r, where T is the preamplifier's exponential decay time. The exponential decays are then:

V = V 0 + (V e -V 0 )exp((t e -t)/τ) for t < t e , and

V = V 0 + (V g +A-V 0 )exp(-(t-t e )/τ) (11) for t > t e , and s ι = (Ve-Vo)r- 1 exp((L s +G s )/(2τ)) = - (V^V Q ) ^ , S 2 = (V g +A-VoJT "1 exp(-(L s +G g )/(2r)) = (12) We can approximate H by:

H = A + (S 2 +S 1 ) (L s +G s )/2 = A + (S 2 +S 1 )K r. (13)

The slopes S-^ and S 2 , to the same accuracy, are:

T S χ = "(V i -Vo) = -(V g -S^K-Vo), or S j . = (V e -V 0 )/(τ(l-K)) and: (14)

S 2 = -(V g +A-V 0 )/(τ(l+K))

Substitution into Eqn. 13 gives:

H = A/(l+K) - 2K(V e -V 0 )/[(l+K) (l-K)] (15)

where neither V e nor V Q is a measured variable. We can obtain an estimate for V e by measuring the instantaneous voltage at any point. For

mathematical simplicity, we choose the point V 2 , at time (L g + G s )/2, where:

V 2 = (V e +A-S 2 τK) = V e +A-(V g +A-V 0 )K/(l+K) , so (16)

V e = (1+K)V 2 -A-KV 0 . (17)

Substituting into Eqn. 15 gives:

A - H(1-K)+2KV 2 -2KV 0 (18)

where H and V 2 are measured quantities and V Q is nominally a constant. A can be scaled by the system gain G to obtain the x-ray energy just as in Eqn. 9. Estimates of 2KV Q can be obtained by measuring values of A when no x-ray is present. 2KV Q plays exactly the same role in computing A values in Eqn. 18 as the baseline B does in Eqn. 9 and the same algorithms can be used to accurately estimate its value. Any linear slope terms arising from detector leakage current will also fall into this term.

Implementing the CD preamplifier correction, is therefore implemented in the DSP's 27 code, with Eqn. 9 being replaced by:

E = G[(1-K)PKVAL + 2K(UFVAL-<V 0 >) ] (19)

and the individual values of V Q used to compute <V Q > are found from

V 0 = [ (1-K)PKVAL/(2K) - UFVAL] A=0 . (20)

4.4.3.3. Alternate Continuous Discharge Preamplifier Case

A noise analysis shows that, Eqn. 19 suffers from excess noise when the value of K is not small (i.e., the filter time approaches the preamplifier decay time) . This is both because the noise in PKVAL decreases as the filter length increases and because the weight K of the unfiltered term UFVAL increases. For a typical preamplifier decay time of 50 μs, resolutions at 4 μs filtering are only degraded a few percent, while at 20 μs noise will increase almost 90%. The issue, then, is to get a statistically more accurate value of V 2 to use in Eqn. 18. By recognizing that <V 2 > is the most accurate measurement of V 2 we can make, and noting that H is just <V 2 >-<V >, we can derive an alternative correction by substituting S 2 and S-_ from Eqn. 12 into Eqn. 13 for H, noting that H = <V 2 >-<V 1 >:

H = A - K(V 2 +V χ ) + 2KV 0 = <V 2 > - <V χ > (21)

Replacing both V 2 and V-^ by their average filtered values <V 2 > and <V χ> , and rearranging gives:

A = <V 2 > (K+1 ) - <V 1 > (K-1) - 2KV 0 ( 22 )

as a replacement for Eqn. 18, wherein all terms are now as statistically accurate as possible. Implementing Eqn. 22 requires a modified FiPPI slow filter design, as shown by the schematic and traces in FIGS. 21A and 21B, which should be compared to FIGS. 7A and 7B. This circuit produces the running average V 2 and then uses a FIFO to produce V 1# which is just the same signal delayed appropriately. Since decimation by 4 bits will typically be required for the long shaping times of interest, the input signal CS[13:0] 527 is now 14 bits wide. The FIFO 528 length is set by the parameter PA[4:0] 152 which is L.. D 532 has only 12 bits on the assumption that no x-ray pulse will exceed 1/8 of the ADC's input range; otherwise the number of bits in D and following stages may be increased. The delay between V 2 and V-^ is equal to L s +G s and is set by parameter

PB[4:0] 162 to FIFO 537. V 2 and V χ are captured in the output buffer 100 by the action of the Pile-up Checker 108 exactly as described above, with V2[16:0] 535 output as PKVAL 117 and VI [16:0] 538 output as UFVAL 118.

Because the FiPPI is implemented in a field programmable gate array (FPGA) in the preferred implementation, choosing between Eqns. 18 and 22 does not physically change the spectrometer but only changes the FPGA's download file and the DSP's software.

Because Eqns. 18 and 22 were derived based solely on the nature of decaying exponential curves and independently of the presented digital implementation, they can also be implemented by analog means.

Thus, by DC coupling a CD preamplifier to an analog spectroscopy amplifier with triangular shaping and baseline correction and using the amplifier output as H in Eqn. 18 and a time delayed copy of the amplifier input as V 2 , then a signal is generated which is corrected for Instantaneous baseline shifts resulting from the exponentially decaying signal, eliminating the need for pole-zero compensation which is required in AC coupled systems.

Eqn. 22 can also be implemented using analog circuitry, as schematically indicated in FIG. 22. This circuit comprises a direct analog translation of the digital circuit shown in FIG. 21A, as will be clear to those skilled in the art of analog electronics, coupled to an op-amp summing circuit 552 to implement the sum of V 2 and V- ^ . The correction for VQ would be supplied in practice by adding a baseline restoration circuit to the output of the circuit, as is well known to those skilled in the art. This circuit may offer substantial advantages over existing approaches when high input rates and short shaping times are desired, particularly within the time regimes where analog delay lines are easily implemented.

Conclusion

In conclusion it can be seen that the present invention provides a physically compact, low cost, high speed method and apparatus for processing the pulse signals from a detector-preamplifier system and providing a complete energy analysis of the radiation impinging on the detector. Combinatorial logic is used to perform a limited, but sufficient amount of processing at the sampling rate, while a programmed processor is used to carry out the more refined analysis at the event rate. This division of labor allows the invention to achieve high performance and low cost.

While the above is a complete description of specific embodiments of the invention, various modifications, alternative constructions, and equivalents may be used. As a first example, while the specific embodiment employs a signal conditioning front end to reduce the number of ADC bits required, the operation of the rest of the invention is not dependent on this construction. If cheaper, faster ADCs with more bits became available this section might be eliminated. Further, while it is cost effective to use a single digital signal processor to implement the various computations required in the invention, these computations could be distributed between multiple microprocessors and, in certain applications this might be more effective (e.g., when higher total count rate capability is required) . Therefore, the above description should not be taken as limiting the scope of the invention as defined by the appended claims.