Kronos Robotics and Electronics
Site Map
 
Home Zeus Projects App Notes Downloads Dios Athena Forums
 

AAN148

How to Transmit IR Codes

  By Michael Simpson

The Athena has a command called irout.  It can send IR commands in a Sony protocol format or raw.  This application note will concentrate on the Sony protocol.   The protocol is strait forward, transmit the first 7 bits of the command code then the 5 bits for the device code.

Start it all with a 2500us start bit then use a 600us interval for low and a 1200us interval for high for each bit transmitted.  There is a 600us high pause between each bit. 

I use the Hardware PWM (hpwm) to generate a 40Khz carrier and just turn it on and off as needed.

Hookup

There are two ways to hookup an IR Emitter.  The first is to just connect it directly to the Athena.

Schematic 1

You must use IO port 6 because that it the port that the hardware PWM is connected to.  A 39 ohm resister will keep the IR LED from overloading the port.  This will get you up to an 8 foot range.

 

The second approach is to use small NPN transistor such as the 2N2222 to allow us to send more current to the IR LED.

Schematic 2

The circuit used in schematic 2 will allow you to bounce the signal off all the walls. 

 

Lets Have Some Fun

In the following example I created a gag circuit.  Once turned on and placed near a Sony TV it will lower the volume every time some tries to increase it.  It will raise the volume each time someone tries to lower it.  My wife threatened to divorce me if I ever used it again so use at your own risk.  Note that by making changes to the program you could also use this circuit as a IR range extender.

!!! This is for demonstration purposes only !!!

Schematic 3

In schematic 3 we add a Vishay IR module.  It is powered by the IO port leads 1 and 2 set to low and high.  This will allow us to plug it directly into the IO port holes.

The same can be done with the 2N2222 transistor but I dont show it in the schematic. 

If you wish to power the circuit from a 9v battery you will need to add a voltage regulator like the 7805.

 

The Program (download it here)

   dim cmd,device
   dim x

   output 1
   output 2
   low 1 'Port 1 Gnd for IR module
   high 2 'Port 2 Vdd for IR module

loop:
   irin 0,cmd,device
   if device = 0 then
      goto loop
   endif

   print cmd," ",device

   if cmd = 19 then
      gosub dovolup
      goto loop
   endif

   if cmd = 18 then
      gosub dovoldown
      goto loop
   endif

   goto loop

'-------------------------------
dovolup:
   longpause 250,20 '5 second pause
   for x = 1 to 40
      irout 1,18
      pause 50
   next
   longpause 250,4
   return

dovoldown:
   longpause 250,20 '5 second pause
   for x = 1 to 40
      irout 1,19
      pause 50
   next
   longpause 250,4
   return

 

You can use these commands with any application.  You can create your own remote or use them to add some wireless communications between  projects.

Parts

Easy RS232 Driver  

Athena

Vishay IR Module

IR Emmitter LED

2N2222 Trnasistor

Voltage Regulator

8" Battery clip

12 Pin Female Header

 

7.5V AC Adapter

9 Pin Cable

Breadboard and Wire Kit

Breadboard Regulator

 

Copyright © 2001 - 2007 Kronos Robotics