CREW-TV trials

31.03.2014 21:09

The European FP7 CREW project I'm working on at Jožef Stefan Institute had a few open calls in the past two years. Anyone with an interest in one of our testbeds could apply and, if it passed a review, was given funds and support from the CREW consortium for running their experiment on our hardware.

One of the chosen experiments in the second open call was CREW-TV by Instituto de Telecomunicações from Portugal. They proposed to use our spectrum sensing network to dynamically update a database of occupied radio channels. They would then test this database by setting up an experimental video broadcasting system with dynamic spectrum access (they have an interactive demo you can click around).

The CREW-TV experiment ended this past week when experimenters from Portugal, a colleague from the Institute and myself performed an actual trial of the system in the field and took some spectrum measurements. You could see us around Logatec in a van full of laptops, instruments and a few antennas sticking out.

Van with measurement equipment and an antenna for CREW-TV trial.

Considering the amount of effort that went into this experiment from my part, the conclusions were disappointing to say the least.

The trial itself has been delayed for a month and missed an European Commission deadline because our testbed was damaged by ice. With local services still busy repairing more critical infrastructure, it was sometimes difficult to get the necessary support. Running an out-door testbed on public infrastructure has a hidden cost that shows itself in such situations. Even though people in Logatec have been most supportive of our activities, a lot of time and effort was necessary to coordinate everything across different organizations.

Discone antenna for CREW-TV trial base station.

I also learned a few hard lessons in organizing an event like this. I overestimated the amount of effort that was put into this experiment by our partners from Portugal. I should have insisted that we double check the list of required field equipment after they arrived. I should have insisted that they test their system first in the lab before attempting to set it up in the field, regardless of how confident they were. I should have insisted that we stick to reasonable working hours.

If my colleague and I would have spent two days waiting for them to debug their system at a warm desk, the trial would be a much more pleasant experience for everyone involved. Instead we were all freezing in the rain, attempted to download hundreds of megabytes of software through slow and costly mobile connections and had to mess with equipment at dangerous heights during the night.

I understand there are sometimes cultural differences and a language barrier, but at one point the hospitality must end.

Measuring DVB-T spectrum and bit error rate.

A year and a half ago our group organized a meeting for the CREW project and hosted some experiments at the then brand-new testbed. Not everything was working yet and a lot of things had to be hastily prepared in the last minute. I felt bad then because I thought we didn't show ourselves in a good light to our visitors. I guess I now find myself on a different side of a similar situation.

In the end, out of the mess of notes and spectrum measurements I have, there might be some useful data that could be used to evaluate the performance of VESNA spectrum sensors. So far some of it points at some shortcomings in detection of packet based transmissions. That would be interesting to investigate further in the lab. Other measurements are too contradictory to be of much use.

Posted by Tomaž | Categories: Life | Comments »

Concentrated Python cuteness

20.03.2014 19:45

Yesterday, I wrote the following piece of Python code to answer a question asked on IRC by Jure. It was more of a joke than a serious suggestion.

Update: In case you want to use this code in some serious application, please be warned that it does not work for a general case. See comments below for some better suggestions on how to solve this task.

def list_pages(page_num, cur_page, n):
	k = sorted([	0, 2*n+1, 
			cur_page-(n+1), cur_page+n, 
			page_num-(2*n+1), page_num])
	return range(1, page_num+1)[k[1]:k[-2]]

What it does is take a list of page numbers from a total of page_num pages. If possible, the list is centered on cur_page and includes n pages in front and back. At the edges, it still returns the list of the same length. For example:

list_pages(10, 1, 2)  = [1, 2, 3, 4, 5]
list_pages(10, 2, 2)  = [1, 2, 3, 4, 5]
list_pages(10, 3, 2)  = [1, 2, 3, 4, 5]
list_pages(10, 4, 2)  = [2, 3, 4, 5, 6]
list_pages(10, 5, 2)  = [3, 4, 5, 6, 7]
list_pages(10, 6, 2)  = [4, 5, 6, 7, 8]
list_pages(10, 7, 2)  = [5, 6, 7, 8, 9]
list_pages(10, 8, 2)  = [6, 7, 8, 9, 10]
list_pages(10, 9, 2)  = [6, 7, 8, 9, 10]
list_pages(10, 10, 2) = [6, 7, 8, 9, 10]

This is likely one of the most incomprehensible pieces of Python code I have ever written. The idea came from Python's cutest clamp function. It's a kind of cleverness I never want to see in a serious product.

The version Jure ended up using took around 30 lines of code to accomplish the same thing. However even with descriptive variable names it's not immediately obvious to me what it does or how it does it. If I would come across it without any additional comments, it would probably take some time and a few tests to see what is its purpose.

I failed to come up with a version that would be self-explanatory.

Perhaps comprehensive code documentation is dead these days, but I think this is one example where an English sentence can be much more expressive than code.

Posted by Tomaž | Categories: Code | Comments »

RGB LED versus RGB sensor

15.03.2014 12:43

Recently two somewhat related things met on my desk:

  • A self-cycling RGB LED extracted from a nose of a plastic deer, a kitschy New Year ornament and
  • a VESNA sensor board with a TCS3772 RGB sensor.

Naturally, I had to see how they work together.

Self-cycling LED from a New Year ornament.

I have no idea what the LED part is. It's simply connected in series with a resistor to a lithium button cell. When voltage is applied it slowly cycles through a range of colors in an apparently random fashion. SparkFun sells something that looks similar.

