Top Banner
MASARYK UNIVERSITY FACULTY OF I NFORMATICS Methods of Optical Communication for Embedded Systems BACHELOR THESIS Filip Roth Brno, spring 2008
30
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Thesis

MASARYK UNIVERSITY

FACULTY OF INFORMATICS

w !"#$%&'()+,-./012345<yA|Methods of Optical Communication

for Embedded Systems

BACHELOR THESIS

Filip Roth

Brno, spring 2008

Page 2: Thesis

Declaration

Hereby I declare, that this paper is my original authorial work, which I have worked outby my own. All sources, references and literature used or excerpted during elaborationof this work are properly cited and listed in complete reference to the due source.

Advisor: prof. Ing. Vaclav Prenosil, CSc

ii

Page 3: Thesis

Acknowledgement

I would like to thank Microchip Technology for providing free samples of the MCP2120IrDA encoder/decoder, Gatema s.r.o. for a generous discount on printed circuit boardmanufacturing and Soltech s.r.o. for quick assembly of the prototype modules.

I would like to thank my advisor, prof. Ing. Vaclav Prenosil, CSc, for helpfulness andguidance during writing of this thesis.

Last, but not least, I would like to thank my parents for their support during mystudies.

iii

Page 4: Thesis

Abstract

This thesis deals with current-day wireless optical data transfer technologies used withinembedded systems. Thesis is divided into two parts, theoretical and practical. Theoreticalpart covers signalling standards and communication protocols used in through-the-airoptical communications, followed by a practical example of an embedded system usingthese technologies. The basic test results of the designed module and a comparison withradio frequency devices are also provided.

iv

Page 5: Thesis

Keywords

IrDA, remote control, wireless communication, optical communication, microcontroller,embedded system

v

Page 6: Thesis

Contents

1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Optical communication standards . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.1 Infrared Data Association (IrDA) . . . . . . . . . . . . . . . . . . . . . . . . 32.1.1 Physical layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.1.2 Link Access Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.1.3 Link Management Protocol . . . . . . . . . . . . . . . . . . . . . . . 52.1.4 Optional layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.2 Carrier-based communications . . . . . . . . . . . . . . . . . . . . . . . . . 52.2.1 Physical layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.2.2 Data encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Simple test device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.1 Design requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.2 Hardware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.2.1 Microcontroller block . . . . . . . . . . . . . . . . . . . . . . . . . . 83.2.2 USB interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2.3 IrDA interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.2.4 Infrared transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2.5 Infrared receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.2.6 ISM radio frequency module . . . . . . . . . . . . . . . . . . . . . . 12

3.3 Software description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3.1 Main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3.2 Application walkthrough . . . . . . . . . . . . . . . . . . . . . . . . 14

4 Verification of functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.1 Basic IrDA PHY compatibility test . . . . . . . . . . . . . . . . . . . . . . . 174.2 Data integrity test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

5 Comparison of optical and radio frequency technologies . . . . . . . . . . . . 196 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23A Test device schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24B Contents of the enclosed CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

1

Page 7: Thesis

Chapter 1

Introduction

Nowadays, as various embedded systems are being incorporated into a growing rangeof devices, many of these systems are required to employ some form of communicationinterface for data exchange with the environment or with each other. In recent years,wireless technologies have grown in popularity, presumably due to their simplicity ofuse. Although dominated by radio frequency devices, such as wireless networking orBluetooth, some applications may benefit from using an optical data link.

Optical communicaton as we know it today was made possible with the developmentof light emitting diodes, which feature very low switching times and therefore provide away for hi-speed data transfer.

Optical communication uses LEDs to transmit a specific pattern of data which is thenreceived and decoded by an appropriate receiver. The wavelengths of light sources usedare usually located around 900nm and the receivers have appropriate matching spectralsensitivity peaks.

The major optical communication standard IrDA and the principles of carrier-basedoptical communication are described in Chapter 2, Chapter 3 covers the development ofan embedded system using optical communication, Chapter 4 provides test results of thesystem and Chapter 5 provides an comparison of optical and radio frequency wirelesstechnologies.

2

Page 8: Thesis

Chapter 2

Optical communication standards

In this chapter, two major optical communication standards are described. Infrared DataAssociation (IrDA) specification and a carrier-based communication used in small controlsystems (e.g. TV remotes).

2.1 Infrared Data Association (IrDA)

The Infrared Data Association[1] is an industry-wide group, established in 1993, foundedto create an unified optical communication standard. The standard quickly spread intomany electronic devices, most notably personal computers, portable digital assistants(PDAs) and cellphones. The names of the founding organization (Infrared Data Associa-tion) and the physical port are commonly interchangeable.

The IrDA set of standards was originally developed to allow for short-range dataexchange without the need of interconnecting cables. For handheld electronic devices,such as PDAs, the need for cables severely limited devices’ usability.

Throughout its history, the IrDA underwent several extensions and improvements.The maximal communication speed was increased from 115200bps in the original spec-ification to a current maximum of 16Mbps, in the future a maximal speed of 100Mbpsmay be possible. The protocol set was also extended (while maintaining backwards com-patibility with older devices), most recent additions are the IrSimple and IrSimpleShotprotocols for digital images transfer between handheld devices and printers.

2.1.1 Physical layer

The IrDA specification defines four different physical layer implementations. These areSIR (Serial InfraRed, IrDA rev. 1.0), MIR (Medium InfraRed, IrDA rev. 1.1), FIR (FastInfraRed, IrDA rev. 1.1) and VFIR (Very Fast InfraRed, IrPHY rev. 1.4). In this work, onlySIR specification is covered. For more detailed description of IrDA standards MIR andabove, please see the related sources in the References section[3].

The SIR physical layer uses return-to-zero bit encoding for the transmission and re-ception of infrared data. Each bit is encoded as a pulse present for logic zero and pulseabsent for logic one. The pulse length is 3/16 of the selected baudrate with a minimum of1.63uS. The frame format for one byte of data is a standard UART 8 databits, one start, noparity and one stop bit data frame. This makes IrDA SIR transmission very easy to use inembedded systems, because an UART is a standard periphery in most microcontrollers.

A framer may be considered a part of the physical layer. The framer is responsiblefor the reception of data frames and its presentation to the higher protocol layer (IrLAP),transmission of data frames when requested by IrLAP and also for changing communi-

3

Page 9: Thesis

2. OPTICAL COMMUNICATION STANDARDS

Figure 2.1: IrDA SIR physical layer frame format

cation speed based on IrLAP requests. The framer is the last IrDA layer dependent onhardware.

Both the physical layer and the framer are mandatory layers of the IrDA specification.

2.1.2 Link Access Protocol

The Link Access Protocol (IrLAP) provides reliable data transfer for the upper layersand manages initial connection procedures such as device discovery and best possiblecommunication speed negotiation.

When communicating, the IrDA compliant device behaves either as a Primary (mas-ter) or a Secondary (slave) station. The Primary station is responsible for connection ini-tiation and setup, data flow management and link error recovery. The Secondary stationonly responds to master commands. Primary stations are usually devices with relativelylarge computing resources, such as personal computers or PDAs, required for overallIrDA connections management. Secondary stations are usualy devices with limited re-sources (e.g. embedded systems). However, all Primary devices are required to be able tofunction as a Secondary device (otherwise, no communication between two Primary de-vices such as PDAs would be possible). The distinction between Primary and Secondarystations ends at this layer, higher IrDA layers are able to initiate data transmission re-gardless of being a Primary or a Secondary device.

The IrLAP layer has two connection states, idle (Normal Disconnect Mode or NDMin IrDA terminology) and connected (Normal Response Mode or NRM). When in NDM,the device monitors the IR media and upon detection of another device it negotiatesthe communication parameters and switches to NRM. The Normal Response Mode endswhen the connected devices disconnect or the link has been broken for a sufficiently longtime.

The IrLAP protocol is a mandatory part of an IrDA compliant device.

4

Page 10: Thesis

2. OPTICAL COMMUNICATION STANDARDS

2.1.3 Link Management Protocol

The IrLMP layer of the IrDA specification consists of two parts, the Link ManagementInformation Access Service (LM-IAS) and the Link Management Multiplexer (LM-MUX).

The LM-IAS provides a way for service discovery of the connected device. Each IrDAdevice has a list of supported services (for example, a cellphone would have some mo-dem capability), which are accessible upon request by the connecting party. The list ofservices has always at least one entry with device properties and IrDA device name.

The LM-MUX is responsible for creating logical channels to each requested LM-IASservice over a single IrLAP connection. For each service a separate access point (LinkService Access Point, LSAP) is created for use by higher protocol layers.

The IrLMP is a mandatory part of an IrDA enabled device. For more detailed descrip-tion, please see the related sources[3].

2.1.4 Optional layers

Above the mandatory layers, a variety of extensions exist. Because the IrDA specificationsare no longer public and are only available for purchase, the optional layers are coveredonly briefly. The extensions are:

· TinyTP, a flow control mechanism for use above the IrLMP

· IrCOMM, a legacy serial/parallel port emulation protocol

· IrLAN, wireless network attachment over IrDA

· IrOBEX, an object exchange protocol

· IrSimple, an improvement of the original protocol set achieving higher transferspeeds

· IrSimpleShot, a protocol for wireless image transfer used in mobile phones

Of particular concern for use in embedded systems is the IrCOMM protocol. Thisoptional IrDA layer allows for emulation of an standard RS232 serial port, which is eas-ily interfaceable to any modern microcontroller. Additionaly, single-chip solutions exist,handling all of the IrDA communication on-chip and providing standard serial port in-terface (for example, MCP2150 from Microchip Technology). Although not usable fortime-critical tasks, this solution may be suitable for many simple data transfer applica-tions.

