Sunday, June 10, 2012

One hot Pi


I've been busy the last couple of days with the Pi and slowly setting up the server and website which will host the data from the sensors.
I've noticed that two parts of the board get hot really quickly after it's turned on: the main CPU and the LAN/USB controller. Apparently this is acknowledged by other users too, but the common agreement is that it does not heat up so much that it could be harmful to the board - around 50 °C.
Nevertheless, I think it's better to try to reduce the heat on the components somehow, so I was very happy today when we found some aluminium heatsinks at my friend's house that came with his old graphic card.
Since the heatsinks had a film of glue on the bottom already, it was very easy to install them on the board. The heatsinks fit perfectly over the CPU, but are a bit too large for the LAN/USB controller. I didn't want to get messy with metal saws and files so I just hoped nothing gets shorted and attached the heatsinks to both units.
The board with the new heatsinks.
 It worked! The board is now running for several hours, not minding the new attachments. The heatsink over the CPU is noticeably cooler than the CPU was before, and the other heatsink is still quite hot, but this only means that it's dissipating more heat away from the LAN/USB controller.
So this mini-project has been a success. It will help to cool the board and probably extend its working life.

Sunday, June 3, 2012

The Pi has arrived


After a long, long wait and countless delays, it's finally here.
The Raspberry Pi.
I ordered one on day 0, the rarest of all dates - 29. February, along with hundreds of thousands of other enthusiasts, and after exactly three months it arrived in the mail.
I didn't have much time to play around with it yet, so just a few quick thoughts:
It's really picky about the SD cards and power supplies. The SD card issues are being fixed with the firmware upgrades though, and hopefully it will support more cards as they figure out the problems.
My plan is to build a weather station based on the Pi and some sensors. For now there will only be the bare minimum pressure and temperature sensor BMP085 but I will be adding others over time.
Some pics:
The first encounter
The first successful boot - I had to use a different SD card, power supply, and boot settings to make it work.
The pic is crappy because the phone's camera is crappy.
Pi over SSH - very smooth and easy to set up.
This is it for now, I will be adding new posts when I really start to work on the weather station.

Friday, December 23, 2011

Automated Mathematica language module BBEdit or TextWrangler


I realize that a few people will find this useful, however those will appreciate it.

If you're a frequent user of Wolfram Mathematica like me, you've probably found yourselves in situations where you could not simply edit your code stored in notebooks (files with.nb extensions) with Mathematica itself. This could be due to various reasons, for example when you don't have Mathematica installed on your current machine or operating system. Luckily, most, if not all, text editors can open and edit notebooks. However, if you use a text editor that supports advanced features like syntax coloring, you will be disappointed when the whole Mathematica code will be in the same default color.
My text editor of choice on OS X is TextWrangler, developed by Bare Bones Software, Inc. In my opinion it captures the perfect balance between the simplicity of use and its many powerful functions. It is also free, in comparison to its bigger brother, BBEdit, which comes with even more features.
Both TextWrangler and BBEdit support syntax coloring for a number of programming languages out of the box, but Mathematica is not one of them. This is not a problem though, as you can easily create a so called language module, a property list (file extension .plist) file with syntax coloring specifications for your language of choice that the text editor will recognize.
Of course, the first thing I did when I found out that TextWrangler does not recognize the Mathematica code was go to google to search for the language module. The only useful result was an old blog post with the property list file made long ago in 2004 for Mathematica 5.0. Now, seven years later, Mathematica has more than doubled the number of its built-in functions, so I was not really satisfied with it. Getting the list of all built-in functions in Mathematica is very easy, so I used parts of that deprecated code to create my automatic generator of the property list file that will always be up to date. It's written in Mathematica and it's only required to be run once every time you install a new version of Mathematica. It supports both TextWrangler and BBEdit. I'm releasing property list files for both TextWrangler and BBEdit (built with Mathematica 8.0.4, in case you don't have access to Mathematica or you have an older version) and the notebook with the generator code under the Creative Commons Attribution-ShareAlike License.

Download the files below:

Saturday, March 26, 2011

