Fighting with computers

Computers are not always friendly.

Thursday, June 26, 2008

Shopping list problem

Definitely this has been the most challenging problem I've found on the Code Jam practice site. It asks you to determine the optimal selection of what to buy where. With a couple of twists: the cost of going from one place to another is factored in; plus a rule that forces you to drive back home whenever you're buying perishable goods.

The approach that worked for me was to first consider the different combinations of articles from different shops, just to obtain the list of shops to visit for each instance. Each one of list of shops to visit is a traveling salesman problem (perishable rule just changes the cost of some of the links).

Combine both costs, the article's prices at selected shops and the transportation costs to determine how much each realization will amount. The minimum case is the answer you're looking for.

The main problem I faced with the large set is that unless the code is quite efficient (and mine was not) it will take a long long time to finish the calculation.

Thursday, June 19, 2008

Google Code Jam '08

I've just got a notice about the new edition of Google Code Jam. I guess if you like challenges it is a place to go. I've spent part of the evening solving the "Alien Numbers" problem just to discover how rusted I am. It was fun though, and it was satisfying to make it right (though not very fast I would say).

Monday, June 16, 2008

Single data packet TCP

For Ethernet enabled devices I've used in the past (and I was happy with) the cores from Rabbit Semiconductor. They offer a lot of data and program memory and a royalty-free TCP/IP stack.

Not in the same league but still surprisingly useful is the Ethernet shield I've bought from Nuelectronics (a UK-based company). The shield plugs-in nicely on an Arduino board and it can easily allow you to create a simple network appliance.

In the picture I have my sample system that using a DS18B20 digital temperature sensor offers the temperature reading as a web page.

All the code used is the sample code and TCP/IP library provided by Nuelectronics. I had some minor trouble with my setup as I am using the so-called parasitic power on the temperature sensor and a few lines of code where added to the original code to make it work. The symptom of the problem is that I was getting +85.00 C no matter what the temperature was. The cause was that the sensor did not get enough power from the 1-wire bus pull-up resistor. After adding these three code lines:

Add them just before the second call to OneWireReset to fix the problem, thus providing enough energy for the conversion to take place.

If all you need is an web-based thermometer you can buy the whole thing for less than 30 UK pounds.

In my case I needed the Ethernet interface for another project but I like the idea of the Internet thermometer (so I can see what's going on with my office's air conditioning).

Interestingly enough, the TCP protocol implementation I've used is based on the idea of just having a single data segment and then closing the connection. It keeps many things simpler and faster so the code can fit in a much smaller footprint.

I'm using a USB port to power this project but an external power supply is possible too.

Friday, June 06, 2008

Kudos to Canon

I dumped my old Epson color printer, an Epson Stylus Photo Color 830, after playing any trick to get a decent printing performance for quite a while (I failed). As we needed a new printer at home I searched and browsed around and I settled with Canon's IP4300 that also had good Linux support.

Unfortunately that model was no longer available (I learned this at the computer shop) so it was not an option. I guessed the next model, Canon's IP4500 won't be that different. It was cool as it could do duplex printing automatically.

I was wrong: While the printer worked like a charm ("New" is the best printer brand!) I was disappointed to discover there was not Linux driver. And when I tried the IP4300's driver it did not work at all.

Time to go to the Ubuntu forums: There I was referred to a Canon's portal. In there I downloaded and install a couple of .deb files and next I restarted cups. I connected the printer's USB cable to my computer and it was automagically detected and installed. Couldn't be happier. That's why I want to send my kudos to Canon.

However, as a side note, I do not think ink-jet printers handle well not to be used for more than a week. After the initial excitement and excellent performance, my new printer needed two nozzle cleaning spells this morning after a few days being off. Luckily it now seems to be back to normal.

Thursday, June 05, 2008

Another format for arduino

I've just bought another arduino board for a project. My main complaint with arduino standard board is that it is not prototype board friendly. I am afraid this was a 'feature' and not an error: This way people would have to buy special prototype boards for arduino. This was a design error that later on has survived to maintain compatibility with existing shields (thanks for shedding some light on this, David)

There are other solutions like Modern Device BBB, but the new iDuino does include the USB adapter that may power and interface to a PC your project. And iDuino kit costs less than $18 so it seems quite cost effective. The main con is that the kit includes a resonator instead of crystal.

I haven't used it yet but it seems another development to have a look at. If you plan to buy one I think you better use Fundamental Logic website instead of eBay.