Infrared Interface
The two most popular mediums in the wireless arena are Infrared (IR) and Radio Frequency (RF). IR technologies are better suited for short distance, low-to-medium data throughput, and wireless communication channels. Two common types of IR technologies are currently in use. These are:
- TV Remote (TVR) and
- IrDA (Infrared Data Association) standard protocol.
The IrDA (Infrared Data Association) has defined the standard as a wireless communication link between two devices in which the information is transmitted using infrared light.
The IrDA standard is a set of specifications for providing a universal two-way wireless infrared data communications, based on a practical cost, short-range point-to-point user model. The standard defines the physical characteristics of the interface, the communications protocols that provide for different needs, and the transmission speeds at which the infrared device communicates.
The two basics of the infrared communication standards are IrDA-Data and IrDA-Control.
IrDA-Data defines the standard for the wireless, two-way infrared data transmission between two devices and consists of a set of mandatory protocols: IrPHY (Physical), IrLAP (Link Access), and IrLMP (Link Management).
IrDA-Control is the infrared standard that allows wireless peripherals such as keyboards, mouse, game pads, joysticks, and other pointing devices to interact with many types of host devices. Host devices include PCs, home appliances, game consoles, and TV/ audio devices/ Web set top boxes.
IrDA-Control is not the same as the standard TV Remote Control. IrDA-Control has its own set of mandatory protocols: PHY (Physical), MAC (Media Access Control), and LLC (Logical Link Control).
IrDA technology has emerged as one of the most promising wireless solutions because it offers several compelling advantages over other types of wireless communication interfaces.
Although infrared is only applicable between two devices at a time and cannot transmit through walls, the positive aspects of this technology are many.
Because infrared can only communicate from one device to another and because this communication must be line-of-sight, there is no risk that someone may intentionally or unintentionally obtain your information as it is being transferred.
IrDA infrared port module is the most mature of the wireless communications standards. These devices include cell phones, pagers, laptops, PDAs, digital cameras, handheld scanners, and laser printers. The IrDA standard has both support and user applications in all major operating systems including all recent versions of Windows, Windows CE, Linux, as well as the Palm operating systems.
IrDA Protocol
The standard should be adaptable to a broad range of mobile appliances that need to connect to peripheral devices and hosts.

Figure 1 IrDA protocol architecture
IrDA has defined an interface for infrared communications that consists of base three layers:
- IrPHY (Infrared Physical Layer), is implemented by hardware
- vendorsand and defines four types of infrared hardware implementation.
- IrLAP (Infrared Link Access Protocol) is a protocol, based on the HDLC, designed to control an infrared link.
- IrLMP (Infrared Link Management Protocol) is a multiplexing protocol designed to run on top of IrLAP. IrLMP is multipoint-capable.
IrDA defined four kinds of infrared links to support different data rates. Included in these links are Serial Infrared (SIR) supporting speeds up to 115.2 Kbps, Medium Infrared (MIR) supporting 0.576 Mbps and 1.152 Mbps data rates, Fast Infrared (FIR) supporting a 4.0 Mbps data rate, and Very Fast Infrared (VFIR) supporting 14.0 Mbps.
In addition to the base standards, IrDA has specified several optional layers such as:
- Tiny TP (Tiny Transport Protocol) provide independently flow controlled transport connections segmentation and reassembly.
- IrCOMM determines how different devices can talk to each other via infrared.
- IrOBEX. (IrDA Object Exchange) is a communications protocol that facilitates the exchange of binary objects between devices
LM-IAS (IrDA link management protocol information-access services) provides a set of services that allows stations to advertise information describing their capabilities to peer stations.
.A IR transmitter / receiver that use AVR microcontroller and specific IR module
An example of a IrDA SIR interface is presented in figure 2. The interface include two circuits, U6, TOIM4232 that adapt the level of RS232 interface at the requirement of IrDA transmitter/receiver U5, TFDU4100 include the infrared (IR) LED transmitter and the IR diode.

Figure 2 Schematic of an IR SIR module interface. ZTA crystal has the value 3.6864 MHz.
The lines S1,S2 represent output lines that could be individual set/reset, by program. In order to programming the interface, is necessary to put on 1 logic the input BR/Data and to transmit to interface circuit U6 two word.
The first is used to select the baud rate (see figure 3), and the S0 bit select the width of pulses transmitted by IR LED (S0 = 1=>1.627 ms pulses S0 = 0 => 3/16 bit time pulses, not recommended), the second word specify the baud rate value, conform with the figure.

Figure 4.16 Structure of the two command words
Figure 3 Table the show the preset values of baud rate control bits: B0,B1,B2,B3
A transmission of data needs to introduce a microcontroller that drive the IR module interface. We exemplify the programming of system that is show below:

