Pages

Friday, April 24, 2020

Repurpose old TV remote as a universal remote control- [parasite design] [chip in the middle modifier on IR signals]

Most of us will have a couple of old infrared remote controllers lying around. Often we need to use several remote controllers and complicated sequences of key presses to get a specific channel on a TV set which is connected to a cable box. Those old remote controls uses Infrared light to control the equipment

Wave forms which drives an infrared led inside a remote control. The top trace is demodulated and inverted (same as what you get from an IR receiving modules, TSOP) 

The simplest solution to go around the "remote burden" is to use universal remote controllers which can be programmed to control all our devices and for example Logitech's harmony and similar products are some of the solution and there may be many other solutions, for example use an esp-12 with an IR led connected to it and control it from the mobile phone.

A finlux TV remote (RC5 protocol) which is modified to control a cable box (NEC protocol) and a TV (NEC protocol)
The small green circuitry is the attiny13 controller which intercepts the signals to the IR led and modifies it into what we need

Here is  a simple project  where i inserted an attiny13 into an existing TV remote. It basically decodes the modulated (38khz carrier) electric signals going to an ir led and replaces it with a new sequence which can then control devices according to our wish. The attiny13 goes to sleep mode and the idle current is extremely low, so the battery stays fine for several months.

The fun part for this project was to fit everything in the 1024 bytes of flash  and 64 bytes of  memory available in attiny13. You could of course use a  better avr ( atmga328 or atleast attiny85). But this project was more of a fun project to learn new things and put some pressure on the memory usage. But if you need some extra space and more possibilities, just use a better micro-controller.

Other points are:

1) Use the existing remote and its buttons without any alteration ( no reading of key pads)
2) Efficient usage of the battery (i.e put everything to sleep)
3) Minimal components count
4) "Minimal surgery" on the existing board- just one trace needs interception

Mode of operation

The project basically intercept the encoded signals (in my case RC5) and remap and re-encode it into the target sequence and send the signals to the IR emitter

Modify the signals by man in the middle translator

In the case of FINLUX the taping points are shown below ( two wires , one to take the signal out and one to return the new signal)

Tapping points on the IR circuitry

The signals goes to the PB1 pin on attiny13 (INT0) via a mosfet ( 2N70007similar) to invert the signal ( Source -> GND,  GATE (input), DRAIN to positive rail via 1Meg resistor ). A 22 pf capacitor is connected from VCC to drain and the drain is connected to attiny13 (PB1)

PB0 on the attiny13 is used to feed the modulated, reencoded signals back to the IR emitter circuitry.

Internals of the modified IR remote


The project can be accessed on my github and can be compiled with AVR-gcc
RC5 decoding logic is from pinkeen and Guy Carpenter. The latter has a nice explanation of the state machines used in decoding the signals. To decode the signals of the target codes, it is much easier to hook up an  arduino with an IR receiver and will spit the hex values to the console (recommended to use Ken Shirriff's libraries which has several nice demo applications)

For using with your own remote controls, you need to modify the signal lists below to what is required in your remote. Below is for FINLUX tv remote. For example when you press a button on this remote, it emits 0x45 which will be recognized by Attiny13 and send corresponding NEC codes (A05F in this case, where a 4 byte prefix is added to match my TV/Decoder)


//0...4 are sat and rest to tv
#include <avr/pgmspace.h>
const uint8_t rc5_code_data[] PROGMEM ={
0x45,
0x49,
0x50,
0x51,
0x57,
0x41,
0x42,
0x43,
0x4A,
0x4C,
0x4D,
0x53,
0x54,
0x55,
0x56,
0x59,
0x60,
0x61,
0x6A,
0x70,
0x71,
0x73,
0x75,
0x78 };  

const uint16_t nec_code_data[] PROGMEM ={
0xA05F ,
0x906F ,
0xA45B ,
0x18E7 ,
0x48B7 ,
0x738C,
0x33CC ,
0x9768 ,
0x14EB ,
0x10EF ,
0x906F ,
0x827D ,
0x02FD ,
0xE01F ,
0x609F ,
0x0DF2 ,
0x40BF ,
0xC03F ,
0xA956 ,
0x3EC1 ,
0x5DA2 ,
0xDA25 ,
0x22DD ,
0xD02F   }; 


IR Translating block of code

The snippet below will check the table for the RC5 codes and find the corresponding NEC codes.
sat function encoded & generate the pwm signal for satellite decoder and tv function will do the same for tv. [i kept first five commands for cable box and don't handle the repeat codes]



   //RC5_GetCommandAddressBits(command) 
   uint8_t rc5_byte;
   uint16_t nec_byte;
   char i;
   for(i=0;i<24;i++)  //our table has 24 entries and 0..4  are satellite  
   
    {
     rc5_byte = pgm_read_byte(&(rc5_code_data[i]));
     if(rc5_byte==RC5_GetCommandAddressBits(command)){
      nec_byte = pgm_read_word(&(nec_code_data[i]));
      if(i<5)
       {sat(nec_byte);}
      else
       {tv(nec_byte);}
      _delay_ms(200);
      RC5_Init();
      }
           
    }
  sleep();  

Other possibilities

Space constrain has limited my experiments but could have accomplished even more by using assembly. But other things i tested on a prototype based on attiny85 which includes, possibility for macros, ie a set of commands from single key press, proper handling of repeat codes, learning mode (added a TSOP ir sensor/alternatively you could use the IR led to sense),  options to bypass the entire parasite and send the default codes,  emulate multiple remotes by using a shift switch etc 

schematic ( dirty)

schematic of attiny13 ir remote intercept



3 comments: