VCR Remote Control via SMS
Imagine it, it’s 3:15 on a weekday afternoon and you’ve just realised you’ve forgotten to set the video to tape ‘Pet Rescue’. Usually you would be condemned to an afternoon of misery and disappointment, knowing you had no heartwarming cute animal stories to come home to. But not any more. Below I describe a simple interface between a T28 mobile phone (ME) and Matsui VX770 VCR to allow remote recording of programmes.
The heart of the interface, the only active component, is a PIC16x84 microcontroller.
It has 1024 bytes of program/data memory, 36 bytes of static RAM and 64 bytes of non-volatile RAM. In this application it runs at 6 MHz, giving an instruction cycle of 0.67us (1.5 MIPS), plenty to handle the low data rates of the two interfaces. Read all about the awsome power of the 16×84 here.
Two interfaces are required, one to the ME to send and receive SMS messages and one to the VCR to control channel selection and recording. These are described below.
This is a simple interface as we can exploit the existing infra-red (IR) remote control interface which will provide all the necessary functions via a single wire link. The VCR’s IR sensor output was disconnected and replaced with a link to one of the pins of the PIC.
Then the required IR codes were captured by connecting a photosensor to the microphone input of a PC soundcard and recording the appropriate transmissions from the remote control.
An example of the captured output is shown below. You can hear the output by downloading matsui_ir_code-stop.wav.
The high/low transitions are clearly visible and easily interpreted. There is an initial long high level followed by a low. This is to allow the IR receiver’s automatic gain control to adjust to the signal level. There then follows 32 bits of data forming 4 bytes. A binary ‘0’ is coded as a high->low pulse of equal mark-space ratio while a ‘1’ is coded with a mark-space ratio of about 3.5. The waveform above is the ‘STOP’ command and represents the bitstream:
00000001 11011110 11101000 00010111
i.e. the bytes:
10000000 01111011 00010111 11101000
0x80 0x7B 0x17 0xE8
Studying other codes showed that the first two bytes, 0x80 and 0x7B, are constant and are probably manufacturer/model specific. The next byte is the command code and the final byte is its complement, probably for error checking.
The timing of the stream was easily measured from the captured waveform and code to emulate the stream developed. In addition to the control line, a power sense line was connected to the VCR’s power LED so the PIC knows if it has to turn the VCR on before recording can commence. The bitstreams of the other functions are given in matsui_codes.txt.
; IR control codes
; (6MHz CLOCK = 0.6us instruction cycle)
IR_CODE_PWR EQU B'00010011'
IR_CODE_STOP EQU B'00010111'
IR_CODE_REC EQU B'00010101'
; the channel codes are simply
; the desired channel number (0-9)
; define some macros for controlling the IR line
; handy because some systems use inverted levels (as in this case)
WAIT MACRO DELAY
; SEND A BYTE (IN W) OVER IR
; for each bit
; THE ON TIME IS THE SAME FOR 1'S AND 0'S
MOVLW 13 ;'zero' delay
BTFSC TX_BYTE,0 ; test LSB of TX byte
MOVLW 35 ; 'one' delay
RRF TX_BYTE,F ; get next bit
IR_TX ; transmit the byte in W in Matsui IR format
; prepare the complement of the required code
; time critical - stop interrupts
; IR intro - sets up IR receiver's agc
; now send the (manufacturers?) 2-byte code
; now send the required code
; and its complement
; all done - just one last pulse
; bring back interrupts
A standard data connector was used to connect the PIC to the ME.
The link is 9600 bps, 8 data bits, 1 stop bit, no parity. This is implemented in the PIC by simple toggling of the data lines in a similar way to the IR emulator. An example of the byte 0x30 (00110000) which represents the character ‘0’ is given below.
The use of a TTL-RS232 level converter is not required as both the PIC and the ME use TTL levels. The Ericsson T28 supports most of the AT command set as described in GSM specification 07.05 (freely available from
www.etsi.org) which allows the reception and transmission of SMS messages from external equipment (TE). This page explains the message formats very nicely.
A typical exchange between ME and TE is given below. The ‘<‘ and ‘>’ characters show direction of data (> = from TE to ME, < = ME to TE), # denotes a comment.
# AT commands from ETSI TS 100 585 V7.0.1 (1999-07)
# GSM 07.05 version 7.0.1
# This session with an Ericsson T28 World
# Software version 010314 0130 prgCXC125206
>AT # ping the ME
>AT+CNMI=3,1,2,0 # setup message format/incoming SMS notification
>AT+CPMS="ME","ME","ME" # store all messages on ME
<+CPMS: 10,15,10,15,10,15 # messages/max messages in each location specified above
<+CMTI: "ME",11 # message stored on ME at index 11
>AT+CMGR=11 # request read from index 11
#Delete message from ME:
>AT+CMGD=11 # request delete from index 11
The format of the received SMS message string is as follows:
SMSC address Originating number TP-PID/TP-DCS Date Time Message length 7-bit encoded message 'REC4'
07914 48720003023 040C91 447730816315 0000 206052 11159540 04 D2E29006
You can see that it is a simple matter to check the originating number corresponds to your phone so no one else can seize control of your VCR! In my implementation it also provides a convienient point to synchronise to when looking for the start of the message. The parser on the PIC is quite unintelligent so any deviation from the format described above will result in failure.
Code was developed in the PIC to configure the ME and listen for incoming messages. Two SMS commands were implemented, record and stop. The command formats are as follows:
1 RECn - start recording on channel 'n'
1 STOP - stop recording
In addition, the PIC echoes the message back to the sender to confirm reception using the send message (+CMGS) command. The ME uses a Vodafone Pay As You Talk SIM which has the advantage of no line rental. Even if it runs out of calling credit it can still receive messages okay, but will no longer be able to acknowledge received commands. If you have an old mobile phone lying around then this system will just cost you the price of a PIC (about £2.50). Once these interfaces are implemented, some simple logic holds it all together to control channel selection and recording functions. The PIC ASM code can be downloaded here.