With the circuit design described here, any derivative of the 8051 microcontroller can communicate using the serial-infrared (SIR) format established by the Infrared Data Association (IrDA). Communication is a two-stage process in which the microcontroller first transmits via a “bit-banged” SPI serial interface to a tiny UART (IC1). The UART then formats the message in IrDA mode.
Note that the UART included in many 8051 derivatives isn’t IrDAcompatible, and can’t easily be made as such. The circuit shown, however, can easily be added to an existing 8051 system with a minimum of cost, power, and software overhead.
IC1 includes an IrDA timing mode in addition to the conventional UART timing modes (see the figure). It’s capable of 115 kbaud, but in this case the optical components shown limit the data rate to 4800 baud. The components are inexpensive, though, and most IrDA devices support data rates as low as 2400 baud. If necessary, the maximum 115 kbaud is easily attainable with high-quality optical components such as the HP-1000 IrDA module. Most IR LEDs and photodiodes are acceptable for this application, but to avoid being swamped by visible light, the photodiode should include a filter. If necessary, you can place an external ambient-light filter in front of an unfiltered photodiode.
The operating voltage can range from 2.7 V to 6 V, subject to limitations imposed by the 8051. Power-supply current is about 1 mA for IC1, plus 1 mA per megahertz for most variants of the 8051. Timing for the SPI interface isn’t critical. The UART performs all real-time processing, so the processor clock can have any reasonable frequency. Unlike most system clocks, this one doesn’t require time and temperature stability.
In the MAX3100-8051 driver code, the subroutine UTLK provides driver support for the MAX3100 (see the listing). This code translates from IrDA to RS-232 and back (for demonstration and test purposes), using the 8051’s internal UART to talk on the RS-232 side.
The circuit offers other advantages over the alternatives. One such alternative is to write a software routine for IrDA UARTs at low data rates, but the software is tricky. It uses up to 100% of the CPU’s attention when active, and is impractical above 2400 baud. You also can generate IrDA timing with discrete logic or a PAL, but that approach is expensive, powerhungry, and requires an external baud generator for the clock source.