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

DAN148

How to Transmit IR Codes

  By Michael Simpson

The IR function library was one of the first libraries I added to the Dios.  It has been primarily for receiving Sony IR codes.   I recently started a new project where I needed an IR transmitter.  After an hour or so of experimenting I came up with a new function to transmit the IR codes.

Its really 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 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 Dios.

Schematic 1

You must use IO port 13 because that it the port that the hardware PWM uses.  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.  The mini ultra is used in the schematics but any of the Dios chips or boards could be used.

 

Lets Have Some Fun

In the following example I used a modified 32 pin module to create 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.

!!! 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 is done with the 2N2222 transistor.  It is plugged into IO Ports 12, 13, 14.   12 and a 14 is left as input so the actual voltages placed on the pins does not matter.

I have also connected the optional voltage regulator to the Dios 32 Pin module.  This way I can power the whole thing with a 9v battery.

I placed the whole thing in a small radio shack case. Part number 270-1802.

It makes the perfect size for hiding in a inconspicuous place.

 

The Program (download it here)

'Simple IR Gag
func main()
dim cmd

'Used to power IR Reciever Module
'Port 0 is IR Mod input
output 1,2
low 1 'Port 1 Gnd
high 2 'Port 2 +5v

IRinitsend()


loop:
'pause 10

cmd = IRread(0,10000)

if cmd = 0 then
goto loop
endif



print IRcmd," ",IRdevice

if IRcmd = 19 then
dovolup()
goto loop
endif

if IRcmd = 18 then
dovoldown()
goto loop
endif

endfunc

'Force the Channel back down
func dovolup()
dim x
pause 5000

for x = 1 to 40
IRsendcode(1,18)
pause 50
next

pause 1000
endfunc

'Force the Channel back up
func dovoldown()
dim x
pause 5000

for x = 1 to 40
IRsendcode(1,19)
pause 50
next

pause 1000
endfunc



include \lib\DiosIR.lib
 

 

The program uses the functions added to the library.  IRinitsend() and IRsendcode(device,cmd).  

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

 

Parts list

Vishay IR Module

IR Emitter LED

2N2222 Transistor

Voltage Regulator

8" Battery clip

12 Pin Female Header

 

 

DiosPro 40 Pin Chip

Dios Workboard Deluxe

 

Easy RS232 Driver  

DiosPro 28 Pin Chip

Dios 32 Pin Carrier (Carrier #1)

 

9 Pin Cable

Breadboard Regulator

 

 

Copyright © 2001 - 2007 Kronos Robotics