Sending IR Codes...without IR LED

I’m probably going about this completely wrong. I have a device that can accept a video source from 3 video sources. In order to use the remote, I have to connect an IR sensor to the device and then I can select input 1, 2, or 3.

What I’m trying to do with my Arduino Uno is make a switcher (3 positions) to send these input codes. The idea is that the small switcher would plug into the IR port and send the codes directly. All the IR codes and libraries I’ve found assume a sensor and LED are being used. (Because who would be crazy enough to send IR codes directly into the device?)

I’ve tried this:

// #include "irCMDs.h"
#include <IRremote.h> // use the library

int timer = 10000;

unsigned int sigInputOne[68] = { 
	30432, 8850,
	4400, 600,
	1650, 550,
	550, 550,
	550, 550,
	600, 550,
	550, 550,
	600, 550,
	500, 600,
	500, 550,
	600, 500,
	1650, 550,
	1650, 600,
	1650, 500,
	1700, 550,
	1700, 550,
	1650, 550,
	1650, 550,
	1650, 600,
	600, 500,
	550, 500,
	550, 550,
	600, 500,
	600, 500,
	600, 550,
	600, 500,
	600, 500,
	1650, 600,
	1650, 550,
	1700, 550,
	1650, 500,
	1650, 600,
	1650, 550,
	1650, 550 
};

// input 2: 807F906F
unsigned int sigInputTwo[68] = {
	3296, 8950,
	4350, 650,
	1600, 550,
	550, 600,
	500, 550,
	550, 600,
	500, 600,
	550, 550,
	550, 550,
	550, 550,
	550, 550,
	1650, 600,
	1600, 650,
	1600, 550,
	1650, 600,
	1650, 550,
	1650, 550,
	1650, 550,
	1650, 600,
	500, 600,
	500, 600,
	1650, 550,
	550, 550,
	550, 600,
	500, 600,
	500, 550,
	600, 550,
	1650, 550,
	1650, 600,
	500, 550,
	1650, 600,
	1650, 550,
	1650, 600,
	1600, 600 
};

// input 3: 807F00FF

unsigned int sigInputThree[68] = {
	18590, 8900,
	4400, 600,
	1600, 600,
	500, 600,
	500, 600,
	550, 550,
	550, 550,
	550, 550,
	550, 550,
	550, 600,
	500, 550,
	1650, 600,
	1650, 600,
	1600, 550,
	1650, 600,
	1650, 600,
	1600, 550,
	1650, 600,
	500, 600,
	550, 550,
	550, 550,
	550, 550,
	550, 550,
	550, 600,
	500, 550,
	600, 550,
	1650, 550,
	1600, 650,
	1600, 600,
	1600, 600,
	1650, 550,
	1650, 550,
	1650, 550,
	1650, 650
};

IRsend irsend;

void setup() {
  // setup code, runs once
  
  Serial.begin(9600);   
  
}

void loop() {
  // main code here, run repeatedly

  delay(timer);
  irsend.sendRaw(sigInputOne,68,38);
  delay(timer);
  irsend.sendRaw(sigInputTwo,68,38);
  delay(timer);
  irsend.sendRaw(sigInputThree,68,38);  
}

With no results. As well as this, with no results…(the decode example from the IR library suggested the codes from my remote were NEC)

