The Galician's dilemma

Today's the day that commemorates Galician literature, the "Día das Letras Galegas", so it's obviously time to write about more Galician weird stuff. This is something you'll encounter if you share a meal with Galicians.

Let's first set the scene: you are having lunch, or perhaps dinner, in Galicia, with Galicians. As Galicians are wont to do, multiple serving trays are brought to the table, and everybody takes from them whatever they'd like to eat. After a couple of hours, the table is full of serving trays, all of which have one morsel left. Around the table, many Galicians talk and joke, trying to appear nonchalant while they eye the left-over portions of food greedily, obviously wanting to eat them. Yet they never touch them.

This situation is called "a vergoña do galego", which can be translated literally as "the Galician's shame", but I think a better translation would be "the Galician's dilemma". It goes like this:

Initially, the serving trays are full of food, and they circulate around the table so everyone can take a portion commensurate to how hungry they are, how much they like that particular food, and now many other trays full of food they expect to see during the meal. At the end of the first round, anyone who wants seconds can just call for a tray and serve themselves. However, as the amount of food in each tray diminishes, a secondary consideration starts to take hold: "what if someone else wants this food too?" So, when they go for seconds, or thirds, people will usually serve themselves less food than they'd actually like, so that there's still enough for someone else who may want it.

This situation reaches its logical conclusion when there's only one portion left in the serving tray. At this point, the desire to eat the food is less powerful than the dread of depriving someone else from eating that morsel. As a result, multiple trays will be on the table, each one displaying a single morsel of food that somebody wants to eat and nobody dares to touch. This situation often reach ridiculous levels, where you could have trenchers with only one solitary slice of octopus, or dishes displaying one piece of raxo and one potato chip.

Galicians recognize and acknowledge this phenomenon, so they've developed some coping strategies. For example, at a restaurant, when a waiter needs to remove the serving trays, they'll just choose one of the diners and have a conversation like this:

"How did you like the octopus?"
"Ah, it was wonderful."
"So you won't mind finishing it up for me, I need to take the trencher away." (Removes last slice of octopus from trencher, puts it into Galician's plate, takes trencher away.)

At this point the dilemma is solved, because it was the waiter, not you, who put the food in your plate. What can you do about it? Nothing, of course. May as well just eat it.

Another solution to the dilemma involves having the presence of someone who is not Galician. Non-Galicians are exempted from the dilemma, and not only are they allowed to take the last morsel without fear of repercussion, they will actually be encouraged to.

"Ah, only one portion of empanada left!"
"Yes, this is the Galician's dilemma." (Explanation of the dilemma follows.)
"But you are not Galician, so it doesn't affect you, so just take it!"

Savvy non-Galicians may even just go ahead unprompted and cut the Gordian knot of the Galician dilemma:

"Is this the last prawn?"
"Yes, it is."
"Oh well, I'm not Galician, so..." (Takes it.)

Galicians being cognizant of the dilemma, they won't resent the person taking the last portion, and may even thank them for it.

When there are no non-Galicians around, the situation can require a bit of negotiation and diplomacy:

"So, why is there a Padrón pepper left?"
"The Galician's dilemma!"
"I know, but it needs to go."
"You can take it if you want it."
"Don't be absurd! It's clearly saying your name."

Etc., etc.

I got myself an address stamp

I got myself an address stamp.

My address, stamped once in a piece of paper.

It is fun to use.

My address, stamped several times in a piece of paper.

It is indeed quite fun to use.

Several pieces of paper covered in stampings of my address.

I think I may need to buy a new ink pad soon.

Some rain-related Galician sayings

Some time ago I wrote a post about some popular sayings in the English language. Today it's time to talk about a couple of funny sayings in the Galician language.

As you may know, I'm from Spain, but when I tell people I always specify that I'm from the part of Spain where it's rarely sunny and people aren't particularly fond of flamenco. Then people often say "oh, Basque?" and I explain that the Basque Country is in the North, while I'm from Galicia, in the North-West. In Galicia we have our own language, fittingly called "Galician", which is related to Portuguese (they were one and the same language until the 14th century, though there are many people who claim they still are.)

Galicia is notorious in Spain because it's way rainier than the rest of the country. Its capital is Santiago de Compostela, my hometown, which is notorious in Galicia because it's way rainier than the rest of the region. So I assume it wouldn't surprise you if rain featured heavily in our popular sayings. This post, in fact, is about three of those sayings.

The first one is a proverb: "nunca choveu que non escampara", which means "it's never rained for so long that it didn't eventually stop". For my region, that's quite an uncharacteristically optimistic saying that means that bad things don't last forever, so there's no need to despair. Or perhaps it's just that it rains so relentlessly that people need to be reminded that it will stop.

The second one is something you say to someone who's acting foolish or making little sense. "A ti chóveche", literally means "it's raining on/in you". You can say it too of a third person: "a ese home chóvelle" ("it's raining in that man"). I'm guessing it's short for "a ti chóveche na cabeza" ("it's raining inside your head"), which to me is quite evocative. It's basically saying that this person's head is so empty there's enough room for water to evaporate, gather into clouds, condensate and precipitate in the form of free-falling drops of water. That's quite a lot of emptiness.

The third and final one for today is "xa choveu", which means "it has rained [quite a bit since then]". You say it to express that quite a long time has elapsed since something. For example, you show someone a photo of your childhood, and this conversation ensues:

"Mira que delgado estaba nesta foto." ("Look how thin I was in this photo.")
"Xa choveu." ("It's been quite a while since.")
"Vai tomar polo cu." ("I resent that remark.")

The last sentence is not translated literally, because I've often observed that English speakers have a lower tolerance for profanity than Galician speakers :-)

For now, that's it for rain-related Galician language sayings. I should probably write a post about Galician language profanity, since we have quite a bit of it, and it's quite creative even for rest-of-Spain standards :-)

