Wednesday, June 1, 2011

Decoding

Progress progress progress. Since my last post I received my order from Little Bird which contained the IR receiver. Time to start decoding IR signals. I've read the heater remotes tend to send large multi byte "Status Packets" which, rather sending a signal to increment or decrement the temperature, waits for the user to set a temperature and other settings then  sends all the settings in one big lot. This is great for my project as it means I don't have to know what the heater is currently set to before I set a new temperature.

The down side of this is that any signals are going to be big fat things full of info. In order to cut my teeth on decoding IR signals I decided to have a crack at a TV remote. Fortunately I had access to a TV with a remote! Yay! So I plugged the IR receiver into my trusty Pickit 2 and fired up the logic analyser software and got to work.

First capture. Head scratching ensued


Gibberish. IR gibberish. In my research I'd come to believe that most IR signals were sent with Manchester encoding which indicates 1's and 0's by a rising or falling edge. Seems simple enough. Until you try to decode it by eye. The problem I was having was that I didn't know how long a clock pulse was. This is a problem as the Manchester signals use 2 clock pulses per bit. Not knowing the boundaries of the bits made it tricky. I also didn't have an easy way of overlaying a grid to divide the bits using the clock pulses I didn't have. I could have used Gimp or Photoshop but I am unapologetically lazy. All in all this gave me a headache and many other things suddenly seemed more important and interesting than this project of mine.

Then one day a week or so later I was surfing the intertubes and came across a great blog post that showed the process a certain dude took when he was decoding IR signals. In his case a 1's and 0's were indicated by a short high pulse followed by either a long or short low. The high pulses marked the boundaries between bits and the lows indicated a 1 or 0. The "aha" moment came when I realised that his logic captures started low. When I was setting up the trigger for my logic analyser I had to set it to a falling edge as the signal from my receiver started high. I didn't even click. After that I took another look at my data and for the hell of it flipped the image in Gimp.


Victory!


Holy crap! It looks almost exactly like the other guys data, a high preamble, high pulses and long/short lows! Woot! It all made sense now. The signal was not Manchester encoded, it was just upside down! Now it's so much easier to read. I haven't done any actual decoding yet, or set up a spreadsheet with all the signals in it, but it's on my list. I'll probably be ordering some more stuff from Little Bird soon to build a transmitter.

It may seem like an obvious mistake to some but that is the whole reason I'm doing this project! I don't know jack and want to learn in a practical way and have a cool gadget to play with at the end.

No comments:

Post a Comment