My friend and fellow mad scientist Craig Gardner came up with this nifty little project. It is simple and cheap to make, and works really well. It allows the user to send commands to a Stamp using any standard universal remote that can use the Sony protocol. Craig is a Basic Atom guy (don't hold it against him, he's a really nice person ;-)) so I told him I would make a Stamp friendly version.
A super simple IR remote project!
The Basic Stamp IR remote interface
My friend and fellow mad scientist Craig Gardner came up with this nifty little project. It is simple and cheap to make, and works really well. It allows the user to send commands to a Stamp using any standard universal remote that can use the Sony protocol. Craig is a Basic Atom guy (don't hold it against him, he's a really nice person ;-)) so I told him I would make a Stamp friendly version. Craig has an article HERE for his version.
His was neatly designed to plug into the servo pins of the Basic Atom equivalent to the Board of Education. Unfortunately, as we discovered, the Stamp BOE has VIN on the servo pins, and the Atom has VDD. I assumed (making a you know what out of you know who) that the BOE had VDD on the servo pins. The smell of scorching silicon is what alerted me to the problem. Oops! A tribute to the durability of the Stamp, it didn't smoke the pin, although it was really hot and refused to program until it cooled off.
So, I decided to make another board design. If I had any 5V zeners laying around, I might have made one that could mount as Craig intended onto the servo pins. But I didn't, so I made it to plug into a breadboard. I also added a jumper to allow user selection of the baud rates 9600 and 2400. I did this so that the device may be used with the BS1 as well as all BS2's.
Construction of the device is also simple. You will need:
1* PIC12F675
1* 8 pin DIP socket
1* T-1 LED
2* 1k resistor, 1/8 or 1/4 watt
1* 10k resistor, 1/8 or 1/4 watt
2* .1uF caps, 6V or higher ( I used E.G. part # G4408A)
1* pair jumper pins and jumper (Optional, see below)
1* IR module
The IR module I used was from the Electronic Goldmine, part #G6042. It is a Vishay/Telefunken TSOP28. There are many units you can use, but the pinout may be different. A 12F675 may be had for free from Microchip through their samples program. This project can basically be made for nothing on a piece of perfboard in 20 minutes.
As it happened, when Craig gave me one of his units, I was working on a project that has need for a lot of user interface. I was in the process of getting a keypad and decoder set up on a breadboard, but after five minutes of playing with the IR remote, I was hooked, and pulled the keypad off and put it away. Now I have 38 buttons at a cost of one I/O pin, for less than US$6 if all is bought new! And I can use it on four different projects in the same room! It really can't be beat for a simple interface to the Stamp.
Here is the board layout. Note that the jumper can be omitted if you don't want 2400 baud. You must still put the 10K pullup resistor (R3) in place, or the baud rate may not set itself correctly. The long leg of the LED should be facing R3. The LED indicates the serial data output, and should blink once on powerup. It may be omitted along with it's current limiting resistor (R1) for lower power consumption on battery powered devices.
Here is the board artwork. I use the laser printer method, but as you can see it is simple enough that it could be hand drawn or mounted on perf or proto board. To use the artwork, I recommend printing it out and placing the 12F675 on it to make sure that it is the correct size. I have had trouble with downloaded art work not printing the right size before.
IMPORTANT NOTES: The PIC Basic Pro code available for download here IS NOT compatible with Craig's board!! This is because I added the jumper for the baud rate and changed the board layout. The HEX file is available for use with any programmer. The ASM file is available for use with other compilers. There are a number of cheap/easy programmers out there to build if you don't have one.
Here is a Basic Stamp code example for the unit. It is compatible with either unit.
irPin CON 1 ' Change this to whichever pin you want to use
irBaud CON 240 ' Default baud. Change to 1021 if jumper installed
command VAR byte
device VAR byte
main:
SERIN irPin,irBaud,[device,command]
DEBUG "Device: ", dec device, " / ", "Command", dec command,CR
goto main
The PIC Basic code:
'CPU = 16F84A
'MHZ = 4
'CONFIG 16383
@ DEVICE INTRC_OSC, MCLR_off, PROTECT_OFF, WDT_OFF
CMCON = 7 ' Comparators OFF
ANSEL = 0 ' A/D OFF -- Port pins all digital
TRISIO = %010000 ' All I/O but GPIO3 = outputs
GPIO = %000000 ' All 0 on boot
sBaud var byte
IRpulse_length var word(13)
xx var Byte
Command Var Byte
Device Var Byte
input gpio.3
'clear
pause 500
sbaud = 2
if gpio.3 = 1 then
sBaud = 2
endif
if gpio.3 = 0 then
sBaud = 0
endif
Getstartbits:
PuLSIN GPIO.1,0,IRpulse_length(0)
if IRpulse_length(0) < 200 then
goto getstartbits
Endif
for xx=1 to 12
pulsin GPIO.1,0,IRpulse_length(xx)
next xx
displaybits:
if IRpulse_length(1) < 100 then
Command.bit0 = 0
Else
Command.bit0 = 1
endif
if IRpulse_length(2) < 100 then
Command.bit1 = 0
Else
Command.bit1 = 1
endif
if IRpulse_length(3) < 100 then
Command.bit2 = 0
Else
Command.bit2 = 1
endif
if IRpulse_length(4) < 100 then
Command.bit3 = 0
Else
Command.bit3 = 1
endif
if IRpulse_length(5) < 100 then
Command.bit4 = 0
Else
Command.bit4 = 1
endif
if IRpulse_length(6) < 100 then
Command.bit5 = 0
Else
Command.bit5 = 1
endif
if IRpulse_length(7) < 100 then
Command.bit6 = 0
Else
Command.bit6 = 1
endif
Command.bit7 = 0
Command = Command + 1
If Command = 10 then
Command = 0
Endif
if IRpulse_length(8) < 100 then
Device.bit0 = 0
Else
Device.bit0 = 1
endif
if IRpulse_length(9) < 100 then
Device.bit1 = 0
Else
Device.bit1 = 1
endif
if IRpulse_length(10) < 100 then
Device.bit2 = 0
Else
Device.bit2 = 1
endif
if IRpulse_length(11) < 100 then
Device.bit3 = 0
Else
Device.bit3 = 1
endif
'Device.bit1 = 0
SEROUT GPIO.0,sbaud,[Device,Command]
pause 100
goto Getstartbits