Using IR Codes in Hex Format

I recently decided to use arduino to help me satisfy the senior design project for my EE bachelor's degree. My goal is to control my Samsung TV and sound System, as well as my Xbox, via IR codes. I don't have the hardware of yet (waiting on my professor to sign off on my idea), but I've been doing some poking around so as to hit the ground running.

I read a very helpful blog post here: zovirl (dot) com / 2008 / 11 / 12 / building-a-universal-remote-with-an-arduino /

However, the author was working with a very simple remote control, and he was able to decode the IR signal with an o-scope.

When I visit remotecentral (dot) com, I find a hex code like this one, for Power.

0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e

Source: remotecentral (dot) com /cgi-bin / codes / samsung / tv_functions/

I'm pretty sure I'd need to convert this hex back to binary, but I'm not sure how to begin doing so. Is each hex "word" 2 bytes of data?

I know that I need to take the remotes into the lab to know what the modulating frequency is for each of them, but I have no clue where to begin with this data. Am I even looking at the right stuff?

Any help, or even another solution, would be appreciated.

Sorry for the bizzare website parsing.

The blog post was here: http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/

The remote code came from here: http://www.remotecentral.com/cgi-bin/codes/samsung/tv_functions/

Is each hex "word" 2 bytes of data?

It's better to look at it this way - each hex 'digit' (they're not really digits, more like hegits) represents four binary 'digits'.

hex: 006d 0022 --> 0 0 6 d 0 0 2 2 binary: 0000 0000 0110 1101 0000 0000 0010 0010

to know what the modulating frequency is for each of them

That's normally around 40 KHz.

Don

To understand the data you posted (Pronto hex format) I suggest you read the following:

http://www.hifi-remote.com/infrared/IR-PWM.shtml

If you dive into this project I'm sure you will find a number of alternatve strategies however to accomplish what you set out to do.

BenF, floresta,

Thanks for your information. One of the reasons my partner and I opted for arduino was the community of support behind it. Thank you. :)

I'll review the information you posted, and will update this thread with my findings if I go forward on this project. At least this information will be left behind for someone else to find after me.

-Vishal

This is a pretty good explanation of ProntoEDIT Hex too http://www.remotecentral.com/features/irdisp2.htm

I sometimes find it helps me to read a couple of explanations.

HTH GB-)

gbulmer,

The explanation seems nearly identical to the article BenF posted, but thanks for providing the link. :)

Thanks to the material posted, I've learned the Sony and NEC IR formats, and how they're shown in hex. I've also learned that Samsung uses neither of these formats. [smiley=huh.gif] Does anyone know where I can go to find out exactly which format this remote uses?

I'm using the following remotes - Samsung TM-58 A (TV) - Samsung AH59 (Home Theater in a Box) - Xbox 360 remote

If I can't figure it out, I'll work out the format with an o-scope and post my results. Thanks!

So, here's my first crack at it. I made the following guesses Burst pair "0015 003f" --> "1" bit Burst pair "0015 0015" --> "0" bit

It seems to work out...but the bit count is off, and there's an odd 0015 0040 pair in there. Am I onto something?

Source

0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e

