July 1, 2008

Homebrew IR Transmitter

I spent the last week struggling to get a the homebrew IR Transmitter to work so I figured I would write up some notes. My system is a fedora 8 box with a Hauppauge PVR-150 and I wanted to control a motorola DCT700 set-top-box.

I started out by wiring up the simple transmitter (http://www.lirc.org/transmitters.html) and decided to use my laptop and WinLIRC to test the circuit. I thought that this would be easier since the I could move the laptop around.

The problem first problem that I ran into is that LIRC & WinLIRC need a remote definition file. So when you wire up the circuit, its hard to know if your circuit is broken or you just don't have the correct remote file. After searching around, I stumbled on a tip that you can see IR signals with digital cameras. So I flipped on my camcorder in night-vision mode, pointing my cable box remote at it, and bingo! You could see the IR signal like it was a bright flash light. Since then, I've read that people are using regular digital cameras and even web cams to see the IR.

So once I could see the IR, it was really easy to wire up the IR Transmitter. If you don't see anything try flipping the LED and/or the diode since those need to be in the right direction.

After planning around with various remote files, I finally figure out that the Millenium_4_Universal.cfg works with my cable box. I used all the defaults in WinLIRC.

So you would think, if you could control the remote in WinLIRC it would be super-simple to get it to work with LIRC. So I plug my IR trasmitter into my fedora box, configure LIRC with my remote file, setup my camera, and run irsend. I see the LED light up but it doesn't work with my cable box. I then spent a week trying everything under the sun! The following it a list of finding....

1) PVR-150 card includes a IR Reciever so the order of calling modprobe is important. I use

modprobe lirc_i2c
modprobe lirc_serial

which means /dev/lirc is the PVR-150 card and /dev/lirc1 is my transmitter (/dev/ttyS0)

2) The Hauppauge IR Reciever only works with RC5 remotes. So in order to test your IR transmitter you need to use a RC5 remote config file. This is how i finally debugs my issue. I configured them both to use a the hauppauge remote file and played with various module options until i saw the PVR-150 accept the signal.

3) In the end, my problem was that WinLIRC didn't seem to have a problem with either hard or soft carrier. None of the examples out there told me that i needed to set the carrier flag on the lirc_serial module. Once, I set this, I was able to receive the hauppauge signals from the IR receiver. I'm a software engineer not a electrical so I still don't quite understand the difference between my laptop and desktop. But in the end, I needed to set softcarrier=1'

My final configuration:

1) cp Millenium_4_Universal.cfg /etc/lirc.conf
2) /etc/modprobe.conf

# PVR-150
alias char-major-61-0 lirc_i2c
options lirc_i2c debug=1
install lirc_i2c /sbin/modprobe ivtv; /sbin/modprobe --ignore-install lirc_i2c

# IR Blaster
alias char-major-61-1 lirc_serial
options lirc_serial irq=4 io=0x3f8 debug=1 softcarrier=1 type=0
install lirc_serial /bin/setserial /dev/ttyS0 uart none ;\
/sbin/modprobe --ignore-install lirc_serial

3) /etc/sysconfig/lirc

LIRCD_OPTIONS=" --device=/dev/lirc --driver=default --output=/dev/lircd --pidfile=/var/run/lircd.pid "


Finally, here is the bash script I wrote to change the channel.


#!/bin/bash

echo "Changing channel to $1"

# make sure the PVR-150 is tuned to channel 3
/usr/bin/ivtv-tune -c 3

# replace insert a space after each digit.. e.g "100" becomes "1 0 0 "
ch=`echo $1 | sed 's/\(.\)/\1 /g'`

# send the signal for 1 second to make sure that box can detect it in time
function irsend() {
/usr/bin/irsend SEND_START motorola $1
sleep 1
/usr/bin/irsend SEND_STOP motorola $1
}

# send the channels
for f in $ch
do
irsend $f
done

# send enter
irsend ok

# hide the menu
irsend exit

1 comment:

Kevin said...

I recently upgraded my box from ubuntu 9 to 11.10 and ran into an issue with doing an irsend send_once "" 0. I finally fixed it with the config here

https://help.ubuntu.com/community/Motorola_DCT700_Channel_Change_Script