Feb 23, 2013

Voice over laser

So now that I have the laser, I might as well try fun stuff out with it. Like modulating the beam. I know hams have experimented with long-range laser communication, so maybe it could even work.

So I built a poor girl's beam modulator. It is, in essence, a sophisticated optical apparatus which I call a "Laser". It consists of a piezo buzzer stolen from a defunct fire alarm, a piece of a makeup mirror I broke, and lots of Blu-Tack, among other things. The piezo buzzer is directly connected to my laptop's audio Line Out, so I can make it buzz arbitrary signals. The piezo makes the mirror vibrate, which causes deviations in the beam's direction. Kind of like a DMD, except not digital nor micro.

The receiver side is situated a short distance away. It is just a simple wide-spectrum photodiode. It connects to another sound card's Line In. When the beam deviates a little, it won't directly hit the diode any more, and this causes the diode voltage to fluctuate. This should allow us to send information over the channel.

I found a piece of audio with a folk tune in the beginning followed by a lady reading out numbers. I applied a suppressed-carrier single-sideband modulation at 6 kHz, so as to avoid the hum caused by lighting in the room. It's painfully trivial using SoX and Perl, by the way:

I still need to make some amplifiers. The piezo could take a lot more voltage, but line level only goes so far. Also, the unamplified output of the photodiode is very weak at -90 dB, so we're almost hitting the 16-bit quantization floor. Here, the blue spectrum is a local test signal; the diode output is in red.

However, audio from initial crude testing is actually pretty intelligible. In the beginning, you can hear the 50 Hz buzz caused by flickering lamps, and then me tuning the heterodyne to 6.000 kHz. The noise mostly comes from 16-bit quantization/dithering.

Feb 16, 2013

The laser-equipped Lego train

In a previous post I was not very happy with the results of my opto-acoustic capture of the miniature gramophone record, so today I thought I'd try to illuminate the record surface more evenly.

Of course, the straightforward solution is to build a circular LEGO® railroad track around the record and have a laser-hauled train run around the track, illuminating the record surface with coherent light at a constant tangential angle, while a camera captures the image at long exposure.

This time I didn't want to go through the trouble of positioning the high-resolution camera and only got this:

I learned that Lego is not very good for laser work in general; specifically the trains don't run very smoothly, as you can see in the above pic. Updates with audio will follow, anyway. In the meantime, here's a video.

Bonus points if you can hear what's happening in the background.

Update: I didn't post an audio update, because the audio was useless. And the whole laser thing was a dead end anyway. Instead, I edited the high-res photo I took earlier, removing the extreme shadows using Gimp's Dodge/Burn tool, then changed my Perl code a bit so that it actually stays on track, and made this:

Now I can put the robot back together and close this case.

Case modding, the polish way

If you're still using CD-Rs like me, and you store them in cardless "slim" jewel cases, you've probably noticed that text written on the spine is pretty invisible:

But fortunately there's always that bright-colored nail polish you never actually use.

Text appears! It's magic!

Feb 9, 2013

A science campus Marauder's Map

There are hundreds of Wi-Fi access points at our campus. They're constantly broadcasting a beacon signal that identifies each station by a MAC address. The signals can be passively received by any Wi-Fi equipped device. Exploiting this fact, I wrote a program to help locate lost students and staff wandering around the campus. I submitted it as a project for my positioning class.

Before the positioning would work, I could be seen walking around with my computer and mapping the Wi-Fi signal at various places. I would stay in one place for several minutes and collect signal strengths of all devices in range. I would then take each pair of access points and calculate a power ratio every few seconds; then assume a normal distribution and fit a Gaussian curve onto it; and save the Gaussian parameters in a database along with discrete location information input manually. (Kjaergaard, M.B. "Hyperbolic Location Fingerprinting: A Calibration-Free Solution for Handling Differences in Signal Strength", Pervasive Computing and Communications, 2008, Sixth Annual IEEE International Conference on, pp. 110–116)

To determine the position of a computer, a script is run that lists all signal strengths of all stations in range. Again, power ratios are calculated, and the fitted Gaussians are compared to Gaussians saved in the database. A location with the highest probability is determined using Bayesian inference and plotted on a map inspired by the Harry Potter realm.