0000 -- Learned code 006d -- Modulation frequency: 38.02 kHz (from forumla in article 0022 -- Burst 1: 34 bits 0003 -- Burst 2: 3 bits

00a9 00a8: Lead in -- 0000 0000 1010 1001 0000 0000 1010 1000 (0, 169, 0, 168) 0015 003f: "1" Bit 0015 003f: "1" Bit 0015 003f: "1" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 003f: "1" Bit 0015 003f: "1" Bit 0015 003f: "1" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 003f: "1" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 0015: "0" Bit 0015 0040: ????? 0015 0015: "0" Bit 0015 003f: "1" Bit 0015 003f: "1" Bit 0015 003f: "1" Bit 0015 003f: "1" Bit 0015 003f: "1" Bit 0015 003f: "1" Bit 0015 0702: Lead out -- 0000 0000 0001 0101 0000 0111 0000 0010 (0, 21, 7, 2)

00a9 00a8: Lead in -- 0000 0000 1010 1001 0000 0000 1010 1000 (0, 169, 0, 168) 0015 0015: "0" bit 0015 0e6e: Lead out -- 0000 0000 0001 0101 0000 1110 0110 1110 (0, 21, 14, 110)

0015 003f: "1" Bit

0015 0040: ?????

0040 is only 1 bigger than 003f, I wouldn't worry about it. Just round it down to 0015 003f.

I built a 'learning' IR, and a friend gave me a bucket of old IR remotes from a local 'tip shop' (recycling shop at rubbish dump).

Several of those have more than 1 cycle of jitter on the transmitted signal for exactly the same code. My receiver code allows for it.

The acid test is just to try it with your TV, and see if it works reliably.

Have you got sign off yet? If not, and you have an Arduino, you might try to get an IR LED and try it anyway.

IR LEDs are under $1 if you have a good parts supplier who doesn't charge a lot for postage. Or you might be able to recover one from a defunct IR remote. I can sometimes get IR remotes for much less than a $1 at a local refuse centre which also has a recycling shop. To find out if the IR remote works, take a digital camera (mobile phone cameras work) and some batteries. You can see the IR LED glow with most digital cameras. You'd need to be confident at de-soldering to do this though. Maybe even freecycle?

Just a thought

HTH GB

I had a feeling that was what it was, because 3f and 40 are right next to each other…didn’t know I could round down that way.

Yeah, I was thinking the same thing about going experimental. I’m going to be getting sign-off today hopefully…I’ve already picked up a few of the cheaper components.

I’ll definitely post what my experimental results were!

So, with a scope in the lab, I was able to figure out and decode the Samsung IR signals.

However, the Xbox remote still remains a mystery. I know that it uses a variant of Phillips RC6 Mode 6, but nobody seems to have any documentation on it.

The closest I could find is this page: http://www.sbprojects.com/knowledge/ir/rc6.htm. But it only goes into detail about mode 0.

I just need to find a way to reliably re-construct the IR signal for transmission. Short of keeping track of the different pulse widths, is there any way I can do this?

Best, Vishal

Would you explain what you did to decode the Samsung IR, and why this didn't work for your X-Box? What equipment have you now got access to?

A way to control IR appliances is to record the signals the IR remote produces for each button, then play the signal back. So if you have an IR sensor (phototransistor), you could time the signal and play it back.

Some of the ready made IR receiver chips (e.g. some of these http://www.vishay.com/ir-receiver-modules/), are so smart that they filter out some of the modulation. This allows them to be more reliable as detectors, but less useful as receivers for IR remote control code recorders.

This is a code learning TV-Be-Gone, and they use TSOP1738 or TSOP31238 as their IR receiver. So something like those (Vishay have specific devices for IR code learning ) should let you capture exactly what the IR remote is transmitting. Then play it back with IR emitters.

It isn't the same approach as using using ProntoEDIT Hex, but it should get you a working system unless there is a deliberate attempt to encrypt or obfuscate the signal.

HTH GB

[edit]This might be a useful document from Vishay on different IR encoding formats. [/edit]

Sure thing!

The Samsung format uses a very straightforward system. I borrowed a couple of TSOP 1738 chips from the lab (Vishay product), and hooked one up on a protoboard with a scope.

When I zapped the chip with my Samsung remotes, I found out that the pulses were in a pretty distinctive pattern. Every signal always started with a pulse of ~4.5ms, follwed by a gap of 4.5ms. Each signal consisted of ~500us pulses, separated by gaps of either ~1.6ms or ~600us. The signal always ended with a ~500us pulse, and there was a gap of ~46ms before the code re-transmitted.

Using this information, and the library developed here: http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html, I was able to devise a way to properly capture IR signals and re-create them in code. Tip of the hat to Building a Universal Remote with an Arduino for providing the inspiration for this code. Sorry, it’s completely lacking in comments. [smiley=embarassed.gif]

/* PoC#1: Week 3 milestone
   Send signals for different Samsung devices. 
*/
const int TVpin = 13;
char byteIn;

//const int power[] = {224, 224, 32, 223};
const int power[] = {224, 224, 64, 191};
const int psize[] = {224, 224, 124, 131};
const int stereoPwr[] = {194, 202, 128, 127};
const int stereoAux[] = {194, 202, 136, 119};


const int LEADER_PULSE=4400;
const int PERIOD=26;
const int WAIT_TIME=11;
const int PULSE_BIT=600;
const int PULSE_ONE=1600;
const int PULSE_ZERO=500;


void blastON(const int time, const int pin) {
  int scratch = time;
  while(scratch > PERIOD)
  {
    digitalWrite(pin, HIGH);
    delayMicroseconds(WAIT_TIME);
    digitalWrite(pin, LOW);
    delayMicroseconds(WAIT_TIME);
    scratch = scratch - PERIOD;
  }
}

void blastOFF(int time) {
  delayMicroseconds(time);
}

void blastByte(const int code, const int pin) {
  int i;
  for(i = 7; i > -1; i--)
  {
    
    if(1 << i & code) //check if the ith significant bit is 1
    {
      blastON(PULSE_BIT, pin);
      //Serial.print("1");
      blastOFF(PULSE_ONE);
    }
    else
    {
      blastON(PULSE_BIT, pin);
      //Serial.print("0");
      blastOFF(PULSE_ZERO);
    }
  }
  //Serial.print("\n");
}

void command(const int irCode[], const int pin)
{
  int i;
  blastON(LEADER_PULSE-200, pin);
  blastOFF(LEADER_PULSE);
  for(i = 0; i < 4; i++)
  {
    blastByte(irCode[i], pin);
  }
  blastON(PULSE_BIT,pin);
  //blastOFF(LEADER_PULSE);
  delay(47);
}

void setup() {
  Serial.begin(9600);
  Serial.print("Welcome to Arduino. Enjoy your stay.\n");
  Serial.print("Poor Man's Remote: Menu\n1) TV Power\n2) TV P. Size\n3) Sound Power\n4) Sound Aux\n");
  pinMode(TVpin, OUTPUT);
}

void loop() {
  while( Serial.available() > 0)
  {
    byteIn = Serial.read();
    switch(byteIn)
    {
      case '1':
        Serial.print("Sending TV Power...\n");
        for(int i = 0; i < 4; i++)
        {
          command(power, TVpin);
        }
        Serial.print("Sent.\n");
        break;
      case '2':
        Serial.print("Sending TV P. Size...\n");
         for(int i = 0; i < 4; i++)
        {
          command(psize, TVpin);
        }
        Serial.print("Sent.\n");
        break;
      case '3':
        Serial.print("Sending Stereo Power...\n");
        command(stereoPwr, TVpin);
        Serial.print("Sent.\n");
        break;
      case '4':
        Serial.print("Sending Stereo Aux...\n");
        command(stereoAux, TVpin);
        Serial.print("Sent.\n");
        break;
      default:
        Serial.print("Hey! Listen to directions, idiot.\n");
    }
      Serial.print("Poor Man's Remote: Menu\n1) TV Power\n2) TV P. Size\n3) Sound Power\n4) Sound Aux\n");
  }
}

The Xbox remote itself is using a not-so simple formula. (Naturally, that would make my life too easy :o) The Xbox remote uses the RC6 IR remote protocol in mode 6, and that’s about all I know about it. I’ve tried decoding the signal by hand using the scope, but neither my partner nor I can see a discernible pattern. I attempted to use the same code library I linked above, but to no avail.

My only theory is that the Xbox uses a modulating frequency that is very different from the one the Samsung remotes (~39kHz), and as a result, I’m not capturing the data correctly. Both my IR recievers are sensitive to ~40kHz. However, I don’t know where to find this information. :frowning:

I did wonder if the X-box would be awkward.

This person has made an IR extender (receives IR then rebroadcasts) http://english.cxem.net/infrared/ir8.php

The page says it works with X-box. I guess the components would be a few $'s.

I was toying with tearing off the back end, IR re-transmit, and using it as a 'raw' sensor (I'm way too busy, but I can dream ::)). The author has put some effort into excluding ambient signals (e.g. the Sun), so it has some of the benefits of the ready-made IR receivers without filtering by frequency or trimming any pulses.

Thanks for the link. It's certainly something I can check out. But would the modulating frequency of the LED confuse the Arduino logic? Also, I'd still need to know the modulating frequency to transmit. =(

I'm told that the Xbox uses a 56 kHz modulation frequency. Does anybody know if this is the case? Also, what sort of issues would I be seeing if I was using a 40 kHz receiver with a 56 kHz receiver? I was capturing SOME kind of data with this reciever...but how could I capture only part of the signal?

But would the modulating frequency of the LED confuse the Arduino logic?

Do you mean, would the 56KHz modulation of the LED in the XBox IR remote confuse the Arduino logic? It depends on what the Arduino logic is. Assuming the signal were fed into something like Timer1 input capture, or used in pulseIn, I don't think there would be a problem.

I did Google for "56khz IR Xbox remote" and got a bunch of plausible hits.

Also, what sort of issues would I be seeing if I was using a 40 kHz receiver with a 56 kHz receiver?

Well, that is a long way off, but maybe the Vishay datasheets I looked at were for their high-noise-immunity parts, so maybe 'normal' parts are more forgiving, and you were getting hunks of data? Maybe 'patches' within a pulse-train?

Having said that, I think the Vishay parts I have been using suggest only a few KHz deviation.

Sorry, I haven't got any IR remotes that far from 38KHz, which is what I've been using (and I don't have an XBox).

The patchy response would explain my difficulty. I'll look into acquiring a receiver part that takes 56 kHz, and we'll see if I get differing results. Thanks!

Please do some more thorough googling. I just typed in that query, and it looked plausible. I didn't check anything else.

If you have an ordinary IR phototransistor to hand, you could check it for real.

I figured out my problem. It was an issue of a single bit. X.X

I hooked up a photodiode to an opamp, and zapped it with the remote. We then were able to see the marks and spaces in terms of the LED pulsing on an o-scope. Using the cursors, we figured out the frequency was ~36kHz, in spec for RC6. We also figured out that the mark/space timings being picked up by the sensor and code were accurate. It all seemed like a giant brick wall. What was going wrong? :-?

We then found out something interesting. As we continually zapped the remote with the same button, we noticed that one of the hex values kept oscillating between 7 and F. Initially stumped, we remembered that our IR library did not send the toggle bit--we had to do that manually. Hence, 7 (0111) and F(1111). So we would have to send both codes as a pair for it to work. :o

Once I get a chance to try this, i'll let the community know if it works. Since this topic has strayed far from its original intent, I'll create a new topic with the code (if it works) and an explanation of what i'm doing and how I got this to work. :) I'll post a link to it from here.

Thanks for the support! It's been a great help.

Hi there,

I am working on a project to code my PDA as a remote control for my tv. The TV is a samsung... I am struggling to find anything online that can help to do this. At the moment I need to know what is the Samsung IR codes and format used?

I am using an osciloscope to read the signal from the original remote. But this as also been difficult to understand. How do I decode this signal?

I have visited remotecentral.com and seen the hex codes.. how can I apply these to my project..(I am guessing I would need to translate these hex codes into binanry?)

Would like to hear from one you.

Thanks