Sunday, April 26, 2015

21cm hydrogen line telescope, version 2

Much has happened since my last status report on my attempts to observe the galactic hydrogen emission at the famous 1420.4 MHz hyperfine structure line. Now, the new setup is finally proven to be basically working, and in this post I want to describe some of the changes I did.

New data acquisition module

Most importantly, I replaced the spectrum analyzer by a self-made data acquisition unit which is basically a Software-defined radio (SDR). Its purpose is to take the 1.4 GHz signal, digitize it, and send it to a computer.
Revision 2 of the new data-acquisition board. Signal input is at at the top right port, then there is a lot of analog stuff (details below) and the signal is finally fed to the microcontroller (the big black IC) which passes it to the computer via USB. The plug in the upper left corner is an additional power supply.

Functionality description

The board contains various submodules, most of which are labelled in the following image.
Some of the components of the acquisition board.
The first thing which happens is down-conversion through a so-called mixer [data sheet of part used here]: it takes the portion of the 1.42 GHz signal we are interested in and moves it down to a lower frequency of approx. 150 MHz. This has various advantages; especially it makes further filtering, amplifying and digitizing the signal much easier. Since we are only interested in a small part of the signal, this conversion can happen in a way such that no information is lost.
Mixing works by multiplying the actual signal with a reference signal, the so-called Local Oscillator (LO) [data sheet of part used here]. You can imagine the LO as a component which generates a sine wave at a specific, but programmable, frequency (in this case around 1.27 GHz); then the mixer basically subtracts this frequency from the frequency of the original signal (so in this case, with 1.42 GHz and 1.27 GHz you end up at 0.15 GHz = 150 MHz). The lower-frequency signal (the 150 MHz in this case) is called the Intermediate Frequency (IF) signal.

Next, there are various filters and amplifiers which are very simple to understand; they just make the signal amplitude large enough so that it can comforatbly be detected by the analog-digital-converter later on.
This part of the circuit ends with a so-called Surface Acoustic Wave (SAW) filter [data sheet of part used here], which is a quite modern kind of filter with the special property that it can select a relatively small part of the signal very accurately, while blocking everything else almost completely. It only lets the frequency components of the signal pass which have frequencies between about 148 and 151 MHz. Which part of the original signal can be found in this range (remember, we move the original signal to a different frequency) is determined by the mixing step: through programming the local oscillator (LO) for a different reference frequency, one can look at the input signal's spectrum one part at a time.

The bridge between the analog and the digital world is built by the Analog-Digital-Converter (ADC) [data sheet of part used here]. It gets an input clock from the microcontroller, which is just a signal which toggles up and down exactly 11.25 million times per second; on each tick of that clock, it measures the voltage at its input pin, and converts it into an 8-bit digital value. Each of the bits of that value is then provided as a voltage level (either +3.3V for "1" or 0V for "0") on one of the output pins. They are read in by the microcontroller [data sheet of microcontroller], packed into chunks of a few kB in size in the controller's RAM, and then sent out via USB.
Getting the microcontroller firmware to do this as fast as required was surprisingly nontrivial, but that's such a broad topic that I do not want to get started on it here. 
The computer receives the data, calculates the fourier transform to get the frequency spectrum, and averages the resulting spectra (see end of post for software screenshots).

(If you ever heard of the Nyquist frequency, you might wonder how it is possible to digitize a 150 MHz signal with just 11.25 MSa/s sample rate. This is why we need the narrow SAW filter in front of the ADC: it limits the bandwidth of the signal to 3 MHz and thus allows to use the undersampling technique. In this case, the ADC samples the 26th alias of the original signal.)

Below is an illustration of the paths the signals described above take through the board. Note that almost all of the blue path is at 150 MHz; just the first centimeter up to the small black mixer IC is at 1.4 GHz.
Signal paths in the data acquisition board.

Manufacturing the board

