Sei sulla pagina 1di 1

IR Communications using a UART

Dominik Tewiele compare registers OCR1A and OCR1B


VCC
control the frequency and pulse width of
If you wish to set up a medium-range (5 m the signal on output PB2. The NPN transis-
28
to 10 m) communication link between PC5(ADC5/SCL)
26 C5
tor then applies the required modulation.
PC3(ADC3)
two robots or between a robot and a base 25 Here again, we can wire several IR LEDs in
PC2(ADC2)
station, infrared light can be an economi- 10µ 16V parallel to increase the transmit range and
IC
cal alternative to using radio modules. PD0(RXD)
2
R3
T2
coverage angle. The series current limiting
3
Tried-and-tested standard protocols and PD1(TXD)
4
10k resistor for the IR LEDs should be chosen
PD2(INT0)
supporting components are available for PD3(INT1)
5 BC448 with consideration for the desired range
the modulation necessary to suppress the PD4(XCK/TO)
6 R1
and the maximum pulse current that the
11

100Ω
effect of ambient infrared light. Practically PD5(T1)
12
LEDs can handle. This last figure can be
PD6(AIN0)
every modern microcontroller sports one 13 found on the LED’s datasheet, which will
PD7(AIN1) D1
or more asynchronous serial interfaces ATmega8 also help determine a suitable pulse width
(UARTs), which make perfect partners for PB0(ICP)
14
to set in the software.
15 T1
IR receivers and transmitters. PB1(OC1A)
16
R4
PB2(SS/OC1B) 10k
PB3(MOSI/OC2)
17 The maximum baud rate that can be
An example of a suitable receiver is the 18 BC447 achieved will depend on the receiver cho-
PB4(MISO)
19
TSOP17xx, where the ‘xx’ stands for the PB5(SCK) sen. Using a TSOP17xx around 1200 baud
modulation frequency, measured in kilo- is possible, which should be adequate for
hertz. Its output can be connected directly 070170 - 11 simple control commands. For bidirec-
to the RxD pin of a microcontroller. tional communication it will be necessary
Because of the open-collector output stage, to build both a receiver circuit and a trans-
it is possible to connect several receiver mitter circuit at each end of the link. It is
modules in parallel to increase the area be used to provide modulation, or alter- worth bearing in mind that because of the
covered. The transmitter consists simply of natively an external NE555 can be used. effect of reflections scope for full-duplex
an IR diode and a couple of discrete com- In this example we are using an ATMega8 operation is rather limited.
ponents. A timer in the microcontroller can with Timer1 configured so that the output (070170-I

 elektor electronics - 7-8/2007

Potrebbero piacerti anche