Infrared Serial Communications


 Back To Index

The application for infrared goes well beyond the infrared object detection & navigation experiments shown in the IR Navigation project. With a handful of inexpensive parts [included with each Micro-Bot], and a little ingenuity, you can easily put together a half-duplex wireless infrared communications system for all kinds of fun & handy applications.

If you have two robots you can use these circuits for wireless communications between them for some really interesting fun.

The infrared LED transmitter circuit shown below in Figure #1 is capable of sending infrared serial data. Simply turn ON hardware PWM on PortB.3, then send serial data in TRUE mode as shown below. These circuits and techniques can be used for infrared wireless communications between several robots, and even to send wireless infrared data to a remote serial LCD or the PC serial port for debugging.

TRISB.3 = 0    ' PortB.3 CCP1 = PWM output pin
CCPR1L = 25    ' 25=20%, 62=50% PWM Duty-Cycle
PR2 = 124      ' Set PWM for approximately 40KHz
T2CON = 4      ' Timer2 ON + 1:1 prescale
TRUE  CON 12   ' CCP1CON value for PWM ON
FALSE CON 0    ' CCP1CON value for PWM OFF
T2400 CON 0    ' 2400 TRUE Serial Mode
CCP1CON = TRUE ' Turn ON 40KHz PWM
PAUSE 20       ' Allow hardware PWM time to stabilize

SEROUT PORTB.1, T2400, ["Hello There..!"]

The simple code fragment shown above is all that's necessary to send Hello There..! as a wireless message to another robot, or the PC serial port using the infrared detector circuit shown below in Figure #2. To send data to a serial LCD just include the serial LCD commands before the message to display.

Data exiting the PNP transistor receiver shown below in Figure #2 is inverted. This is important since the default mode for most serial LCDs, and all PC serial ports is inverted.

Note: Any device that can receive TRUE serial data such as another PIC or the BASIC Stamp can retrieve serial data directly from the infrared detectors output.

Sending TRUE serial data is required with the transmitter circuit shown in Figure #1 since the idle state for TRUE serial mode is logic 1, and this will hold the IR LEDs off during non-transmit or idle periods.


Figure #1 IR Transmitter Circuit

Note: The 2N3904 NPN transistor, LED, 430 and 10KΩ resistor in the NPN circuit shown below in Figure #2 circuit are optional. This optional circuit provides visual feedback to indicate when the circuit is receiving infrared data. The LED will blink while receiving data. Serial data from the detectors output is as read using the PicBasic Pro SERIN command with the simple receiver circuit shown below in Figure #2.

The output of this receiver circuit will also directly control serial LCDs, and can be input directly to most PC serial ports.


Figure #2 Inverted Serial Infrared Receiver Circuit

There are several reasons for this particular type or receiver circuit.

#1. As shown below in Figure #4 we can see that the IR detector modules idle output state is +5V as seen through the internal 80K pull-up resistor. Inverted serial devices such as serial LCDs, and the PC serial port require the idle state to be logic 0 which is the normal idle logic state for all inverted serial communications. The 2N3906 PNP transistor provides an inverting circuit and the logic 0 idle state expected by serial devices that require inverted serial data.

#2. The 10K base pull-up resistor connected to the 2N3906 PNP transistor aids the infrared detectors weak internal pull-up in holding the PNP transistor off during non-transmit or idle periods. It also helps improve pulse forming to clean up the data signal in electrically noisy operating environments.


Figure #4 IR Detector Internal Block Diagram

Using these simple circuits and techniques, you can easily add infrared communications to Micro-Bot, create your own wireless infrared serial LCDs, and much more. Micro-Bot includes NPN & PNP transistors for you to experiment with.


 Back To Index

Copyright © 2007 Reynolds Electronics
http://www.rentron.com