Showing posts from September, 2008

Moving code from ESP8266 to ESP32

A while ago I made a mashup of Dan Royer's code CNC 2 Axis Demo with my own code for trapezoidal motion stepper and servo control for ESP8266.

I assumed porting the code to the ESP32 would be trivial, and that was true for the most part: changes like library name being Wifi.h instead of Wifi8266.h were not a problem. UDP now does not like multicharacter writes but you can use print instead. So far so good.

However, when it came to the interrupt code I was stuck with the stepper interrupt causing an exception sometimes. And to make things weirder, the servo interrupt worked flawlessly (both of them had the IRAM_ATTR directive if you ask me).

Going little by little, I could narrow down the culprit to a floating point operation during the interrupt, that would cause problems sometimes but not always. Browsing around I found this post. Where the solution was simple: do not use floats within the interrupt routines but doubles. The reason was the float calculation would be performed by…

New VMware vmplayer installer for Linux

Since yesterday vmplayer 2.5 is out for free download. One of the tools missing in Ubuntu 8.04 was this (IMHO). Of course it was possible to install it through a more entertained process. I was surprised that VMware was not offering an easy alternative to the huge Ubuntu user base.

Today I've learnt that current version is distributed with an easy (should I say Windows-like?) installer.

Download the software package with .bundle extensionchmod +x VMware-Player-2.5.0-118166.i386.bundlesudo ./VMware-Player-2.5.0-118166.i386.bundle

Thanks VMware!

Reasons not to upgrade a G4 iBook

Years ago we bought one of the latest G4 iBooks as a bit later Apple started using Intel processors. The 12" laptop served us well but now battery and hard disk were dying a RAM was just 256MB. Acting against my own advice I decided to upgrade the system instead of buying a new one.

Buying RAM was not easy as mini DDR 333Mhz RAM was not popular anymore. Luckily I bought it second hand from a friend. A new battery was required to get more than one hour of autonomy again, so I bought a new battery from a Chinese source on eBay. So far so good.

I knew that replacing the hard disk would be a real PITA but I fell short. I bought a 160GB 2.5" on the local shop for less than $90. I would say that physical replacement is not something you will enjoy doing more than once in a lifetime but I got the job done with only one screw missing. I had to reopen the thing because I forgot to put back the standby magnet, it was not fun.

So once I thought everything was fine as the new hard drive w…

Sterling numbers of the second order

I am sure once in a while you may have faced the problem of distributing n elements into k different groups. It does not seem rocket science but, do you know in how many different ways it can be done? Of course it is not a new problem a all, and here is where the Stirling numbers (of the second kind) come in handy: they tell you the ways of dividing n elements into k groups.

For the Code Jam problem "Square Fields" large dataset the numbers may seem discouraging as the number of alternatives for 15 elements are:
But for the small dataset combinations are just a few after all:
So brute force would have worked nicely for the small dataset case but not so for the large one.

Feeling of frustration

I joined yesterday a CodeJam practice session. It seems Googlers were fine tuning the contest site for the onsite finals to be held soon.

Problems were (or they look) easy but a combination of stubbornness and not thinking before coding let me in an embarrassing position (the best thing I can say I was not the worst player). However I failed to see the very easy relationship on the number of black balls (odd/even) and the final output of the Old Magician problem (too late I found out that even black balls lead to a WHITE result, BLACK otherwise and UNKNOWN was just a distraction).

The square fields problem looked very much like a k-clustering problem, but here the clusters are all same size and square shape. You have to answer what is the minimum size of the squares to get a partitioning on exactly k-clusters.

I can tell you how other people solve it, but you can read this by yourself. Instead I'll tell you what won't work:

My first idea was to use java awt library and Rectangle …

New Arduino form factor

A couple of new versions of Arduino boards can be found on Arduino blog: the Arduino Pro and the Arduino Pro Mini (depicted here). Both work at 3.3V and I think that makes them ideal for battery-powered applications.

In my case I'm going to create a small circuit to interface the Mini to an XBee wireless module to create a smallish wireless sensor. Hopefully I'll get much longer operation times than those Rob Faludi measured with Diecimila and XBee shield.

Klondike with a twist

Before Windows I've never played Klondike (aka Solitaire). I do not like it very much as many times I've got stuck so I do not play it very often.

This time roles have switched and I find myself writing code to play the the game: There is an ongoing TopCoder programming contest where you are asked to write the "game logic" code.

I am a poor Klondike player and it shows in my code. There are many pages out there with guidelines on how to play it well, but sometimes the rules are too high-level.

To make things worse the game is known not to be solvable in some cases.

Competition will be open till September 10th.

It was about time

I've waited till the end of my holidays to upgrade the operating system of various of my computers. I was happily running Ubuntu's Gutsy (7.10) and I'm upgrading to the new Hardy (8.04). Actually it is only one month more for the new version to be available, but this time I did not wanted to upgrade in the middle of the semester.

Contrary to other times, this time I decided to do the upgrade using the embedded upgrade feature of the system updater. My conclusion is that, as usual, it is a risky proposal: My laptop froze when updating the locales (a known bug as I found out later) but killing locale-def allowed the process to come to an end. Lately the system healed itself and everything seems to work as expected now. A minor complain is that now the system takes a few more seconds to wake up from suspend.

On one of my desktops the experience was different but not fault free: No complains or hangs on the locale but an error message about not being able to install linux-ubuntu…