Calibrating a scale


A digital scale is an instrument that should be found in any modern laboratory. They are very cheap and come in various capacities and accuracies, from 1000 g ± 0.1 g to 20 g ± 0.001 g. I have bought a 1000 g ± 0.1 g one a while ago and I think they are the most common. All of them should come pre-calibrated, but you can't know if the calibration was accurate for sure. And because usually you don't have a set of calibration weights at home, you don't know how to do it yourself. It's actually quite simple, providing you have some spare change lying around.
My scale has an option for calibration that demands putting on a scale of declared weight from 1000 g down to 50 g in decrements of 50 g. After some calculations I decided that 100 g weight in coins is the best choice. You will soon understand why.

Using this simple brute-force formula in Mathematica I calculated all possible solutions for various weights:
Reduce[e2*8.5 + e1*7.5 + c50*7.8 + c20*5.74 + c10*4.1 +
    c5*3.92 + c2*3.06 + c1*2.3 == 100 && e2 >= 0 && e1 >= 0 &&
  c50 >= 0 && c20 >= 0 && c10 >= 0 && c5 >= 0 && c2 >= 0 &&
  c1 >= 0, {e2, e1, c50, c20, c10, c5, c2, c1}, Integers]
total weightpossible solutionsmin. number of coinsmax. number of coinsmin. value of coinsmax. value of coins
50 g1156200.29 €11.00 €
100 g467412410.57 €22.00 €
150 g5285818620.85 €33.00 €
200 g31847624830.97 €44.00 €
Note that the solution with minimum coins always has the maximum value, and vice versa.

As you can see the number of solutions increases greatly with each weight. It roughly follows an exponential power function[1] shown on the next plot.
Log-plot of possible solutions vs. total weight.
I think the optimal number of coins is about 30. If you'd want to use a larger number of coins it becomes more difficult to place them on the scale in time (the calibration time is limited, about 3 seconds) without any them falling off because you accidentally bumped a pile with your sausage fingers. A calibration with too few coins would be less accurate because every coin weight varies slightly from the declared weight.

Here are all of the solutions for 100 g total weight. You can download it and import in Excel or Mathematica or some other program if you want to play with it.
The solution with fewest coins and maxium value is the following:
10 × 2 €
2 × 1 €
Totaling 12 coins worth 22 €.

The solution with most coins and minimum value is the following:
1 × 10 c
1 × 5 c
3 × 2 c
36 × 1 c
Totaling 41 coins worth just 0.57 €.

And now for some statistics:
A comparison of coin weights by their values.
A comparison of total coins used in all solutions by their values.
You can clearly see the connection between the above plots. The lighter the coin, the more it will be used. No surprises here.
Also interesting are the distributions of the solutions.
Distribution of solutions by total number of coins used. It almost follows the normal distribution, but there is an unexplained shift of the peak to the left of the calculated distribution.
Distribution of solutions by total value of the solution. This one follows a Chi-square distribution instead of the normal distribution. Note that I've rounded the values to 10 cents for a better representation. The plot with original values can be seen here.
And here is my digital scale, freshly calibrated.
The combination is 11 × 10 c; 6 × 5 c; 8 × 2 c; 3 × 1c - the only one possible with the change from my wallet.
I hope you will find this useful and will calibrate your scales if you haven't already. And remember, it's best to use new coins straight from a bank. Dirt, oxides and scratches on the coins will cause an inaccurate calibration, especially with a more sensitive scale.


[1] The name is my own invention for functions of the type y = a^x^b since I couldn't find any information of this type of functions on the internet.

Wednesday, March 16, 2011

A cup of coffee, please


Warning: high levels of nostalgia

There is a quite well-known urban myth regarding the ritual of drinking coffee. Some say that it's better to add milk right away if you want to cool the drink faster, others say it's better to wait a bit.
Almost two years ago I decided to clear all doubt concerning this argument. It was August 2009 when I got my first pair of the (well known for regular readers) digital thermometers, and this experiment was perfect to make them useful.

