out noise and responding to low level IR signals. At first, I tried building
my own IR receiver with an IR diode detector, but it quickly became
too complicated to be practical. The sensitivity and noise rejection
requirements are just too steep. The Vishay receiver has a respectable
distance signaling spec of 15 feet too.
The Microchip digital potentiometer is the key to controlling the
IR1’s audio level. It responds to an SPI format digital signal — available
from almost any microcontroller — to step the audio level up and down
as required. A Microchip op-amp buffers the output of the digital
potentiometer before sending it to the outside world.
With so many choices between manufacturers, product lines, and
features, choosing a microcontroller can be daunting. For this project, I
could at least zero in on what series I wanted to use, having worked
with the PIC series for years and realizing that their eight-bit versions
were easily up to the task at hand.
Processing speed was one consideration; their 32 MHz units —
using the internal PLL to bump up the internal 8 MHz clock — also
simplified my design (no external crystal/ceramic required). This
frequency accuracy was adequate since the IR detection algorithm was
self-correcting. If the IR carrier frequency was a bit off, it was off by the
same amount for when both programming and detecting an IR signal
(as long as there was not too much frequency drift). The timer in these
microcontrollers has a max counting frequency of one fourth of the
instruction clock or 8 MHz, which is 200X faster than a typical IR
carrier of 40 kHz. About one half percent accuracy in measuring the
carrier frequency and period should be plenty good.
I settled on the PIC18F1840 with 4K of program memory (plenty)
and 256 of EEPROM nonvolatile memory. I would need to store 80
bytes at the most for each of three commands: volume up, down, and
toggle mute. Each byte would hold the number of carrier pulses for
each of the command’s carrier on or carrier off states. Not the most
efficient storage method, but so what. I don’t need much.
One thing I liked the most was the fact that I only needed to deal
with an eight-pin package with this microcontroller, making soldering
easier and the PCB size smaller. I did, however, have to make the
training select button input do double-duty with the LED on an input
pin, which added a little complexity to the code.
The Microcontroller Code
The code for this project is available at the article link. What
follows is a brief description of how it works.
Pressing the training button starts the controller sampling the IR
code start pulse to determine the carrier frequency. This start pulse is
not part of the signaling code and gives us the opportunity to measure
the carrier period. Sixteen IR transitions are counted in the start pulse;
from this, the carrier period (1/16 the time measured with an onboard
timer) is calculated.
With the start of the actual code sequence, the number of carrier
on and carrier off pulses in each segment of the IR command are
26 May 2016
■ FIGURE 5. Top view of the enclosure.
■ FIGURE 3. Prototype with cover removed.
■ FIGURE 4.