Tutorial 3: Example Spectrometer

Introduction

In this tutorial will go over building a simple spectrometer using CASPER DSP and hardware yellow blocks for RFSoC.

This tutorial assumes that the casper-ite is familiar wth the RFDC Interface tutorial. This also assumes that the CASPER development environment is setup for RFSoC as described in the Getting Started tutorial. A brief walkthrough of example of the spectrometer design, software control of the spectrometer will be given in this tutorial. However, it is also beneficial to become learn how to interact with the FPGA using casperfpga as demonstrated in the simulink platform introduction.

A spectrometer is an analysis filter bank that takes for its input a time domain signal and transforms it to a frequency domain representation. In digital systems, this is typically achieved by utilising the FFT (Fast Fourier Transform) algorithm. However, with a modest increase in compute, better spectral bin performance can be improved by using a Polyphase Filter Bank (PFB) based approach.

When designing a spectrometer for astronomical applications, it is important to consider the target science case. For example, pulsar timing searches typically require a spectrometer that can dump spectra on short timescales. This allows the rate of change of the spectral content to be finely observed. In contrast, a deep field HI survey will accumulate multiple spectra to increase the signal to noise ratio above a detectable threshold. It is important to note that “bigger isn’t always better” here; the higher your spectral and time resolution are, the more data your computer (and scientist on the other end) will have to deal with. For now however, we skip the target science case and rather look to more familiarize ourselves with an example spectrometer design.

Setup

This tutorial comes with a completed simulink model files for RFSoC platforms. There are different examples for configuring the RFSoC in different operational modes. Those files can be found here.

Spectrometer Basics

When designing a spectrometer there are a few main parameters of note:

  • Bandwidth: The width of your frequency spectrum, in Hz. This depends on the sampling rate; for complex sampled data this is equivalent to:
../../_images/bandwidtheq11.png

In contrast, for real or Nyquist sampled data the rate is half this:

../../_images/bandwidtheq21.png

as two samples are required to reconstruct a given waveform.

  • Frequency resolution: The frequency resolution of a spectrometer, Δf, is given by:
../../_images/freq_eq1.png

and is the width of each frequency bin. This parameter is a measure of how precise you can measure a frequency, or rather its frequency resolution.

  • Time resolution: Time resolution is simply the spectral dump rate of your instrument. We generally accumulate multiple spectra to average out noise; the more accumulations we do, the lower the time resolution. For looking at short timescale events, such as pulsar bursts, higher time resolution is necessary; conversely, if we want to look at a weak HI signal, a long accumulation time is required, so time resolution is less important.

Configuration and Control

Hardware Configuration

Make sure the RFSoC platform board is running the proper Linux image as explained in the Getting Started tutorial and that clocks are running (e.g., ZCU216 requires clocking module board be installed). You will also need test signals at the inputs of the RFSoC.

The tutorial .slx model files for different platforms are found here. Extending the files to a different platform not yet provided is possible following this tutorial. Open one of the example model files and run the jasper command in the matlab command prompt to build the .fpg and .dtbo files (found in model projects outputs/ folder). After this completes, we can now run and configure casperfpga to communicate with the hardware design to readout and plot output spectra!

Python

We assume here working with the RFSoC 4x2 and provided rfsoc4x2_tut_spec.py script for reading output. But, these instructions and files can be extended to other platforms.

There are two prebuilt model files: one using the RFDC configured to output real time samples and the other enabling the digital down converter to output complex time samples. For the real spectrometer design the RFDC is set to sample at 3932.16 MHz with a decimation rate of 2x. The spectrometer uses the fft_wideband_real set to a transform size of 4096. The number of output bins is only the positive frequency with a a size of 2048. This is an effective bandwidth from 0 to 983.04 MHz. The complex spectrometer design is also set to sample at 3932.16 MHz with a decimation rate of 2x. However, in this design the fine mixer is used with the NCO set to -983.04 MHz. The FFT is set to transform to a size of 2048. With sufficient anti-alias filtering the effective bandwidth of this design is from 0 to 1966.08 MHz.

It may be helpful to first run the python script in the two operating modes before going through the script. This can help identify what the script does by knowing before what is being presented.

To get help information from the script you can run:

python rfsoc4x2_tut_spec.py -h

The general syntax to run the script is as follows. Either an IP address or hostname can be given to connect to the board. The string real or cx must be provided. This is to setup how to read out and display the spectra. The -b option is used to program the board with a specified .fpg file. If no file is provided the prebuilt .fpg files are used. The -a option is used to specify which adc input to plot. The value can be 0, 1, 2, or 3. The default is 0. The -l option is used to specify the accumulation length. The -s option can be used if you know the design has already been previously programmed and is running. If not, it will be expected to a problem.

Run in real mode using the prebuilt model. I am assuming here a hostname of rfsoc4x2 for the board:

python rfsoc4x2_tut_spec.py rfsoc4x2 real

Assuming all goes well and with a plot window should appear updating the spectrum periodically, with the spectrum accumulation count displayed in the title. An example is shown in the following figure. Here a tone at 800 MHz is present on the input of the RFSoC and appears as expected 800 MHz.

../../_images/rfsoc4x2_python_real.png

Now run the complex mode design:

python rfsoc4x2_tut_spec.py rfsoc4x2 cx

Similar to the real mode, a plot should shortly appear. As an example, the same 800 MHz tone is present as shown.

../../_images/rfsoc4x2_python_cx.png

As an example of something more interesting, the following output is from the complex version of the design with wideband noise filtered to a passband from about 1280-1780 MHz and a tone present in that passband at 1520 MHz.

../../_images/rfsoc4x2_python_cx_wideband.png

Conclusion

If you have followed this tutorial faithfully, you should now know:

  • What a spectrometer is and what the important parameters for astronomy are.
  • Which CASPER blocks you might want to use to make a spectrometer, and how to connect them up in Simulink.
  • How to connect to and control a the RFSoC spectrometer using python scripting.