Linux, Games, Programming, and some other random stuff
Thursday, October 8, 2015
Blog moved
I decided to continue this blog on my own installation, so please go to http://blog.svenbrauch.de/ in the future if you're interested. This is the last post around here. :)
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.
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.
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.
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.
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.
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:
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:
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 ...
... 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.
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:
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.
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:
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.
The next thing I will try to do is build another of those boards, and do a bit of interferometry. Stay tuned!
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.Functionality description
The board contains various submodules, most of which are labelled in the following image.Some of the components of the acquisition board. |
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. |
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. |
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. |
Simulated filter response for the optimized design. |
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.
Astronomy
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 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:
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.
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. |
Next steps
The next thing I will try to do is build another of those boards, and do a bit of interferometry. Stay tuned!
Labels:
astronomy,
electronics,
hardware,
hydrogen line,
radio telescope,
soldering
Monday, September 15, 2014
Snippets in Kate 5
Recently I spent some time to port and clean up the Snippets plugin and the underlying template interface for Kate 5. It's now fully working again and more powerful than ever. The template code was originally written by Joseph Wenniger and most of what I show here is still working like originally implemented by him. Still, there were some improvements I would like to show; also, I'm sure many readers might not be aware of this great feature at all.
The template interface, which is part of the long-time stable KTextEditor API, was heavily cleaned up and now just consists of a single function
I also heavily refactored the implementation of the interface. More than 1000 lines of code were removed while effectively enhancing functionality.
The heart of the templates (or snippets) are editable fields (shown in green). They are created in the template string by writing ${fieldname}. They can have a default value, which can be any JavaScript expression. Pressing Tab jumps between the fields of a template. Whenever such a field is changed, all so-called dependent fields are updated. Those can simply be mirror fields (created by having a second field with the same name), or can do something which depends on the contents of the other fields in the template, such as perform replacements or concatenations. Again, you can have arbitrary JavaScript expressions doing that.
The Shortcuts feature for the snippets now actually works in Kate.
Snippets now also have proper undo; in KDE 4, only a single character typed could be undone at once while editing a snippet. Now, undo grouping works like it always does.
The user interface was simplified by removing unneeded options, and an inline quick-help feature was added which introduces the user to the most important features of the snippet language. Just click the "More" button.
Then, enter a name and specify that you want this only for C++ files:
Then, add a snippet:
You can retrieve the document's file name from the editor, make it upper-case and replace dots by underscores automatically to get a nice header-guard-suitable format by using code like this:
If you do not want the guard field to be editable, just create a function which does the upper(fileName...) stuff, and have three fields which call the function (like ${func()}) instead of the two mirror fields and one default-valued editable field. If you do that, the template handler will immediately exit and not present any editable fields.
The ${cursor} variable can be used to place the cursor after all fields were filled. When you type something there, the handler will exit.
Click Ok. Now, to use your snippet, either press the shortcut you defined (if any), click it in the snippets toolview, or use code completion:
Classical snippets use case: insert a for loop witout having to type the iterator variable three times. |
bool insertTemplate(const KTextEditor::Cursor& insertPosition, const QString& templateString, const QString& script = QString());which inserts a template into a view at the given position. It's very easy to use and still powerful -- if you write an application which uses KTextEditor, it might be worth to spend a moment thinking about how you might be able to make use of it.
I also heavily refactored the implementation of the interface. More than 1000 lines of code were removed while effectively enhancing functionality.
Core functionality changes
I changed the language of the snippets a bit to make it more clear and easy to use. In the following, I want to give a short overview of how it works now.The heart of the templates (or snippets) are editable fields (shown in green). They are created in the template string by writing ${fieldname}. They can have a default value, which can be any JavaScript expression. Pressing Tab jumps between the fields of a template. Whenever such a field is changed, all so-called dependent fields are updated. Those can simply be mirror fields (created by having a second field with the same name), or can do something which depends on the contents of the other fields in the template, such as perform replacements or concatenations. Again, you can have arbitrary JavaScript expressions doing that.
The Shortcuts feature for the snippets now actually works in Kate.
Snippets now also have proper undo; in KDE 4, only a single character typed could be undone at once while editing a snippet. Now, undo grouping works like it always does.
User interface improvements
For easy testing of your snippets, the "Edit Snippet" dialog has a "Test snippet" button now, which lets you test your snippet on-the-fly.The user interface was simplified by removing unneeded options, and an inline quick-help feature was added which introduces the user to the most important features of the snippet language. Just click the "More" button.
Inline documentation on how snippets work |
An example: C++ Header guards
As an example for how this feature works, let's look at how to create a snippet to generate a C++ header guard. First, create a repository for your C++ snippets:Open the Snippets toolview and click "Add Repository". |
Create your new repository. |
Add a snippet. Easy. |
You can retrieve the document's file name from the editor, make it upper-case and replace dots by underscores automatically to get a nice header-guard-suitable format by using code like this:
Example code for how you can create C++ header guards fully automatically. |
The ${cursor} variable can be used to place the cursor after all fields were filled. When you type something there, the handler will exit.
Click Ok. Now, to use your snippet, either press the shortcut you defined (if any), click it in the snippets toolview, or use code completion:
Snippets appear in code completion. |
Some more examples on what you can do
Here's a few snippets demonstrating the features of the engine while partly being of debatable practical relevance. I'm sure you can come up with better use cases for some of those things though.Get the file encoding from the editor and use it as the coding of a python file header. |
Some base64 in the selection ... |
... decoded by a snippet which takes the selection and inserts the base64-decoded result. |
Next steps
My next step will be to make this plugin loadable in KDevelop as well -- which should be quite easily possible due to the awesome work done in kate to make the plugin infrastructure more generic. If you have further ideas on how to improve the snippets, let me know :)Saturday, August 30, 2014
1420.4 MHz Hydrogen line: There it is!
With a reasonably simple setup, I finally succeeded in detecting the 1420.4 MHz galactic hydrogen hyperfine structure line:
Since you obviously cannot simply attach a coaxial cable to a parabolic dish reflector, a so-called feed is required to absorb the radiation collected by the dish reflector. I adapted a feed design commonly used for wireless LAN for the HI frequency (which is done by just multiplying all lengths by the ratio of the two frequencies). This design consists of a biquad antenna over a ground plane with two reflectors on the side (those are to make the radiation pattern more symmetric and fit the dish better). It provides an excellent match at the design frequency and seems to work well.
Unfortunuately, my aiming is quite inaccurate and the antenna beam size is 10 degrees, so I can only very roughly tell what is currently visible in the picture. Still, in the picture above, you can clearly see three wide peaks which are HI emission, and three narrow peaks which are interference. We can remove the interference to get a nicer picture:
This works by manually flagging the locations of the interference peaks, and then fitting a curve of the form a*x^2+b*x+c+d*exp(-f*(x-e)^2) to those locations (second-order polynomial for the "real", wide spectrum and a gaussian-shaped peak for the interference).
The d*exp(-f*(x-e)^2) term is then simply subtracted from the data, which leaves only the baseline, without the interference peak. This method even partially "recovers" data hidden by the interference peak (how reliable that information is is a different question, but in this case it looks fine).
After this treatment, you can clearly see three wide bulges in the curve.
You might have noticed that the x axis is not labeled with frequency, but velocity. This is because the actual emission of the kind of radiation observed here only happens at one specific frequency (1.4204 GHz -- where the 0 in the graph is). Still, we see it at different frequencies because of doppler shift. Thus, the observed frequency of the radiation translates directly to the velocity with which the matter which emits the radiation moves towards us -- or away from us.
I would carefully claim that the three observed peaks originate from three different spiral arms of the milky way which rotate with different velocities. I'm not sure if that is accurate though.
With the same method, I took several more similar pictures of different regions of the milky way, some shown below.
For the former, I'm currently trying to build a tilt-compensated compass with elevation sensor (basically a three-axis magnetic field sensor and a three-axis acceleration sensor with software). It's working a bit, but not really.
For the latter, in professional radio astronomy, one tool which is used is a noise diode. That is a small device which injects noise into the receiver system at the very start of the signal path (in my case, it's a small device inside the biquad feed). It is periodically switched on and off and adds a constant offset to the amplitude of the observed signal. The trick is that this constant offset is reliably constant, over long periods of time. When we see it change in the recorded data (and we will), we can be fairly sure this change is caused by the receiver system (amplifier, detector) changing -- for example because of temperature drift. Thus, by dividing the observed amplitude of this constant offset, signals amplitudes can be evaluted even if the receiver and detector system drifts.
I built a zener-diode based noise generator which seems to work fine for my purpose. It can be switched on and off using a transistor and the Raspberry Pi GPIOs, and is powered by battery to get as little fluctuation as possible in the noise signal itself. The generator is attached to a small piece of wire as an antenna and is glued inside the feed.
This also means a spectrum analyzer is not a very good detector for this kind of telecope -- with 10 kHz RBW and 1 MHz bandwidth (about what I used above) 99% of the signal power are lost simply because they are not detected at a given time.
Setup
The setup consists of a 1.2m dish with a feed and two homemade 1.4 GHz low-noise preamplifiers. The amplifiers have about 19dB of gain each at 1.42 GHz and a noise figure too small to measure for my equipment (certainly below 2dB I would claim). The simulated noise figure is about 0.4dB, but that is without taking the Q factor of the matching components into account. A spectrum analyzer (Rigol DSA 815) is used as the detector for now.Dish with mounted feed (for the latter, see text and pictures below) |
Metallic camping mats designed to isolate the user from low temperatures can also be used as faraday cages -- with moderate success. |
Results
With this recording technique, I was able to take some nice data sets. In all of them, the antenna points into a fixed direction of the sky and the sky moves across the picture. The x (right) axis is frequency; the y axis is time in the upper graph, and intensity in the lower one. Intensity is encoded as color in the upper graphs. Thus, if you look in the upper graph from top to bottom, you actually see different regions of the sky moving across the antenna. In the lower graph, you see the intensity of radiation of all those regions added together (the lower graph is the upper one integrated along the top-to-bottom axis, so to speak). All intensity scales are logarithmic.Started quite late in the night, with about 80° elevation (almost straight up); different parts (roughly Cyg, Cas, Perseus) of the milky way move through the picture. |
Same picture as above after interference removal algorithm. |
Small section of the spectrum shown above with interference peak (center). The blue line is data, the green line is a fit of a*x^2+b*x+c+d*exp(-f*(x-e)^2) to the data. |
After this treatment, you can clearly see three wide bulges in the curve.
You might have noticed that the x axis is not labeled with frequency, but velocity. This is because the actual emission of the kind of radiation observed here only happens at one specific frequency (1.4204 GHz -- where the 0 in the graph is). Still, we see it at different frequencies because of doppler shift. Thus, the observed frequency of the radiation translates directly to the velocity with which the matter which emits the radiation moves towards us -- or away from us.
I would carefully claim that the three observed peaks originate from three different spiral arms of the milky way which rotate with different velocities. I'm not sure if that is accurate though.
With the same method, I took several more similar pictures of different regions of the milky way, some shown below.
Transit of (roughly) Perseus through the beam. |
Future plans
My long-term plan is to attempt creating a survey of a significant part of the sky -- basically a map which tells how much HI radiation at what doppler shift is observed at which point of the sky. For that, I need two things: A reliable way to determine the antenna position; and a consistent way to compare signal amplitudes.For the former, I'm currently trying to build a tilt-compensated compass with elevation sensor (basically a three-axis magnetic field sensor and a three-axis acceleration sensor with software). It's working a bit, but not really.
For the latter, in professional radio astronomy, one tool which is used is a noise diode. That is a small device which injects noise into the receiver system at the very start of the signal path (in my case, it's a small device inside the biquad feed). It is periodically switched on and off and adds a constant offset to the amplitude of the observed signal. The trick is that this constant offset is reliably constant, over long periods of time. When we see it change in the recorded data (and we will), we can be fairly sure this change is caused by the receiver system (amplifier, detector) changing -- for example because of temperature drift. Thus, by dividing the observed amplitude of this constant offset, signals amplitudes can be evaluted even if the receiver and detector system drifts.
I built a zener-diode based noise generator which seems to work fine for my purpose. It can be switched on and off using a transistor and the Raspberry Pi GPIOs, and is powered by battery to get as little fluctuation as possible in the noise signal itself. The generator is attached to a small piece of wire as an antenna and is glued inside the feed.
Noise diode test. Pink curve: noise diode powered on; yellow curve: noise diode off. This is without the feed and amplifiers, but it looks similar with them. |
Caveats of using a spectrum analyzer as a detector for radio astronomy
It took me a while to figure out how to best configure the spectrum analyzer for this purpose. One thing which is easy to overlook (because it is nearly irrelevant in most applications) is that a spectrum analyzer does sweeping measurements, i.e. it measures intensity at one frequency span at a time, then goes to the next etc. This means the resolution bandwith (RBW), which basically controls the spectral resolution of the analyzer, also controls how much signal power is detected at once during the sweep. If it is set to 100 Hz, the analyzer will walk through the whole frequency span in 100 Hz chunks, detecting only 100 Hz of the spectrum's power at once. If set to 10 kHz, it will detect a hundred times as much power at once -- which gives an effective signal-to-noise ratio which is a hundred times better in the end! This is very unintuitive because the noise level displayed by the analyzer actually increases for higher RBW values (which makes sense of course if you think about it: if you accumulate a larger part of the spectrum into a single channel, that channel will have more noise power overall). Thus, when using a spectrum analyzer for this purpose, you have a trade-off between S/N and spectral resolution (you always have a trade-off between S/N and spectral resolution, but in this case it's far more grave than usual -- exponent 3/2 instead of 1/2 [as usual] for the channel count if I'm not mistaken). I selected 10 kHz spectral resolution, more resolution (lower RBW) certainly makes no sense for this kind of signal. Probably 30 kHz would be fine as well -- but that makes interference detection and removal harder again because the narrow interference peaks are quite smeared out.This also means a spectrum analyzer is not a very good detector for this kind of telecope -- with 10 kHz RBW and 1 MHz bandwidth (about what I used above) 99% of the signal power are lost simply because they are not detected at a given time.
Conclusion
It is very nice to finally see some results come out of this project. I'm looking forward to improving the receiver system (eventually I want to replace the analyzer by an A/D converter + mixer) and the calibration process.Wednesday, July 23, 2014
Project: Detecting the 1420.4MHz hydrogen line -- status report
A while ago, I decided it would be a fun thing to try to detect the 21cm hydrogen line. The 21cm line is a hyperfine structure line of hydrogen; the latter is abundant in interstellar matter in our galaxy (and in other galaxies too). That makes this transition's radiation an interesting object to study, especially because you can determine the velocity of the regions emitting the raditation quite precisely by looking at the doppler shift of the radiation. That makes it possible to construct for example rotation profiles of galaxies. You can do that even if your spatial resolution is low (which is important, since spatial resolution is limited by the size of your antenna: as a rule of thumb, the area you see as one big smeared "pixel" is about the inverse of the size of your antenna expressed in wavelengths taken as radians -- so if your antenna is 1.05m big, which is 5 wavelengths at 21cm, that gives you a spatial resolution of about 1/5rad which is about 11 degrees. That's about 22 sun diameters, which is really bad if you wanted to make an image of the sky).
It has quite a lot of tape on it -- I underestimated the size and need for mechanical stability a bit. For the next try, I will definitely use a more sturdy piece of wood as the base. Anyways, first measurements indicate that it should work well enough; not great, but good enough for a first test.
It is very difficult to design a good LNA though; so for some first tests, I use a generic wideband amplifier IC as my preamplifier, which has a not-very-good noise figure of 2dB. I hope it will work as a proof-of-concept; I plan to add a proper LNA later then.
First, besides the noise figure, another not-so-obvious disadvantage of a wideband amplifier is that it is, well, wideband: it will amplify everything, especially for example the very bright GSM (mobile phone stuff) band around 937 MHz. That is bad, because such a strong signal can cause intermodulation products which affect the quality of the signal you actually want to detect, or even cause the amplifiers to go into saturation.
Second, it is very easy to turn broadband amplifiers into oscillators. You have to strictly separate them from each other and avoid any kind of feedback, or they will start spitting out large power levels at seemingly random frequencies.
Both problems seem easy to solve by building a bandpass filter -- but I found it quite hard to build a good bandpass filter for 1.42GHz. It is a frequency where lumped-element filters (those made out of capacitors and inductors) are not really viable any more since you need capacitors with incredibly small values, while distributed-element (microstrip, see this blog post) filters are not that great either because a half- or quarter wavelength of 21cm is still pretty large.
Mixers are very versatile devices which are used basically everywhere where radio frequency signals are present -- for example in WLAN, in GSM, radio, or satellite television (in the latter, there's actually a mixer in the LNA thing which you put in front of your satellite dish which shifts the received ~10GHz signal to somewhere around 2GHz to reduce losses in the cable to your TV receiver).
Professional radio astronomy applications tend to use more than one mixer stage to lower the frequency gradually (that has various advantages mostly related to filtering), but I hope I can get away with just one stage for this project.
I thus built a test board based on the LT5560 mixer (~3€) which is designed to mix a 1420 MHz signal down to 20 MHz using a 1400 MHz local oscillator (LO, that's the name for the frequency you're mixing the signal you're interested in with). As the LO, I use a programmable frequency synthesizer I built a while ago which is based on the ADF4350 (~8€, but wow that thing is difficult to put on a working board -- took me three attempts with a new board design each).
I will not go into details on how to build those baluns here, but good documents describing how to do it include this, this (german), this and this (ready-made components are available and are not even very expensive, but I did not find any Europe-based distributor who actually sells them. And I don't want to pay $20 shipping fees and wait a week each time I need a part).
I checked the performance of the self-made baluns with a spectrum analyzer and directional coupler, and they seem to work well after a few experiments -- although I am not entirely happy with the performance of the transformer-type one: a return loss of -13dB means about 1/20 of the signal power will get reflected back into the mixer, which is more than I would like. I think one reason for this is that the windings of the wire are a bit chaotic which makes the coupling between the windings a bit non-deterministic. Still -- all good enough for the prototype ;)
The S11 curve of the delay-line one is much sharper than the one shown here, and it also has a better return loss at the design frequency.
But most important, it actually works:
And after fixing several grave issues with the LT5560 test board (including components we forgot to solder onto the board, an accidental short-circuit of the power line which involved overlooking that the baluns both pass-through DC current, the lack of enough ground vias across the board, missing DC paths for the input pins, and an oscillating circuit involving the power supply (which was fixed by adding some 10Ω resistors in series with the RF chokes used) and a few more) it actually works! Look:
An antenna
First thing you need is an antenna. For this purpose, I built a 14-element Yagi antenna, as seen below.14-element 1.4GHz Yagi antenna |
Closeup of the amplifier next to the resonator of the antenna. The circuitry is hidden below the copper shielding. |
S11 of the yagi antenna shown above. x is frequency, y is log reflected power (lower is better). |
A Preamplifier
The second thing in the signal path is a preamplifier, which is usually placed directly at the antenna and has the purpose of amplifying the received signal before any degradation can happen (e.g. through cables, which weaken the signal and add noise). The noise figure of the preamplifier (which is often called LNA, for low-noise amplifier) is important; it tells how much additional noise will be present in the detected signal. The noise figure of all subsequent amplifiers is usually not relevant: they amplify the noise added by the LNA, which is far worse than their own added noise. Thus, it makes sense to carefully design the very first amplifier, while the rest of them can be as cheap and simple as possible.It is very difficult to design a good LNA though; so for some first tests, I use a generic wideband amplifier IC as my preamplifier, which has a not-very-good noise figure of 2dB. I hope it will work as a proof-of-concept; I plan to add a proper LNA later then.
More amplifiers
The next thing you want to do is to somehow amplify the received signal so much that its quality is limited by thermal noise: as soon as you reach that point, further amplification buys you nothing, you need to improve the antenna or cool your LNA. How much amplification that is exactly will depend on the circumstances, but since my measurement device can detect power levels down to roughly -120 dBm/Hz without problems and thermal noise from the antenna will probably be somewhere around -180 dBm/Hz, I will need somewhere around +60dB amplification at least -- better a bit more. That's about a factor one million more power.Wide-band gain blocks are not a solution for every problem :(
My first attempt to achieve this was to use several more wideband amplifier blocks -- since they're cheap (~3€) and incredibly easy to use (connect signal in, signal out, add 5V power, done). That wasn't a very good idea for two reasons though:First, besides the noise figure, another not-so-obvious disadvantage of a wideband amplifier is that it is, well, wideband: it will amplify everything, especially for example the very bright GSM (mobile phone stuff) band around 937 MHz. That is bad, because such a strong signal can cause intermodulation products which affect the quality of the signal you actually want to detect, or even cause the amplifiers to go into saturation.
Second, it is very easy to turn broadband amplifiers into oscillators. You have to strictly separate them from each other and avoid any kind of feedback, or they will start spitting out large power levels at seemingly random frequencies.
Both problems seem easy to solve by building a bandpass filter -- but I found it quite hard to build a good bandpass filter for 1.42GHz. It is a frequency where lumped-element filters (those made out of capacitors and inductors) are not really viable any more since you need capacitors with incredibly small values, while distributed-element (microstrip, see this blog post) filters are not that great either because a half- or quarter wavelength of 21cm is still pretty large.
A new experiment: Frequency Mixers
All those resaons taken together brought me away from using this simplest possible solution, so I decided to try what all the cool people do: use a frequency mixer to bring the signal down to a more manageable frequency after the preamplifier, then amplify and filter it at that low frequency. A frequency mixer is effectively a device which shifts the spectrum of a signal along the frequency axis: Mixing a 1GHz sine with a 995MHz sine will result in signals at the difference (and the sum) of those frequencies, so a 5MHz sine (and a 1995MHz sine, but that can easily be filtered away -- if you don't want it). Signal components which are shifted below 0Hz appear mirrored at the appropriate positive frequency (so, if a signal would be shifted to -3MHz, it will appear at 3MHz instead -- with a phase shift, but that is barely relevant).Mixers are very versatile devices which are used basically everywhere where radio frequency signals are present -- for example in WLAN, in GSM, radio, or satellite television (in the latter, there's actually a mixer in the LNA thing which you put in front of your satellite dish which shifts the received ~10GHz signal to somewhere around 2GHz to reduce losses in the cable to your TV receiver).
Professional radio astronomy applications tend to use more than one mixer stage to lower the frequency gradually (that has various advantages mostly related to filtering), but I hope I can get away with just one stage for this project.
I thus built a test board based on the LT5560 mixer (~3€) which is designed to mix a 1420 MHz signal down to 20 MHz using a 1400 MHz local oscillator (LO, that's the name for the frequency you're mixing the signal you're interested in with). As the LO, I use a programmable frequency synthesizer I built a while ago which is based on the ADF4350 (~8€, but wow that thing is difficult to put on a working board -- took me three attempts with a new board design each).
Balanced and Unbalanced signals
Apart from input matching, which is not very difficult to do since it is described in detail in the data sheet of the part, the one difficult thing which needs to be done when using a mixer of this type is that it requires balanced inputs, while the signal on your coax cable is usually unbalanced. The difference between those two is basically that the unbalanced signal has two voltage levels -- ground and the signal, while balanced has three, plus the signal, minus the signal, and ground. A device which converts one of those into the other is called a balun (for balanced-unbalanced). They always work both ways (balanced - unbalanced or unbalanced - balanced). A balun is usually made in one of two ways:- transformer type: the unbalanced signal is passed into a transformer and by clever choice of taps on the load side you can get a balanced signal
- delay line type: transmission lines of certain fractions of the wavelength of the expected signals (e.g. 1/4 and 3/4) are connected to the balanaced signal, and tap different phases of the wave form because of their different length, which allows to extract a balanced signal
I will not go into details on how to build those baluns here, but good documents describing how to do it include this, this (german), this and this (ready-made components are available and are not even very expensive, but I did not find any Europe-based distributor who actually sells them. And I don't want to pay $20 shipping fees and wait a week each time I need a part).
I checked the performance of the self-made baluns with a spectrum analyzer and directional coupler, and they seem to work well after a few experiments -- although I am not entirely happy with the performance of the transformer-type one: a return loss of -13dB means about 1/20 of the signal power will get reflected back into the mixer, which is more than I would like. I think one reason for this is that the windings of the wire are a bit chaotic which makes the coupling between the windings a bit non-deterministic. Still -- all good enough for the prototype ;)
The S11 curve of the delay-line one is much sharper than the one shown here, and it also has a better return loss at the design frequency.
S11 (return loss) of the transformer-type balun; x axis is frequency, y axis is log power |
But most important, it actually works:
Results
LT5560 active mixer test board. Yes, it looks quite horrible because lots of repairs were needed after the initial fabrication ;) Next one will look nicer. |
Next steps
Now, most of the difficult components for my 1.42GHz receiver should hopefully be in place. I plan to build a 20 MHz amplifier and lowpass filter shortly; I hope to be able to present a few more concrete results here shortly!
Subscribe to:
Posts (Atom)