TCS3772 sensor on a VESNA expansion board.

TCS3772 is a surprisingly small (around 2 mm) component. It is the 6 pin package in the center of the photo above. It connects through I2C and reports values for red, green and blue light. It also has a sensor without a filter for over-all brightness and can do proximity detection when used together with an IR LED.

I used the default VESNA driver for it and it does not specify how these raw values translate to a physical unit. I haven't bothered to dig into the datasheet to find out.

Self-cycling LED measurements using TCS3772 sensor.

This is what I got when I touched the sensor to the LED in a dark room and recorded its readings in a infinite loop.

The LED sequence repeats in around 30 seconds, which surprised me a bit. When I was just watching it, it looked random or at least with a much longer sequence.

I'm not sure why there is such a big difference in the amplitude of different colors. All three colors look equally bright by eye. It might be because the wavelengths of the LEDs are not aligned well with the pass bands of the color filters on the sensor.

It's also obvious that this sensor (at least with the settings used by VESNA's driver) isn't really made for recording fast changes. The values that can be read out through the I2C bus only change every once in 600 ms.

Posted by Tomaž | Categories: Life | Comments »

Running TDA18219HN from external clock

06.03.2014 16:38

I'm finishing up the new design for VESNA's UHF receiver and one feature that sunk the most time was the ability to run two receivers synchronously from the same clock source.

Some of the silicon tuners from NXP, like the TDA18271HD, have a dual-tuner feature. The tuner runs a 16 MHz crystal oscillator that is used in a PLL to generate the local oscillator signal. If the chip is programmed as a master, it outputs a buffered differential sine signal on two XTOUT pins. Another tuner can be programmed as a slave and attached to that clock in place of the crystal resonator:

TDA18271HD dual tuner reception

Image by NXP

Unfortunately the TDA18219HN that I'm using doesn't have that feature. You cannot disable the oscillator and set the pins XTALP and XTALN as passive clock buffer inputs. On the other hand, it still has the clock output, because that is useful to run the demodulator. This made me think it should still be possible to run two tuners synchronously, albeit with some additional circuitry.

Datasheet reveals very little about what is behind the XTAL pins:

TDA18219HN crystal oscillator and PLL

Image by NXP

Note that the capacitors are wired in series with the quartz and not to ground. So one thing is immediately obvious: this chip does not use the common Pierce oscillator topology. That makes sense, since the chip mostly uses balanced signals. The single-ended digital clock signal generated by the common oscillator variant would be of little use. It also means that running this chip from an external clock is not a simple matter of finding which crystal pin is the input to the integrated CMOS inverter.

After some browsing of the literature I didn't find any quartz oscillator topologies that would require capacitors wired like that. In a number of experiments with a signal generator, oscilloscope and a pile of test circuits I came up with the following model:

Model of circuit behind TDA18219HN XTAL pins.

XTAL pins are inputs to a differential buffer B. You can produce the correct differential clock even by driving just one pin, although analog performance is reduced because twice the required input level causes saturation.

Pins are also connected to circuits C and D that provide power to a ringing quartz crystal. Circuits on both pins are independent: driving one pin does not cause any change on the other one. The circuit is very prone to oscillations even without a quartz attached and I wasn't able to measure its input impedance directly. From some indirect measurements and calculations it seems that it must lay on this circular path in the complex plane:

Possible values for input impedance of XTAL pins.

Since the circuit compensates for the losses in the oscillator, the real part of the impedance must be negative. The imaginary part is positive, so it exhibits an inductive reactance (at 16 MHz it's equivalent to around 6.6 μH). This is a bit weird, since quartz resonators typically also behave like inductors in a circuit and the inputs should compensate for that.

The final verdict is that it should be possible to drive XTAL inputs from respective XTOUT outputs, provided there's an AC-coupled voltage follower between them. The follower must be powerful enough to drive the relative low impedance of the XTAL inputs. The power required is non-negligible - my worst case estimate from the impedance plot is 10 mW, which seems a bit high considering this is far above the microwatt levels quartz crystals typically endure.

In the end, I can't really test this until I have a prototype circuit on my desk because any stray capacitance from cables ruins the result. I also don't know how much of a problem phase shift between the receivers will be. If it turns out that it won't work at all, scraping this feature won't be too big a loss anyway.

Posted by Tomaž | Categories: Analog | Comments »

Universe in a cup

01.03.2014 16:42

This topic came up in an IRC channel the other day. How does the universe compare to a cup of tea? How long after the big bang did it take the universe to cool through the temperatures, characteristic of the popular hot beverage?

Fortunately both tea and the early universe are fairly well understood these days.

In the case of tea, the cup cools down approximately exponentially. Time constant depends on the thermal resistance between the drink and the ambient, its mass and specific heat. Fortunately, a dedicated research unit provides empirical data on the subject.

As far as the universe is concerned, that part of its cooling is described by the Friedmann equation for the matter-dominated era.

Cooling of a cup of tea and the universe.

As you can see from the graph above, the universe took slightly longer than your five o'clock tea to cool down.

However, unlike the cup of tea, the universe at that age wasn't terribly interesting. All the fun sub-atomic business had finished long ago and darkness was filled more or less evenly with neutral hydrogen and helium.

It will take more than 100 million years for the first stars to light up and another 10-something billion years before an odd biped gets the idea of throwing a fistful of leaves into boiling water.

Posted by Tomaž | Categories: Ideas | Comments »