(Post your comments in the accompanying Google+ post.)

I fixed my radio transmitter

(This was originally posted on Google+.)

Well, I finally looked carefully at the signal coming out of my antenna and, yes, it turned out that most of the energy was being spent outside of the frequency I wanted to transmit on. However, it wasn't because of images and spurious transmissions that took most of the energy... It was because I was actually transmitting on the wrong frequency!

Keep reading because it wasn't just a case of "herp, derp, turned the knob to the wrong position."

In Software Defined Radio we work with quite basic transceivers whose mission is to receive a radio signal and transform it into a form a computer can process, and vice versa. To do that, a lot of mathematics are used in the computer, using something we call "complex numbers". Those complex numbers have two components: a real part and an imaginary part (the name "imaginary" was given to it when mathematicians didn't understand complex numbers yet, so they thought those numbers were less "real" than the numbers they had been using up to that point, but I digress).

So an SDR radio receiver takes a radio signal, does some electronic manipulations, and generates two signals that are converted into complex numbers by the computer. One of those signals, called I, will become those numbers' real parts, and the other signal, called Q, will become the imaginary parts.

When it's time to transmit, the computer takes the complex numbers' real parts and generates an I signal, and also generates a corresponding Q signal from the same numbers' imaginary parts. Those two signals go to the SDR transmitter, undergo some electronic transformations, and become a radio signal.

The problem with my setup was that the wires for the I and Q signals were crossed in the transmit path.

The effect of this is that the signal went out on the wrong frequency. Generally I had my "center frequency" set to 14.080 MHz and my transmit frequency set to 14.097 MHz. However, as I and Q were crossed, the transmitter took the real part as imaginary and the imaginary part as real, which mirrored the transmitted signal around the center frequency, and my transmission went out on 14.063 MHz. Oops!

Fortunately for me, I was transmitting with a small magnetic loop antenna, which has limited bandwidth (I explained this yesterday), so it is likely that only a very small fraction of this out-of-frequency signal actually went on the air, and the rest was converted to heat in the antenna.

Now, I don't know if I've mentioned this, but my signals had actually been received three or four times in the past two weeks. Also, when I used a shortwave radio to listen to my transmissions, I could hear my signal clearly on the right frequency. It's natural that you'd ask how this would be possible, if the signal was going out on the wrong frequency.

The answer is simple: before the complex numbers coming out of my computer get into the transmitter, they first go through a sound card, where they get turned into the I and Q electrical signals, and then they travel to the transmitter through audio cables. Stereo audio cables, to be precise, that have three wires: a ground wire, a wire for the left speaker, and a wire for the right speaker. In this setup, one of the speaker wires carries the I signal, and the other carries the Q signal. When you have two wires running in parallel carrying alternating currents, they induce small currents on each other, which causes a little bit of crosstalk.

So, with this crosstalk, by the time the signals arrive at the radio transmitter, the wire for the I signal will also carry a little bit of Q signal mixed in and vice versa, and when it's finally transmitted, there will be a tiny signal in the originally intended frequency. I could hear it on my radio because it was very close to the antenna, and it was sometimes heard farther away because I was using WSPR (pronounced "whisper"), a digital mode intended for low-power signals, so the people who received those signals were already listening for very faint transmissions.

After fixing this issue I sent another transmission through WSPR. This time, four stations heard me at once; the farthest of those stations was in Alaska. My second signal was heard in New Zealand. Both were transmitted with 1 watt of power. I think it is safe to say that both my transmitter and my homemade antenna work correctly now :)

