Using the RCX to send infared messages to control the TV.

Post your RCX projects, project ideas, etc here!

Moderator: roger

danjl1100
New User
Posts: 5
Joined: Fri Jul 24, 2009 9:19 pm
Contact:

Using the RCX to send infared messages to control the TV.

Postby danjl1100 » Sat Aug 08, 2009 8:32 pm

Hey, I was wondering if there was any way possible to control the television by using the RCX as a remote. I thought that I could create a program to read bytes in from the regular television remote, then record them. Then I would write another program to write the same bytes out and control the TV with it. I tried to read bytes in, but I encountered the problem that regular remotes don't write bytes for the RCX to read.

I could read bytes from the Lego Mindstorms remote, but not my television remote.

I was just wondering if i was doing anything wrong in my program. (maybe serial listener was the wrong choice or something)

Here is my class named RemoteControl.java:

Code: Select all

import josx.platform.rcx.*;
public class RemoteControl implements SerialListener, ButtonListener{
        byte[] received;
        short receivedNum = 0;
        boolean reading = true;
        short viewNum = -1;
        public RemoteControl(){
                received = new byte[20];
                Serial.addSerialListener(this);
                updateDisplay();
                Button.VIEW.addButtonListener(this);
                while(!Button.RUN.isPressed()){
                        updateDisplay();
                        try{Thread.sleep(100L);}
                        catch(Exception e){}
                }
                while(Button.RUN.isPressed()){}
        }
        public void updateDisplay(){
                LCD.clear();
                if(viewNum>=0){
                        int num = received[viewNum];
                        LCD.showNumber(num);
                        LCD.showProgramNumber((int)viewNum);
                }
                else{
                        TextLCD.print("NONE");
                }
                LCD.refresh();
        }
        public static void main(String[] args){
                RemoteControl rc = new RemoteControl();
        }
        public void packetAvailable(byte[] packet,int length){
                if(reading) for(int i=0;i<length;i++) addByte(packet[i]);               
        }
        public void addByte(byte b){
                Sound.beep();
                received[receivedNum] = b;
                receivedNum++;
                if(receivedNum==10){
                        reading = false;
                        Sound.buzz();
                }
        }
        public void buttonPressed(Button b){
                viewNum++;
                if(receivedNum==0) viewNum = -1;
                else{
                        if(viewNum==receivedNum) viewNum = 0;   
                }
        }
        public void buttonReleased(Button b){}
}
-Dan

ILOVEPIE
New User
Posts: 2
Joined: Sun May 15, 2011 10:01 pm

Re: Using the RCX to send infared messages to control the TV

Postby ILOVEPIE » Sun May 15, 2011 10:07 pm

Infrared light like all EM(electromagnetic) radiation (radio,gamma radiation,visible light,UV,X-ray etc.) has a frequency, the problem is that the RCX uses a different frequency of Infrared light from your TV remote and TV, making it not sense that specific frequency of infrared light. You are able to detect the tower because it uses the same frequency as the RCX.

danjl1100
New User
Posts: 5
Joined: Fri Jul 24, 2009 9:19 pm
Contact:

Re: Using the RCX to send infared messages to control the TV

Postby danjl1100 » Mon May 16, 2011 1:40 am

Thank you for the reply.

I am glad someone could finally explain this to me. (I never thought that the RCX would use a different frequency)

I'm only curious how you found this topic years after I posted it.

Thanks!
-Dan

s.frings
Active User
Posts: 130
Joined: Tue Jul 20, 2010 2:01 pm

Re: Using the RCX to send infared messages to control the TV

Postby s.frings » Fri Aug 12, 2011 3:19 pm

Almost all remote control senders of home entertainment devices (Radio, TV, DVD, Receiver, ...) let their infrared LED's flicker at 30 - 40khz. To send data, they switch that flickering LED on and off for different durations. The data bitrate is usually 0.5 - 2kbit/sec.

For example, to send 1000100011, the LED could do that:

- flicker at 36khz for 1ms
- dark for 3ms
- flicker at 36khz for 1ms
- dark for 3ms
- flicker at 36khz for 2ms

I hope it's clear now how the singal is modulated. It is a 100% amplitude modulation of an infrared light of 36khz fixed frequency.

On the receiving side, most devices use a filter that allows a range of 30 - 40khz. If they detect such a signal, the output is LOW. If there is no such signal, the output is HIGH. This binary signal gets decoded by a microcontroller.

The wavelength of the infrared signal usually does not matter because on the receiving side, the photo-transistor is sensitive to a wide range of wavelengths. However, using a matching pair of sender LED and receiver transistor improves the maximum distance.

So if you want to receive (and analyze or copy) signals from an unknown remote control, get an infrared receiver with integrated demodulator, such als TSOP 31236. It was made for 36khz but can also detect a little lower and higher frequencies. Connect the output directly to the input of a microcontroller and record the input signal into memory by sampling it every 500ns. Thus you get a raw serial code, like: 0001110101010010101101011010. You can simply re-send these codes or you can analyze them to find out how they are encoded. For example, press the buttons 1-9 and see what bits change. Most remote controls send the same code repeatedly or with a checksum for error detection, some other send the code followed by the inverse of it. And some use the more complicated RC5 protocol which is well documented in wikipedia.

Im not sure if the NXT or RCX is quick enough to sample its inputs so quickly using Java code.

danjl1100
New User
Posts: 5
Joined: Fri Jul 24, 2009 9:19 pm
Contact:

Re: Using the RCX to send infared messages to control the TV

Postby danjl1100 » Sat Aug 13, 2011 3:16 am

**jaw drops onto the floor**
Thank you for the very detailed response s.frings!

I'm glad that you answered this ancient thread two years later, because I wouldn't have a clue what you were talking about if I read it in back 2009. I've recently moved on from RCX to Arduino, and I will do some experimenting with this new information.

Thanks for all your help! :D
It's because of people like you that these forums are so helpful.

I really owe you one!
-Dan

s.frings
Active User
Posts: 130
Joined: Tue Jul 20, 2010 2:01 pm

Re: Using the RCX to send infared messages to control the TV

Postby s.frings » Fri Nov 25, 2011 11:43 am

Yes, you got it. You will possibly need to attach another external microcontroller that modulates the signal.

Judie
New User
Posts: 1
Joined: Mon Dec 12, 2011 2:14 pm

Re: Using the RCX to send infared messages to control the TV

Postby Judie » Mon Dec 12, 2011 2:19 pm

This makes sense! I have actually been trying to solve the same problem, I haven't really considered that I was dealing with different frequencies. Thank you!


Return to “RCX Projects”

Who is online

Users browsing this forum: No registered users and 1 guest