How to use 2 IR receivers ?

Hi all,

I need to be able to read some IR signals at two different physical points too far from each other to use the same receiver. See my ASCII drawing :

0 0
-+- -+-
| <-3m-> IR recv1<-10m cable->[Arduino]<-10m cable->IR recv2 <-3m-> |
/\ <------------------------------ ~26 meters ------------------------------> /\

As you can see, because of the distance between the two points, a single receiver can't work.
That's why I need a second receiver.
They won't receive a signal a the same time

How can I get this to work ?

NOTE : Ken Shirriff (IRRemote library) talked many months ago about "AND-ing" the output. It wasn't clear to me...

Thanks for your help.

If you wanna get this done reliably, use hardware on every receiver's end (an ATtiny should be enough) and use RS485 for the connection to the Arduino. If you don't wanna invest that much, use the best cable you can afford and connect it directly to your Arduino. If you wanna use the IRremote library you have to modify it quite extensively, but the principal functionality should work with multiple receivers.

ANDing the input is probably not what you want. If you put the two signal to an OR gate and then to one input pin. If you never have concurrent signals, this is just a if you just have one receiver but two remote controls sending signals. This is OK, if you don't need to distinguish between signals from one receiver and the other, but unusable if you need that information.

Do you have a reference to the ANDing output article from Ken Shirriff?

The signal on the lines for a 38KHz receiver is only ~6KHz. I think you could get away with the cable lengths you're describing, or at least it would be worth a try to see if things run stably.

Hi, thanks for your answers.

First, here is the link mentioning the AND gate to couple two receiver :

The AND logic seems odd to me too, the OR is more what I'm looking for.
In fact, I don't need to know which receiver receives the signal, both will act exactly the same in my program. I just need two of them because of the distance between the two points.

My need could be satisfied with the OR gate solution. Could you please tell me more about this ? Should I choose a CMOS gate ? a particular model ? do I need something else to wire the whole thing ?

@Chagrin : do you need it won't work due to the cable length ? Should I try with a shielded cable ? What is the maximum cable length you think I can use ?

NOTE: I may be able to reduce the cable length this way:
each 10 meters cable may become 4 to 5 meters.

Is a RS485 based solution more robust ?

Thanks for your tips

The AND logic seems odd to me too, the OR is more what I'm looking for.

The linked post from Ken tells the reason for the AND gate: the signal is active low. So if one of the two goes low, the output has to be low, an AND gate is doing exactly this.

Is a RS485 based solution more robust ?

Definitely, but it's also a lot more work. I agree with Chagrin, that testing the low cost version is worth a try.

So an AND gate is what I need to test the low cost version, right ?

If so, should I choose a TTL or CMOS gate ? Any model in particular (I've found this one for instance: CD4081 (CD4081 Datasheet(PDF) - Fairchild Semiconductor)) ?
Do I need something else ? like some kind of (frequency) filter to remove noise from my signal?

Is a shielded cable worth the price in my case ?

So an AND gate is what I need to test the low cost version, right ?

Yes, that's right.

Any model in particular (I've found this one for instance: CD4081

I'm not the specialist in those things but I see no reason why a simple 7408 wouldn't do the job.

Is a shielded cable worth the price in my case ?

This depends a lot how electrically noisy your environment is. If in doubt and you can afford it, take the shielded version.

If you wanna use the IRremote library you have to modify it quite extensively,

Why ?

This is the code of one of the IRremote examples (dump function stripped down because it's long and not relevant here):

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

// ...

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    dump(&results);
    irrecv.resume(); // Receive the next value
  }
}

Just by looking at this example I don't see why instantiating two IRremote objects each one on its own pin shouldn't work. (Of course there should be also two results variables...)

Why ?

Because the receiving part is not done in the object but in an interrupt service routine. The object constructor sets a global variable with the RECV_PIN parameter, so if you initialize a second object the first object's pin will be overwritten. The interface looks very object oriented but in fact only one object can be used.

Thanks for your detailed and informative reply. :slight_smile:

Just to contribute to the knowledge base: I've tested with some 5 meters long cables, clearly not the best quality cables, and my (single for the moment) receiver works like a charm.
=> That's a good point!

I've have to try with a second receiver and a logical gate now (have to buy both before).

delirii:
Just to contribute to the knowledge base: I've tested with some 5 meters long cables, clearly not the best quality cables, and my (single for the moment) receiver works like a charm.
=> That's a good point!

Where I work we had a Satellite box at one end of the building and someone who wanted to channel change it one floor down and at opposite side of building. We de-soldered the IR LED from the remote and placed it on about 50 meters of screened audio cable at the satellite box and it worked a charm. I would assume IR receiver would work just as well.

Riva:
Where I work we had a Satellite box at one end of the building and someone who wanted to channel change it one floor down and at opposite side of building. We de-soldered the IR LED from the remote and placed it on about 50 meters of screened audio cable at the satellite box and it worked a charm. I would assume IR receiver would work just as well.

That's even better. Thanks for sharing. If my logical gate does the trick, I'll solve my problem!