2.2 Carrier-based communications

Complementary to IrDA baseband communication (i.e. without carrier signal), there ex-ists a range of devices using some carrier frequency to optically transfer data. It is beingwidely used in systems not requiring high transmission speeds and focusing more on thetransmission range, most notably the television remote controls.

5

Page 11: Thesis

2. OPTICAL COMMUNICATION STANDARDS

2.2.1 Physical layer

The physical layer of an carrier based communication channel consists of a carrier signalmodulated by a data signal. The carrier signal frequency ranges from tens of kilohertzto several hundred kilohertz. The information is represented by an return-to-zero PCMencoded signal.

Figure 2.2: Example of an carrier-based communication channel transmission

The return-to-zero encoding is necessary due to the fact that the receiver usually con-tains an automatic gain control (AGC) circuit to atapt itself to changing ambient illumi-nation levels. With non-return-to-zero encoding, the transmitted signal would be “invis-ible”to the receiver after some time because the AGC circuit would consider it a part ofthe ambient illumination.

2.2.2 Data encoding

There exist several data encoding schemes for carrier-based remote controls. The speifica-tions were originally developed for remote control of home appliances such as televisionsand VCRs. Most common are the Phillips RC5 and Sony RECS80, describing a one-waydata transmission consisting of individual data frames, usually transmitted when a but-ton is pressed or held for some time. A single data frame consists of a preamble, address-ing information and command identification number.

However, these encoding protocols are not necessary to use for wireless communica-tion. Being much easier to implement, a standard RS232 frame timing may be used aswell. Because the receivers usually have some requirements on burst duration and burstseparation times, a bit stuffing should be used to fulfill these requirements. For example,when using the TSOP7000[13] infrared receiver, inserting a single logical zero bit in themiddle of a standard 19200bps, 8-databit UART frame complies with the TSOP7000 re-quirements on pulse and separation lengths and therefore provides an easy to implementwireless optical communication.

6

Page 12: Thesis

Chapter 3

Simple test device

To fulfill the thesis assignment, a simple device was designed to demonstrate the tech-nologies described above. The possibility of the device being used in Digital SystemsArchitecture and Construction Laboratory was kept in mind during the developmentprocess.

3.1 Design requirements

The following requirements were followed during the design of the module:

· the module must be easy to use

· the module must use the USB communication interface for personal computer con-nection

· the module must provide an IrDA compatible communication interface

· the module should provide some form of an carrier-based interface

· the module must provide a programming connector

· the module should be usable without the USB-provided power supply

· the module should be usable with a development board, so some form of wiredserial communication interface should be provided

· the module should be small

3.2 Hardware description

The hardware was designed using EAGLE Layout Editor[19]. Because of the relativeboard complexity, the in-built autorouter did not perform very well and the board hadto be routed manually. Surface-mount technology (SMT) was used where possible tominimize overall module dimensions. The board was designed to fit into the Hammond1455C801 enclosure[15].

The device consists of several blocks, each performing some function of the module.The electronic components of each module are positioned on the board as close as possi-ble to minimize track lengths and decrease the resulting electromagnetic interference.

The individual blocks are described below.

7

Page 13: Thesis

3. SIMPLE TEST DEVICE

Figure 3.1: Render of the module (some components not shown)

3.2.1 Microcontroller block

The module is based on an Atmel AVR RISC microcontroller. The AVR family was se-lected for its C-optimized instrucion set and a relatively high computing power.

The device selected is ATMega324P[7]. This microcontroller features 32kB of Flashmemory, 1kB of configuration memory and 2kB of SRAM. Although the Flash memoryusage is not very high with the current firmware, 32 kilobyte device was selected to en-able future firmware extensions. The microcontroller was connected in accordance withAtmel application note describing AVR hardware design considerations[6].

The periphery usage is as follows:

· USART0 is available on the three pin connector

· USART1 is connected to the IrDA transceiver

· SPI is used for communication with the RFM12B radio module

· INT2 triggers on incoming USB data

· PCI1 triggers on SETUP button press

· PCI2 triggers on incoming radio data

· PCI3 triggers on incoming modulated carrier data

· PORTA is used for USB communication

· Timer1 output compare A is used for modulated carrier frequency generation

· Timer0 is used for modulated carrier data signal generation and reception

The microcontroller block also features three status LEDs and an Atmel ISP program-ming connector not shown in the schematic diagram.

8

Page 14: Thesis

3. SIMPLE TEST DEVICE

Figure 3.2: Microcontroller block schematic

3.2.2 USB interface

Most modern computers do not contain a RS232 serial port, therefore an USB interfacewas selected to connect the device to personal computer. In addition to data connection,the USB also provides power supply lines and so there is no need for an external powersupply to power the device.

