Decode RC5 ?


Closed Thread
Results 1 to 8 of 8

Thread: Decode RC5 ?

  1. #1
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161

    Default Decode RC5 ?

    Hello Guru's

    Any code available for decoding RC5 (IR) signals using PICBASIC Pro.

    Thank you.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default RC5

    Here's a section of a routine I've use to decode RC5. It's pretty simple.

    '// Philips RC5 IR decoder

    DEFINE OSC 20
    DEFINE LOADER_USED 1
    DEFINE HSER_BAUD 2400

    Y VAR WORD ' Holds 12-bit RC5 code
    Loop VAR BYTE ' Loop variable
    PIN VAR PORTB.0 ' RB.0 input pin reading data

    TRISB.0=1 ' Set RB.0 direction to input
    OPTION_REG.7 = 0 ' Internal pull-ups = on

    Home:
    IF PIN = 1 THEN Home ' Wait for low going pulse
    PAUSEUS 100 ' Short delay
    IF PIN = 1 THEN Home ' Was it noise?
    PAUSEUS 1350 ' Pause to read 2nd half of 1st bit period

    Y.0[13] = PIN ' Record 1st synch period bit value
    FOR Loop = 12 to 0 STEP - 1 ' 13 pulses MSB to LSB
    Y.0[Loop] = PIN ' Y.Bit.Loop = data bit
    PAUSEUS 1800 ' Wait 1.8mS to read next RC5 bit
    NEXT Loop ' in middle of 2nd bit period

    IF Y.LowByte = $FF THEN Home ' Was it noise?
    Y = ~Y & $003F ' Mask upper 10-bits to return 6-bit data
    ' in lower 6-bits of word result
    HSEROUT ["Key Pressed = ",DEC Y,13,10]
    Y=0 ' Clear key codes
    PAUSE 250 ' Used for testing only
    GOTO Home ' Return Home

    Here's a tutorial on the RC5 protocol that will give you a better understanding of how & why the above code works.

    http://www.xs4all.nl/~sbp/knowledge/ir/rc5.htm
    Last edited by Bruce; - 4th April 2004 at 05:06.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Thank you Bruce

    Hello Bruce,

    Thanks a lot with the help on the RC5 Code. I must say that you'll at Rentron are really doing a good job in educating people with programing. I am sorry to use this foroum to say a few words, but nevertheless I steal the opportunity.

    regards
    Charudatt

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    You're welcome. I just posted a short tutorial on creating your own infrared encoder & decoder ICs with PBP if you're interested.

    http://www.rentron.com/PicBasic/IR_Chips.htm

    The same code allows the PIC to function as encoder or decoder by selecting the mode on power-up. It compiles to only 495 words so it will fit into the 16F627 or 628.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Manchester coding for RF use

    Hello Bruce,

    Thank you for being so kind with the explanation and I am sure a lot of people would benifit on this group.

    What modification would I need to do to adapt it to RF work ?

    regards

    Charudatt

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Charudatt,

    You would have better results using a protocol similar to the RC5 example for RF since it's manchester type encoding. You don't want or need the 40kHz modulation routine like the one in the IR Chips project for RF.

    The purpose of modulating IR data at 40kHz is because this is the pass-band frequency of the IR detector module used for the project.

    Visit the RC5 tutorial link in my previous post. It's very simple to implement something similar for an RF link.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Apr 2004
    Posts
    34


    Did you find this post helpful? Yes | No

    Exclamation RC5 program

    Bruce,

    First of all thanks for the code.

    I tried out your program and I get some data in.
    However depending on the angle I keep getting other values when pressing the same button (distance about 60cm)
    I know there is a toggle bit that changes when pressing the same button twice but this should not affect the 'data' part of the RC5 that is filtered out here.
    I have to say that I run the program with a 10MHz crystal instead of 20MHz as specified in your program.
    Can this be the cause?

    Thank you.

    Best regards

  8. #8
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Small Problem

    Hello Bruce,

    Tried your program on a 16F72 MCU and it works. I get some consistant data on Keypress but it does not tally with the key I pressed. I have a very similar code in PICBASIC PLUS (PROTON) and it works OK.

    Just wanted to ask you:

    1. How do I remove the address code from the data
    2. A couple of keys don't get registered , any idea. Namely #7

    Once again thank you for your help.

    regards
    Charudatt

Similar Threads

  1. RC5 code for infrared receiver
    By Dennis in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 11th January 2017, 12:34
  2. Timer + rc5
    By naga in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th November 2009, 07:56
  3. RC5 decode on a 10F + Question
    By ultiblade in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 11th September 2008, 08:20
  4. IR decode problem "hitachi TV remote"
    By chai98a in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th March 2006, 15:29
  5. RC5 Encode / Decode
    By charudatt in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 18th October 2003, 05:14

Members who have read this thread : 2

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