Shop OBEX P1 Docs P2 Docs Learn Events
Re-purpose that old IR beta max remote control — Parallax Forums

Re-purpose that old IR beta max remote control

Ok, so inferred remotes were invented after that so it's not from a beta max VCR.

Anyway I have this remote that has a nice keyboard on it that was used to program one of those scrolling display things and I wanted to interface it to the propeller.

The first thing is to setup a 38khz demodulator circuit to decode what is coming from the remote. Second was to create some code that can capture the pulses that the remote was sending. This sounds simple but required some complicated code to get an accurate track of what the remote was sending.

Not only did I want to see the low pulse time but also the high pulse time so I could figure out how the keys were encoded. I also needed to know when it was sending data and when it was finished so I could decode the key sent.

So the following code reads the pulse data including how long the high and low pulses take just like an oscilloscope would. From there I can decode the key into highs and lows that could be use to build a binary representation of the key value.

So now you can use that old remote to control your propeller if you want.
#include "simpletools.h"

#define PIN 20

int getInput(int);
void doValue(void);


int Data[100];
int n;
int i, j, k;
long tmo;

int main(void)
{

  n = 0;  
  k = 1;
  set_io_timeout(CLKFREQ/100);  //set to 10ms
  print("TimeOut:%d, Time:%d\n", st_timeout, st_iodt);
  tmo = st_timeout/st_iodt;
  input(PIN);
  
  while (1)
  {
    i = getInput(k);
    if (i > tmo)  // we timed out
    {
      if (n > 0)  // we have a sequence of pulses
      {
        doValue();
      }        
      n = 0;
      k = 0;
    }
    else
    {
      if (i > 1)
      {
        if (k == 1) // type of pulse and length
          Data[n++] = -i;
        else
          Data[n++] = i;
      }
    }
    k = 1 - k;
  }
  return 0;
}

int getInput(int x)  // get pulse data
{
  long i;
  long j;
  
  i = st_timeout;
  j = CNT;
  while ((x == get_state(PIN)) && (CNT - j < i));
  return (CNT - j) / st_iodt;
}

void doValue(void) // output value
{
  int i;
  int j;
  
  print("%d>", n);
  for (i=0;i<n;i++)
    print("%d,", Data[i]);
  print("\n");
  
  n = n - 1;
  for (i=1;i<n;i++)
  {
    j = abs(Data[i]) - abs(Data[i+1]);
    if (abs(j) > 150)
      print("H");
    else
      print("L");
    i++;
  }
  print("\n");
}


Mike