Figure 4 IR transmission module using an AVR microcontroller
The program wrote for the AT90S2313 that illustrate the initialization of IR module interface is list bellow:
// Target : 2313
// Crystal: 11.059Mhz
#include
#include
char baud_ascii[14]="ABCDEFGHIJKLMN"; //Character corresponding at baud rates
char baud[14]; //Baud rate constats: 115200bps,...1200bps.
char *p_baud; //Pointer at baud rate constant
char c; //Temporary buffer
char counter=0; //Represent the number of bytes to transmit
char buf_trs[16]; //Transmit buffer
char buf_rec[16]; //Receive buffer
char *p_trs; //Transmit Pointer
char *p_rec; //Receive Pointer
void port_init(void)
{
PORTB = 0xFF;
DDRB = 0x03;
PORTD = 0x7F;
DDRD = 0x00;
}
//UART0 initialisation
// desired baud rate: 19200
// actual: baud rate:19200 (0.0%)
void uart0_init(void)
{
UCR = 0x00; //disable while setting baud rate
UBRR = 0x23; //set baud rate
UCR = 0xD8; //enable
}
#pragma interrupt_handler uart0_rx_isr:8
void uart0_rx_isr(void)
{
//uart has received a character in UDR
*p_rec++=UDR; //Store the received character
if(p_rec>buf_rec+16)
{
p_rec=&buf_rec[0]; //Implementation of circular buffer (16 bytes)
}
}
#pragma interrupt_handler uart0_tx_isr:10
void uart0_tx_isr(void)
{
//character has been transmitted
counter--; //Store the next stage of transmission
if(counter !=0)
{
UDR=*p_trs++; //Send data to serial interface
}
else
{
p_trs=&buf_trs[0]; //Initialization of buffer transmit pointer
}
}
//call this routine to initialise all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
uart0_init();
MCUCR = 0x00;
GIMSK = 0x00;
TIMSK = 0x00;
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
//
void main(void)
{
// Initialization routine
init_devices();
// Functional code here...
p_trs=&baud_ascii[0];
p_rec=&baud[0];
counter=14;
while (counter !=0)
{
*p_rec++=(*p_trs++ - 0x41);
counter--; //Convert and transfer the ASCII table in binary table 0x31->0x01,...
}
//Initialization of IR SIR module interface
p_rec=&buf_rec[0]; //Initialization of buffer receive pointer
p_baud=&baud[3]; //Select baud rate 19200bps
PORTB=0xFF; //Put on 1 logic all the lines of PORTB =>DB/Data=1 Programming baud
buf_trs[0]=0x01;
buf_trs[1]=*p_baud; //Complete the telegram for programming the baud rate IR module
p_trs=&buf_trs[0]; //Initialization of the buffer transmit pointer
counter=2; //Number of bytes to transmit
UDR=*p_trs++; //Send the first control byte
while(counter)
{
//Wait for the transfer of programming control bytes
}
PORTB=0x00; //Control BR command to 0. That means send/receive data through IR module
while (1)
{
//Write the specific code
}
}
The SIR and MIR protocol are applicable in the majority of transfer between PCs and other peripheral devices.
Core Control Module
All the state machines perform parallel-to-serial conversion on the transmitter side, and serial-to-parallel conversion on the receiver side. On the transmitter side, the corresponding frame includes not only the data that must be transmitted but some redundant information too.
On the receiver side, the incoming frame is examined and the proper data is extracted and saved into the RX_FIFO (Receive First In First OUT stack). If an error occurs, an interrupt signal will be asserted if it’s enabled and the last frame will be reject. The framing format varies from mode to mode, as shown in figure 5.
For SIR mode, its frame format is the same as for an UART, which begins with one start bit (logic 0) followed by 8 data bits and optional parity bit(s), and ends with one or more stop bits. This format is called asynchronous format, because only one byte of data is transmitted/received in one frame. In contrast, the MIR format is synchronous format, which is more complicated than asynchronous format.

Figure 5 IR framing formats: asynchronous (SIR) and synchronous (MIR)
High-level data link control (HDLC), documented in ISO 3309, specifies how are packed the data in order to be transferred through the serial line. HDLC supports several modes of operation, including a simple sliding window mode for reliable delivery.
The MIR protocol that reproduces partially the HDLC's protocol has the following frame:
01111110 |
01111110 |
Address |
Control field |
Data |
Frame Check Sum (FCS) |
01111110 |
Figure 6 The MIR protocol frame
The beginning of the frame includes two 0x7E bytes that could occur in the control field or in the data field too. At the receiver part the decoding of the header of frame will generate the initialization of receiver buffer.
After the decoding of control word the receiver will store all the bytes until he will receive the frame check sum (FCS). Then, the receiver will calculate check sum, using the data from the frame.
Then he will compare it with the received check sum. If he detects the equality between these two values he will accept the frame, otherwise he will reject it. The FCS is a CRC calculated using the check polynomial:
(1)
Stuffing/de-stuffing is performed for the proper data and CRC fields benefit. This means one zero is inserted after five consecutive ones are transmitted in order to distinguish the flag from data, while one zero is taken out after five consecutive ones when receiving.
Modulation and Demodulation

Figure 7 IR modulation schemes
The modulation and demodulation schemes for SIR and MIR modes are shown in figure 7. For SIR, a pulse of 3/16-bit duration represents a zero. An absence of a pulse indicates a one.
For example, 3/16 of a pulse width at 115,200 bits/s is 1.6 µs. The code is power-efficient, since infrared is only transmitted for zeros. The tall narrow pulse has a better signal-to-noise ratio than a short wide pulse of the same energy. The MIR modulation scheme is similar to that of the SIR, except it has a pulse width of 1/4 of the bit-cell time.
Transmitter Section
The transmitter section contains several major state machines, each performing its task in sequence for the transmission of a bit-stream. As mentioned previously, different modes require different frame formats. MIR requires transmission of a 16-bit CRC and beginning/ending flags.
Receiver Section
When the receiver front-end detects an incoming frame, it will start de-serializing the infrared bit stream and load the resulting data bytes into the RX_FIFO. This module has two objectives—to limit the pulse width of the common IR input to a fixed value, invert the polarity of the input signal, and remove the noise spike from the input signal.
The receiver waits for the first following falling-edge of the incoming data stream. This allows calculation of the detected pulse width and time to the centre of the next and all the following bit-time frames.
The receiver interprets the edges and calculations depending on the mode. For an SIR or UART mode, it indicates the leading logic '0' (start) bit for the first byte; in MIR mode, it indicates the leading logic '0' in the 'start-stop-flag' (0x7E). After detecting the correct beginning flag, the receiver will process the consecutive bits in sequence, much like the transmitter; for example, decoding, de-assembly, de-stuffing and doing a CRC check.