How to Communicate to the BX-24 with an Infrared (IR) Universal Remote Control and an IR detector.

Parts Needed:

  • Radio Shack Infrared Sensor, Sharp GP1U52X Infrared Detector (Radio Shack 276-137) about $2.00

  • Radio Shack ITZA 2 Universal Remote Control. (These are presently out of production, but we have one available on the floor. Technically, you could use any universal remote programmed to the right channel, but we had problems using others.)


How It Works:

The Remote Control Sends out an Infrared Signal on a 40kHz carrier wave. The IR-Decoder receives the signal and strips out the 40Khz carrier wave. The IR Decoder then outputs the remaining serial data stream without a carrier to the BX-24 chip through a serial connection. Connecting the decoder to Pin 12 on the BX-24 is recommended, since this is the input capture pin. The data stream is then decoded through software on the BX to give you discrete numbers from the keys of the remote control.

Getting discrete numbers for each key pressed from a remote is a little tricky. Each manufacturer uses a different encoding scheme to transmit information. Fortunately, there are some sample programs written from NetMedia that are in the examples folder that come with the BasicX Environment. There is also really good documentation on Infrared Serial Commmunication in the Application Notes section in the BasicX environment folder. I highly recommend reading it. The programs that come with the BasicX environment decode the infrared signal produced by the Universal Remote Control Programmed to VCR # 0048 and send the data to a computer through a serial connection on COM 1. The programs are:

  • IRcapture.bas - This one is good if you do not know your source remote control. It just gives you the pulse widths it sees and it doesn't matter what remote you use.
  • IRbinary.bas - This is good when using The Radio Shack Universal Remote Set to VCR program #0048. It gives you the binary code for each key pressed on the remote.
  • IRcodes.bas - This is good when using The Radio Shack Universal Remote Set to VCR program #0048. It gives you the number for each key pressed on the remote.

The IR Detector rejects all sources that are not modulated at a 40kHz carrier. This cuts back on noise from background IR. The Detector operates on 5V and can be run from the power the BX-24 chip provides.


Step By Step:

  1. Wire up the IR detector as seen below. You might want to connect the metal housing of the IR detector to ground as well to minimize noise. The documentation from radio shack recommended this. Connecting the 5 k-ohm resistor in parellel between the power and output is essential. It will not work without it. I am not positive what it is for. Someone I asked thought it might be used to bump up the signal travelling to the BX chip. I just know you need it.

  2. Make sure you connect the input from the IR detector to pin 12 if you are using the code provided in the BasicX Environment.
  3. Download the program IRcodes.bas or a modified version of it to the BX-24. If you are on a PC only use Com1 to connect to the BX-24. In the application notes for IR Serial Connections it says that there is a conflict with Timer1 on the port Com2.
  4. Program the IR remote control to VCR #0048.
  5. Now when you send the IR detector signals from your remote you should get consistent number reading in the debug window for corresponding keys on the remote. We noticed that we got 2 different numbers corresponding to each key on the remote. The numbers seemed to oscilate each time you pressed the key. The numbers were consistent though, so you just have to check for each number in your programming.


Some Things To Note:

Most of the things below were stated above but I'll re-list the things that we felt were important or that cost us a lot of time to figure out.
  • Make sure your input is connected to pin 12 on the BX-24.
  • Definetly connect the 5k resistor in parellel between the power and the input to the BX-24.
  • Do not connect the BX-24 to the computer using COM2 on a PC when reading data from the IR detector.
  • Make sure you have the right remote and that it is programmed correctly (VCR #0048). This cost us a lot of time.
  • Read the IR serial application notes that come with the BasicX environment. We would have saved a lot of time if we did that first.
  • Please Note that for each key pressed on the remote you can get one of two numbers. You need to account for this when testing for a key pressed.

I hope it all works.

Part 2 - Now comes the fun part - futzing with code.

There are actually two parts to the BX24 IR application note - IRcodes and bxserial. These should be in the "application notes" folder in the bx24 program folder. If they are not, you can download them from Nettmedia (http://www.basicx.com/).

If you are making your application portable, both of these files need to be in the same folder. The only one you need to touch will be IRcodes. Remember that if you do a "save as" to create a new project, you may need to manually change the path in your bxp file. (Just open it in notepad and replace "ircodes" with your project name). Most of the programming is dedicated to interpreting the strange timing of the IR demodulator. The rest of it prints out the codes on your computer. There are two codes for each button. The ITZA remote control will continue to send the codes if you hold down the buttons. I can't vouch for any other remote controls.

After you go through all the buttons and write down their codes (do it yourself so you can't blame us if it doesn't work), you can comment out all the programming dealing with printing out codes. (By the way, there is no code for the volume button. In case you were wondering.) There is also a 1 second delay. We reduced it down to 0.01 seconds and it worked fine.

Because the code is a series of subroutines, it is easiest to call your own subroutine from within the existing programming and send it the value of the IR code. We used a series of case statements to check the value of the codes (2 codes per button) and then called other subroutines from within the case statements.

Problems you may run into:

  • If you have any delays in your subroutines, the bx may miss when you press a button on the remote. You may try using the "sleep" function instead of "delay."
  • Interference from overhead lights and sunlight. This did not seem to have too large an effect, but it could...
  • The demodulator received fairly well at 15 ft. But it is limited and does not work very well at a severely acute angle.
  • Communicating serially with a computer while communicating serially with the demodulator: A friend of ours was trying to talk to Director while using the demodulator and was not having any luck. We do not know how to solve this problem.

Other notes:

If you just want to use a remote control as an On/Off, you don't need any of this fancy programming. Simply use getADC. The demodulator is normally high (+5 v), but dips low (apx. 0 v) when it transmits.

Our Code

If you'd like a reference you can download our code.
You will also need the file SerialPort to be in the same project file as the file above.
Just copy and paste the code into the BasicX Environment Editor.


Good Luck!

If you have any questions, don't hesitate to email us.

Sasha Harris-Cronin
sasha@mortalspaces.com
Scott Wolynski
swolynsk@hotmail.com

Click here to return to Sasha's physical computing home page.

] mortalspaces [