Comments

  • ercoerco Posts: 20,255
    edited 2016-03-19 21:30
    Nice to meet someone else who still thinks IR remotes are the bee's knees. While the world has gone mad for Bluetooth WiFi web-enabled GPS IoT dingle dongles, us IR guys are just getting things done and moving on with our lives.

    If any one needs a nice simple $2 universal remote with TONS of useful buttons (every button except one works when set up as a Sony TV remote), see my favorite at http://www.ebay.com/itm/Universal-Portable-Remote-Controller-Control-for-Television-TV-Set-TV-139F-SG-/281939674305

    I buy 'em 4 at at time and use them in all sorts of projects.

  • erco wrote: »
    Nice to meet someone else who still thinks IR remotes are the bee's knees. While the world has gone mad for Bluetooth WiFi web-enabled GPS IoT dingle dongles, us IR guys are just getting things done and moving on with our lives.

    If any one needs a nice simple $2 universal remote with TONS of useful buttons (every button except one works when set up as a Sony TV remote), see my favorite at http://www.ebay.com/itm/Universal-Portable-Remote-Controller-Control-for-Television-TV-Set-TV-139F-SG-/281939674305

    I buy 'em 4 at at time and use them in all sorts of projects.

    And the fellow who listed now insists it was sold.

    I agree. Based on spurious readings whilst making use of this remote,
    "Infrared Keychain Remote" https://sparkfun.com/products/retired/10280 which they included in this kit,
    "Sparkfun IR Control Kit" https://sparkfun.com/products/13235

    And yes first talking to one of those dratted Ard**** things first. I then tracked down a remote from Target who did much the same thing and wouldn't annoy my HDTV when I had it on.

    It was much more fun to figure out how to adapt the kit's contents to talk to a Basic Stamp, and when I discovered the one for the BOE Bot it was slightly easier.
    ---
    Strange no robots here, they now live across from you erco.
  • iseries wrote: »
    Ok, so inferred remotes were invented after that so it's not from a beta max VCR.

    Anyway I have this remote that has a nice keyboard on it that was used to program one of those scrolling display things and I wanted to interface it to the propeller.

    The first thing is to setup a 38khz demodulator circuit to decode what is coming from the remote. Second was to create some code that can capture the pulses that the remote was sending. This sounds simple but required some complicated code to get an accurate track of what the remote was sending.

    Not only did I want to see the low pulse time but also the high pulse time so I could figure out how the keys were encoded. I also needed to know when it was sending data and when it was finished so I could decode the key sent.

    So the following code reads the pulse data including how long the high and low pulses take just like an oscilloscope would. From there I can decode the key into highs and lows that could be use to build a binary representation of the key value.

    So now you can use that old remote to control your propeller if you want.
    #include "simpletools.h"
    
    #define PIN 20
    
    int getInput(int);
    void doValue(void);
    
    
    int Data[100];
    int n;
    int i, j, k;
    long tmo;
    
    int main(void)
    {
    
      n = 0;  
      k = 1;
      set_io_timeout(CLKFREQ/100);  //set to 10ms
      print("TimeOut:%d, Time:%d\n", st_timeout, st_iodt);
      tmo = st_timeout/st_iodt;
      input(PIN);
      
      while (1)
      {
        i = getInput(k);
        if (i > tmo)  // we timed out
        {
          if (n > 0)  // we have a sequence of pulses
          {
            doValue();
          }        
          n = 0;
          k = 0;
        }
        else
        {
          if (i > 1)
          {
            if (k == 1) // type of pulse and length
              Data[n++] = -i;
            else
              Data[n++] = i;
          }
        }
        k = 1 - k;
      }
      return 0;
    }
    
    int getInput(int x)  // get pulse data
    {
      long i;
      long j;
      
      i = st_timeout;
      j = CNT;
      while ((x == get_state(PIN)) && (CNT - j < i));
      return (CNT - j) / st_iodt;
    }
    
    void doValue(void) // output value
    {
      int i;
      int j;
      
      print("%d>", n);
      for (i=0;i<n;i++)
        print("%d,", Data[i]);
      print("\n");
      
      n = n - 1;
      for (i=1;i<n;i++)
      {
        j = abs(Data[i]) - abs(Data[i+1]);
        if (abs(j) > 150)
          print("H");
        else
          print("L");
        i++;
      }
      print("\n");
    }
    
    

    Mike

    Mike?
    What about the header you included? Shouldn't that be disclosed also?
  • Heater.Heater. Posts: 21,230
    Not really. simpletools is an open source library for the Propeller. Sorry I forget who has built that. We have to assume that is what the include refers to.
  • Heater. wrote: »
    Not really. simpletools is an open source library for the Propeller. Sorry I forget who has built that. We have to assume that is what the include refers to.

    Never assume. In this context we can assume nothing. It might be that library you are thinking of. Then again it might be something he wrote to support the remote he was using.

  • PublisonPublison Posts: 12,366
    edited 2016-03-20 14:38
    simpletools.h is installed when you install SimpleIDE.
  • Publison wrote: »
    simpletools.h is installed when you install SimpleIDE.

    Of course. I wrote that phrase, ah, that way, because I wasn't thrilled regarding how he responded.

    I have copies here of it, both for windows and for the Raspberry Pi. I also have a PAB (Prop Activity Board) here, but I've not gone over what it can do, since those pixels came out last year.
    ---
    That's strange, erco what is that robot doing in his den preparing to watch some difficult to understand sporting event on a wide flatscreen TV?
  • ercoerco Posts: 20,255
    Buck, you're slipping.








    You failed to mention my robots in two posts here. Now don't rush, take your time and do things right.
  • erco wrote: »
    Buck, you're slipping.








    You failed to mention my robots in two posts here. Now don't rush, take your time and do things right.

    No I didn't they were busy moving themselves across the street. Except for the one who went cross-country to watch some silly sporting event in a small town in CT, and in someone's home.
Sign In or Register to comment.