VCR interface


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)
IR_ON	MACRO	
		BCF		PORTA,IR_DATA
		ENDM

IR_OFF	MACRO	
		BSF		PORTA,IR_DATA
		ENDM

WAIT	MACRO	DELAY
		MOVLW	DELAY
		CALL	WWAIT
		ENDM

; SEND A BYTE (IN W) OVER IR

IR_BYTE	

		MOVWF	TX_BYTE
		
		; for each bit
		MOVLW	8
		MOVWF	LOOP
IRB1	
		IR_ON	
		; THE ON TIME IS THE SAME FOR 1'S AND 0'S
		WAIT	10
		IR_OFF
		
		MOVLW	13			;'zero' delay
		BTFSC	TX_BYTE,0	; test LSB of TX byte
		MOVLW	35			; 'one' delay
		
		CALL	WWAIT
		
		RRF		TX_BYTE,F	; get next bit
		
		DECFSZ	LOOP,F
		GOTO	IRB1
		
		RETURN
		
		
; ***************************

IR_TX ; transmit the byte in W in Matsui IR format

		MOVWF CD_BYTE
		MOVWF CP_BYTE
		; prepare the complement of the required code
		COMF CP_BYTE,F

		; time critical - stop interrupts
		MOVLW B'00000000'
		MOVWF INTCON

		; IR intro - sets up IR receiver's agc
		IR_ON
		WAIT 248
		WAIT 248
		WAIT 248
		WAIT 248
		IR_OFF 
		WAIT 248
		WAIT 248

		; now send the (manufacturers?) 2-byte code
		MOVLW B'10000000'
		CALL IR_BYTE
		MOVLW B'01111011'
		CALL IR_BYTE

		; now send the required code
		MOVF CD_BYTE,W
		CALL IR_BYTE

		; and its complement
		MOVF CP_BYTE,W
		CALL IR_BYTE

		; all done - just one last pulse
		IR_ON 
		WAIT 10
		IR_OFF

		; bring back interrupts
		MOVLW B'10100000'
		MOVWF INTCON

		RETURN
; ***************************