Sending RC-5 Extended code using IrSender

I have been working on this project to control my AV receiver (a Marantz NR1906) which uses RC5 and RC5x. Clearly, I'm missing something, I have the RC5 working and I can see this using my scope, but when sending RC5x the scope shows RC5 code only. I have the original remote and have captured the RC5x codes which has additional code after a short pause. I am using an Arduino UNO for this project.

I have searched the Internet for details of the RC5x protocol, but have come up with nothing and most code and examples are for receiving RC5x which has not proven helpful. I would like to understand more about the fine details of RC5 and RC5x. Could this remote be using a modified RC5 protocol??

Does anyone have any insite that could help me out with this?

I don't know RC5x, the only information I have found googling is the RC5x protocol has only one start bit (RC5 has two), the second bit is used as inverted seventh command bit (so you need to invert it to get the right value).
I solved a similar problem using AnalysIR software, so my advise is to do the same and buy it.

Okay, I finally found some information about RC5 Extended IR code. The information I found does agree with what I see on my scope so I do believe this info is accurate. If anyone has information otherwise please let me know.

RC5x (extended) code is much different than RC5 or RC6. Some people call it RC5 Marantz code. I think that is because Marantz uses this on most of their electronics. The first part of the code is the same as far as the five system bits go, but the 2nd START bit is always a zero which indicates this is RC5x. After the address there are two 'spaces' which are one bit wide each, but are NOT modulated at all, followed by the six command bits, followed by the six extended command bits.

This is the link where I found the information:
RC5 Extended

I can also verify the IRremote Library V3.9.0 does not send RC5x correctly (unless I'm doing something wrong, which is quite possible). I have RC5 and NEC working with my TV and receiver now, but I have yet to get RC5x working.

Ok, but what about buying AnalysIR and deeply check the protocol usage?
Or, simpler, just capture/use raw data and ignore the protocol format?

Sure, that could be done more easily, but then what would happen to man's quest for knowledge? :grin:. Seriously though, I will likely buy AnalystIR and build a portable IR decoder that will tell me the code any remote is using and decode the data as well. I love learning new things in detail! Also, there is a code that is not on the remote that would be very handy and that is the RC5x code (of course). Marantz provided a list of codes for the receiver.

Something that really irks me is the cheap IR remotes that seem to fail quickly forcing you to buy a new remote that is of the same quality - they should sell them in quantity! The other thing is the myriad of remotes one must have to operate equipment if you choose different manufacturers. Then there are the 'universal' remotes that not; I have had a few of those, they just don't do the job. The remote I'm building will do everything I want and nothing I do not need.

Yesterday, I tested my circuit and sketch and it works with a small glitch that I believe is switch bounce which is an easy fix.

Thank you Docdoc.

Hehe I get your point (and mostly agree), but it's not quantum mechanics where you need to discover nature secrets, it's just a protocol you want to capture and send back, as it isn't implemented (yet) on our library. :wink:

I suggested you to use AnalysIR because it's the solution for me for the infamous MySky (and SkyQ) remote and I was able to map a common remote I use to control Sky from another room (it's quite simple, a "client" receiver decodes the standard RC5 remote signals, the via UDP sends a char code to the "server" next to SkyQ decoder and sends that weird raw codes).
I'm happy to see your sketch is working (debounce is a common and easy to solve problem). Happy coding!

Docdoc, I did take your advice and purchased 2 copies of AnalysIR, one for my workbench PC and one for my laptop. It's an amazing piece of software that makes IR decoding so much easier; I highly recommend it to anyone doing IR work.

AnalysIR actually could not decode the extended code, but identified the non-extended as RC5, which I was fairly certain was correct. Chris from AnalysIR requested a full Session History so he can analyze the code.

I did find the reason the code does not work with IRremote and that is because it has a 'pause' in the extended code which is not a SPACE, but a pause of the carrier for 2 bit periods and that fools utilities that resend captured code; it thinks the pause is the end of the code. It thinks these are 2 separate button presses I believe.

At any rate, you (and I) may need to update AnalysIR in a week or so. :grinning:

p.s. - I like your avatar, we used to name all our servers after Simpson characters at work. :laughing: I got to name a server Apu after my favorite Simpson's character.

I can say you I had more: MySky code is divided into two blocks, separated by a very long pause, approx. 79000 microseconds, exceeding the unsigned int values AnalysIR gives as C code output and IRremote accepts. So I was forced to split the codes into two blocks and use a "manual" delayMicroseconds() between the blocks like:

