024 - Sony RX (Remote Control - Receive)
Summary - Listen for / Receive Sony Infrared Messages
Syntax:
24 <BYTE2> <BYTE3> <BYTE4> (decimal format)
Where:
BYTE1: 24 (the command)
BYTE2: Speed of the LED display.
0 = display off
01= very fast
30 = slow
BYTE2: 01 = Decimal Output
BYTE2: 02 = ASCII Output
BYTE2: 03 = ASCII Output - Delimited
(Not that of this is set outside these parameters (1-3) then no output will be transmitted)
BYTE4: 0= single shot or 255=continuous
Response from IRCF360:
Decimal format: <DEVICE CODE> <BUTTON CODE>
Ascii Format: DEVICE_CODE = <DEVICE CODE> BUTTON_CODE = <BUTTON CODE> (Carrage return)
Ascii Delimited: <DEVICE CODE> ; <BUTTON CODE>; (Carrage return)
Circular Display Feedback:
For each message received the circular display will display a pattern called "swipe". See videos for demonstration.
Description:
Receive Sony (SIRC) IR Commands and output results to serial port as two-bytes in decimal, ascii or ascii delimited format. This is can be used for receiving IR signals from other IRCF360 modules or other IR devices.
The IRCF360 will listen for Sony (SIRC 12-bit) IR messages. The returned data from the IRCF360 consists of two bytes, the 'Device' byte containing the type of remote used. i.e. TV, Video etc, and the 'Command byte' containing the actual button value pressed. The order of the bytes is Command (low byte) then System (high byte).
This command can be used also for receiving infrared remote control commands that control your robot. See videos
Technical Features
The IRCF360 receives a 12-bit infrared package which is split between button code and device code. Sony also use a 15-bit version which does not work correctly with this command as 3 bits of information will be missing. See "Principle of IR remote control" for more details
Example Code:
For PICAXE
In this PICAXE example, the remote control button and device code are sent to the programmers transmit pin (SERTXD(" Button= ",#ButtonCode," Device= ",#DeviceCode, " ") which is then displayed on the PC screen in the terminal program.
This demonstrates that the remote control data could also be sent to PC and interpreted by software running on PC. It could therefore be possible to control a PC using this device.
Note that in this example the display is turned off (BYTE2 =0). This makes the reception of remote control commands very fast. As most rmote control devices usually repeat the same command based on how long a button is pressed, the IRCF360 will receive these repeated command. To slow this down turn on the display to 1 for fast or 30 for slower.
PICAXE Example
SONY_RX:
SEROUT b.2,T9600_8, (24,0,1,255)
LOOPING:
SERIN 2,T9600_8, ButtonCode,DeviceCode
SERTXD("Button= ",#ButtonCode," Device= ",#DeviceCode, CR)
GOTO LOOPING
For Basic Stamp
Basic Stamp Example
SEROUT 2, 84, [23,4,1,0]
SERIN 2, 84, TIMEOUT, [N, NE, E, SE, S, SW, W, NW]
The following code is an example of how the received results can be interpreted by the robot controller to turn the robot left, right, forward, backward or stop.
Example PICAXE code
Remote Control demo - using a remote control to turning a robot left or right based on
the button pressed. In this case button code 49 is right and button code 48 is left. The device code was ignored.
SONY_RX:
'SEROUT b.2,T9600_8, (10,0,0,0) ' 'turn on echo
SEROUT b.2,T9600_8, (24,1,0,255) ' Send Sony Command - continuous
'SERIN 2,T9600_8, b12 'Capture the echo
'if b12 <> 24 then goto LOOPING 'keep looping until a message is received
LOOPING:
SERIN 2,T9600_8, ButtonCode,DeviceCode
SERTXD("Button= ",#ButtonCode," Device= ",#DeviceCode, 13) ' Send the results to the terminal scree
'SEROUT b.2,T9600_8, (11,0,0,0)
If ButtonCode = 49 then Gosub Turn_right_sony
IF ButtonCode=48 then Gosub Turn_left_sony
ButtonCode=0 ' reset button code
GOTO LOOPING
Here is another example, but this time the LED's on the Circular diplay are illuninated according the the button that was pressed on the remote control (see the video below)
Command 24 + 40 - Sony Remote Control
SONY_RX:
SEROUT b.2,T9600_8, (24,1,1,0)
SERIN 2,T9600_8,DeviceCode, ButtonCode
SERTXD("Button= ",#ButtonCode," Device= ",#DeviceCode, CR)
IF ButtonCode = 49 then
SEROUT b.2,T9600_8, (40,2,255,255) 'Flash the east LED
SEROUT b.2,T9600_8, (11,0,0,0)
PAUSE1000
ENDIF
IF ButtonCode = 48 then
SEROUT b.2,T9600_8, (72,0,6,255) 'Flash the West LED
SEROUT b.2,T9600_8, (11,0,0,0)
PAUSE 1000
ENDIF
GOTO SONY_RX
Videos: