Positron Compiler Documentation

RC5in

Source: Positron8 Compiler User Manual, PDF page 182

Syntax

Variable = RC5in

Overview

Receive Philips RC5 infrared data from a predetermined pin. The pin is automatically made an input.

Parameters

Variable can be a Bit, Byte, Word, Long, Dword, or Float variable, that will be loaded by RC5in. The return data from the RC5in command consists of two bytes, the System byte containing the type of remote used. i.e. TV, Video etc, and the Command byte containing the actual button value. The order of the bytes is Command (low byte) then System (high byte). If a byte variable is used to receive data from the infrared sensor then only the Command byte will be received.

Example

' Receive Philips RC5 data from an infrared sensor attached to PORTC.0
  Device = 16F1829
                                ' Select the device to compile for
  Declare Xtal = 16 ' Tell the compiler the device will be operating at 16MHz
  Declare RC5in_Pin = PORTC.0 ' Choose port.pin for infrared sensor
  Declare Hserial_Baud = 9600 ' Set the Baud rate for HRsoutLn
  Dim RC5_Word as Word
                                ' Create a Word variable to receive the data
'
' Alias the Command byte to RC5_Word low byte
'
  Dim RC5_Command as RC5_Word.Lowbyte
'
' Alias the System byte to RC5_Word high byte
'
  Dim RC5_System as RC5_Word.Highbyte
  Do
                                ' Create an infinite loop
    Repeat
      RC5_Word = RC5In
                                ' Receive a signal from the infrared sensor
     Until RC5_Command <> 255 ' Keep looking until a valid header is found
     HRsoutLn "System ",Dec RC5_System," "  ' Display the System value
     HRsoutLn "Command ",Dec RC5_Command," "  ' Display the Command value
  Loop

There is a single Declare for use with RC5in: -

Declare RC5in_Pin Port.Pin Assigns the Port and Pin that will be used to input infrared data by the RC5in command. This may be any valid port on the PICmicroâ„¢.

If the Declare is not used in the program, then the default Port and Pin is PORTB.0.

Notes

The RC5in command will return with both Command and System bytes containing 255 if a valid header was not received. The CARRY (STATUS.0) flag will also be set if an invalid header was received. This is an ideal method of determining if the signal received is of the correct type.

RC5in is oscillator independent as long as the crystal frequency is declared at the top of the program. If no Xtal Declare is used, then RC5in defaults to a 4MHz crystal frequency for its timing.