To comply with Universal Serial Bus specification, a single-chip solution was pref-fered. In the end, two devices were considered for use: FT232R and FT245R from FTDI.After some research into each devices’ properties[9], FT245R was selected. AlthoughFT232R can be used with lower microcontroller I/O usage compared to the parallel in-terface, it has some disadvantages over FT245R. Firstly, to successfully establish a con-nection with the MCU, the device must be correctly configured with a matching baudrate. Using parallel interface, the virtual COM driver baud rate settings are ignored andthe device successfully operates irrespective of baud rate settings. Secondly, although notmandatory, the FT232R requires the user application to implement a flow control algo-rithm to prevent data loss. With the FT245R, the flow control is handled by proper usageof the RXF and TXF status flags.

The FT245R[8] is connected in default bus powered configuration with external logicpower switching. This is important to meet Universal Serial Bus power requirements inSuspended mode, where the maximal power consumption is limited to 500uA. Both theVBUS and GND signals are filtered with noise suppression filters to reduce electromag-netic interference coming out of the device through the USB connector.

From the software point of view, the FT245R device driver creates a virtual COM port,therefore allowing a wide range of applications to connect to the device. The MicrosoftWindows drivers are royalty free and certified by Microsoft, Linux kernels 2.4.20 andabove natively support the device. FTDI also provides an MPROG utility to properly

9

Page 15: Thesis

3. SIMPLE TEST DEVICE

configure the FT245R parameters, such as manufacturer and product description stringsand maximal power consumption.

Figure 3.3: USB interface schematic

3.2.3 IrDA interface

To allow for a simple way of transmitting and receiving IrDA physical layer data, a ded-icated integrated circuit was used. The MCP2120 from Microchip Technology is an IrDAencoder/decoder with standard UART interface and the option to select baud rate bysoftware. The IC also features an internal baud rate generator using the external crys-tal, so the need for an x16 UART clock signal is avoided. The MCP2120 is subsequentlyconnected to TFDU4100 IrDA transceiver from Vishay. This device integrates a transmitLED diode and a receive PIN photodiode together with pulse shaping. The SC(SensitivityControl) pin selects between shorter range with higher immunity against ambient inter-ference sources and longer range with worse noise suppression parameters. The sensitiv-ity control is accessible through the experimental devices’ setup utility along with IrDAbaud rate setting.

Both MCP2120 and TFDU4100 are connected in accordance with the respective rec-ommended application circuits. For more information see devices’ datasheets.

10

Page 16: Thesis

3. SIMPLE TEST DEVICE

Figure 3.4: IrDA interface schematic

3.2.4 Infrared transmitter

The main part of this modulated carrier transmitter is the IRF7304 dual P-channel MOS-FET transistor. In this configuration, the device functions as a two-input AND gate (withboth inputs inverted), effectively creating a simple hardware AM modulator. The LEDsused are TSHA5202, the current is limited to about 200mA(using MC CARRIER duty cy-cle of 50%, an average current of 100mA is obtained). The capacitors are used to providesupply current for the LEDs during transitions from OFF to ON and therefore to reduceEM interference.

The MC CARRIER signal is generated using MCUs’ Timer1 in waveform generationmode. For the 455kHz TSOP7000 receiver, using no prescaling and Timer 1 overflowvalue of 22, output frequency of 454.54kHz can be generated. The MC TX signal is thedata signal for the transmitter. Stopping waveform generation and setting both signals tohigh disables the transmitter.

Figure 3.5: Modulated carrier transmitter schematic

11

Page 17: Thesis

3. SIMPLE TEST DEVICE

3.2.5 Infrared receiver

The TSOP7000 device is a 455kHz infrared receiver from Vishay Semiconductors, similarto the TSOP17xx family of remote control receivers. However, being operated at 455kHz,the device allows for significantly higher data rates (20kbps compared to 2400bps whenusing receivers with carrier frequencies around 40kHz) with similar ranges.

The electrical design is simple, the capacitors together with R3 are used to improvepower supply stability and R6 is used to reduce output signal rise time. The output of theTSOP7000 is directly connected to the AVR MCU port D, where an dedicated interruptvector on pin change is used to trigger sampling of the incoming asynchronous data.

Because the TSOP7000 is pin compatible with standard remote control receivers fromVishay, should the need for different carrier frequency arise, the device may be replaced.

Figure 3.6: Modulated carrier receiver schematic

3.2.6 ISM radio frequency module

Although the experimental device is primarily aimed at providing infrared communi-cation interfaces, to create a more flexible platform and increase the utilization of themicrocontroller, an low-cost radio transceiver was incorporated into the design.

