18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 12<br />

may have to experiment with different component values. Some combinations might cause<br />

the oscillator to run at harmonics of two or more times the crystal frequency. Digi-Key is<br />

one source for the sometimes hard-to-find 40-kHz crystals. A ceramic resonator is another<br />

option for a 40-kHz source.<br />

<strong>The</strong> other option is U3, which is a TLC555 timer configured as a 40-kHz oscillator.<br />

Components R7, R8 and C5 determine the output frequency, according to the formula<br />

shown. For accuracy and stability, use 5% or 1% tolerance values for these components.<br />

<strong>The</strong> timing error of the 555 can also add a few percent error to the output frequency.<br />

For best accuracy, use a CMOS timer like the TLC555, rather than the bipolar 555. For an<br />

adjustable frequency, substitute a 50K potentiometer for R8. Connect the center tap and one<br />

other lead of the potentiometer in place of R8, and adjust the wiper for a 40-kHz output. If<br />

you have no way to monitor U3’s frequency, you can adjust R8 later, by watching the<br />

receiver’s response as you transmit.<br />

<strong>The</strong> two inputs to NAND gate U2B are the 40-kHz oscillator and U1’s pin 15 (DATA OUT).<br />

When DATA OUT is high, pin 6 of U2B pulses at 40 kilohertz. When DATA OUT is low, pin 6<br />

of U2B is high. <strong>The</strong> result is a form of modulation, with the presence or absence of the<br />

40-kHz signal representing the logic levels at the encoder’s output.<br />

When pin 6 of U2B is low, PNP transistor Q1 switches on, and current through IRED1 causes<br />

it to emit infrared energy. When pin 6 of U2B is high, Q1 and IRED1 are off. <strong>The</strong> result is<br />

that IRED1 pulses at 40 kilohertz when pin 15 of U1 is high, and IRED1 is off when DATA<br />

OUT is low. Resistor R3 limits Q1’s base current. You can use any general-purpose or<br />

switching PNP transistor for Q1. Resistor R4 limits the current through IRED1 to about 50<br />

milliamperes, which is high enough for basic testing. If necessary, you can increase the<br />

IRED’s current later for increased range.<br />

For best results, use an IRED with a high-power output. Radio Shack carries high-output<br />

IREDs. Digi-Key also has a selection, including Harris’ F5D1QT and F5E1QT. Devices<br />

with outputs at 880 or 940 nanometers are acceptable. Look for a maximum continuous<br />

forward current of at least 100 milliamperes.<br />

Receiver Circuits<br />

<strong>The</strong> IRED transmits the encoded address and data. On the other end, you need to detect the<br />

transmitted signal, find out if the address matches, and if so, convert the received data into<br />

a usable format. Figure 12-2 shows a circuit that does these, using an infrared-receiver<br />

module and an MC145027 decoder that complements Figure 12-1’s encoder.<br />

<strong>The</strong> infrared-receiver module. MOD1 is a Sharp GP1U52X infrared-receiver module. Its<br />

circuits are enclosed in a metal cube about half an inch on each side. <strong>The</strong> module has just<br />

204 <strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!