Sunday, May 29, 2011

The (illustrated) story so far

Picking up this project after it had been idle for a year meant going back to the drawing board and rediscovering many things. The last 2 months have seen a great deal of progress after the frustrations of my previous attempts. Here are some quick highlights.

April

Having identified the problems with receiving IR through the wrong sensor, there was much work to understand the IR codes being received. This is an early attempt at analysing them:

Early May
After many false starts, I eventually found some techniques to learn (most) IR codes that I encountered:

This was coupled with a new Linux program to capture the IR in the first place:


Mid May
Successful testing of the IR transmission:


The initial prototype iPhone app running (teathered):


Late May
In the past few days, I have developed a new test app which allows all the functions of my AV equipment to be controlled. Here is the advanced design system in use:

As I write this, it is about to go into testing:

Monday, May 23, 2011

The Real Deal

I had a 4 day weekend and although there were many things to do, I managed to squeeze a few hours of Elmo into the proceedings.

During the week I had managed to create a simple iOS App which basically consisted of a number of buttons (rather hopefully labelled with various satellite box functions). On Thursday I hooked this up with some hastily engineered network code to produce something that, on the simulator at least, could drive the Elmo Linux box to produce IR signals.

Flushed with this success, I embarked on the painful process required to run this creation on a real device. It soon became clear that I'd need to update my version of XCode (4Gb of download) as well as update my development iPhone 3G (650Mb download). On my woeful broadband connection this took somewhere around 5-6 hours to download.

So it was quite late on Thursday that I fired up the provisioning portal on the Apple dev site and, after two attempts, managed to get to a point where I could run my software on my iPhone via the tethered debug interface. Wow! Not as painful a process as I was expecting.

About half-an-hour of research and fiddling on Friday morning got me to the point of being able to run the App standalone without the teather.

Finally, on Saturday morning, I set the system up in the lounge and successfully controlled the satellite box with my iPhone via the Linux box. The real set of devices were now communicating! There was only one screen of hard-coded buttons, but all the parts I need for the full system are now working - fantastic news indeed.

I managed to grab a couple of hours over the rest of the weekend which allowed me to start developing a more fully featured App which has multiple pages of buttons and that development continues into this week whilst I'm away from home.

Monday, May 16, 2011

Elmo is Born

There has been a great deal of work over the past week. This has mostly been concerned with the network comms side of things. Because I decided to run an XML based protocol I needed to implement some support code to drive it all. The result is rather pleasing in its functionality and simplicity.

Having got the basic comms up and running, I then wanted to be able to query the Elmo server for the available devices and commands, so a Catalogue was needed to keep track of this information and the appropriate XML formats designed.

I wrote the client in Windows (using MFC - that takes me back) and integrated my previous socket client into the new program. I then added my socket server to the server side and was able to get command catalogue information passed between the two machines. I also got a cross-compiled Windows-based test server so I could continue to develop away from home.

Come the weekend it was time to link this up to the IR side of things. That took a few hours on Saturday, so on Sunday the big moment of truth. I set all the test kit up in the lounge, ran up the client on the laptop and tried to send some commands. It didn't work.

After lots of investigation and fiddling around, everything looked correct but the signals weren't being transmitted. Eventually I realised that the new server program had the wrong version of the IR Protocol library. Correcting this brought Elmo to life - finally.

The system now accepts button presses for various remote control functions on the laptop, passes them over the wireless network to the server where they are converted to the appropriate infrared signals and transmitted from the dongle. It sounds quite simple, but represents rather a lot of work, both investigating, prototyping and developing code.

There are still some limitations to the IR codes I can learn, but I intend to push on with the development now and start work on the iOS client program that will allow control from the iPhone.

Monday, May 9, 2011

You don't need pants for the victory dance

A good deal of effort and testing during the week led me to the conclusion that I need to re-implement code to decode the actual protocol of the IR signals, rather than try to do some clever, generic capturing. Some hunting on the web found 2 main protocols, a pulse width scheme and a level-based (bi-phase) scheme. Manual decoding soon showed that, broadly, all of the signals I'd captured could be classed as one of these two.

Some frenzied late evening work resulted in a new analysis program which could decode both of these schemes. Feeding in my test code showed that the results were highly consistent - giving the same values for each command from a single remote - a very promising development.

Some further tweaking before the weekend and then some quick testing revealed partial success. We had visitors at the weekend, so there was limited time to code or test but I quickly realised that the Sony devices sent their signals multiple times. I managed to grab a couple of hours to add repeat code detection and then retransmit them.

A hastily set up test rig resulted in complete success - all my codes worked and successfully controlled the equipment. I can command the TV, amplifier, satellite box and blu-ray player. Finally, the result I'd been looking for.

Having used up as much time away for our visitors as I was allowed, I didn't have any more time to work over the weekend, but I feel very satisfied that the infra-red is now working. I will need to add functionality for things like volume, which are repeating signals, but that can come later.

Next step is to integrate the new IR functionality with the network server program and to write a test client to run on the laptop. This will demonstrate a prototype of the complete Elmo system. Exciting times.

Tuesday, May 3, 2011

Return of the Jedi

I managed to spend a fair amount of time over the 4 day weekend working on Elmo (thank you Royal Wedding).

After initially having great success with learning the codes from the Sky remote, the amplifier was very elusive. In the end I had to write some new signal analysis software, capture the raw data on the development box and then process it on my laptop, using a bit of human intervention as well.

The results have been very encouraging as I can now control 3 different devices using the codes I captured. The only downside is the reliability of the control is not good and this is because I am always transmitting the same code, whereas most IR remotes alternate between two codes each time you press the button (so the device can tell the difference between holding down a button and pressing it twice in rapid succession). I had anticipated this on the transmission side, but do not yet have a capture algorithm that can find the two versions of the signal.

My tasks during the week whilst away from home are firstly to develop an algorithm to detect the two codes. To this end, I have captured raw data from the 4 devices I originally want to control and will feed this through my new software as I develop it. Secondly, I need to develop the client-server software so I can actually control some devices - initially using the laptop. When I can achieve both of these, a fledgling Elmo will have been born.