So I gathered all the required instruments: two identical digital thermometers, two identical ceramic cups (0.15 L each), two identical stainless steel spoons and a digital camera.

I cooked a large pot of coffee and poured equal amounts (0.1 L) of the boiling liquid into each cup wherein I have already put the probes of the digital thermometers. Then I immediately poured two spoons of refridgerated milk (kept at 8 °C) in the first cup and after approximately five minutes I did the same to the second cup. After every addidion of milk I stirred the mixture with the spoon for two full turns (clockwise).
An artist's impression; the original image is probably lost forever but the reproduction is pretty accurate.
Temperature of the room was 23.5 °C. The temperature changes were recorded in real time with a digital camera and the data was then processed for easier understanding. The thermometers were not calibrated, so there was a small difference between the initial temperatures. Also, the coffee was poured in the second cup with a small delay. I adjusted the data of the second cup accordingly.
The results:
The plot of the temperatures.
As you can see the temperature differences are minimal. The initial temperature drop after the addition of milk was about 5 °C for both cups. On average the coffee with the milk added right away was cooler for 2 °C before the addition of milk to the second cup and about 3 °C hotter immediately after. Because the thermodynamic phenomenon that a hotter body cools more quickly and the poor thermal conductivity of ceramic the first cup was actually cooler after seven minutes from the addition of the milk in the second cup. Unfortunately I was still a rookie scientist at the time and I did not have a control cup.
In conclusion it's pretty irrelevant when will you put the milk in because you probably won't even notice the difference. But it was still a fun experiment and all doubts about the myth are cleared.
Some possible extensions of the experiment: measuring the temperatures in plastic cups; measuring the temperatures when adding ice cubes into the drink immediately and after 5 minutes; measuring the temperatures with different mixing techniques; and so on.

Friday, February 25, 2011

At work


I work at the Jožef Stefan Institute in Ljubljana, Slovenia, in the Department of Surface Engineering and Optoelectronics. But don't let the title mislead you, I'm still a mere student. I took this job only because it sounded interesting and I have some free time to kill.

So what exactly is my job? I am studying the effect of plasma on the physical properties of polymers. More specifically, how plasma affects the surface energy of a polymer. I'm sure you have long forgotten everything about plasma and polymers, so here's a short reminder.

Plasma.

Plasma is a state of matter similar to gas, but obtaining it is not as easy. There are various types of plasma and even more ways to obtain them, but I won't get too much technical. As always, you can educate yourself by following the link to the trusty Wikipedia article. Nevertheless, you might have already come in contact with plasma without knowing it. For example, plasma lamps are in my opinion the cheapest way to generate significant amounts of plasma at home without running unnecesary risks of burning the house down or being killed by imploding glassware.
Plasma lamp
More dangerous than it looks!
Plasma TVs also contain some plasma (duhh) but if it weren't in the name you wouldn't even know it's there.

And why is plasma useful?

