Why you should read planet.debian.org from time to time

30.12.2005 16:10

Wow. I just found out that Linux kernel on my machine wasn't using all of the available memory.

Posted by Tomaž | Categories: Code | Comments »

I like snow

28.12.2005 22:23
Posted by Tomaž | Categories: Life | Comments »

Interesting PCB etching hack

28.12.2005 15:02

Toner transfer etching looks simpler and cheaper than the photoresist method I've been using recently. I have to try it some day. (found via hackaday.com)

Posted by Tomaž | Categories: Ideas | Comments »


26.12.2005 19:03

I heard several (mostly older) people say that the electric current is "stronger" in the evening. This was usually said in reference to cooking on electric stoves - for example you need to set the stove on a lower setting in the evening to get the same effect as with a higher setting in the morning. Recently I got into an lengthy argument about whether this is true or just an urban myth, so I decided to check it myself.

The UPS on my server keeps logs of the RMS voltage in the electricity distribution network so this seems to be a good point to start.

As you can see the voltage in the socket can vary as much 15V during a day and is far from the declared 240V.

On the other hand the digital voltmeter in the UPS can't be trusted, since it wasn't designed for such precise measurements (its only purpose is to tell the UPS when to switch to battery power). Because of this I double checked these values with a true-RMS voltmeter and it looks like the UPS measurements are constantly off by 10 volts (UPS shows 228.0V, voltmeter shows 238.0V), however the relative values seem to be quite accurate.

So let's say that I want to boil 2 liters of water on a 1kW electric stove. Such an electric stove has a heater with resistance of R=(240V)2/1kW=57.6Ω. To heat 2 liters of water from a room temperature of 20ºC to 100ºC you need Q=m·c·ΔT=4200J/kgK·2kg·80K=672kJ of heat. If the electric stove is operating at its declared power it will provide this quantity of heat (if we ignore the heat loss) in t=Q/P=672s=11.2min.

Now let's see how much time it would take to boil the water if we take into the account the swings in the line voltage. The graph shows that the lowest voltage measured is 222.2V. This is Umin=232.2V when corrected for the UPS measurement offset. At this voltage, the stove has a power output of Pmin=Umin2/R=936W. It will heat 2 liters of water to boiling point in tmax=12.0min.

On the other hand the highest measured voltage is Umax=247.5V. This gives the power output of Pmax=1063W and the water will boil after tmin=10.5min.

The maximum difference is obviously 1.5min or around 13%. This is value falls somewhere in the middle: I can't say that I would notice if the water for my spaghetti would begin to boil 90 seconds too early, but it is quite possible that some people can notice that. On the other hand most modern electric stoves have thermostatic control. This means that the temperature of the stove is controlled with some kind of a feedback loop. This loop should attenuate any effects of the line voltage swings to such a degree that I'm sure noone could notice (even if with a stopwatch I don't think you could measure any effects but I'll try to prove that at some later time).

Posted by Tomaž | Categories: Life | Comments »


24.12.2005 21:51

Happy winter solstice everyone.

Posted by Tomaž | Categories: Life | Comments »

Applied transmission line theory

17.12.2005 20:00

Today I saw this very interesting downspout (pipe that carries rain water) in Idrija. It bares amazing resemblance to an electrical transmission line that has a single short-circuit stub before a change in the line impedance.

For some reason I find this to be extremely funny.

Posted by Tomaž | Categories: Analog | Comments »

Thank you Borland

15.12.2005 21:21

Thank you Borland, for making your antique Turbo C 2.01 compiler available on the internet as a free (as in beer) download.

I was stuck with my keylogger project. For some reason as soon as the size of the code for the 89C4051 microcontroller grew above 2048 bytes it stopped working. The program ran fine in the simulator but when I burned it to the actual chip, it remained completely dead.

I first suspected the old Keil compiler I'm using. But why would the code then run fine in the simulator? The programmer was also unlikely to cause this kind of a problem because the flash memory on the controller is programmed via a serial bus. So it is impossible for example for a single address line to loose connection.

At the end it turned out that the programmer software, a small DOS program, was only capable of dealing with 2 kilobytes of data at once. It took me so long to figure that out because the verify function also only compared the first 2 kb of the file on the disk with the first 2 kb of the flash memory. It looks like someone at Atmel really did not want to waste to much RAM.

After some searching on the Atmel website I found the C source code for this software, but without any instructions on which C compiler should I use. This string inside the compiled program gave me the first hint where to look:

MS Run-Time Library - Copyright (c) 1988, Microsoft Corp

So obviously this was compiled with a Microsoft C compiler. Now Microsoft C compilers for DOS vintage 1988 aren't exactly easy to find so I installed the best alternative I could find on my FreeDOS machine - Borland Turbo C. Of course the compiler then gave me a ton of errors. For example, Microsoft C obviously known C++ style comments back then, but Borland didn't. Also Microsoft C used some ugly-named functions for dealing with character graphics. Compare for example this from MS:

_clearscreen( _GCLEARSCREEN );

With the equivalent from Borland:


Luckily some search & replaces with the DOS version of VIM fixed that. It turned out however that a part of the program was written in assembler in a syntax that Borland C didn't recognize.

Some tweaking later I managed to successfully link the object file from Turbo C with the object file of the assembler part I got from Atmel that was made with Microsoft Assembler. I still can't believe that this worked. From my experience linking two object files even from different versions of the same compiler is asking for trouble.

After I got this working the solution to my problem was simply a matter of increasing a single constant from 2048 to 4096. So in case anybody else has the same problems, I'm putting the fixed compiled software on the net.

Posted by Tomaž | Categories: Code | Comments »

Emails and cosmology

13.12.2005 23:55

Let us say that on average I receive N emails per day, where N is a relatively large number, say 80 or so. On average I manage to read only a part of that quantity of emails, say kN, where k is usually much less than 1. The rest remains unread in my inbox. Since Murphy's law says that those unread messages are the most urgent and the senders of those emails will get upset because I didn't read them, they will re-send them the next day.

So after the first day I have x0 = N - kN = N(1-k) emails in my inbox. After the second day I'll have x1 = 2 x0 + N(1-k) = 2 N(1-k) + N(1-k) = 3 N(1-k) and after the third day I'll have x2 = 2 x1 + N(1-k) = 7 N(1-k).

If we substitute W=N(1-k) and write a recursive formula for the number of emails in my inbox on the ith day we get the following result: xi=2 xi-1 + W. It can then be proved that the non-recursive formula for xi is xi=W (2(i+1)-1).

The highest estimate for the number of atoms in the universe today (including possible dark matter) is somewhere around 1081. A simple calculation shows that for a very optimistic value of k=0.6, the number of stored emails on my inbox will rise above the number of atoms in the universe in n days, where n is roughly equal to (log2 (1081 / N(1-k) + 1) - 1 = 266.4.

If we apply the anthropic principle to this result, we arrive to the conclusion that the universe must be rapidly expanding. In the other case all existing atoms in the cosmos would be used for storing emails and none would be left to form carbon-based human beings which could then argue about cosmology and full inboxes. However if we disregard the anthropic principle we can arrive at a different conclusion with much more serious consequences. If the flow of emails will not stop until August 2006 the universe as we know it will cease to exist when it will no longer be capable of archiving arriving emails.


I would like to thank Tina for a very interesting and deeply philosophical discussion we had a few hours ago that led me to the conclusions written above. I would also like to thank all CS students who need help writing various GA projects and several high-volume mailing list for providing crucial statistical data for this research. And no, the number of unread emails that have accumulated recently in my inbox had absolutely nothing to do with this line of thoughts.

Posted by Tomaž | Categories: Ideas | Comments »

Google rank

11.12.2005 0:33

It seems that with the recent addition of Tablix package to Debian Unstable, https://www.tablix.org finally became the first hit on Google for tablix. Until now the first hit for this query was the old page at www.kiss.si which only contains a link to the new page.

It took 10 months for Google to find out that the page has moved, which is kind of interesting. Also interesting is that Tablix Systems, which appears to be a Danish software company that has nothing to do with my timetabling software, barely gets on the first page of results.

Tablix is now also the 19th hit (second page) for query timetabling, a great deal behind FET, a free software project similar to Tablix, which is on the 8th place.

Posted by Tomaž | Categories: Life | Comments »

Keylogger project, 7

05.12.2005 19:25

Finished circuit board front:

and back:

I also found out that overtone 24MHz quartz crystals don't work here since they tend to oscillate at their fundamental frequency instead of their 3rd overtone. When I used an overtone quartz the keylogger stopped working because the microcontroller ran at 1/3 of the correct clock frequency.

Posted by Tomaž | Categories: Digital | Comments »

Interesting NetHack patch

04.12.2005 18:19

I guess the author of this NetHack patch died of hunger one time too many in the Mazes of Menace. Now if you are feeling hungry, your deity is angry with you and there are no edible creatures around you can simply pull out your cell phone and order a pizza. Wonderful.

Posted by Tomaž | Categories: Life | Comments »

On latex gloves

03.12.2005 19:35

I was etching the printed circuit board for my keylogger project today. When I tried to turn the board over in a bath of hydrochloric acid and hydrogen peroxide I got this warm feeling in my left palm. I quickly withdrew my hand from the acid and saw that the protective glove I was wearing had three little holes near the center of the palm.

I quickly washed my hands under running water and everything turned out fine in the end (the circuit board looks great), but I'm never going to buy another pack of "beste qualität" Spontex disposable latex gloves again. When I checked four other gloves in the box, two disintegrated when I just tried to put them on. And this was a freshly opened pack I bought a week ago (no "best before" or production date printed anywhere on the box).

I wonder if these guys are also making condoms of such fine quality.

Posted by Tomaž | Categories: Life | Comments »