Pages: [1] 2   Go Down
Author Topic: Using IR Codes in Hex Format  (Read 13172 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Code:
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.
« Last Edit: April 05, 2010, 02:15:41 am by dishbreak » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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/
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 26
Posts: 4119
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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


Quote
to know what the modulating frequency is for each of them
That's normally around 40 KHz.

Don
Logged

Offline Offline
Edison Member
*
Karma: 3
Posts: 1001
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley

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
Logged

UK
Offline Offline
God Member
*****
Karma: 0
Posts: 710
Arduino is Genius
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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-)
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

gbulmer,

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

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!

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Code:
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)
Logged

UK
Offline Offline
God Member
*****
Karma: 0
Posts: 710
Arduino is Genius
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
0015 003f: "1" Bit
Quote
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
« Last Edit: April 06, 2010, 09:03:39 am by gbulmer » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

UK
Offline Offline
God Member
*****
Karma: 0
Posts: 710
Arduino is Genius
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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]
« Last Edit: April 13, 2010, 05:29:18 am by gbulmer » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ for providing the inspiration for this code. Sorry, it's completely lacking in comments.  [smiley=embarassed.gif]

Code:
/* 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. smiley-sad


« Last Edit: April 25, 2010, 05:43:04 pm by dishbreak » Logged

UK
Offline Offline
God Member
*****
Karma: 0
Posts: 710
Arduino is Genius
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  :smiley).
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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley-cry

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?
Logged

Pages: [1] 2   Go Up
Jump to: