Archive for February, 2011

Nexus 7 (Andromeda) and Interference (Sanity)

Friday, February 25th, 2011

Just had to leave my tribute here to these two demos that really amazed me when I was a kid… the effects and art were great (the Interference opening image is a classic), the transitions very well thought out, and the music… oh, the music… it is simply brilliant! ๐Ÿ˜ฎ

Nowadays, I always have with me a selection of musics from my Amiga days (I must remember to post the list), and these two are some of the best. Ever.

Hats off to you guys, even if 16 years later! ๐Ÿ˜‰

P.S.: If you were an Amigan back then (this should bring back memories), and want to watch the demos again, just remember: nothing beats the real thing! Get your old Amiga out of storage and boot it up! ๐Ÿ™‚

Fun with the Arduino Ethernet Shield

Wednesday, February 23rd, 2011

I’ve been using the Arduino platform as a means to develop some of the devices I’ve been needing, from the most simple (my daughter’s color-changing nightlight) to the most complex (a stand-alone, fault-tolerant, inexpensive telemetrics system). Somewhere along the way, the Ethernet shield come into the picture. To be a part of my designs, I had to tweak a few things on the shield:

* The reset is not dependable; many times the shield would simply not startup as expected, and the Arduino lost connection to the outside World. Solution: I lifted the shield’s reset pin (so that it does not enter it’s connector on the Arduino) and connected pin 8 to the shield’s reset line. Like this I can programmatically reset the shield on every boot, and every time I loose a connection to the Internet.

int rebootEthShield()
Serial.println("Rebooting ethernet shield...");
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);
digitalWrite(8, LOW);
digitalWrite(8, HIGH);

Ethernet.begin(mac, ip, gateway, netmask);

You can obviously choose any other output pin.

* I test the Internet connection by connecting to a server on the outside World (i.e. my server). But since this is hardly a static World, and IPs are apparently volatile entities, I needed to have a means to change the test IP. The problem is, the Arduino does not really support object instantiation. So, you create a client socket like so:

byte cl[] = { 192, 168, 1, 1 };
Client clienteLink(cl, 80);

And that’s it. You can no longer change de IP throughout execution. ๐Ÿ™ To be able to do it, I had to add a method to the Client class: reconfigure(). On the Client.h file, add:

void reconfigure(uint8_t *, uint16_t);

On the Client.cpp file, add:

void Client::reconfigure(uint8_t *ip, uint16_t port) {
_ip = ip;
_port = port;
_sock = MAX_SOCK_NUM;

This is on Arduino Alpha 022 (older versions need slightly different code, but it’s very simple).

Now, all I need to do is close the Client before issuing a reconfigure(). Then I can try to connect to another server. There may be a simpler way to do this, but I couldn’t find it. If you do, please post! ๐Ÿ™‚

Have fun!

…jumps over the lazy dog!

Thursday, February 17th, 2011

There is one part of the HMI system I did in a somewhat “lazy” way. I’m creating display objects (JFrames, charts) in memory for each of the display elements. While this ends up being a nice tradeoff between memory and speed (changing between elements is near-instantaneous), I should probably reduce the memory footprint of the HMI application.

Then again, this version has quite a lot going on (charts, threads, etc), and I should probably leave it alone and develop an alternate, slimmed-down version (to run on embedded and tablet machines). Without charts or Swing widgets, pure raster graphics, like a game. After all, I won’t need charts on every element in every control point of the home automation. Most of the time I just want an overview of the house, give some commands, check out the results, and be done with it. Quickly. If I must analyse something, the historic screen is a very capable tool.

Next up, is creating a simple, yet good Web-based interface, or at least a simple dashboard. Check out this project’s web interface, it’s really cool!

And while I’m at it, create a version of the server app without the JFrame… and a socket I can connect to to send commands (Start/Stop).

The quick brown fox…

Thursday, February 10th, 2011

In your home, when you touch a button, you expect the associated lamp to light immediately. For example, if you open the door to your basement, you need light right now to go down the stairs safely. Waiting a couple of seconds for the lamp to light is not expected, nor desirable. After all, the most basic and primitive lighting controls work directly on the power source, and act immediately, so when you have a state-of-the-art home automation system installed you expect the very same performance.

But, from a developer point-of-view, when you have a network of almost 20 nodes, you need to pay close attention to your data paths if you want to achieve lightning-fast response times. I’m working on the near-realtime domain, but I need to be as close as possible to real-time.

So, I’ve been finetuning my home automation’s data subsystem. I think is it of the utmost importance that the controls feel immediate, quick and nimble. And the physical controls (wall buttons) need to behave real-time, or very, very close to it. The HMI (geared towards touch panel use) needs to behave accordingly, and flow at least as fast as your mind can move your finger. That’s why I’ve developed my home automation’s HMI to be that fast.

Usability is a heavily studied subject, but a historically highly neglected one (although nowadays things seem to be improving). Thankfully I’ve had some training on the subject (and I must thank my University teacher that introduced my to the art, she was inspiring), and you can be sure it won’t be neglected.

I’ve had to tweak the data gatherer thread on the server application, adapt the nodes’ firmware, and scatter data polling in the time domain. Talking in numbers, I reached a half-second (median) response time in the physical control buttons, which seems to be perfectly acceptable. This performance is on a 500Mhz AMD K6-III CPU, 196MB RAM, still running under Windows XP. The final target machine will outperform this test-bed in every aspect (and it will not normally run Windows, but a very light Linux distro, AmigaOS, or MacOS X), so I’m quite happy with the results so far.

Obviously, I have a plan B to accelerate this even further if needs be. It involves bypassing each nodes’ polling overhead, by centralizing data in the header node and fetching in one go (asynchronously). Heck, I even have a plan C to respond in the minimum time possible, involving a full duplex protocol on the header node. Plan C will eventually get implementedย (once I sort out the asynchronous communication arbitration between nodes), since it is the best way to do it.

Onwards! ๐Ÿ™‚

My house is growing up

Monday, February 7th, 2011

My super-secret project advances pretty well! Ok, so my home automation project is not that super secret anymore, but the progress is definitely there.

The network of nodes is working perfectely, lighting and blinds control is 100% done in terms of logic (I still need to prettify these elements visually), as are the temperature sensors. The sensors still need some low-pass-filtering, because the noise is a bit harsh for the logic I need the nodes to execute in “Emergency Mode”.

Yes. Emergency Mode. When the control machine is offline, the home automation keeps on going. The nodes, when not talked to for a few seconds, take control of their critical systems. Lights, blinds and climate control keep on going in a basic way, so that you still can control your house. You loose special control routines, like turning on lights based on motion sensing, opening blinds to harvest the sun’s heat in winter, blind positioning, earth tubes house air intake, etc, but the basic funcionality is always there.

In the beggining, this emergency mode was the mode the home automation was running in, every day. Now the control “server” is online, the system is accessible remotely, and complex control can easily be achieved.

The climate control system is now coming along nicely, including control of radiant floor valves via temperature sensors, solar hot water tank (with solid fuel boiler support), and earth tubes for the house air intake (with direct exterior air alternative).

The roadmap includes the complete security system (that is presently working but via a very quick and dirty hack, needs reimplementing) with volumetric and periferic sensors, the botanic manager (gardens, vegetable growing, fruit trees, greenhouse, etc), and meteorology center. There are a couple of very advanced (and useful) features planned, but that will be a surprise… ๐Ÿ™‚

Stay tuned for more info!