/*
 * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
 * An IR LED must be connected to Arduino PWM pin 3.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

IRsend irsend;

void setup()
{
  Serial.begin(9600);
}

void loop() {
      irsend.sendNEC(0x807F807F, 32); // input code 1
      delay(10000);

      irsend.sendNEC(0x807F906F, 32); // input code 2
      delay(10000);

      irsend.sendNEC(0x807F00FF, 32); // input code 3
      delay(10000);
}

I’m just not sure what I’m overlooking here. Maybe I need to emulate something?

Searching arduino and IR has only led me to more sources about using LEDs and Sensors =\

What I'm trying to do with my Arduino Uno is make a switcher (3 positions) to send these input codes. The idea is that the small switcher would plug into the IR port and send the codes directly.

Leaving aside the program code for now, how is the Arduino connected to the "device", whatever it is ? Can you let us into the secret of what this device is ?

It's a wireless receiver for HD video. Here are a few pics from the setup.

Currently no HDMI out of the video receiver nor am I powering it but this is just to show the IR cable setup. The cable is from an IR sensor (pic 1) that normall would be connected to the receiver (pic 2) but instead I'm trying to send these codes directly to the receiver via that sendNEC code (pic 3)



The codes came from the IRdump example from the IR library and it dumped this into the Serial Monitor:

807F807F
Decoded NEC: 807F807F (32 bits)
Raw (68): 5066 8950 -4400 600 -1650 500 -600 550 -550 600 -500 550 -550 600 -500 600 -550 500 -600 550 -550 600 -1600 600 -1600 600 -1650 600 -1600 600 -1650 550 -1650 600 -1650 600 -1600 550 -550 600 -550 600 -500 550 -550 600 -500 600 -500 550 -550 650 -500 600 -1600 600 -1600 550 -1650 650 -1600 600 -1600 600 -1650 600 -1600 650 

807F906F
Decoded NEC: 807F906F (32 bits)
Raw (68): 19674 8900 -4400 600 -1650 550 -550 600 -500 600 -500 550 -600 550 -550 550 -550 550 -550 600 -500 600 -1650 550 -1650 550 -1650 600 -1650 550 -1650 550 -1700 550 -1650 600 -1600 550 -550 600 -550 600 -1600 600 -500 600 -550 550 -550 550 -550 600 -500 550 -1650 600 -1650 600 -500 600 -1600 600 -1650 550 -1650 600 -1650 550 

807F00FF
Decoded NEC: 807F00FF (32 bits)
Raw (68): -30966 8900 -4400 600 -1600 600 -550 600 -500 600 -500 550 -600 550 -550 550 -550 550 -550 600 -500 600 -1650 600 -1600 550 -1700 550 -1650 600 -1600 550 -1700 550 -1650 600 -500 600 -550 500 -600 550 -550 600 -500 550 -600 550 -500 600 -550 550 -1650 600 -1600 600 -1600 600 -1650 600 -1650 550 -1650 550 -1650 600 -1650 550


TIA

From the pictures i looks like pin 3 of the Uno is connected to something. The IRremote library normally uses that pin to output pulses to the IR LED so that would make some sense, but for your scheme to work the Arduino and the video receiver would need a common GND. Is that what you have ?

IR data is modulated normally at 38KHz, that sensor strips off the modulation just leaving the signal. You have to strip off the modulation at the send end if you hope to transfer the data over.

Okay so if I were to stick with the sendRaw function I see in the library the code is as such

void IRsend::sendRaw(unsigned int buf[], int len, int hz)
{
  enableIROut(hz);
  for (int i = 0; i < len; i++) {
    if (i & 1) {
      space(buf[i]);
    } 
    else {
      mark(buf[i]);
    }
  }
  space(0); // Just to be sure
}

I’m stretching myself here but I’m going to assume that the modulation part is being done by enableIROut(hz) which looks like this:

void IRsend::enableIROut(int khz) {
  // Enables IR output.  The khz value controls the modulation frequency in kilohertz.
  // The IR output will be on pin 3 (OC2B).
  // This routine is designed for 36-40KHz; if you use it for other values, it's up to you
  // to make sure it gives reasonable results.  (Watch out for overflow / underflow / rounding.)
  // TIMER2 is used in phase-correct PWM mode, with OCR2A controlling the frequency and OCR2B
  // controlling the duty cycle.
  // There is no prescaling, so the output frequency is 16MHz / (2 * OCR2A)
  // To turn the output on and off, we leave the PWM running, but connect and disconnect the output pin.
  // A few hours staring at the ATmega documentation and this will all make sense.
  // See my Secrets of Arduino PWM at http://arcfn.com/2009/07/secrets-of-arduino-pwm.html for details.

  
  // Disable the Timer2 Interrupt (which is used for receiving IR)
  TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt
  
  pinMode(TIMER_PWM_PIN, OUTPUT);
  digitalWrite(TIMER_PWM_PIN, LOW); // When not sending PWM, we want it low
  
  // COM2A = 00: disconnect OC2A
  // COM2B = 00: disconnect OC2B; to send signal set to 10: OC2B non-inverted
  // WGM2 = 101: phase-correct PWM with OCRA as top
  // CS2 = 000: no prescaling
  // The top value for the timer.  The modulation frequency will be SYSCLOCK / 2 / OCR2A.
  TIMER_CONFIG_KHZ(khz);
}

So here is my modified sendRaw function. (not running enableIROut function)

void IRsend::sendRaw(unsigned int buf[], int len, int hz)
{
//  enableIROut(hz);
  for (int i = 0; i < len; i++) {
    if (i & 1) {
      space(buf[i]);
    } 
    else {
      mark(buf[i]);
    }
  }
  space(0); // Just to be sure
}

It compiles and uploads fine but still does not seem to be sending the signals. Is there another way I can check the pins to see if the signal is even being sent?

Also, when modifying those functions I tried taking out the “int hz” but even when all declarations and references had been modified to reflect that ‘int hz’ had been removed…the compiler insisted the 3rd variable still be used. I restarted the Arduino IDE thinking maybe the library file was unchanged in memory or something…no difference which is why I left the ‘int hz’ declaration. I also realize I may not be using the correct terms here, still learning clearly. :slight_smile:

You can check the pin is outputting something by using an oscilloscope which I assume you haven't got. Electronics is virtually impossible without one.

You are treating the libary like it is a person not like it is code. You need to look inside the libary files to see what is happening but your results do not supprise me.

I haven’t looked into your wiring, but one potential issue is a bug with the Dump of IRremote…

Raw (68): 5066 8950 -4400 … the first 5066 should have a ‘-’ in front of it.
Also, when sending in RAW mode always start with the positive pulse and discard the first negative, like 5066 above. This was the error in your first post - you would have ended up with an inverted signal.

I have imported your 3 signals into AnalysIR and attached a screenshot, FYI. The good news is that it looks like you captured clean NEC signals.

I have also included the code to insert into your sketch to send these signals using IRrermote. No need to use RAW mode

/*
Automatically Generated by AnalysIR - Batch Export Utility
Registered to: xxxxxxxx
Session History
Type : Key : Value : Bits
0 : NEC :  : 0807F807F : 32
1 : NEC :  : 0807F00FF : 32
2 : NEC :  : 0807F906F : 32
*/

