need help in decoding RC-5 IR-remote


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2007
    Location
    Mumbai-INDIA
    Posts
    22

    Smile need help in decoding RC-5 IR-remote

    Hi All,

    I need some help in decoding RC-5 IR remote, can somebody help me in getting started with some simple example code as I am still novice. I plan to use pic16f72. I searched forum but did not find sufficient info to start.

    Any help would be much appreciated especially with sample code to start.

    Thanks in advance
    vu2iia
    www.vu2iia.blogspot.com

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

  3. #3
    Join Date
    Mar 2007
    Location
    Mumbai-INDIA
    Posts
    22


    Did you find this post helpful? Yes | No

    Wink Abt decoding RC-5

    Thank you Ioannis for you help.

    Below is the modified code from Proton to PBP. I made very minor changes and it works very well. Novice may do the modification to suit their needs. Its not my original work.

    Original code is available at http://www.picbasic.nl/indexes_uk.htm

    modified code is given below.It may contain some unwanted lines ignored.
    Code below shows DEC key values on 2x16 LCD. Modify code to suit
    PIC of your choice.
    ************************************************** ***********
    'Device pic16f72, Its very cheap
    define osc 4
    DEFINE LCD_DREG PORTB 'LCD data port
    DEFINE LCD_DBIT 4 'LCD data starting bit 0 or 4
    DEFINE LCD_RSREG PORTB 'LCD register select port
    DEFINE LCD_RSBIT 3 'LCD register select bit
    DEFINE LCD_EREG PORTB 'LCD enable port
    DEFINE LCD_EBIT 2 'LCD enable bit
    DEFINE LCD_RWREG PORTB 'READ/WRITE SELECT PORT
    DEFINE LCD_RWBIT 1 'READ/WRITE SELECT BIT
    DEFINE LCD_BITS 4 'LCD bus size 4 or 8
    DEFINE LCD_LINES 2 'Number lines on LCD
    PAUSE 500
    lcdout $fe,1,"LCD OK"
    pause 500

    ALL_DIGITAL
    ADCON1 = 7 'disable A/d work digital
    ;Normal aliases (constants)
    Glitch con 52 ;Max 255: Reduction glitches
    SYMBOL LED_Time = 500 ;mSec: Error LED's burning time
    Ok con 50 ;Max 255: Controltime of the RC5 code is received ok

    ;Port aliases
    IR_Receiver var PORTA.4 ;TSOP1736
    ByName var PORTB.0 ;When low the IR-code is given else (unconnected) the System-name and Command-name
    ; 76543210
    TRISA = %11110000

    ;BYTE
    Command VAR BYTE
    CommandOld VAR BYTE
    Systeem VAR BYTE
    SysteemOld VAR BYTE
    BD1 VAR BYTE ;Byte Dummy
    ;BIT
    ByNameOld VAR BIT ;When switching between code- and text-mode and sending the same RC5 code then should the LCD not been updated
    ToggBit VAR BIT
    Value VAR BIT
    ' ID1 VAR BIT ;bIt Dummy
    CLEAR

    GOTO Start

    ;Subroutines
    BitOphalen:
    Value = IR_Receiver ;Make value 0 or 1 dependent from received IR-code
    BD1 = 0
    WHILE IR_Receiver = Value AND BD1 < Ok;Level must change within time 'Ok'
    BD1 =bd1+1
    WEND

    IF Ok = BD1 THEN ErrorReceive ;No level-change whitin the 'Ok' time
    pauseUS 1100 ;950 - 1600
    RETURN


    ;Mainprogram
    Start:

    ByNameOld = ByName

    BD1 = 0
    WHILE IR_Receiver = 1
    WEND ;Wait until a IR-signal is received

    WHILE IR_Receiver = 0
    if BD1 < Glitch then BD1 =bd1+1 'Glitch val 52
    WEND

    IF BD1 < Glitch THEN GOTO ErrorGlitch

    CommandOld = Command ;Save old values for repair in case of a error
    SysteemOld = Systeem


    pauseUS 500 ;200 - 825; Avoid RC5 header

    GOSUB BitOphalen
    Command.6 = Value ^ 1 ;Extended bit

    GOSUB BitOphalen
    ToggBit = Value

    GOSUB BitOphalen
    Systeem.4 = Value

    GOSUB BitOphalen
    Systeem.3 = Value

    GOSUB BitOphalen
    Systeem.2 = Value

    GOSUB BitOphalen
    Systeem.1 = Value

    GOSUB BitOphalen
    Systeem.0 = Value

    GOSUB BitOphalen
    Command.5 = Value

    GOSUB BitOphalen
    Command.4 = Value

    GOSUB BitOphalen
    Command.3 = Value

    GOSUB BitOphalen
    Command.2 = Value

    GOSUB BitOphalen
    Command.1 = Value

    GOSUB BitOphalen
    Command.0 = Value

    lcdout $fe,1
    lcdout $fe,$80,"Sys:", DEC Systeem
    lcdout $fe,$c0,"Com:", DEC Command
    pause 100

    goto start


    ErrorGlitch:
    'original ckt has LED to indicate error, but I have not used.
    'Receive error (No RC5 code or glitch) ' not used
    'pause LED_Time ' not used
    GOTO Start


    ErrorReceive:
    Command = CommandOld ;Repair Command and Systeem
    Systeem = SysteemOld
    GOTO Start
    ************************************************** **************

    Thanks

    vu2iia

Similar Threads

  1. Replies: 17
    Last Post: - 12th April 2014, 02:17
  2. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  3. Plz help in completing RC-5 IR remote lamp dimmer project
    By vu2iia in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd April 2008, 08:44
  4. Decoding car alarm remote
    By George in forum Off Topic
    Replies: 1
    Last Post: - 19th June 2007, 14:36
  5. "momentary" IR decoding
    By sporker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th June 2005, 01:53

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts