# 05dec08

Computing the register levels
Plotting the bandpass and rms for 16 bits, standard register settings

# Computing the register levels

The pdev spectrometer has a number of parameters that configure the processing pipeline (see layout of spectrometer scaling). This page discusses how they should be setup. It starts at the A/D  input and works it way back towards the power accumulation and output.

 location in pipeline Setting A/D input 1 sigma=30 a/d counts butterfly down shifts(pshift) 9 down shifts then alternate each butterfly stage. DSHIFT=0 no down shift at output of power Computation before power accumulate. ASHIFT upshift 40 bit accumulator before taking upper 32,16, or 8 bits for output.

## A/D input:

• pdev uses a 12 bit A/D converter.
• The input level for the a/d should be set so that 1 sigma is around 30 a/d counts.
• There is some digital scaling of the number between the a/d output and the butterfly stages (polyphase fitler bank (.75).

## Butterfly down shifts (pshift)

• Each fft will have alog2(fftlen) butterfly stages.
• Each stage has a multiply and add using 18 bit registers.
• At each stage noise increases by sqrt(2) because of the adds (sine waves increase by 2).
• You need to down shift every two butterfly stages to guarantee that the noise does not overflow.
• The down shift occurs prior to the stage. Downshifting the first stage divides the input voltage by 2 before the multiply and add.
• Place the original 12 bit number in the upper most 12 bits of the 18 bit number. This lets you down shift in the first 6 butterfly stages without losing precsision. These 6 stages will see the noise grow by 2^3 so you can do an additional 3 more down shifts giving a total of 9 down shifts before worrying about underflow.
• If the fftlen is longer than 9 butterfly stages (512) then begin alternating the down shift every other stage after the nineth.
• The butterfly computation has the largest problem with dynamic range. Noise increases by sqrt(2) every butterfly stage while tones (radars) increase linearly with each butterfly stage. If an overflow occurs in the butterfly stages the spectral features are generated throughout the spectrum.

## Computing power:

• The power computation is polA=2*Va*Va,   polB=2*Vb*Vb, stokesI=Va*Va + Vb*Vb.
• polA, polB output has the same magnitude as the summed polarizations.

## Downshifting power before accumulator.

You can down shift the output of the power computation prior to adding it into the 40 bit accumulator. This is needed for long integrations (1 sec) with short fftlens (around 512 channels). If not, the 40 bit accumulator may overflow.

## Accumulation:

The power accumulation is done in a 40 bit accumulator.

## Packing and output.

• The spectrometer can output 8,16, or 32 bit data.
• These bits are taken from the upper most bits of the accumulator.
• The ashift parameter specifies how many bits to upshift the 40 bit accumulator before taking the data from the upper bits.
• ashift is a 4 bit register so the maximum upshift is 15 bits. For 8 bit sampling this is not enough for short integrations to move the data into the upper 8 bits of the 40 bit accumulator (maybe the upshift after fft, before power computation could be used).

## Computing which bits to output.

• For 8 and 16 bit outputs we need to compute the ashift (40 bit accumulator upshift) value to position our signal in the bits that we are going to keep.
• The A/D sigma is nominally set to 30 counts independent of the stages that follow the A/D.
• The butterfly down shifts (pshift) will try to make the output of the butterfly stages the same level. It can vary by sqrt(2) in voltage (or 2 in power) (since we need to shift every other stage).
• The value will grow in the accumulator by the number of accumulations. The rms baseline fluctuation will grow  by the sqrt of the number of accumulations.
• We use a reference setup and adjust things to give the desired output levels. We then compute the relative change between the reference and the requested setup to decide what the ashift level should be.
• The default setup is:
• .001 seconds integration or 84 accumulations.
• 4096 channels or 12 butterfly stages.
• pshift=0xffa or 10 downshifts.
• dshift=0
• ashift=14   for 16 bit outputs.
• To  compute the currentPower/reference power:
• sclPshiftRefVoltage=2^(NbutterFlyStages/2. - pshiftNRef))
• sclPshiftRefVoltage=2^(alog2(fftlenRef)/2. - pshiftNRef))=2.^(11./2. - 10)
• sclPshiftRefPwr   =sclPshiftRefVolage^2.=2.^(alog2(fftlenRef) - 2*pshiftNRef)
• sclAccumRefPwr=naccumRef
• MeasPwr/RefPwr=
• (2^(alog2(fftlen) - numPshift*2)*naccum)/(2.^(11 - 20) * 84) or
• (2^(alog2(fftlen) - numPshift*2 + 9)  * naccum/84.
• These computations will keep the output power level close to the same level for most setups.
• The rms fluctuations in the spectral channels will not be the same. For short fft's the rms power fluctuations will be smaller by sqrt(fftlenMeas/fftlenRef).

## Plotting the average spectra and rms.

The average spectra (over about 1 second) and the rms by channels was computed using data taken on 05dec08. The setup was:
• Using the if2noise source set the a/d rms levels to 30 counts.
• Take data using dumptimes of:
• .064, .1,1,2.5,10 milliseconds.
• For each dump time take 5 secs of data at the fftlengths of:
• 128,256,512,1024,2048,4096,8192 channels.
• Only take data with allowable i/o rates < about 65 mB/sec.
• Switch to stokes I for short dumptimes where polAB data would be too fast
• 16 bit data was taken (max positive value: 32767).

Plotting mean and rms vs fftlen  and dump time(.ps) (.pdf):
• page 1 top : mean value of the spectra in counts (throwing out 10% of channels on each edge).
• The scaling keeps the mean value constant.
• The different dump times are plotted using different colors.
• page 1 bottom: mean value of the rms/channel (throwing out 10% of channels on each edge).
• The rms changes with fftlen.
• The colors are different dump times. The bottom black line is 10 ms dump time.
Plotting the average spectra and rms vs channel

For each fftlen and dumptime the average spectra and rms by channel are plotted (the rms/channel is the lower plot in the frame). Black is polA and red is polB (For stokes I data black is stokes I).

 fftlen dump times (millisecs) Notes 128 .ps (.pdf) .064, .1,1.,2.,5.,10 > 5 ms rms  < 10 counts 256 .ps (.pdf) .064, .1,1.,2.,5.,10 >10 ms rms < 10 counts 512 .ps (.pdf) .064, .1,1.,2.,5.,10 1024 .ps (.pdf) .064, .1,1.,2.,5.,10 2048 .ps (.pdf) 1.,2.,5.,10 4096 .ps (.pdf) 1.,2.,5.,10 8192 .ps (.pdf) 1.,2.,5.,10

processing: x101/081205/tstrms.pro, pltspcrms.pro