And now I have a 50-watt amplifier to fix.

Improving my homemade amateur radio antenna

(This was originally posted on Google+.)

Yesterday I worked a bit on my magnetic loop antenna. More properly called a "small magnetic loop antenna" (or SMLA for short), it basically consists of a long loop of wire connected to a variable capacitor. The loop of wire forms an inductance, which together with the capacitance forms a resonant circuit. So by wiring it appropriately, you can use a SMLA to receive and transmit signals in the SMLA's resonant frequency, which you can change by turning a knob to vary the capacitance.

As you might guess, the more resonant the antenna is, the better it works: the signals in that frequency are amplified more. Also, when the antenna is more resonant it has narrower bandwidth: the energy in the antenna is concentrated into a smaller band of frequencies. The amount of resonance is given by a number called "quality factor" (or Q, for short). Q is affected by the values of the inductance, capacitance, and resistance in the SMLA. In particular, the lower the resistance, the higher Q is. So if you make an SMLA you need to reduce the electric resistance as much as you can to get the best value of Q.

There is another reason why it's important to reduce the electric resistance if you want to make a transmitting SMLA: the antenna's radiation resistance is very small, in the order of milliohms, so any additional resistance reduces the antenna's efficiency dramatically.

People like me, who are used to dealing with continuous currents, would think that it would be enough to use wide-gauge wiring, solder all connections to reduce contact losses, etc. A couple of weeks ago I measured my SMLA's resistance as 50 milliohms, which doesn't sound so bad; however my antenna's Q factor seemed quite low and my transmissions were heard by nobody.

What I'd missed is that alternating currents (and radio waves in a cable are alternating currents) don't travel along the full section of the cable, like continuous currents: there's a phenomenon called "skin effect" by which those currents only travel on the surface of the conductor. The higher the frequency, the shallower the skin: for example, in copper, at 14 MHz, most of the current is concentrated at a depth of less than 17 micrometers.

The first consequence of this is that the resistance of a wire doesn't go down with the square of the diameter of its section as for continuous currents, but linearly with the diameter. So using wide gauge wire doesn't help much. What you need to use instead is flat ribbon or, even better, copper braid: braid has a lot of surface area for its volume, so it should present a low resistance to alternating current.

The second consequence is that you should avoid solder joints: since the current travels on the surface, spots where the surface is tinned will have a lower conductivity than the bare copper surface.

So yesterday I remade the connections between the loop and the capacitor in my SMLA, replacing the 10-AWG wires with copper braid ribbons. I fastened them using screws and washers so that they were pressed against the terminals on the ends of the loop and the capacitor, making sure that as much surface area as possible touches.