~/koodi/wstalk - zsh ×
Hearing 40 APs ┌─────────────────────────────┐ │═ │ 9.417e-217 24 Haxxorointiluokka │═════════════════════════════│ 2.011e-207 28 Navetta │══════════════════ │ 2.607e-211 27 Gurulan sohva │════ │ 8.437e-216 25 Gurulan pöytä │═══════════════════ │ 8.032e-211 25 Unicafe Exactum (Gurulan puoli) │═══════════════ │ 1.079e-212 25 CK112 t │══════════════════════ │ 1.107e-209 25 CK112 k │═════════════════ │ 9.121e-212 25 CK112 e │════════════════ │ 1.986e-212 24 Unicafe Exactum (Normaali puoli) │ │ 0.000e+00 2 BK107 │═════════════ │ 4.054e-214 27 D123 │═ │ 6.020e-218 18 C127 │ │ 0.000e+00 12 C222 │ │ 0.000e+00 10 D234 │ │ 0.000e+00 9 B123 t │ │ 0.000e+00 0 Liikuntakeskus │ │ 0.000e+00 0 Unicafe Physicum │ │ 0.000e+00 0 Chemicumin aula │ │ 0.000e+00 2 A111 t │ │ 0.000e+00 4 B221 │ │ 0.000e+00 0 Unicafe Protoni │ │ 0.000e+00 0 Unicafe Neutroni │ │ 0.000e+00 5 B222 │ │ 0.000e+00 12 C323 │══════ │ 8.308e-215 25 CK110 │ │ 0.000e+00 0 Puutarha │ │ 0.000e+00 0 Kirjasto: yläkerran lukumesta │ │ 0.000e+00 0 Kirjasto: hiljainen lukusali │ │ 0.000e+00 0 Kirjasto: alakerran lukumesta (íkkunat) │ │ 0.000e+00 0 Kirjasto: alakerran lukumesta └─────────────────────────────┘ we're in: --> Navetta <-- done

This is fun but presents a few problems. To get low-level access to the Wi-Fi interface on Linux, iwlist wlan0 scan needs to be run as a privileged user (i.e. root). Also, the prerecorded model of signal strengths gets out of sync with the real world in a few weeks, probably because of minute changes in room interiors. The positioning still works, but room-level resolution is lost. An automatically updating model would be practical, since the manual recording phase is pretty tedious.

The Perl source is on GitHub [hox: for scientific interest only; it's not a complete, working program].

Feb 2, 2013

The Atomic-Powered Robot

This is my mechanical baby, Tommy. He's an atomic-powered [sic] robot that can talk and walk around the room. Born in 1984, he's been with me since the early 1990s, but for the last ten years he's been quite ill and not able to talk.

Today I finally fixed him. While doing that, I decided to do a full autopsy for the sake of science, as I've found his vocal cords especially intriguing. So please observe: Tommy's internals. (As with all medical imagery, it's not for the faint of heart.)

Tommy's belly is dominated by a pink-colored contraption that looks like it has a speaker on the front. The pink device gives Tommy his ability to utter the words "I am the atomic powered robot. Please give my best wishes to everybody!" and also make the sound of a laser gun. Below the sound player is the walking motor, which is quite simple and I'm not going to concentrate on it.

Removing the cover of the pink device, we see a large funnel-shaped object that looks a bit like a speaker. It has a tense plastic membrane, like a drumhead.

Now it gets really interesting. The speaker is resting on a tiny gramophone arm, which is playing a little vinyl record! There's even a simple electro-mechanical end-of-disc detection and arm-return mechanism. The vibrations of the needle are mechanically transferred to the speaker membrane; there's no electric amplification of any kind.

Could a gramophone record get any cuter?

And here's Tommy sending you his best wishes.

UPDATE: Okay, yeah, he's cute and all. But take another look at the above photo of the record. Don't you think it contains a lot of information about the recording? Perhaps you could even extract the audio from a good enough photograph. Just a silly thought.

Well, let's get to it.

First I'll need a good quality picture of the record's surface. My roommate lended me her expensive camera for this purpose. To get the rough surface evenly exposed, I used an exposure time of 10 seconds with an aperture of f/32. I circled a lamp around the record for 10 seconds and got this cool image.

I'll hint the positions of the groove at every turn and then let Perl interpolate a smooth spiral:

I'm going to read the record along the spiral at 360 RPM and just convert the pixel brightness at every point of the groove into PCM amplitude. This will probably result in something audible, although quite noisy. There appears to be two interleaved grooves: one for the speech, one for the laser sound. The groove gets randomly selected when the robot's head button is pressed, depending on where the needle happens to land. So I made a stereo sound file.

It's very noisy indeed and there's a lot of crosstalk, but something can be heard in the background. After edge detection on the image and some noise removal on the audio:

Update: Further studying of the record and better sound samples in "The laser-equipped Lego train".