As mentioned before, plasma TVs (that provide the best looking picture of all technologies available to the common man.)
Also, metals and other materials can be coated, etched, cut and welded using plasma. (Who wants to melt some rocks?)
Also, fluorescent lamps (I still prefer the oldschool tungsten coil though.)
Also, various modern chemical analytical techniques are based on inductively coupled plasma. (This is the kind of plasma i'm wrking with, too.)

You can't immagine a world without plasma, really.

So to obtain plasma you need a strong pulsating magnetic field. For that, you need a pulsating electrical field. Long story short, connect the plug to the wall socket. But not so fast, you will also need a vacuum pump and a chamber where your gas of choice will be rarefied. In a semi-professional laboratory it will look something like this:
Plasma tube with the coil
Close-up of the Tube with some oxygen plasma in it. Note the Coil around it - this generates the necessary magnetic field.
Generator
The Machine. On the left there is a High-Current Electric Generator that powers the Coil. Also note the open-source CubeSpawn frame.

With all equipement provided working with plasma is a walk in the park. I just put a sample of a polymer in the tube, adjust the pressure to the appropriate level, provide some cooling if the things get too intense and then sit back and enjoy the show. After a couple of seconds the process is done and I can move to the next step - figuring out what just happened.

Surface tension and surface energy.

What is this all about? Wikipedia tries to help: "Surface energy quantifies the disruption of intermolecular bonds that occurs when a surface is created." What? Basically, it is a physical property that tells you how strong the drops will hold on to the surface of a given material. The lower the energy, the more the drop will stick to the surface and the more flat it will be (the "flatness" is defined by the contact angle).
Some drops wth different contact angles
Different contact angles correspond to different surface energies.
Bacause drops are usually small (I use 1 µL standard volume), a special instrument is needed for a precise determination of the contact angle. Here comes the goniometer.
Advex Instruments' Surface Energy Evaluation System
Advex Instruments' Surface Energy Evaluation System
This is nothing more than a webcam with a stage where you place the sample and some wheels to adjust the focus. All you have to do is connect the goniometer to a USB port and run the provided software. You can now make some pretty pictures of your droplets, and with a simple point-and-click procedure determine the contact angle.
See Software 6.0
See Software 6.0
Calculating the surface energy from the contact angle is a bit more complex and definitely more boring, so I will spare the details. Furhermore, everything is done automatically. Once I will have a nice large enough set of surface energy data corresponding the different pressures of the plasma and exposure times I will be able to make some pressure- and time-dependency plots. Stay tuned.

Thursday, February 24, 2011

By request: Setting up Google Voice from outside US


wThis does not come under my regular topics but I've received some requests to write an article about setting up a Google Voice Account from anywhere in the world. It can be done both on Windows or Apple OSX. Probably on Linux too, but I haven't tested it.

First of all, you have to have a computer with an internet connection and administrative rights.

After you've met all initial requirements, proceed to step one.

  1. Go to CallCentric.com and sign up for a free account. You can use a fake email addres for this, for example I use the website 10minutemail.com. Enter the requested details and confirm the registration with the new email that you will receive. Agree to the terms (read them if you want) and click "Sign me up". Step one status: done.
  2. If you now log in to your CallCentric account, you will notice your newly assigned SIP phone number in the form of 1777** where ** is a sequence of digits. Write this down or save it to a .txt file for later use. Step two status: done.
  3. Go to phone.ipkall.com and get yourself a real US phone number based on the information from your CallCentric account. I recommend using the same username, email and password for the sake of simplicity. In the field asking for a SIP username, write the previously copied SIP number. In the hostname field write "in.callcentric.com" without the quotes. Step three status: done.
  4. While you wait for a confirmation email from IPKall, download and install Express Talk (available for Windows and Apple OSX). After the installation run the application. You will be asked to fill in the information of your SIP account. Enter the SIP number of your CallCentric account, the same password you used there and for hostname, enter "callcentric.com". (Note how you must not write the in. prefix here. If you do, it won't work.) If all went well, Express Talk should successfully connect to the server and if you go to your CallCentric account, you should see a note saying "Your phone is registered". Step four status: done.
  5. Find a proxy listing site, for example I used this one. Make sure the proxy is using the port 80 and is stationed in the US, otherwise it will probably not work. Assuming you use Firefox internet browser on Windows, to use a proxy you must go to Tools -> Advanced -> Network tab -> Connection -> Settings... Here you select "Manual proxy configuration" and input the proxy IP and port number. Also check the option "Use this proxy server for all protocols". Confirm the settings. To verify that you are successfully connected to the proxy, go to ip-adress.com and it should show your location somewhere in the US. If the proxy doesn't work, try another one from the list. Step five status: done.
  6. Now is the time to finally set up a Google Voice account. While still connected to the proxy go to voice.google.com and log in with your Google account. If it says that Google Voice is unavailable in your country, delete your cookies and try again. If all goes well you should see a frame asking you to choose your very own Google Voice phone number. Search around for a bit until you find a number to your liking. In the next step choose a PIN number and write it down somewhere in case you ever need it. Next, enter your IPKall number that you previously registered, and click "Call me now". Hopefully Express Talk should ring and you can press the required numbers. This concludes the registration. Step six status: done.
The entire process status: DONE.

References: