SonyIR

Circuit assembled on prototype board

Ben Ryves 2007 for MaxCoderz.

A routine and test application to send and receive data using the SIRCS (Sony infrared controller) protocol.

Download the latest version.

Table of Contents

Features

Sending

Receiving

Documentation and Limitations

I haven't found any formal documentation on the protocol, so the project was built using a number of sources of information as well as my own research and testing.

Many thanks to the following:

For testing purposes I have used a Sony RM-826 and Sony DVD/PlayStation remote control. The RM-826 (12-bit) can be configured to send to different devices; the PlayStation remote controller transmits 20-bit commands. I have not got access to any 15-bit remote control units.

Hardware

Components

The hardware is easy enough to assemble. You can build either the transmitter, receiver, or both.

For the transmitter, you need the following parts:

Part Rating/Part Number
Infrared LED SFH 484 or SFH 485
Current-Limiting Resistor 330Ω

The receiver is more complex, and requires the following parts:

Part Rating/Part Number
Infrared Module HRM538BB5100 (38kHz)
Smoothing Capacitor 4.7µF
Current-Limiting Resistor 330Ω
Pull-Up Resistor 4.7KΩ

The circuit layout is as follows. Note that you omit either side of the design to suit your needs. It has been presented as a suggestion; check the datasheets for your parts and adjust the layout or ratings of components to suit.

If you have already constructed a PS/2 adapter for your calculator, you can plug the components into that instead (viewed from the PS/2 socket):

Software Protocol

Each command is made up of two parts; a button press code and a device ID.

The device ID is used to target a particular device (for example, to differentiate between sending a channel up command between a TV and a VCR).

An added complication is that command words can be different lengths. The three I know of are 12-bit, 15-bit and 20-bit.

The software routines return or take as inputs the three different parameters:

RegisterParameter
cCommand code. Only the least significant 7 bits are used.
deDevice code. For 12-bit controllers the lower five bits of E are used, for 15-bit controllers only E is used, and for 20-bit controllers the lower 5 bits of D are used along with E.
aCommand word size (measured in bits).

You must reset any bits in parameters that are unused, otherwise the timing between writes will be incorrect.

A single physical device can respond to multiple device IDs - a TV with Teletext support will respond to both TV and Teletext device IDs.

See the appendices for some sample codes.

Software

Included is a piece of software that can be used to turn your TI-83+ series calculator into a programmable remote control. It uses a simple GUI that should hopefully be pretty self-expanatory.

If you do not have any layout files installed, the software will prompt you to create one when you first start it. It cannot be used without a layout file.

At the default screen you can carry out a number of actions:

Press the softkey (F1 to F5) under each option to carry out its action.

Pressing any of the other buttons on the calculator's keypad will transmit the command you have associated with that particular key.

Entering Text

The software uses its own text input routines. Press Alpha to cycle through input modes - uppercase, lowercase, numbers and special keys. Press Del to step backwards and correct mistakes, and press Enter to confirm.

The input routines automatically correct you when you are entering text in a mode that the current field doesn't support (for example; switch between numeric and uppercase modes when entering hexadecimal values).

Editing a Layout

When the device you wish to edit is active, go into the Edit mode. You will need to press the key (on the calculator) that you wish to customise.

Any key apart from the F1-F5 keys can be edited (even the On key)! You can then edit each of the three properties of the key - command word length, device code and command code - by moving the selection arrow up and down then pressing Enter to start editing.

If the command word length is set to 0, the key is effectively disabled and all of the options disappear. You can still edit them, however.

If you have built and attached the receiver to your calculator you can speed up data entry by simply pointing your remote control at it and pressing the button you want to associate with a key. It will be assigned automatically.

Bundled Layouts

I've bundled a few layout files with this release; I'm sure you'll want to edit them to your own requirements but they can at least help to illustrate how the program works.

Television

KeyFunction
OnPower
ModeCycle Auxillary Devices
DelTeletext
0 to 9Button 0 to 9
(-)-/--
↑/↓ Up/DownVolume Up/Down
←/→ Left/Right; −/+Previous/Next Channel
ClearMute

Video Recorder

KeyFunction
OnPower
0 to 9Button 0 to 9
(-)-/--
↑ UpPlay
↓ DownPause
← LeftRewind
→ RightFast Forwards
ClearStop
−/+Previous/Next Channel
PrgmRecord

PlayStation 2

KeyFunction
0 to 9Button 0 to 9
ClearClear
AppsMenu
↑/↓/←/→↑/↓/←/→
EnterEnter
SinPlay
CosPause
TanStop
(/)Previous/Next
÷/×Scan Backwards/Forwards
−/+Slow Backwards/Forwards
DelReturn
,Subtitles
MathAngle
2ndDisplay
AlphaTitle

Routines

There are three routines; one covers receiving data and the other two cover transmitting data. All three use the same register set for ease of use.

Receiving Data

The Read routine will read and decode a single command. If it times out, or an invalid number of bits were read, it clears Z and returns.

For increased reliability, read multiple commands until two match. If you want a blocking version of the routine, poll the least significant bit of the link port status until it goes low and then call Read.

ReadReceives data from a Sony IR remote control.
Outputsz on success, nz on failure.
de = target device ID (variable bit length).
c = command.
a = length of command word (bits).
Destroysaf, bc, de, hl.
RemarksDisables interrupts.

Transmitting Data

To send a single command, use the Write routine.

