Has anyone been successful in receiving with two infrared receivers at the same time? I've tried a couple of libraries with the code below and I can get them separately but not together. Thank you in advance.
#include <IRremote.h>
int IR_Left = 10;
int IR_Right = 11;
int outL=2;
int outR=13;
In general you have to make both receivers use different timers, or different irparams.
In practice this requires to change the IRremote library, so you have to create two copies of the library in your sketchbook, rename at least one of them, and configure both differently. I'm not sure what in detail has to be renamed, so that the compiler will really use both copies. At least rename all library files and class names, and the timer #define.
It may be easier to change the ISR to handle two receiver pins, with two sets of irparams. Then you have to deal with only a single library copy, but the modifications for the use of different irparams still require some C++ coding skills.
Thanks for the replies. I'm trying to control a car with the two receivers, the car will follow a beacon signal. I was able to restrict the field of view where its only triggered on a 30-40 degree angle, and I plan to have one on each side of the car. Where if only the left receiver is triggered then the right wheel will rotate until both receivers see the transmitter and then both will rotate straight to it. At least I'm hoping this will work once I'm able to see both receivers on the Arduino UNO simultaneously.
Thank you for the suggestion. I tried adding another library and still get errors of undeclared variables. Will keep trying and confirm results.
For that you don't need to actually receive any coded data that would require the IR library.
Just transmit a continuous 38 kHz and have two simple digital inputs (digitalRead).
You may have noticed already that IR control also works with reflections, maybe white walls or ceiling. Your robot may not be able to find the beacon, due to received reflections.
I'd use simple IR photodiodes/transistors, which allow to measure the IR intensity in either direction.
Shpaget:
For that you don't need to actually receive any coded data that would require the IR library.
Just transmit a continuous 38 kHz and have two simple digital inputs (digitalRead).
Very good suggestion. I attempted this, but it basically receives everything now. do you or DrDiettrich think its due to reflection?
It wasn't as sensitive with the IR library. Is there a way to measure signal strength? that way I could filter the weak signals.
DrDiettrich:
I'd use simple IR photodiodes/transistors, which allow to measure the IR intensity in either direction.
I'll attempt this as well. I'm using a A382X5 emitter/receiver pair. However I was doing the tests with a tv remote control
Depending on the transmitting diode you may need better shielding.
Even though something is opaque in visible spectrum, it may be translucent, or even transparent in IR. For best shielding use metal. Aluminium foil is good stuff for prototyping.
In one of my projects I used powerful (100mA) IR LEDs and they were shining through a sheet of plywood 10mm thick so strongly that a cheap IP camera (with some sort of night mode, that uses IR) had no problem seeing the light.
38 kHz receivers don't offer a good ability to measure intensity of received signal since they have their own electronics to filter out noise and amplify the signals which can interfere with measurements.
I'd suggest a proof of concept. Using ordinary IR diodes and a simple amplifier circuit, you can find out the received signal level when you turn around the receiver diode. Then you can start experiments with shieldings, i.e. tubes of variable length and variable interior coating.
Shpaget:
For that you don't need to actually receive any coded data that would require the IR library.
Just transmit a continuous 38 kHz and have two simple digital inputs (digitalRead).
A continuous carrier signal @38kHz using TSSP4038 as the 2 IR receivers and as mentioned good optical shielding should work with no need for a library...just 2 GPIOS.
Turning the IR power to the lowest that works would help to avoid/minimise reflections. Putting the receiver in shielding tubes would also help.
An alternative to lowering power would be to reduce the carrier frequency away from 38kHz towards 30kHz as a method to 'simulate' reduced power.
Another way to reduce reflections etc would be to pulse the signal @ say 600uSecs, but this would need some simple processing to filter out false detections/noise.
Of course, this all assumes it is indoors or dark!
Some of those "all in one" IR receiver packages don't work with a continuous IR carrier - I found in the past when experimenting with them if I gated them with a 1khz square wave they worked OK (although you could not get signal strength from them - they have built in amps and AGC).
Do you have an IR filter over the detectors? Many of those require a filter (piece of plastic that blocks visible light but passes IR) to keep the receivers from simply saturating in normal lighting conditions. Many of the receivers are expected to be used in some other device (TV, stereo etc.) that provides a filter in front of the receiver.
You might also want to do a quick search on "glide slope" and perhaps some of the ideas there might be helpful to your design (the "glide slope" is used to tell airplanes on approach if they are too high, too low or "just right" on approach to the runway, but the ideas may be useful to the robot too).
gpsmikey:
Some of those "all in one" IR receiver packages don't work with a continuous IR carrier - I found in the past when experimenting with them if I gated them with a 1khz square wave they worked OK (although you could not get signal strength from them - they have built in amps and AGC).
That is why I suggested the TSSO4038 TSSP4038, which is designed for a continuous carrier.
The TSxP TSOP series receivers already have a filter in the package & thereafter 'physical' barriers are useful.
Hmmm - I don't find a listing for TSSO4038, but there are listing for TSOP4038 (obsolete) and TSSP4038 out there. Did you mean one of them? (always looking at cool chips for various projects )
gpsmikey:
Hmmm - I don't find a listing for TSSO4038, but there are listing for TSOP4038 (obsolete) and TSSP4038 out there. Did you mean one of them? (always looking at cool chips for various projects )
Sorry ..typo TSSP4038 as in my earlier post. I will correct the post if possible.
Thank you all for your input. I'm close to giving up using the IR libraries. I attempted changing variables and even using IRlib for one sensor and IRremote for the other but apparently this conflicts with the timer for the Arduino and I get errors.
Going the digitalRead solution seemed promising and it works well when there is a signal being triggered, however when there is nothing triggering, I did a Serial Print and the IR is always receiving a 1 while the sensor is connected therefore making my wheels rotate. Is there any suggestions to avoid this?