Methods to avoid IR receiver jamming?

Hello,

I am interested in creating a swarm of robots. The robots I'm interested in using have one accelerometer, three IR LED transmitters (pointing horizontally), and one 38hHZ TV remote receiver (pointing up). This is a link to the robot: https://www.plumgeek.com/ringo.html

In order to inform each robot of all other robots' locations, I'm wondering if I could do the following:
Place one master Arduino with a 38hHZ TV remote receiver and an IR LED transmitter in a central location in the room (the ceiling, for example). Assign each robot an ID code (e.g. A, B, C, D, etc). Then, using one of each robot's on board IR LED transmitters, send their location to the Arduino master using their ID code, followed by their accelerometer's current coordinates (for example: "A, current coordinates"). Once the master has received all of the robots' coordinates, it would then broadcast the list in a single message to the group (e.g. "A, current coordinates; B, current coordinates; C, current coordinates").

My concern is with jamming the master IR receiver. One possible work around might be to continually synchronize the robots and receiver by doing the following:

  1. Master sends out start signal to robots.
  2. Robot A waits for start signal, then waits 10 milliseconds, then transmits its location.
  3. Robot B waits for start signal, then waits 20 milliseconds, then transmits its location, etc.
  4. Master waits 500 milliseconds from start signal, then sends out list of coordinates.
  5. Cycle is repeated.

I would very much love to hear any suggestions, solutions, or concerns that you have!

Thank you so much for your input!

That is a standard approach, called time division multiplexing or more commonly TDMA. Try it and let us know.

Amazing--thanks so much for your input!

One additional configuration question: do you foresee an issue with the fact that the IR emitting LEDs are oriented horizontally towards the walls, and the IR receiver is pointing down towards the floor? In other words, do you think the emitted signal will reach the IR receiver with this physical configuration?

Only experiments will tell.

Do you have to point your IR remote right at your TV to get a response?

Ok, thanks! (And yes, I find that I do have to point it directly at the TV, which was why I was concerned. But I will test it out and see how it goes. If it was a strict 'no, it won't work' then I wouldn't invest in the robots to do the testing. I'll give it a whirl!)

My TV responds if I can point the remote at the wall behind me. You might try replacing the batteries in your remote.

It would be a VERY wise move to get the IR communications working satisfactorily, before committing yourself to a design. Do that with two Arduinos in a mockup.

Another popular approach is to simply have the individual robots broadcast their data using randomly chosen intervals between broadcasts. If the broadcasts are short, collisions will be infrequent, and the loss of data shouldn't matter much.

No wireless communication method is 100% reliable, so you have to plan on missing data anyway.

Hello,

I’m starting the IR testing process and have grabbed an IR receiver and an Arduino. I want to learn how to use the IR receiver so that I can 1) start coding it, and then 2) start coding for the LEDs that are sending messages to it.

I’ve downloaded the code that is posted at the bottom of this post. I found the code online here. I’ve test it out with the only two remote controls that I have (a Bell TV, and a Samsung DVD (I think)). Neither registers any activity in the serial monitor.

I’m new to all of this and I’m wondering:

  1. Maybe the IR receiver is built to only pick up certain KHz (like 38KHz), and my remotes are sending out different frequencies (like, 50KHz)? Can IR receivers pick up any/all ranges of KHz, or are they dialled into one narrow range (like 38KHz)?

  2. If it is that the IR receiver can only pick up a certain frequency, is there a way to find out what that frequency is? I don’t know the exact model of the IR receiver I’m using, but it’s form factor looks like this.

  3. Once I find out what frequency my unit can read, How do I write code for an LED to transmit at that frequency?

Thanks for any suggestions you might have :slight_smile:

/* Raw IR decoder sketch!
 
 This sketch/program uses the Arduno and a PNA4602 to 
 decode IR received. This can be used to make a IR receiver
 (by looking for a particular code)
 or transmitter (by pulsing an IR LED at ~38KHz for the
 durations detected 
 
 Code is public domain, check out www.ladyada.net and adafruit.com
 for more tutorials! 
 */