The RFM12B[11] from Hope Microelectronics is a low-cost 10mW radio transceiverwith SPI interface and data rates up to 115.2kbps. The module operates in the 868MHzISM (Industrial, Scientific & Medical) band. The transceiver features programmable fre-quency and low turnaround times (from transmit to receive mode and vice versa) so asto allow for frequency hopping applications.

The module requires a 3.3V power supply voltage which is provided by an LE33 low-drop voltage stabilizer. The RF output is routed to an SMA connector for an externalantenna connection. The antenna output impedance is 50Ω.

12

Page 18: Thesis

3. SIMPLE TEST DEVICE

Figure 3.7: Radio interface schematic

3.3 Software description

The firmware of the module was programmed using ATMEL AVRStudio[16] softwaredevelopment kit with WinAVR[17] compiler plugin installed. The ASIX Presto[18] USBprogrammer was used to upload the firmware into the AVR microcontroller.

3.3.1 Main features

The module offers a total of five communication interfaces. These are USB, IrDA, MC(modulated carrier), ISM radio and RS232 (operating with TTL-compatible logic levels).It was assumed that only two interfaces at a time will be used. The interfaces to bind maybe selected via the setup utility.

The setup utility is an terminal-accessible part of the firmware, responsible for userconfiguration of the module. The configuration utility may be executed by pressing theSETUP button located on the printed circuit board next to the USB connector. This utilityallows the user to select which interfaces to bind, configure interface hardware parame-ters, save settings and reboot the system to resume normal operation.

The main function of the module is to transfer data between two currently bindedinterfaces. Because the interfaces may have different speed settings, some form of databuffering was required. After some research, two circular buffer structures were used tobuffer the data streams.

The circular buffer is an memory structure used for buffering of data between twocommunicating processes. The circular buffer may have fixed size or may be resizedwhen necessary. Due to the limited SRAM resources of the AVR microcontroller, two256 byte fixed size buffers were implemented. To ensure correct operation of the buffer,three conditions must be met. Firstly, the buffer must not be written when full, secondly,the buffer must not be read when empty and thirdly, the read and write operations on

13

Page 19: Thesis

3. SIMPLE TEST DEVICE

Figure 3.8: Circular buffer principle

the buffer must be atomic. The first and second conditions are checked by an dedicatedfill count variable and the third one by simply disabling and then reenabling interruptswhen performing buffer read/write operations.

Because the data on each interface is received asynchronously, buffer write operationsare performed in interrupt handlers. Data transmission is realized in the main programloop.

Following is an application walkthrough describing the main parts of the firmware.

3.3.2 Application walkthrough

The main application starts when the device is powered up. The program performs basicI/O ports configuration to ensure correct pin input/output settings.

DDRB = (1 << PORTB3)|(1 << PORTB4)|(1 << PORTB5)|(1 << PORTB7);PORTB = (1 << PORTB0)|(1 << PORTB3)|(1 << PORTB5);

Then, the module configuration is loaded from the microcontroller EEPROM memory.

eeprom_read_block(&configuration, 0, sizeof(configuration));

When the application is aware of what interfaces are requested by the user, it config-ures the circular buffer pointers for each interface.

usb_buffer_src_ptr = buffer_1;usb_buffer_src_start_ptr = &buffer_1_start;usb_buffer_src_fcnt_ptr = &buffer_1_fillcount;usb_buffer_dest_ptr = buffer_2;usb_buffer_dest_end_ptr = &buffer_2_end;usb_buffer_dest_fcnt_ptr = &buffer_2_fillcount;

And enables the requested interfaces.

usb_rx_active_buffer_full = 0;EICRA = 0;EIMSK = (1 << INT2);

14

Page 20: Thesis

3. SIMPLE TEST DEVICE

Buffer variables are initiated.

buffer_1_start = 0;buffer_1_end = 0;buffer_1_fillcount = 0;buffer_2_start = 0;buffer_2_end = 0;buffer_2_fillcount = 0;

Interrupts are enabled.

sei();

And the program jumps into the main loop.

while (1) if (buffer_1_fillcount > 0)

switch (configuration.interface1) case 1: if_usb_transmit(); break;case 2: if_uart_transmit(); break;case 3: if_irda_transmit(); break;case 4: if_mc_transmit(); break;case 5: if_radio_transmit(); break;

if (buffer_2_fillcount > 0) switch (configuration.interface2)

case 1: if_usb_transmit(); break;case 2: if_uart_transmit(); break;case 3: if_irda_transmit(); break;case 4: if_mc_transmit(); break;case 5: if_radio_transmit(); break;

if (enter_setup == 1)

cli();setup();

When data arrives on an interface, it is processed by an interrupt handler and storedinto the respective interface buffer.

ISR(INT2_vect) uint8_t temp;PORTB &= 255 - (1 << PORTB3);asm volatile ("NOP");asm volatile ("NOP");temp = PINA;PORTB |= (1 << PORTB3);usb_buffer_dest_ptr[*usb_buffer_dest_end_ptr] = temp;

