Trying to control my Denon amp with IR

Hi everybody !

This is my first post here ! English is not my mother tongue so sorry if my english is not perfect…

I’m quite new to arduino programming (but I understand quite fast) and I have good basis in electronics as my work consists in repairing (but not building or programming) electronic devices.

One of my dreams since I started playing with arduino is to use it to control all my electric and electronic devices with my computer. Using infrared I could control quite a lot of devices with a kind of arduino based scriptable universal remote controller…

I’m giving my first try trying to control my Denon PMA-700AE Hi-Fi amplifier with no success for now.

As I didn’t find anything about the protocol used by the RC-1022 remote control or by Denon devices, I started recording the signals received by the amplifier using this program : http://www.arduino.cc/playground/Code/InfraredReceivers

I managed to record these signals and reproduce them on nice graphics using gnuplot :



I also have text files with all the timings of the recorded signals (in microseconds) which can be downloaded here : http://benjaprud.free.fr/Arduino/Timings.zip

So as I don’t know anything (except a little theory) about IR protocols I tried to reproduce one of these signals (the standby one) inverting the received one and using delays (yes I know it’s bad, but… it might have worked ;)) with the following code (please don’t laugh :-[) :

#include <avr/interrupt.h>
#define TIMER_RESET TCNT1 = 0

int ledPin = 8;
int triggerPin = 2;

void setup()
{
  
  
  pinMode(ledPin, OUTPUT);
  pinMode(triggerPin, INPUT);
  
  attachInterrupt(0, isr_sendIRcode, RISING);
  
  Serial.begin(9600);
  
  TCCR1A = 0x00;
  TCCR1B = 0x03;

}

void isr_sendIRcode() {
  
  TIMER_RESET;
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(356);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(689);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(360);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1741);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(328);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(721);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(300);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(773);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(272);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(773);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(276);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(773);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(272);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(773);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(272);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(777);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(272);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(773);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(272);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1829);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(272);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(773);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(272);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(777);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(268);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1829);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(272);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(773);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(252);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(797);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(256);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(16000);
  delayMicroseconds(16000);
  delayMicroseconds(16000);
  delayMicroseconds(269);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(274);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(773);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(272);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1829);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(272);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(773);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(276);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(769);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(276);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(769);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(280);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1821);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(252);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1853);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(268);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1833);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(248);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1849);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(268);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(777);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(252);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1849);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(272);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1829);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(252);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(793);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(276);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1825);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(252);
  digitalWrite(ledPin, LOW);
  delayMicroseconds(1849);
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(248);
  digitalWrite(ledPin, LOW);
  
  Serial.println(TCNT1);
  
  
}

void loop() {
  
}

… Laughy isn’t it ? ;D I had a lot of fun writing this sketch…

All the delays were calculated assuming a digitalWrite is about 4us long (actually slightly less than that so i added one microsecond delay here or there so that the duration of my signal is exactly the same as the recorded one).

So as you might have guessed, it does not work !

I’ve got several problems. First, it seems the IR LED I’ve bought does not trigger the receiver at all ! It does light up (confirmed with a CCD digital camera) but the receiver does not receive anything (confirmed with the same program I used to record the signals). I’m able to trigger the receiver with other brands remote controls but not with my arduino driven one.

I wired it on a 5V digital output in series with two 330 Ohms resistors in parallel (which would result in a 165 ohms resistor and 23,6 mA current assuming the drop voltage in the IR LED is 1,1V). Is the resistor value sufficiently low to bring enough power to the LED ? Are there several types of IR LEDs with different wavelengths (the grey, the green and the white ones ?)

Anyway i tried another weird manipulation to know if my delay code works. I plugged the output of the arduino directly on the driver transistor of a remote control which seems to work with the receiver. Once again, the LED does light up but the amplifier does not go to standby mode as expected. (I’m not able to see what the receiver receives as I’ve got only one arduino board and not much measurement tools).

  • So ? What is your question ?

  • Ah… Eeeeeeeh… My question seems to be this one :

I’ve read several posts about people trying to control devices with IR but always with known protocols (such as SIRC or RC-5) which resulted in nice sketches with beautiful code understanding start/stop bytes, messages and so on. My problem is that I start from scratch with absolutely no knowledge of the protocol used by my device. Has anybody ever tried to do that ? Which one is the best approach to use ? Am I going wrong by trying to reproduce the signals I’ve recorded on the receiver output ? Have I missed something (the demodulation done by the integrated receiver) ? Do anybody recognizes this protocol and is able to explain me how to reproduce it ? Is there a way to do what I want ? Am I dumb ? Is the world going crazy ?..

Thanks in advance to all for your answers and your patience reading this post…

[EDIT] After further reading on the subject, especially this article : bigmike.it - infrared remote control for Nikon, I realized I missed the modulation of the led. Do anyone can help me implementing this modulation in my delay code ? That would be very helpful…

Another question, here I see that someone plugged an IR LED directly between digital output and ground. I burnt a few old remote control LEDs by doing this… Is it recommended to do that ? http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1152957061