This change has apparently raised my SMLA's Q factor: I can work on about 40kHz before having to retune, while before I could use some 60kHz. I hoped that transmit performance would also be improved, but, alas, nobody heard my transmissions the whole day today. I guess my antenna is not good enough yet.

There may be another explanation for this failure to be heard, though. Using a shortwave receiver I could hear spurious signals around the signal I wanted to transmit. Using an RTLSDR dongle I could see the spectrum around the frequency my transceiver was tuned to, and there were lots of spurs and images on transmit. I don't know if it's a fault in the particular transceiver kit I'm using, or whether it's a drawback of the design itself. In any case, this suggests to me that perhaps too much energy is being wasted on those spurs. That's certainly something I'll need to look at again and more carefully.

Why a radio signal carrying Morse Code is called Continuous Wave even though it's turned on and off

(Originally published on Google+.)

As you may know, lately I'm into amateur radio. In this world, Morse code is still alive and well, though it is not necessary to learn it to get a license. When two operators use Morse code to communicate, quite often they use a mode called "Continuous Wave", or CW for short.

For quite a while I thought that CW was quite an odd name for a way to transmit Morse code. There's certainly a wave: that's the radio wave on which the Morse code is modulated. What I didn't see so clearly was the reason for the "continuous" adjective. After all, the wave is being turned on and off all the time: that's precisely how you can send Morse. If it's being turned on and off, it's not continuous. What's the deal?

Well, the deal is that before we had continuous waves, we already had Morse code on the radio, transmitted with a different kind of radio wave: the Damped Wave.

A Continuous Wave is a sinusoidal wave with a precise frequency. Nowadays it's very easy for us to produce precise and stable sinusoidal waves using pretty cheap electronics. However, in the early days of radio it wasn't so: there weren't good enough electronic oscillator circuits that could produce a quality continuous wave. So radio stations used a different mechanism to produce a different kind of radio waves.

This mechanism was the spark-gap transmitter. The general idea is that a high voltage across a gap produces an electric arc (a spark). The transmitter contains a circuit that, when an arc starts, produces a "ringing" oscillation, like the sound of a bell being struck once by a hammer. This oscillation is fed to an antenna to transmit it as a radio wave, which is called a "damped wave" because it loses amplitude with time, just like the sound of a bell stroke.

As the damped wave only lasts for a tiny fraction of a second, the spark gap is set up so that those sparks are extinguished almost as soon as they start, and a new one starts almost immediately, which produces another damped wave. In this way, lots of damped waves are produced and transmitted every second, like a school bell ringing seemingly continuously because its hammer strikes the bell several times per second.

The problem with spark-gap transmitters is that they are very inefficient and produce a prodigious amount of interference, so a lot of effort was spent in discovering a good way to generate a "continuous wave" that doesn't lose strength with time so you only need to produce the one wave and turn it on and off as needed.

Eventually, several systems were developed, like high-frequency electric generators, electronic oscillators, etc. As those became commonplace, the old spark-gap transmitters and the damped waves they produced were retired and then banned worldwide (so big was the interference problem).

And that's why a radio signal carrying Morse Code is called Continuous Wave even though it's turned on and off.

How magnetic stripe cards work

Lately I've been experimenting with a magnetic stripe card reader. In summary, I bought the cheapest one I could find on Amazon, opened it up, soldered some wires to it, added some electronic components, plugged it to my computer's microphone socket and recorded things like this: the raw signal read from a magnetic stripe. In this post I'll explain how magnetic stripe cards work and how to decode them.

Magnetic stripe cards were invented by Forrest Parry in 1969, which was quite the prolific year for giant leaps for humankind. The first company to develop and produce those cards was IBM, which chose to leave the basic ideas "open" for the rest of the industry to develop their own card systems. Some time later, the banking and airline industries met up and defined a set of standards so that all magnetic stripe cards would have the same size, their magnetic stripes in the same position, use the same encodings, etc.

The magnetic stripe is the usually dark-colored strip that appears in the back of the card. The data in the card are recorded in the magnetic stripe, but to read on how those data are stored, you'll need to click the "read more" link.