WriteSend data using the Sony IR controller protocol.
Inputsde = target device ID (variable bit length).
c = command.
a = length of command word (bits).
Destroysaf, bc, de, hl.
RemarksDisables interrupts. Bits that are not to be sent should be reset (eg command should only be in the 0..127 range). Setting them can result in inaccurate timing.

You should send data at 45mS intervals; to make this easier you can use the WriteMultiple routine that handles all the mucky timing for you. The Sony remote controls I have access to all seem to send data a minimum of 3 times for each button press.

WriteMultipleSend data multiple times.
Inputsde = target device ID (variable bit length).
c = command.
a = length of command word (bits).
b = number of times to send the data.
Destroysf, b, hl.
RemarksDisables interrupts. Bits that are not to be sent should be reset (eg command should only be in the 0..127 range). Setting them can result in inaccurate timing.

Hardware Protocol

Waveform

(Exact timings may vary slightly).

The transmitter sends a series of carefully timed bursts of infrared light, modulated at 40kHz. Each command is made up of 12, 15 or 20 bits of data and one start bit.

The timing is based around multiples of 0.6mS. There is a 0.6mS delay ('silence') between each bit. The start bit is 2.4mS long, a 0 bit is 0.6mS long and a 1 bit is 1.2mS long.

The data is sent least significant bit first, and the command ID is sent before the device ID.

If you look at the image above (produced by recording the output of the TI-83 Plus) you can clearly see there are 'thin', 'fat' and one 'terminally obese' burst corresponding to the timings above.

The exact sequence looks to be S010010010000, which would make the control code %0010010 ($12) and the device ID %00001 ($01); that's the volume up button for a TV.

Each command should be sent at least three times, at intervals of 45mS. That's 45mS overall; not a 45mS delay between commands - the start bit of the second command should be transmitted 45mS after the start bit for the first was transmitted. This makes timing rather more interesting (as commands are different lengths depending on how many bits were sent) but can be easily worked around by counting set bits afterwards and working out how much to pad the command with silence so that they're always the same length.

Appendices

Appendix 1 - Device IDs

IDDevice
$01TV
$02VTR1
$03Teletext
$04Widescreen
$06MDP/LaserDisk
$07VTR2
$0BVTR3
$0CSurround Sound Processor
$10Audio/Cassette Deck and Tuner
$11CD Player
$12Pro-Logic/Equalizer
$1ADVD Player
$A4TV Digital Effects (15-bit)
$093APlayStation 2 (DVD) (20-bit)
$1B5APlayStation 2 (PS2) (20-bit)

The PlayStation 2 remote controller is an interesting one - it generates two different device IDs depending on whether you are pressing a DVD-player related button or one of the PS2-related buttons. There are four buttons on the controller that apply to both modes - the up, down, left and right buttons - and the controller sends out alternating DVD and PS2 codes for these buttons.

By truncating the PS2 DVD remote controller's device ID down to 5 bits you get $1A, which is the usual code for a DVD player.

Appendix 2 - Command IDs

I cannot vouch for most of these command IDs, so best to check against a real remote control before using them.

TV

IDFunction
$001 Button
$012 Button
$023 Button
$034 Button
$045 Button
$056 Button
$067 Button
$078 Button
$089 Button
$0910 Button/0 Button
$0BEnter
$10Channel Up
$11Channel Down
$12Volume Up
$13Volume Down
$14Mute
$15Power
$16Reset TV
$17Audio Mode: Mono/SAP/Stereo
$18Picture Up
$19Picture Down
$1AColor Up
$1BColor Down
$1EBrightness Up
$1FBrightness Down
$20Hue Up
$21Hue Down
$22Sharpness Up
$23Sharpness Down
$24Select TV Tuner
$25Cycle Auxillary/External Modes
$26Balance Left
$27Balance Right
$29Surround On/Off
$2AAux/Ant
$2FPower Off
$30Time Display
$36Sleep Timer
$3AChannel Display
$3BChannel Jump
$3FTeletext Mode
$40Select Input Video 1
$41Select Input Video 2
$42Select Input Video 3
$4ANoise Reduction On/Off
$4ECable/Broadcast
$4FNotch Filter On/Off
$58PIP Channel Up
$59PIP Channel Down
$5BPIP On
$5CFreeze Screen
$5EPIP Position
$5FPIP Swap
$60Guide
$61Video Setup
$62Audio Setup
$63Exit Setup
$6BAuto Program
$70Treble Up
$71Treble Down
$72Bass Up
$73Bass Down
$74+ Key
$75- Key
$78Add Channel
$79Delete Channel
$7DTrinitone On/Off
$7FDisplays a Red RtestS on the Screen

Teletext

IDFunction
$4CRed Button
$4DGreen Button
$4EYellow Button
$4FBlue Button

DVD

IDFunction
$001 Button
$012 Button
$023 Button
$034 Button
$045 Button
$056 Button
$067 Button
$078 Button
$089 Button
$0910 Button/0 Button
$0BEnter
$0EReturn
$0FClear
$1ATitle
$1BMenu
$1FProgram
$28Time
$2AA↔B
$2CRepeat
$30Previous
$31Next
$32Play
$33Scan «
$34Scan »
$35Shuffle
$38Stop
$39Pause
$54Display
$60Slow «
$61Slow »
$63Subtitle
$64Audio
$65Angle
$79↑ Up
$7A↓ Down
$7B← Left
$7C→ Right

PlayStation 2

IDFunction
$50Select
$51L3
$52R3
$53Start
$54↑ Up
$55→ Right
$56↓ Down
$57← Left
$58L2
$59R2
$5AL1
$5BR1
$5C△ Triangle
$5D○ Circle
$5EX Cross
$5F□ Square