Thanks in advance… [/EDIT]

Ok, a little sleep and now everything works fine both in my head and on the arduino !

I finally made it to work implementing the modulation or the IR LED. Here is the code I used.

#include <avr/interrupt.h>
//#define TIMER_RESET TCNT1 = 0

int ledPin = 8;
int triggerPin = 2;

int switchDelay = 8;  // Change this to modify the modulation frequency, 8 is for a 38,6kHz modulation

int pulseDuration = 0;
int loopCount = 0;

// long timeMeasure = 0;

void pulse (int pulseDuration) {
  
  for (loopCount = 0; loopCount < pulseDuration; loopCount++) {
    digitalWrite(ledPin, HIGH);
    delayMicroseconds(switchDelay);
    digitalWrite(ledPin, LOW);
    delayMicroseconds(switchDelay);
    }
  
}

void setup()
{
  
  
  pinMode(ledPin, OUTPUT);
  pinMode(triggerPin, INPUT);
  
  attachInterrupt(0, isr_sendIRcode, RISING);
  
  //Serial.begin(9600);
  
  //TCCR1A = 0x00;
  //TCCR1B = 0x03;

}

void isr_sendIRcode() {
  
  //TIMER_RESET;
  
  pulse(15);                //368us
  delayMicroseconds(684);   //1052us
  pulse(15);                //1420us
  delayMicroseconds(1740);  //3160us
  pulse(14);                //3504us
  delayMicroseconds(712);   //4216us
  pulse(13);                //4536us
  delayMicroseconds(760);   //5296us
  pulse(12);                //5588us
  delayMicroseconds(760);   //6348us
  pulse(12);                //6640us
  delayMicroseconds(764);   //7404us
  pulse(12);                //7700us
  delayMicroseconds(756);   //8456us
  pulse(12);                //8752us
  delayMicroseconds(760);   //9512us
  pulse(12);                //9804us
  delayMicroseconds(760);   //10564us
  pulse(12);                //10860us
  delayMicroseconds(1812);  //12672us
  pulse(12);                //12964us
  delayMicroseconds(760);   //13724us
  pulse(12);                //14020us
  delayMicroseconds(760);   //14780us
  pulse(12);                //15076us
  delayMicroseconds(1808);  //16884us
  pulse(12);                //17176us
  delayMicroseconds(760);   //17936us
  pulse(12);                //18232us
  delayMicroseconds(760);   //18992us
  pulse(12);                //19284us
  delayMicroseconds(16000);
  delayMicroseconds(16000);
  delayMicroseconds(16000);
  delayMicroseconds(240);   //67524us
  pulse(12);                //67820us
  delayMicroseconds(756);   //68576us
  pulse(12);                //68872us
  delayMicroseconds(1812);  //70684us
  pulse(12);                //70976us
  delayMicroseconds(760);   //71736us
  pulse(12);                //72032us
  delayMicroseconds(756);   //72788us
  pulse(12);                //73080us
  delayMicroseconds(760);   //73840us
  pulse(12);                //74136us
  delayMicroseconds(1812);  //75948us
  pulse(12);                //76240us
  delayMicroseconds(1820);  //78060us
  pulse(12);                //78356us
  delayMicroseconds(1812);  //80168us
  pulse(12);                //80464us
  delayMicroseconds(1808);  //82272us
  pulse(12);                //82564us
  delayMicroseconds(760);   //83324us
  pulse(12);                //83620us
  delayMicroseconds(1812);  //85432us
  pulse(12);                //85728us
  delayMicroseconds(1812);  //87540us
  pulse(12);                //87832us
  delayMicroseconds(760);   //88592us
  pulse(12);                //88888us
  delayMicroseconds(1812);  //90700us
  pulse(12);                //90992us
  delayMicroseconds(1816);  //92808us
  pulse(12);                //93104us
  
  //timeMeasure = TCNT1;
  //Serial.println(timeMeasure * 4);
  
}

void loop() {
  
}

Now I’ll try to make the signal a bit more regular and get all the components to make my LED a bit more powerful to increase its range.

I’ll have to try other frequencies to see if I can improve the efficiency of the whole thing…

Hi Benja,

I did some work on the protocol Denon uses for its IR remote, based on a remote belonging to my CD player. It's 15 years old though, so I'm not sure if they still use that same protocol.

I did not make an IR transmitter myself (since I already have the remote), but my analysis may help you with your project: my webite.

Thanks for your help Saxdude...

For the moment i think i'll stick with delays instead of trying to understand the way the code works. This will be the next step.

My problem for now is the frequency of the modulation. The code I use does not allow a fine tuning of frequency. It results in a 38,6 KHz modulation which is too far from the receiver's frequency. My remote control only works a few centimeters away from the receiver. I guess I'll have to learn more about timers and interrupts to generate a precise frequency, or use assembly delay code.

If anyone has got interesting links about timers and interrupts or frequency generation, then it would be greatly appreciated.

I'd like to try it with a 40 KHz frequency which seems to be the most commonly used by IR remotes.