Mystery signal challenge

I'm currently doing some experiments with electronics, and in the process I captured the signal you can find in the attached file. I captured it through my sound card's microphone input, and I've amplified it in software so it's easier to "appreciate". (Update: I've managed to perform a way better capture, so this is as it comes straight from the sound card, with no extra amplification.) Obviously I know what it is, but I'd like to know who among the people who happen to read this will also be able to identify it — and better yet, tell me what's in the signal.

One clue: this signal is produced by something that was invented in 1969.

Post your guesses and comments in the story on Google+.

Cómo demodular radio FM estéreo

En el artículo anterior hablé de cómo demodular una señal de radio AM o FM, y en este artículo voy a hablar de lo que os encontraréis después de la demodulación (lo que di en llamar "el programa"). Tal vez os sorprenda que vaya a dedicar un artículo completo al asunto, pero, como podéis imaginar por su longitud, puede tener bastante tela. Al menos, para nuestro alivio, el asunto es muy sencillo en AM y en FM "mono": después de demodular la señal de radio, lo que tenemos es una onda sonora. Sin embargo, la cosa se complica cuando se trata de FM estéreo.

En un sistema de sonido monofónico sólo hay un altavoz, o hay varios altavoces pero todos reproducen la misma señal sonora. En un sistema de sonido estereofónico, en cambio, hay dos juegos de altavoces; uno que reproduce sonidos destinados al oído derecho y otros que reproducen sonidos destinados al oído izquierdo. Esto permite realizar efectos como hacer aparentar que un sonido procede de una determinada dirección (el sonido estereofónico se inventó para el cine en los años 30; la palabra "estéreo" viene de la palabra griega στερεός, que significa "sólido").

Cuando quisieron inventar un sistema para transmitir sonido estéreo por la radio, decidieron añadir esta capacidad a la radio FM. El objetivo era que una emisora FM pudiese transmitir sonido estéreo por el mismo canal que venía usando para el sonido mono de manera que las radios monofónicas que ya estaban en el mercado pudiesen recibir correctamente esas transmisiones estéreo, aunque (por supuesto) se escuchasen en mono. Para ello, las frecuencias audibles del programa demodulado deben contener una señal monofónica de manera que una radio FM mono pueda tratar el programa estéreo como si fuera un programa mono y que se oiga igual la música o las noticias o lo que sea. Sin embargo, no había nada que impidiese añadir más información en frecuencias superiores a estas frecuencias audibles. Lo que hicieron fue precisamente eso: generar una onda con toda la información necesaria para reconstruir la señal estereofónica y desplazarla en frecuencia hasta una frecuencia inaudible, y luego hacer que el receptor la vuelva a trasladar hasta las frecuencias audibles.

Tengo dibujitos y diagramas en el artículo completo, que podéis leer pulsando en "leer más". O podéis no pulsarlo y quedaros con la duda para siempre. Vosotros mismos.

Modulación en amplitud y modulación en frecuencia

Imaginad que tenemos un programa que queremos emitir por la radio. Este programa podría ser una canción, o un partido de fútbol, o un noticiero, o lo que sea. El programa puede ser en directo, o puede estar grabado en una cinta o en un CD o en un MP3. En todo caso, el programa se compone de ondas sonoras que queremos convertir en ondas de radio para que la gente pueda recibirlas y escuchar el programa en sus casas.

Obviamente, esto no es tan sencillo como enchufar directamente el micrófono o el reproductor de MP3 a la antena emisora. Si esto pudiese funcionar, sólo podría haber una emisora de radio en cada sitio. Además, las ondas de radio no se transmiten nada bien a las frecuencias de las ondas sonoras; para una buena transmisión, las ondas de radio necesitan tener frecuencias de cientos de miles o millones de ciclos por segundo. Por lo tanto, es necesario un proceso para convertir las ondas sonoras de baja frecuencia en ondas de radio de alta frecuencia; este proceso se llama modulación.

Pulsad en "leer más" para leer más. No pulséis en "leer menos" porque no lo hay.