IR

Overview

The most easiest way to get a user input is using push button switches.

However, Many pins on mbed have a peripheral and we can't use their pin if we use the peripherals.

It's OK to add a few switches. But over 10 switches ... It's not good way to get a user inputs. It's not beautiful way for it.

So I created IR remote transmitter and receiver class library.

You can get a user inputs with only a pin if you use this class library.

Now we can control many machines that have a IR port.

http://mbed.org/media/uploads/shintamainjp/remoteir.png

The simple interfaces

To setup the receiver.

#include "ReceiverIR.h"
ReceiverIR ir_rx(p15);

To use the receiver.

RemoteIR::Format format;
uint8_t buf[32];
int bitcount;
if (ir_rx.getState() == ReceiverIR::Received) {
    bitcount = ir_rx.getData(&format, buf, sizeof(buf) * 8);
}

To setup the transmitter.

#include "TransmitterIR.h"
TransmitterIR ir_tx(p21);

To use the transmitter.

RemoteIR::Format format = RemoteIR::SONY;
uint8_t buf[] = { 0x80, 0x00 };
int bitcount = 12;
if (ir_tx.getState() == TransmitterIR::Idle) {
    bitcount = ir_tx.setData(format, buf, bitcount);
}

That's it all.

It's easy to setup your IR remote application.

API

» Import this library into a program

Public Types

enum   State
 

State.

More...

Public Member Functions

  ReceiverIR (PinName rxpin)
  Constructor.
  ~ReceiverIR ()
  Destructor.
State   getState ()
  Get state.
int  getData (RemoteIR::Format *format, uint8_t *buf, int bitlength)
  Get data.

» Import this library into a program

Public Member Functions

  TransmitterIR (PinName txpin)
  Constructor.
  ~TransmitterIR ()
  Destructor.
State  getState (void)
  Get state.
int  setData (RemoteIR::Format format, uint8_t *buf, int bitlength)
  Set data.

Library

Example application

» Import this programRemoteIR_TestProgram

A test program for RemoteIR library.

The receiver

/media/uploads/shintamainjp/_scaled_circuit_for_ir_rx.png

The transmitter

/media/uploads/shintamainjp/_scaled_circuit_for_ir_tx.png

References





10 comments:

18 Oct 2010

Hi Shin,

wiring a receiver to pin 17 and an emitter LED to pin 21 I deduce from your example code.

It would be nice for the general public out there to have a hardware example however (for example the set-up you used).

18 Oct 2010

Dear Mr.Johan Philippe-san

Thank you for your comments. I added schematics of the receiver and the transmitter.

Thank you so much again.

Regards, Shin.

18 Oct 2010

user Shinichiro Nakamura wrote:

Thank you for your comments. I added schematics of the receiver and the transmitter.

Thank you. Thanks for sharing

21 Oct 2010

Hello Mr. Nakamura,

I tried your program with a Sony remote and it worked very well. After that I tried a different remote, from a european satellite receiver, but did not get any output. There's some info about those here: http://lirc.sourceforge.net/remotes/dream_multimedia/ Can you please take a peek at the definitions on the link above and see if these can be adapted for use on the mbed ?

Would it be possible to integrate your Classes with Lirc config files, so that we can use any of the remotes already defined in: http://lirc.sourceforge.net/remotes/ This would make it easier for the user, as this time they could put the config file on the mbed flash, and then call the IR class by remote and key, using names, ( opposed to code sequences).

thank you. :)

28 Oct 2010

Hi Mr.Luis-san

Thank you for your comments.

user Luis Ferreira wrote:

Would it be possible to integrate your Classes with Lirc config files, so that we can use any of the remotes already defined in: http://lirc.sourceforge.net/remotes/ This would make it easier for the user, as this time they could put the config file on the mbed flash, and then call the IR class by remote and key, using names, ( opposed to code sequences).

Oh, That's a great idea! I need more time to think about it. :)

Thank you again for your great tips.

Regards Shin.

11 Dec 2010
08 Jul 2011

Sparkfun has a couple IR breakouts that might come in handy for breadboarding and save some time

r

http://www.sparkfun.com/products/8554 is an IR receiver and

t

http://www.sparkfun.com/products/10662 is the IR transmitter/driver

Noticed them a few days ago.

08 Aug 2011

can you receave IR codes and retransmit them?

for example grabbing the power code on the remote (14 bit binary i believe) than playing it back with a command

sample code anyone?

04 Sep 2011

I have been unable to make the TransmitterIR work. The output from that pin appears to be on for 10ms then turns off again (according to my scope). I've tested the pwm at 38kHz, and it is working correctly. Before I spend more time trying to debug my program, has anyone got any suggestions?

07 Oct 2011

Found the problem, seemed to be a peculiar conflict between different I/O, not sure why though. I've had my prototype recording and re-transmitting commands, my thanks to the library's author!