2005-11-24 · in Tech Notes · 522 words

When I first started using MythTV, I didn't have a DVB-T receiver card — but I did have an analogue TV card and an old Philips DTX6371 OnDigital set-top box. I wrote the digi* scripts, which use writepp to control the OnDigital box via an elaborate (and rather silly) hardware hack.

While the digibox has a serial port, it doesn't appear possible to use it to change channels; OnDigital sold a serial-attached keyboard, but it had to use a separate IR transmitter for the regular remote control functions. This meant that I needed to generate appropriate IR signals for it. The box uses the RC6 protocol, but I didn't have any idea what the ID numbers for it are, and I didn't have the appropriate hardware to find out. Instead, I used the existing remote control to generate the signal.

The remote control uses a matrix of switches, which is arranged as follows — pin numbers are on the chip inside the remote:

        p1      p3      p4      p6
p9      6                       7
p10     3
p11             2
p14             5               1
p15     9       8       0       4

The chip is very picky about what it's got connected in the matrix; using analogue switch chips or transistors doesn't work, so I ended up with 10 miniature relays, one for each button, controlled from my MythTV machine's parallel port. The circuit was approximately:

                                             5V
                                              |
PC parallel                                   =    o---
 port                                   relay = .. /    to key 0
                                              =    o---
Gnd o--GND    __________                      |
             | 74HC154 |                      |
             |         |              ___   |/
 D0 o--------|A0    /Y0|------|>o----[___]--|  BC108
 D1 o--------|A1    /Y1|--...         33k   |\,
 D2 o--------|A2    to |                      |
 D3 o--------|A3    /Y9|--...                GND
             |         |
 D4 o-+-|>o--|/E0      |
      |    ,-|/E1      |
      |   GND|_________|            All inverters |>o 1/6 CD4069
      |  ___
      `-[___]--GND
         33k

The idea behind inverting the enable input was that having the parallel port's data lines be all ones or all zeroes will not result in any of the relays turning on, and thus won't run down the remote control's batteries. The pull-down resistor on the enable input similarly stops the relays turning on if the parallel port lines are set to be inputs.

The relays I used have internal back EMF protection diodes; if yours don't then you'll need to add them. Types of components (and values of resistors) aren't critical; they just happened to be what I had around.

The digibox unfortunately has a habit of ignoring keypresses for no obvious reason. This was noticable when I was using the remote by hand — examining the remote's IR LED with a webcam shows that it is firing quite happily. The scripts work around this by sending each channel number several times, but this obviously doesn't work for multi-digit channel numbers, since you can't tell if it's ignored one of the digits. The workaround is to set all the channels you want to record from to have single-digit numbers. If there are more than ten, you're out of luck, I'm afraid.

I could have done this rather more simply by buying an IR transmitter/receiver unit and building one of the designs from lirc.org, but if I'd been actually spending money on this project then I'd just have bought a PCI DVB-T card instead of messing around with an external digibox. (Which is exactly what I did a few months later.)