Society of Robots - Robot Forum

Software => Software => Topic started by: dannytemmerman on February 08, 2009, 12:56:35 PM

Title: TV-remote controlled $50 robot
Post by: dannytemmerman on February 08, 2009, 12:56:35 PM
Hi, i am new here.

I have build the $50 robot.
I don't know much off programming.
But I want to have it remote controlled with TV-remote and i want it to have a program installed.

For an example: I want it to move around with the TV-remote if i press 4,8,6,2 and i want it to act as a object avoider when i press 5.And if i press 5 I regain control. What kind off receiver do i need and what kind of code.

Sorry for my maybe bad English.

I live in Belgium.

Thanks
Title: Re: TV-remote controlled $50 robot
Post by: frodo on February 08, 2009, 01:20:16 PM
you need IR receivers. brilliant english by the way
Title: Re: TV-remote controlled $50 robot
Post by: pomprocker on February 08, 2009, 04:35:03 PM
First step, is to find out what sort of IR pulses the remote puts out. You can either look that up online, or you would have to build something like the IR widget to record it.

http://www.compendiumarcana.com/irwidget/ (http://www.compendiumarcana.com/irwidget/)


Or

you could use a documented solution:
http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/remote/List/1/ProductID/63/Default.aspx?SortField=ProductName%2cProductName (http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/remote/List/1/ProductID/63/Default.aspx?SortField=ProductName%2cProductName)

Title: Re: TV-remote controlled $50 robot
Post by: frodo on February 08, 2009, 05:48:53 PM
nice IR widget. once you have the pulses of the remote, you need to get IR receivers that are compatible with the remote.
Title: Re: TV-remote controlled $50 robot
Post by: dannytemmerman on February 09, 2009, 03:00:36 AM
i use a universal TV-remote to control a philips TV.
And what kind of IR receiver must i use. Is a normal Ir receiver okay?
And how about the code?
Title: Re: TV-remote controlled $50 robot
Post by: dannytemmerman on February 09, 2009, 03:02:41 AM
Do you have the documentation on other universal remotes?
I use a Welltech 40085/HTFB85 universal remote.
I have a Philips 28PT4418/01.

Edit:
Would it be possible to use a 555 timer with various resistors and switches. For example when switch 1 is pressed the resistance is 1K and so the pulse changes. And when switch 2 (switch 1 must be released) is pressed the resistance in 10K so the pulse changes again.
Title: Re: TV-remote controlled $50 robot
Post by: pomprocker on February 09, 2009, 11:05:37 AM
i use a universal TV-remote to control a philips TV.
And what kind of IR receiver must i use. Is a normal Ir receiver okay?
And how about the code?

Do you know the pulse frequency of the remote?
Title: Re: TV-remote controlled $50 robot
Post by: dannytemmerman on February 09, 2009, 11:34:27 AM
i use a universal TV-remote to control a philips TV.
And what kind of IR receiver must i use. Is a normal Ir receiver okay?
And how about the code?

Do you know the pulse frequency of the remote?
No and i don't want to build that ir widget.

I would like to use this code for finding the frequency but I don't now how many loops are 1 sec.

Here is the code i already create.
If there are any mistakes in the code please mention.
The sensor_left is an ir receiver with a 120 ohm resistor.
"Nee" means "No"
"Ja" means "Yes"



void ja_sensor(void)
   {
   servo_left(44);
   delay_cycles(30000);
   }
void nee_sensor(void)
   {
   servo_right(44);
   delay_cycles(30000);
   }



//store sensor data
      sensor_left=a2dConvert8bit(5);

        int loops=29;
      int count=1;
      int frequentie=0;
      
        for (count = 1; count <= loops; count++)
        {   
      if(sensor_left < 240)
      frequentie++;   
        }
      
      if(frequentie<1)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<2)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }

      if(frequentie<3)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<4)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }         
         
      if(frequentie<5)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }         
         
         
      if(frequentie<6)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }         
         
      if(frequentie<7)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }         
         
         
      if(frequentie<8)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }         
         
      if(frequentie<9)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<10)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<11)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<12)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<13)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<14)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<15)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<16)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<17)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<18)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<19)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<20)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<21)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<22)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<23)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<24)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
         
      if(frequentie<25)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }   

