Click to see a high resolution version of the block diagram
For the IR input I'm using an infrared sensor IC designed for infrared remote control extenders. It works the same way as a normal receiver does, except for one thing: it also outputs the carrier wave. That way I can connect it directly to a CPP module.
Capture, Compare, PWM modules can be used in PICs for calculating frequency and do pulse-width modulation. Since we are internally storing values on the microcontroller to replicate the signal later instead of displaying them as a frequency counter would do, we don't need absolute accuracy in the microcontroller's timer. What we do need is stability over time. And since most remote controls only use a low-accuracy ceramic, it's not big deal either so I will stick to a cheap crystal or a decent ceramic resonator.
Now, we have calculated the carrier wave frequency and it's guaranteed to be relatively stable over time, but, how do we store the actual data? We do it by sampling a separate pin without the carrier wave on it. To remove the high-frequency carrier wave we use a low pass filter. To use a passive low pass filter we need to isolate the signal coming from the output of the IR receiver because it is an open collector output. I used an op-amp in the block diagram, but a push-pull buffer gate can do the job much better and cheaply.
With some software magic I haven't figured out yet, I will store everything into a 24LC512 EEPROM. It has a 128 byte buffer size and a 128 byte page size. 128 bytes worth of samples from the IR sensor will be loaded on the PIC's RAM. When it's done receiving this, the data is transferred to the EEPROM buffer, and at the same time another 128 bytes of samples will be recorded on a separate memory location.
When the PIC is done writing data to the EEPROM, buffer the EEPROM will move the data from its buffer to the corresponding address. The reason for this is because you cannot write 128 bytes one by one on the EEPROM without a relatively long pause. By the time you write that single byte, you will have missed several others. This doesn't happen when writing in 128 byte chunks, as long as they are all located on a single EEPROM page.
To store the frequency data I will use the PIC's built-in EEPROM, just to make development easier and to use a feature I am paying for. I will just store the value captured by the CPP module and then do some conversion to write that value into the PWM frequency register. I think one of them works with 10 bit resolution and the other with 8 bits.
I have two options for the IR LED driver. One is to have a PWM output working at the frequency I recorded for the button that is being pressed and have another pin changing according to the value of the bits I sampled at a fixed and known sampling rate. If I used an AND gate on the output of both, I could modulate the output at the carrier frequency and imitate the remote control.
The other way is to eliminate the AND gate and make the output an input to turn the output transistor off instead of using a separate pin to do this.
For driving the LED I could use a transistor current sink, which is not affected by changes in voltage like a voltage dropper resistor is.
For the next post I will tell you about the different IR sensors I can use and how parts selection will affect my choices on how to power this circuit. I may use a direct connection to the batteries with an extra boost regulator for certain ICs. Perhaps I could get away with using just the batteries and nothing else (minimum operating voltage would be 2 to 1.8V). Or maybe I will just make my life simple and have a boost regulator with 5V or 3.3V output. Maybe if the regulator used less than 20µA when the remote is idle it could last more than a year.
This is getting cool.