*usb_buffer_dest_end_ptr = (*usb_buffer_dest_end_ptr + 1) & 255;

*usb_buffer_dest_fcnt_ptr = *usb_buffer_dest_fcnt_ptr + 1;if (*usb_buffer_dest_fcnt_ptr == 256)

usb_rx_active_buffer_full = 1;EIMSK = 0;PORTC |= (1 << PORTC3);

After the return from the interrupt handler, the main loop is aware that there is somedata in the buffer.

15

Page 21: Thesis

3. SIMPLE TEST DEVICE

if (buffer_2_fillcount > 0) switch (configuration.interface2)

case 1: if_usb_transmit(); break;case 2: if_uart_transmit(); break;case 3: if_irda_transmit(); break;case 4: if_mc_transmit(); break;case 5: if_radio_transmit(); break;

And so the data is transmitted by the appropriate interface transmit function.

while (!(UCSR1A & (1<<UDRE1))) ;cli();UDR1 = irda_buffer_src_ptr[*irda_buffer_src_start_ptr];

*irda_buffer_src_start_ptr = (*irda_buffer_src_start_ptr + 1) & 255;

*irda_buffer_src_fcnt_ptr = *irda_buffer_src_fcnt_ptr - 1;if (usb_rx_active_buffer_full == 1) usb_rx_active_buffer_full = 0;EIMSK = (1 << INT2);PORTC &= 255 - (1 << PORTC3);sei();

Optionally, the interrupts are disabled and the setup utility is entered.

cli();setup();...printf("\n\n");printf("Communicator setup menu\n");printf("=======================\n\n");...

The application does not return from the setup utility back to the main loop. Instead,the system is reset using the watchdog timer.

printf("\nRebooting ...\n");wdt_enable(WDTO_1S);while (1 == 1);

16

Page 22: Thesis

Chapter 4

Verification of functionality

Simple tests were performed to test the functionality of the designed module. The testschecked whether the device is compatible with standard IrDA physical layer and if themodule transfers data correctly even when overloaded. The test setup for each experi-ment and obtained results are described below.

4.1 Basic IrDA PHY compatibility test

The Infrared Data Association physical layer compatibility was checked by listening todevice discovery requests by standard IrDA devices. The module was configured to bindUSB and IrDA interfaces and the IrDA speed was set to 9600bps. This is the speed atwhich the IrLAP device discovery takes place. The virtual COM port created by theFT245R drivers was configured to 921600bps with hardware flow control. A standardMicrosoft Windows Hyperterminal utility was used to connect to the COM port. Twodevices were tested with the module, an Siemens S65 cellphone and an Fujitsu SiemensC1020 notebook.

When the respective IrDA ports were enabled and placed in close proximity of theIrDA receiver on the module, IrLAP discovery queries were received by the Hyperter-minal application. Among the binary data of the query, both the cellphone (“SIEMENSS65”) and notebook (“HEX”) IrDA names were correctly received.

This suggests that the module is indeed compatible with standard IrDA enabled de-vices.

4.2 Data integrity test

This test checked the correct data transfer through the module. This time, two moduleswere used, each connected to a separate PC using the USB interface. Both modules wereconfigured with the same parameters as above, the Hyperterminal applications likewise.The only difference was that the transmitting Hyperterminal was configured to appendCarriage Return (CR) symbols after Line Feed (LF). This was done because Hypertermi-nal defaults to discarding CR symbols from the input stream. The modules were placedabout one centimeter apart with the IrDA transceivers properly aligned so as to preventrange limits and receiver noise from affecting the test results.

As a source of data was used the LATEX source code of this thesis having at that time26210 bytes. After the transmission from one module and the reception of data by theother one, both source and received file had same sizes. To check for full match, an MD5hash utility was run on both files, producing same hash results.

17

Page 23: Thesis

4. VERIFICATION OF FUNCTIONALITY

Most importantly, this test had shown that the data buffering functions are correct.The file size was large enough to fill the USB incoming data buffer of the module (par-allel USB interface operates significantly faster than IrDA at 9600bps), this fact beingconfirmed by the red status LED (buffer full condition) on the device. Therefore correcthardware flow control was demonstrated (the buffer full condition successfully propa-gated through the USB interface and virtual COM port drivers to Hyperterminal).

It may be concluded from this test that the data transmission control and data buffer-ing are reliable.

18

Page 24: Thesis

Chapter 5

Comparison of optical and radio frequency technologies

Although the field of wireless communications is dominated by radio frequency devices,in some applications, infrared optical communication may be used with the same or bet-ter resulting parameters compared to RF-based solution. Let’s take a look at some of theadvantages and disadvantages of both technologies.

Assuming no external optics added to the transceivers, both IrDA and carrier-basedoptical interfaces may be considered a short-range communication. For this transmissionrange, there exists a variety of RF alternatives, such as Bluetooth[23], ZigBee[22] and acollection of custom RF modules. Both optical and radio frequency devices have a set ofparameters affecting the choice of optimal design solution. For example, parameters suchas transmission distance, obstacle surpassing, speed, security, interference immunity orprice may be considered. The following paragraphs compare these parameters of bothtechnologies (only commonly available devices are used for comparison).

Considering usable transmission distance, radio frequency devices usually providehigher ranges than optical interfaces. For example, the TSOP7000 device integrated inthe module allows for transmission distance of several tens of meters[13], whereas theRFM12B radio module is capable of communicating over hundreds of meters in the openair[11]. Both technologies allow for range extension with external optics/antennas (e.g.RONJA[20]).

Obstacle surpassing is much better in devices utilizing RF technology, because forelectromagnetic radiation with frequencies in the RF band most non-metallic objects aresemitransparent. For the optical wavelengths, care must be taken when designing thesystem to ensure visibility (or sufficient reflection from surroundings) between the com-municating parties. This also limits the use of optical technology in handheld devices,because the devices must be correctly positioned to communicate. With RF based design,only the transmission distance is an issue.

Speed ranges of both technologies are approximately the same. Most low-power radiomodules feature speeds up to several megabits per second [23] and IrDA FIR physicallayer offers the same range[1]. However, IrDA VFIR transceivers are currently availablefor sampling from Vishay, offering speeds up to 16Mbps[21]. This parameter is difficultto compare because both technologies are continuously being upgraded.

Where transmission security is of particular concern, optical communication is moresuitable than radio frequency technology. Most infrared transmitters are strongly direc-tional and therefore make eavesdropping on an optical channel much harder than onalmost omnidirectional radio link.

Both technologies are prone to interference from sources emitting electromagneticnoise on wavelengths similar to the frequency ranges used. Radio frequency devices aremore susceptible to noise from power grids, electric motors, computers and other simi-

19

Page 25: Thesis

5. COMPARISON OF OPTICAL AND RADIO FREQUENCY TECHNOLOGIES

lar sources, whereas optical communication may be disrupted by fluorescent tubes, HIDlamps or by simply too much light saturating the receiver (e.g. from the Sun). Thereforethe operating conditions must be taken into account when selecting the optimal technol-ogy.

Last, but not least is the price factor. For low speed wireless communication, an one-way optical data link may be designed for as low as CZK 24 (using L-53F3BT infraredLED and TSOP4838 receiver, prices for single quantities from TME[24] at the time ofwriting this thesis). The cheapest radio link may be created for CZK 158 (RFM01 andRFM02, price source same as above), however, this link operates at much higher speeds.

20

Page 26: Thesis

Chapter 6

Conclusion

This work provided an overview of current optical communication methods togetherwith an embedded system example design utilizing these technologies as requested bythe official assignment.

The IrDA overview research was somewhat difficult due to the fact that the officialspecifications are no longer freely available and are only provided for a fee. Thereforebest effort was made to cross-reference other available sources.

The test device was designed to provide a simple platform for infrared communica-tions development. Basic transmission parameters were tested and correct operation ver-ified. The device was extended with the radio communication module. Should the needarsise, the firmware can be modified. The application may be rewritten to use packetcommunication instead of simple data forwarding. This could be more optimal solutionconsidering that the majority of the provided interfaces is only half duplex and the incor-porated radio module has frequency hopping support. The onboard microcontroller hasenough memory capacity to make the implementation of (some layers of) IrDA protocolstack possible. If higher IrDA interface speeds are required, the crystal reference of theMCP2120 encoder/decoder may be replaced to allow for communication speeds up to312.5kbps. However, with this modification, the IR signal timing would not meet IrDArequirements for minimal pulse duration.

Some of the interfaces provided by the module have not yet fully finished softwareimplementations. However, all of the interfaces share the same data transmission algo-rithm verified by the testing and therefore it may be reasonably expected the implemen-tations will have the same correct behavior. Of course, the development continues.

A comparison of optical and radio frequency technologies was performed. Both tech-nologies are present on the test device for possible future wireless communications de-velopment.

21

Page 27: Thesis

Bibliography

[1] Infrared Data Association official website [online]. Infrared Data Association, [cited2008-05-21]. URL: http://www.irda.org.

[2] P.J. Megowan, D.W. Suwak, Ch.D. Knutson: IrDA Infrared Communications: AnOverview [online]. Counterpoint Systems Foundry, [cited 2008-05-21]. URL: http://dogbert.mse.cs.cmu.edu/charlatans/References/Overview.pdf.

[3] SES Technology: Introduction to the IrDA Protocol [online]. SES TechnologyR&D group, [cited 2008-05-21]. URL: http://www.palantirisystems.com/publications/IntroductiontoIrDA.pdf.