#define KEYPAUSE 79738
short unsigned int Signal1[KEYS][VALS] = {
{240,1016,244,1152,236,748,244,2788,240,1288,244,1288,244,1148,244,880,240,12956,240,1016,244,2652,236,748,244,740,236,748,240,744,244,740,240,744,244}, // "0"
...  
};
short unsigned int Signal2[KEYS][VALS] = {  {244,1012,244,1148,244,744,244,2788,240,1288,244,1288,244,1148,240,880,240,12960,232,1024,236,1428,244,1836,240,744,244,736,240,884,236,744,244,740,248}, // "0"
...  
};
...
    irsend.sendRaw(Signal1[k], codeLen, KHZ);
    delayMicroseconds(KEYPAUSE);
    irsend.sendRaw(Signal2[k], codeLen, KHZ);

Hello gromit19,
can you please dump the RC5x with the ReceiveDump example
and post the "Raw result in microseconds - with leading gap"?
And please post the your code for sending RC5x.
Does the "pause" problem occurs while decoding or sending?

As you can see the protocol is unknown and I cannot find a way to include the extended data byte for RC5x in IRSender; any additional data is just ignored and I get RC5 code. I have tried IRSender.sendRC5x and IRsender.sendRC5Ex, but that was in past versions of IRremote, not V3.9.0. I also have a XLS file I downloaded from Marantz that shows the IR codes for the NR1509 receiver that calls the code RC5x so I'm confident it is nothing else. See the screenshot below.

I have gathered bits and pieces of information about this protocol form the Internet and it is sometimes referred to as Marantz Extended maybe because Marantz is the only one using it?? My code is posted below as well and everything, but the RC5x does work. Some of the comments may not be correct any longer since I have been tweaking the RC5x code, but the line that sends RC5x begins with:

else if (digitalRead(btn5Ch))

I want to thank everyone for the help. The command I want to send is not on the remote, but shows up in the XLS and does work on my receiver. Using Docdoc's code I could very likely make the raw send work with some trial and error. Thank you Docdoc!

Here is the ReceiveDump for the 'Option' button:

Protocol=UNKNOWN Hash=0x10B1B5AF 15 bits (incl. gap and start) received

Raw result in internal ticks (50 us) - with leading gap
rawData[30]:
-65535
+36,-33
+19,-16 +36,-16 +19,-16 +18,-17
+18,-89 +19,-33 +36,-16 +19,-33
+36,-16 +19,-16 +18,-34 +36,-33
+18,-17 +18
Sum: 750
Raw result in microseconds - with leading gap
rawData[30]:
-3276750
+1800,-1650
+950,- 800 +1800,- 800 + 950,- 800 + 900,- 850
+900,-4450 + 950,-1650 +1800,- 800 + 950,-1650
+800,- 800 + 950,- 800 + 900,-1700 +1800,-1650
+900,- 850 + 900
Sum: 37500

Result as internal ticks (50 us) array - compensated with MARK_EXCESS_MICROS=20
uint8_t rawTicks[29] = {36,33, 19,16, 36,16, 19,16, 18,17, 18,89, 19,33, 36,16, 19,33, 36,16, 19,16, 18,34, 36,33, 18,17, 18}; // Protocol=UNKNOWN Hash=0x10B1B5AF 15 bits (incl. gap and start) received

Result as microseconds array - compensated with MARK_EXCESS_MICROS=20
uint16_t rawData[29] = {1780,1670, 930,820, 1780,820, 930,820, 880,870, 880,4470, 930,1670, 1780,820, 930,1670, 1780,820, 930,820, 880,1720, 1780,1670, 880,870, 880}; // Protocol=UNKNOWN Hash=0x10B1B5AF 15 bits (incl. gap and start) received

Pronto Hex as string
char prontoData[] = "0000 006D 000F 0000 0046 003F 0025 001E 0046 001E 0025 001E 0023 0020 0023 00AA 0025 003F 0046 001E 0025 003F 0046 001E 0025 001E 0023 0041 0046 003F 0023 0020 0023 06C3 ";

Code is below:

#include <Arduino.h>

/*
   Define macros for input and output pin etc.
*/
#include "PinDefinitionsAndMore.h"
#include "IRremote.hpp"
#include "IRFeedbackLED.hpp"

#define DELAY_AFTER_SEND 100
#define DELAY_BETWEEN_PRESS 750

int btnChUp = 10;
int btnChDn = 9;
int btnPwr = 8;
int btnMute = 7;
int btnVUp = 6;
int btnVDn = 5;
int btn5Ch = 4;

void setup() {

  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);
  pinMode(8, INPUT);
  pinMode(9, INPUT);
  pinMode(10, INPUT);

  enableLEDFeedback();

  Serial.begin(115200);

  // Just to know which program is running on my Arduino
  IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK);  // Specify send pin and enable feedback LED at default feedback LED pin
}

/*
   Set up the data to be sent.
   For most protocols, the data is build up with a constant 8 (or 16 byte) address
   and a variable 8 bit command.
*/
uint16_t sAddress = 0x0010;  // 16 base 10, 1 0000
uint16_t nAddress = 0xFB04;  //
uint8_t sCommandM = 0x0D;    // 13 base 10, Mute Toggle 00 1101
uint8_t sCommandVUp = 0x10;  // 16 base 10, Volume Up
uint8_t sCommandVDn = 0x11;  // 17 base 10, Volume Down
uint8_t sCommand5Ch = 0x25;  //Need to work on this
uint8_t sRepeats = 0x00;     //
uint8_t nCommandPwr = 0x08;
uint8_t nCommandChD = 0x01;
uint8_t nCommandChU = 0x00;

bool bToggle = false;

void loop() {

  if (digitalRead(btnMute)) {
    do {
      IrSender.sendRC5(sAddress & 0x1F, sCommandM & 0x3F, sRepeats, bToggle);  // 5 address, 6 command bits.  MUTE
      delay(DELAY_AFTER_SEND);
      bToggle = false;
    } while (digitalRead(btnMute));
    bToggle = true;
    delay(DELAY_BETWEEN_PRESS);

  } else if (digitalRead(btnVUp)) {
    do {
      IrSender.sendRC5(sAddress & 0x1F, sCommandVUp & 0x3F, sRepeats, bToggle);  // 5 address, 6 command bits.  Vol Up
      delay(DELAY_AFTER_SEND);
      bToggle = false;
    } while (digitalRead(btnVUp));
    bToggle = true;
    delay(DELAY_BETWEEN_PRESS);

  } else if (digitalRead(btnVDn)) {
    do {
      IrSender.sendRC5(sAddress & 0x1F, sCommandVDn & 0x3F, sRepeats, bToggle);  // 5 address, 6 command bits.  Vol Down
      bToggle = false;
      delay(DELAY_AFTER_SEND);
    } while (digitalRead(btnVDn));
    bToggle = true;
    delay(DELAY_BETWEEN_PRESS);

  } else if (digitalRead(btn5Ch)) {
    IrSender.sendRC5(sAddress & 0x1F, (sCommand5Ch & 0x3F) + 0x40, sRepeats, false);  // 5 address, 7 command bits.  Set Multichannel Stereo
    delay(DELAY_AFTER_SEND);
  }

  else if (digitalRead(btnPwr)) {
    do {
      IrSender.sendNEC(nAddress & 0xFF, nCommandPwr, sRepeats);  // 16 address, 8command bits.  Power toggle
      delay(DELAY_AFTER_SEND);
    } while (digitalRead(btnVDn));
    delay(DELAY_BETWEEN_PRESS);
  }

  else if (digitalRead(btnChDn)) {
    do {
      IrSender.sendNEC(nAddress & 0xFF, nCommandChD, sRepeats);  // 16 address, 8command bits.  Power toggle
      delay(DELAY_AFTER_SEND);
    } while (digitalRead(btnChDn));
    delay(DELAY_BETWEEN_PRESS);
  }

  else if (digitalRead(btnChUp)) {
    do {
      IrSender.sendNEC(nAddress & 0xFF, nCommandChU, sRepeats);  // 16 address, 8command bits.  Power toggle
      delay(DELAY_AFTER_SEND);
    } while (digitalRead(btnChUp));
    delay(DELAY_BETWEEN_PRESS);
  }
}

Thanks for the Dump, it seems that Maranz protocol is like RC5 with more bits and an gap in the middle and therefore not decoded.

From what I've been able to gather, that code is RC5x. I have not been able to find any resource with an official definition of what RC5x should look like. It should have 20 to 22 bits (opinions vary).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.