Positron Compiler Documentation

SonyIn

Positron8 · Revision 4.0.6.5 · PDF page 192

Variable = SonyIn

Receive Sony SIRC (Sony Infrared Remote Control) data from a predetermined pin. The pin is automatically made an input.

Variable - a Bit, Byte, Word, Long, Dword, or Float variable, that will be loaded by SonyIn. The return data from the SonyIn 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.

' Receive Sony SIRC data from an infrared sensor attached to PORTC.0
  Device = 16F1829
  Declare SonyIn_Pin = PORTC.0 ' Choose port.pin for infrared sensor

  Dim SonyIn_Word as Word    ' Create a Word variable to receive the SIRC data
'
' Alias the Command byte to SonyIn_Word low byte
'
  Dim SonyCommand as SonyIn_Word.Lowbyte
'
' Alias the System byte to SonyIn_Word high byte
'
  Dim SonySystem as SonyIn_Word.Highbyte

  Cls                           ' Clear the LCD
  While                         ' Create an infinite loop
     Repeat
       SonyIn_Word = SonyIn      ' Receive a signal from the infrared sensor
     Until SonyCommand <> 255   ' Keep looking until a valid header found
     Print at 1,1,"System ",Dec SonySystem," "    ' Display the System value
     Print at 2,1,"Command ",Dec SonyCommand," "  ' Display the Command value
  Wend

There is a single Declare for use with SonyIn: -

Declare SonyIn_Pin Port.Pin Assigns the Port and Pin that will be used to input infrared data by the SonyIn command. This may be any valid port on the device.

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

The SonyIn 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.

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

View original PDF page 192Open page in PDFOriginal PDF page 192