Title: Re: TV-remote controlled $50 robot
Post by: Razor Concepts on February 09, 2009, 11:43:06 AM
An easier way to write that would be:

Code: [Select]
for(int i = 0; i < 25; i++)
{
if(frequentie < i)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
}
Title: Re: TV-remote controlled $50 robot
Post by: dannytemmerman on February 09, 2009, 11:57:41 AM
An easier way to write that would be:

Code: [Select]
for(int i = 0; i < 25; i++)
{
if(frequentie < i)
         {
         ja_sensor();
         }
      else
         {
         nee_sensor();
         }
}

Thanks

Do you now how to let the ATmega8 count the number of pulses in 1 second.
Something like:

For(time <= 1 second)
{
 if(sensor_left < 240)
      frequency++;  
}



But I don't now the exact code in C so i can't make the program.
Title: Re: TV-remote controlled $50 robot
Post by: pomprocker on February 09, 2009, 12:44:08 PM
Check out the knowledge base on this:

http://www.sbprojects.com/knowledge/ir/ir.htm (http://www.sbprojects.com/knowledge/ir/ir.htm)


If you set your universal remote to a code that doesn't have a corresponding television in your home, then the pulse will already be known.

For example, here is the sharp protocol:

http://www.sbprojects.com/knowledge/ir/sharp.htm (http://www.sbprojects.com/knowledge/ir/sharp.htm)


Here is another good table:

http://www.geocities.com/SiliconValley/Lakes/3947/TABLE.HTML (http://www.geocities.com/SiliconValley/Lakes/3947/TABLE.HTML)
Title: Re: TV-remote controlled $50 robot
Post by: Admin on February 09, 2009, 09:52:34 PM
Chances are your IR remote transmits at 44Khz, its just standard . . .

That being said, IR remotes transmits a fairly large code in IrDA. I think like ~20 characters if I remember right, but too lazy to look it up, and its different for different remotes.

IrDA will then need to be converted to TTL format for use with the UART pin on your microcontroller.

You read the entire command in as a string, then use if statements to control your robot.
Title: Re: TV-remote controlled $50 robot
Post by: dannytemmerman on February 10, 2009, 01:18:58 AM
I have created a device that can sent 20,30,40,50 and 60Hz.
Now i need a code to recognise with frequency is send to the robot.
I already created some pseudocode.

Here it is:

Read IR-receiver
IF(IR-receiver=on)
WHILE(IR-receiver=on)
{Read IR-receiver}
WHILE(time=< 1 second)
IF(IR-receiver=on)
WHILE(IR-receiver=on)
{Read IR-receiver}

frequency++



Would you see if its correct and please give me the code for 1 second.
Title: Re: TV-remote controlled $50 robot
Post by: Admin on February 13, 2009, 01:32:52 AM
Quote
I have created a device that can sent 20,30,40,50 and 60Hz.
Now i need a code to recognise with frequency is send to the robot.
In this case, what you need to use is a hardware interrupt and a timer.

This forum has a few code examples, same with google.

Actually, at such a slow speed, you can just use a while loop that checks for a pin change. :P
Title: Re: TV-remote controlled $50 robot
Post by: pomprocker on February 13, 2009, 10:57:30 AM
for detecting i/o pin changes, there are macros defined in sfr_defs.h which is included in io.h, but for the timing with an MCU, I don't know how accurate it would be without some sort of real-time clock or a 555 or something. In the case of IR pulses, how accurate does the timing need to be?
Title: Re: TV-remote controlled $50 robot
Post by: dannytemmerman on February 13, 2009, 11:03:00 AM
for detecting i/o pin changes, there are macros defined in sfr_defs.h which is included in io.h, but for the timing with an MCU, I don't know how accurate it would be without some sort of real-time clock or a 555 or something. In the case of IR pulses, how accurate does the timing need to be?

I just need to see which frequency it is.
And I also use a 555 timer to make my homemade remote sent out 20,30,40,50 and 60 Hz.
I just need my robot to recognise it with code.