This is a 4-layer board; that means, it has tracks on the top and bottom side, and two metal layers in between (you cannot see them, they are glued inside the board) which also have tracks. Connections between the layers are established by metal-filled drill holes (in this case about 1000 of them, each 0.3mm in diameter).
Having 4 layers makes it much easier (or possible at all) to arrange tracks in a way that they do not cross, and also has some important advantages for high-frequency signals. Unfortunately, it also makes fabrication of the prototypes more expensive. There are various chinese vendors which will manufacture a small amount of pieces of such a board for an affordable price; including customs and shipping it will end up costing about 100 € for 5 pieces (less pieces doesn't get cheaper though). Components are extra and you have to put them on the board yourself.
There is specific software to design such circuit boards; first, you usually draw a schematic, and then you use the layout editor to place components and tracks in accordance with the schematic. The layout itself quickly becomes hard to overlook; the software guarantees electrical equivalence between the easy-to-read schematic and the layout (e.g. it guarantees you don't have wrong connections, missing connections, or tracks which cross or are too close together -- of course only if you did it right in the schematic).
The software exports vector-graphics like files for each layer and a list where holes must be drilled, which is then sent to the manufacturer.
This board's layout loaded in kicad. Only the top (red) and bottom (green) layers are shown.
A raw board without components (but with soldering paste on it) and the stencil for the board. Also an example for how not to use a stencil.
For this, I decided to use a stencil this time, which is a rather thin piece of metal with all the pieces cut out where a component is supposed to be soldered onto the board. The stencil is put on top of the board, then you smear some solder paste on it, and force it through with a credit card; then, you lift off the stencil to only have the solder paste on the places where it belongs. You can then put the components into their spots and heat the whole thing; the solder paste will melt and form a firm, electrically conductive bond between the component and the pad on the board after cooling down again. After a few attempts, I managed to get a good result for the paste print: it is important to firmly fix the stencil in the right postion, then press the paste through with a single swipe, and then remove the stencil again by lifting it straight up carefully.
Board with solder paste, ready for component placement.
Board with components placed, after heating it up and letting it cool down again (and fixing a few things by hand). Most of the solder joints look pretty good.
With all the software and tooling stuff already in place from a first version of the prototype, it was quite easy to get this board to work as expected. Only very few minor fixes were needed.

Mirror filter

When mixing a signal to a different frequency as described above, there is one problem I did not mention so far: if I mix 1.27 GHz with a broadband signal (as it comes from the antenna, it doesn't only contain the 1.42 GHz part but lots of uninteresting noise at basically all other frequencies as well) of which I am interested in the 1.42 GHz part only, there are actually two frequencies of the broadband signal which will end up at 150 MHz in the intermediate frequency (IF) signal. This is the 1.42 GHz = 1.27 GHz + 0.15 GHz part I want, but also the 1.15 GHz = 1.27 - 0.15 GHz part, which I have no interest in. After the mixing step, those two signals are added together and cannot be separated again. It is thus necessary to remove the 1.15 GHz part of the signal before it reaches the mixer.
To do this, a bandpass filter is needed. I did some simulation with Sonnet (give it a try if you want to do stuff like this, it has a quite functional free version), which basically allows you to simulate electromagnetic waves in planar (i.e. "mostly 2D") arrangements of metal, and ended up with this magic-looking design:
Geometry for a microstrip bandpass filter at 1.42 GHz.
The green stuff is copper, white is just board material, and the 1 resp. 2 is the input / output port. This is the simulated filter response:
Simulated filter response for the optimized design.
Looks good! It lets through the 1.42 GHz signal nicely, and blocks the unwanted signal at 1.15 GHz by 40 dB (factor 10000 in power).
For a prototype, I then proceeded to cut this geometry into a copper board by hand ...
Hand-made prototype (with a cutter knife).

... and measured it to compare with the simulation. As expected, it has more loss in the passband than in the simulation (reality always has more loss than expected) but not much, and the shape of the response is much more irregular, probably mostly because of manufacturing inaccuracies. Still, the important parameters agree really well with the simulation, which I find quite impressive.
Measured filter response. Note that the filed-of-view is much wider to the left than in the simulation image shown above (it goes down to f = 0 Hz here), the two markers M1 and M2 are in the same spot though. Everything below the y= -40dB line can be completely neglegected in practice for this application.


Now, finally all the important components are in place! I set up my 1.2m dish and pointed it at the sky, and tadaa -- the familiar HI signature of our galaxy showed up:
The two wide peaks probably are two spiral arms of our galaxy. The slope in the underground signal (more signal to the right, less to the left) is wideband interference from some human-made source. About 21 gigabytes of data were acquired and averaged (to reduce noise) by the board described above to create this image. Integration time is 12 minutes, total measurement time 24 minutes (12 minutes on-source observation and 12 minutes background noise measurement)
I really need to repeat this test outside of a city full of people with interfering electrical devices (that really makes a huge difference), but as a proof-of-concept, this is completely sufficient. As such, this is the first spectrum I acquired with all significant components in the reception chain made by myself :)
The signal is calibrated by a method called frequency switching: one periodically shifts the observation frequency by a few MHz, and thus observes just the background noise. This background noise is then subtracted from the actual measurement. This might sound like it reduces noise (it does not, but that's not trivial to understand), but the real gain is that the frequency dependence of the IF part of the acquisition board is removed from the signal. Why this is important may become evident from the following image:
Screenshot of PC software (written specifically for this board). The curve on the right is the acquired spectrum, and contains information from about a million ADC samples fourier-transformed and averaged together. One can nicely see the bandpass; the shape is almost entirely determined by the Surface Acoustic Wave (SAW) filter mentioned above. At the left, there's controls for adjusting amplitude and looking at different parts of the spectrum by changing the local oscillator frequency.

None of the peaks shown there is an actual astronomical signal; the signal shown in the plot is far too weak to see it here. The non-flatness of the band is created by the bandpass filter (the sharp spikes are interference); this non-flatness should be calibrated away in order to reliably distinguish real signals from the bandpass shape.
Spectrum obtained by frequency switching. The structure of the bandpass is mostly removed. (You might wonder why the edges left and right are still visible; this is due to wideband interference signals with non-constant amplitude. In a more noise-free environment, those should not be visible either and the baseline should be completely flat)
As you can see, the bandpass shape is removed, and the actual astronomical signal is visible in the middle (this is already averaged for a while, though).

Another interesting thing is to look at the waterfall plot of the record, i.e. encode signal intensity by color, and use the y-axis for time instead:
Waterfall diagram of the acquired signal.
The relatively faint green vertical stripe around x=1000 is the signal we are looking for. Other vertical stripes are narrow-band interference; horizontal stripes are temporary but broad-band interference.

Next steps

The next thing I will try to do is build another of those boards, and do a bit of interferometry. Stay tuned!