TxIR

Overview

This is a low level library that handles sending infrared (IR) commands. IR commands are normally sent on a carrier frequency. Depending on the device, the frequency can vary some, but it's generally around 40kHz (26us). To send a bit of data the sender alternates between a 50% duty cycle pulse and a 0% duty cycle pulse. The relationship between these pulses determines what data is being sent. For a good description about how IR commands are normally sent see http://www.hifi-remote.com/infrared/IR-PWM.shtml.

This library lets you choose how long pulses should be sent for. It's very low level, but it lets you control devices that only need a couple of codes. Hopefully, libraries for other devices will derive from this library. I used it to control the shutter on a NIkon DSLR camera.

To use the library you need to connect an IR led to one of the PWM enabled ports on the mbed. In my case I'm using port 21.

To use the transmitter

#include "TxIR.hpp"
TxIR txir(p21);

// Send the code for a Nikon ML3 remote
const unsigned nikonShutter[] = {2250, 27600, 650, 1375, 575, 3350, 650, 62000,
                                 2250, 27600, 650, 1375, 575, 3350, 650};
txir.txSeq(26, 15, nikonShutter);

Code

Library:

Import libraryTxIR

This library is a very low level interface to a transmit IR codes. Other libraries could be built on top of it to transmit different manufactures codes, or a specific code. I use the library to remotely trigger a Nikon DSLR camera the same way an ML3 Nikon remote does.

API:

Import library

Public Member Functions

TxIR (PinName pin)
Initialize the TxIR library.
bool inUse ()
If something is currently being sent.
bool txSeq (unsigned freq, unsigned len, const unsigned *data)
Transmit an IR sequence.

Circuit

/media/uploads/ASaidi/irtx.png


All wikipages