// NB: Not all protocols are supported by IRremote or IRLib. You may need to edit the code below manually
// Automatically Generated by AnalysIR for xxxxxxxx, visit http://www.AnalysIR.com or email info@....... for further details
//int khz=38; //NB Change this default value as neccessary to the correct modulation frequency
irsend.sendNEC(0x0807F807F, 32); // AnalysIR IR Protocol: NEC, Key:  
irsend.sendNEC(0x0807F00FF, 32); // AnalysIR IR Protocol: NEC, Key:  
irsend.sendNEC(0x0807F906F, 32); // AnalysIR IR Protocol: NEC, Key:

This is probably too advanced of a project for me to be learning this stuff on. What I need to learn is how to send a signal directly from the arduino and into the IR port of my receiver (unit pictured above). I've been reading through some docs on PWM and the IR library trying to understand what is happening when sendRaw or sendNEC is used. It's a bit over my head but I'm trying.

Is it normal that an IR sensor does the decoding or is that typically done by the device receiving the signal?

This is the IR sensor I plug into the receiver when I want to use the IR remote.

As was mentioned earlier, the libraries encode the data onto a 38kHz carrier. This goes into the IR LED. At the receiver end that module you cut off the cable removes the 38kHz carrier leaving just the data.

You need to send just the data (no carrier) if you are going to plug it in directly. You also need to know the electrical characteristics of what you are plugging the Arduino in to. For example if that receiver runs at 3V and you plug an Arduino Digital pin in which has 5V logic levels, you will likely destroy the input of the video splitter.

Have a read of this site to find out how IR works.

IR is quite simple once you get your head around it. The IRremote(or IRLib) library is the best way to go . Make good use of the examples.

===
The IR sensor demodulates the signal into HIGH/LOW digital signals. IRrermote will be sending a Modulated signal, which is subsequently received & demodulated by the IR receiver and normally inverted. Things would be a lot easier for you to connect an IR LED to the Arduino and an IR Reciever to your other device and let the IR Receiver do its work, as designed.

Is it normal that an IR sensor does the decoding or is that typically done by the device receiving the signal?

No it is not normal that an IR sensor does the decoding, BUT it is normal that the IR sensor does the DEMODULATING.

Decoding - Turning data into useful actions
Demodulating - Removing the carrier. A carrier is what carries the data.
In the case of IR then there is a rapid pulsing on an off at 38KHz, this is the carrier. Then that pulsed signal is turned on an off at a much lower rate about 1KHz, that is the data. So for example you might have a 1mS data pulse, this consists of 38 on off pulses of the LED ( at 38KHz) followed by 1mS of nothing at all.

Vegas, I know that it has been a year, but have you figured this out? I too am trying to send a NEC 32-bit Hex string to a device without using the 38KHz carrier freq.

One thing I figured out is that if you eliminate the IR-LED and receiver, you have to invert the signal. I used a simple NPN BJT for that.