// We need to use the 'raw' pin reading methods
// because timing is very important here and the digitalRead()
// procedure is slower!
//uint8_t IRpin = 2;
// Digital pin #2 is the same as Pin D2 see
// http://arduino.cc/en/Hacking/PinMapping168 for the 'raw' pin mapping
#define IRpin_PIN      PIND
#define IRpin          2

// the maximum pulse we'll listen for - 65 milliseconds is a long time
#define MAXPULSE 65000

// what our timing resolution should be, larger is better
// as its more 'precise' - but too large and you wont get
// accurate timing
#define RESOLUTION 20 

// we will store up to 100 pulse pairs (this is -a lot-)
uint16_t pulses[100][2];  // pair is high and low pulse 
uint8_t currentpulse = 0; // index for pulses we're storing

void setup(void) {
  Serial.begin(9600);
  Serial.println("Ready to decode IR!");
}

void loop(void) {
  uint16_t highpulse, lowpulse;  // temporary storage timing
  highpulse = lowpulse = 0; // start out with no pulse length
  
  
//  while (digitalRead(IRpin)) { // this is too slow!
    while (IRpin_PIN & (1 << IRpin)) {
     // pin is still HIGH

     // count off another few microseconds
     highpulse++;
     delayMicroseconds(RESOLUTION);

     // If the pulse is too long, we 'timed out' - either nothing
     // was received or the code is finished, so print what
     // we've grabbed so far, and then reset
     if ((highpulse >= MAXPULSE) && (currentpulse != 0)) {
       printpulses();
       currentpulse=0;
       return;
     }
  }
  // we didn't time out so lets stash the reading
  pulses[currentpulse][0] = highpulse;
  
  // same as above
  while (! (IRpin_PIN & _BV(IRpin))) {
     // pin is still LOW
     lowpulse++;
     delayMicroseconds(RESOLUTION);
     if ((lowpulse >= MAXPULSE)  && (currentpulse != 0)) {
       printpulses();
       currentpulse=0;
       return;
     }
  }
  pulses[currentpulse][1] = lowpulse;

  // we read one high-low pulse successfully, continue!
  currentpulse++;
}

void printpulses(void) {
  Serial.println("\n\r\n\rReceived: \n\rOFF \tON");
  for (uint8_t i = 0; i < currentpulse; i++) {
    Serial.print(pulses[i][0] * RESOLUTION, DEC);
    Serial.print(" usec, ");
    Serial.print(pulses[i][1] * RESOLUTION, DEC);
    Serial.println(" usec");
  }
  
  // print it in a 'array' format
  Serial.println("int IRsignal[] = {");
  Serial.println("// ON, OFF ");
  for (uint8_t i = 0; i < currentpulse-1; i++) {
    //Serial.print("\t"); // tab
    Serial.print("pulseIR(");
    Serial.print(pulses[i][1] * RESOLUTION , DEC);
    Serial.print(");");
    Serial.println("");
    //Serial.print("\t");
    Serial.print("delayMicroseconds(");
    Serial.print(pulses[i+1][0] * RESOLUTION , DEC);
    Serial.println(");");

  }
  //Serial.print("\t"); // tab
  Serial.print("pulseIR(");
  Serial.print(pulses[currentpulse-1][1] * RESOLUTION, DEC);
  Serial.print(");");

}

Git you the IR remote library. With this you can discover which codes your remote is sending. Note: Use a three-terminal detector, as shown at the link, one which demodulates the 38KHz signal to produce the actual ones and zeroes of the code. You can sometimes find these in homeless TVs by the side of the road.

Maybe the IR receiver is built to only pick up certain KHz (like 38KHz), and my remotes are sending out different frequencies (like, 50KHz)?

That is certainly possible, and if so, the 38 kHz receiver probably won’t work with a 50 kHz remote.

You could use a phototransistor and an oscilloscope to check the remote modulation frequency, but see this discussion: frequency - Can you get an infrared remote's signal modulation with an Arduino? - Electrical Engineering Stack Exchange

If you use the Arduino to generate both the 38 kHz modulation and the IR codes, there is no problem. Tutorial here: http://www.circuitbasics.com/arduino-ir-remote-receiver-tutorial/