Infra red decoding and re-encoding
2009-08-11 by Dave McLaughlin
Hi All, I originally posted this on the Codevision AVR list and then realised it was not the right place so I searched to find the best place to post it and found this list instead so I hope it is the correct place to post? I am developing some home automation gear for my apartment. When I lived in the UK all the heating was controlled over CAN bus but now that I am in the Far East I only have air con to deal with. The problem is that I can't run cables here as I live in an apartment block and most of the walls are concrete with a few exceptions. What I have developed is a small module based around a www.display3000.com ATMega2561 based board with TFT display and putting this on my own motherboard with a Zigbee Pro radio module. The radio part is easy and working. The part that I am trying to improve upon is the Infra Red input and output. Doing a search I can find loads of RC5 decoding but the problem is that the aircon units here are all National (Panasonic) so the infra red code is very different. I also need it to work with other aircons in the future. Using the logic analyser it appears to be around 30+bits for each button press. There doesn't appear to be a discrete ON/OFF, rather it causes the unit to toggle ON or OFF at each command transmission. The output from the Infra Red receiver is connected to an interrupt pin. I also have an infra red emitter connected to one of the timer output pins via a drive transistor. The code is designed such that the user selects from a menu, the programme mode and then points the original remote control at the receiver and the device then reads the pulse stream. I have developed some code to look for a start from the remote and using one of the timers, time the high and low times and store these in memory. Not very efficient on memory as I am using around 120 bytes to store the 16 bit time and the HIGH or LOW state. I have not tried using an 8 bit timer and this was next on my list. I could store the HIGH or LOW in the top bit of the 16 bit value and this would reduce the count by about 30 bytes. For transmission, I setup a timer for a 38Khz output and then just switch the PORT bit on or OFF based on the original times recorded during the reception phase. As for ON or OFF I have to keep a flag in the code to know what state the unit was last in. This works fine until my partner switches the ac with the original remote. Something I am still trying to train her for :o) I am still looking at a way to do this more effectively as I would like to be able to do temp control from the unit also. At present, all it does is switch on or off the aircon. I would need to be able to decode the infra red bit stream and so far have not been able to find anything on the net that describes the encoding scheme used. I would appreciate any thoughts you all might have on how I could improve this system? I am not looking for help with the code as I can do that myself, what I am looking for is some ideas on how to improve what I have attempted so far. I have built 2 systems so far and have 4 aircons in total to control. PS. These little TFT displays are well cool. Regards Dave. [Non-text portions of this message have been removed]