[4] Vishay Electronic GmbH: Infrared Data Communication According to IrDA Stan-dard, part 1 [online]. Vishay Electronic GmBH, [cited 2008-05-21]. URL: http://www.vishay.com/docs/82513/physical.pdf.

[5] Vishay Electronic GmbH: Infrared Data Communication According to IrDA Stan-dard, part 2 [online]. Vishay Electronic GmBH, [cited 2008-05-21]. URL: http://www.vishay.com/docs/82504/protocol.pdf.

[6] Atmel Corporation: AVR042 application note: AVR Hardware Design Considera-tions [online]. Atmel Corporation, [cited 2008-05-21]. URL: http://www.atmel.com/dyn/resources/prod_documents/doc2521.pdf.

[7] Atmel Corporation: ATMega324P MCU device datasheet [online]. Atmel Corpora-tion, [cited 2008-05-21]. URL: http://www.atmel.com/dyn/resources/prod_documents/doc8011.pdf.

[8] Future Technology Devices International Ltd. (FTDI): FT245R device datasheet [on-line]. Future Technology Devices International Ltd., [cited 2008-05-21]. URL: http://www.ftdichip.com/Documents/DataSheets/DS_FT245R.pdf.

[9] Future Technology Devices International Ltd. (FTDI): FT8U232/FT8U245 DevicesLatency and Data Throughput Application Note [online]. Future Technology De-vices International Ltd., [cited 2008-05-21]. URL: http://www.ftdichip.com/Documents/AppNotes/AN232-04.pdf.

[10] Microchip Technology Inc.: MCP2120 device datasheet [online]. Microchip Technol-ogy Inc., [cited 2008-05-21]. URL: http://ww1.microchip.com/downloads/en/DeviceDoc/21618b.pdf.

[11] Hope RF: RFM12B device datasheet [online]. Hope RF, [cited 2008-05-21]. URL:http://www.hoperf.com/pdf/RFM12B.pdf.

22

Page 28: Thesis

6. CONCLUSION

[12] Vishay Electronic GmbH: TFDU4100 IrDA transceiver device datasheet [online].Vishay Electronic GmBH, [cited 2008-05-21]. URL: http://www.farnell.com/datasheets/71889.pdf.

[13] Vishay Electronic GmbH: TSOP7000 receiver device datasheet [online]. Vishay Elec-tronic GmBH, [cited 2008-05-21]. URL: http://www.vishay.com/docs/82147/tsop7000.pdf.

[14] International Rectifier: IRF7304 device datasheet [online]. International Rectifier,[cited 2008-05-21]. URL: http://www.irf.com/product-info/datasheets/data/irf7304.pdf.

[15] Hammond Manufacturing Co. Inc.: 1455C801 enclosure datasheet [online]. Ham-mond Manufacturing Co. Inc., [cited 2008-05-21]. URL: http://www.vishay.com/docs/82147/tsop7000.pdf.

[16] Atmel Corporation: Atmel AVR Studio. Atmel Corporation, [cited 2008-05-21].URL: http://www.atmel.com/dyn/Products/tools_card.asp?tool_id=2725.

[17] WinAVR, open source software development tools, [cited 2008-05-21]. URL: http://winavr.sourceforge.net/.

[18] ASIX s.r.o.: ASIX Presto USB programmer. ASIX s.r.o., [cited 2008-05-21]. URL:http://www.asix.cz/a6_presto.htm.

[19] CadSoft Computer, Inc.: EAGLE, freeware PCB design tool. CadSoft Computer, Inc.,[cited 2008-05-21]. URL: http://www.cadsoft.de/info.htm.

[20] Karel Kulhavy et al: Reasonable Optical Near Joint Access (RONJA) website. KarelKulhavy et al, [cited 2008-05-21]. URL: http://ronja.twibright.com/.

[21] Vishay Electronic GmbH: TFDU8108 VFIR device datasheet [online]. Vishay Elec-tronic GmBH, [cited 2008-05-21]. URL: http://www.vishay.com/docs/82558/tfdu8108.pdf.

[22] ZigBee Alliance official website [online]. Zigbee Alliance, [cited 2008-05-21]. URL:http://www.zigbee.org/.

[23] Bluetooth SIG official website [online]. Bluetooth SIG, [cited 2008-05-21]. URL:http://www.bluetooth.com/.

[24] Transfer Multisort Elektronik (TME) e-shop [online]. TME Czech Republic s.r.o.,cited [cited 2008-05-22]. URL: http://www.tme.cz/.

Products and/or technologies referenced in this work may be registered trademarksof their respective owners.

23

Page 29: Thesis

Appendix A

Test device schematic

24

Page 30: Thesis

Appendix B

Contents of the enclosed CD

· PDF version of this thesis

· hardware project files, EAGLE 4.16r2 Light

· firmware source code, AVR Studio 4.12 SP4/WinAVR

· datasheets of components used

· ftdi device drivers

25