Sony TV Control


Ever since I built a MythTV, I have been able to eliminate my DVD and VCR remote controls. However, I still needed my television remote control to turn on the TV as well as to control the volume, mute, and video input signal selection. For a while, I didn't think it was possible to control the TV serially until I was flipping through my Sony TV's instruction manual and found a vague paragraph about the Control-S I/O port on the back of the unit.

At first glance, this looked like something I would want to use to control my TV from MythTV, but as usual the instruction booklet wasn't very specific on how I can use Control-S from home-brew devices. Luckily, I found a SIRCS description web page that provided the basic description of the protocol and information that others had found by experimenting with their Sony remote controls.

Decoding The Remote

With so little official documentation and disagreement on the actual timing, I decided to verify their work by building a simple circuit involving a photodiode sensitive to 940nm light and measuring the response of my RM-Y197 television remote control's IR signal on an oscilloscope. I was able to verify all of the basic codes given on the page referenced above, as well as a few others. All of the buttons for this particular remote are given below.

DescriptionMeasured BinaryDecimalHexidecimal
Right Arrow1100110100005133
Left Arrow0010110100005234
+ Button10100111000010165
Up Arrow00101111000011674
Down Arrow10101111000011775
System Off111101001000

The last few codes are 15-bits and appear to follow a different protocol than SIRCS. These buttons are for functions which I do not use on my remote, so did not pursue them further.

As described on the referred page, SIRCS goes as follows. The start bit is first to be sent, represented as a 2.4ms high pulse, followed by seven bits representing the functional code (LSB first), the ID of the device (LSB first) which is either a 5-bit or 8-bit code, and a frame space. In the case of this particular remote, a 5-bit ID code is sent (1 (base 10) for TV). The frame is then repeated at least two times. The figure below details the SIRCS waveform.

SIRCS Waveform
SIRCS Waveform

Hardware Design

The goal of the hardware is to turn a program code into a modulated signal based on the IR protocol SIRCS. The easist route I saw was to develop a device that would accept one packet from over an RS-232 channel and convert it into the format appropriate for the television.

The figure below shows the schematic diagram of the circuit that accomplishes this functionality. A MAX232 chip is used as a level shifter to convert the ±7.5V signal over the RS-232 line to a 0 to 5V logic level signal. It is fed to a microcontroller where the input code is stored in a register and then each bit is sequentially analyzed and the appropriate timing information is sent over one of the micontroller's output ports. The figure below shows the schematic of the final design.

TV Control Circuit Schematic
Circuit Schematic

After constructing a successful prototype, a final board was soldered and mounted inside a 3x2x1 inch box. Below are some photos of the final package.

Microcontroller Programming

For this project, I selected the Microchip PIC16F627A. This 18-pin part included a USART for RS-232 communications to get the 7-bit code from the computer as well as a timer for measuring the 45ms frame. You are welcome to use and adapt the TV controller PIC assembly code.

Interfacing With MythTV

Now that the circuit is built and connected to an open serial port on the computer, it's time to develop a script that can send a 7-bit control code to the device. A simple Perl script was written for this task. Feel free to adapt this to your own controller.

Next, the lircrc file is modified to map the buttons on my MythTV's remote to the functions of the Sony remote. Below is a snippet from the modified lircrc file. I have mapped the TV/Video button to the blue button on my Hauppauge PVR-150 remote. Also, be sure to restart lircd after changing your LIRC configuration.

# power buttom
prog = irexec
button = POWER
config = /home/mythtv/ power

# Increase Volume
prog = irexec
button = Vol+
repeat = 1
config = /home/mythtv/ vol_up

# Decrease Volume
prog = irexec
button = Vol-
repeat = 1
config = /home/mythtv/ vol_dn

# Mute
prog = irexec
button = MUTE
config = /home/mythtv/ mute

# Change Video Input
prog = irexec
button = BLUE
config = /home/mythtv/ tvvideo


So there you have it, I have shown how Sony televisions (or other consumer electronic devices for that matter) that include a Control-S port may be controlled from the computer or other home-brew devices. I would also like to thank my friend, Arthur Matteson, for teaching me a few things about PICs, particularly the assembly language and which part to use for this project. If you have any questions or comments about this project, feel free to contact me.