RC5 code for infrared receiver


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    I posted an example here: http://www.picbasic.co.uk/forum/showthread.php?t=12555
    that makes learning IR button codes really easy. It uses a special capture module on the
    18F2431 that captures everything. High signal period, low signal period, and spits it all out
    to a serial terminal window. You can learn every button code on your remote in just a few
    minutes.
    Yeah... funny about that. Several days after you posted that some 18F2431's showed up in my mailbox. Just a coincidence? I think not.
    Haven't tried them yet. They're still sitting in their cute little black Microchip box.

    Thanks for all the good code Bruce!

    steve
    Last edited by Byte_Butcher; - 2nd March 2010 at 01:24.

  2. #2
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Last year I bought a device that plugs into a USB port and "reads" IR remotes.
    It shows quite a bit of info... carrier frequency, a visual of the code waveform with high and low times, how many carrier cycles, etc, as well as the button and device code numbers.
    It also has a pretty fair data base that recognizes various codes and tells you what format they are.

    Here's a screen shot of the output:
    http://www.weirdstuffwemake.com/swee...es/irscope.gif


    steve

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


    Did you find this post helpful? Yes | No

    Default

    Did you ever manage to get any reliable way prior to the CCP modules and the 18F2431 ?
    Yeah - I used a USBee SX PC logic analyzer...;o) The 2431 approach is a lot faster, and gives me data I can print to text. I fiddled with one version that would even write PBP code for me to re-generate the same IR signals.

    Steve,

    Looks like a handy gadget. Should be pretty easy to write code with the data that spits-out.
    Regards,

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

  4. #4


    Did you find this post helpful? Yes | No

    Default The hard part about RC5....

    Steve - that does look like a nice gadget indeed :-)

    Bruce - sounds like you have been through a lot of work in efforts to decode the signals.

    @Anand ..that's a nice site :-)

    Unlike SONY protocol which has set pulse sizes for 1's and 0's ,
    I see the issue with decoding the RC5 protocol , it uses bi-phase encoding either a pulse on the first half of a total bit time (denoting a 0) OR the last half of a bit time (denoting a 1) so some code would be required to check the state of the pin.

    There must be some way to measure and capture this....back to the drawing boards I go :-(

    Any thoughts anyone ?

    Kind regards
    Dennis
    Last edited by Dennis; - 2nd March 2010 at 03:07.

  5. #5


    Did you find this post helpful? Yes | No

    Default still trying

    So it seems to decode the RC5 code, after detecting the initial pulse, some sort of check must be done at a regular time interval at the mid-point of each half bit-time since a full bit-time is 1778us (2x889us).
    So after the initial pulse I would have to check midway between the first bit-time, roughly 440us.
    So in terms of the pulses and checks we have the following:
    Start1--Start2--1st BIT--2nd BIT--3rd BIT---...etc
    ____|-------|---------|---------|--------|--------
    1778| 1778 | 889, 889| 889,889 | 889,889|--
    hch__hch____ch__ch___ch__ch___ch__ch

    Header
    check =hch
    ch=bit check
    After initial header check, waste some time and then start testing and collecting.

    So now to find the right code.


    Dennis
    Last edited by Dennis; - 3rd March 2010 at 01:37.

  6. #6


    Did you find this post helpful? Yes | No

    Default Still confused by PULSIN

    Could someone please explain PULSIN to me !
    First off here some code as a starter to test PULSIN
    Code:
    ' Philips RC5 IR decoder for 12F629 @ 4MHZ
    'set for samsung TV on universal rae-1000 (or similar??) remote - TV1 -code 189 most buttons work
            
            define OSC 4 '4MHz
            DEFINE OSCCAL_1K 1          ' Set OSCCAL for 1k -HELPS tuning the crystal for more accurate timing
            CMCON = 7
            'TRISIO = %76543210          ' port GPIO 0=output and 1=input
            TRISIO = %00000100          ' GPIO.2 is an input all the rest are outputs
            'OPTION_REG.7 = 0 ' Internal pull-ups = on
            
        'debug defines
        DEFINE DEBUG_MODE  0    ' Debug sending INVERTED serial data
        DEFINE DEBUG_REG GPIO   ' Debug Port = GPIO
        DEFINE DEBUG_BIT 0      ' Debug.bit = GPIO.0
        DEFINE DEBUG_BAUD 2400  ' Default baud rate = 2400
        'end of debug defines
    
    
    
    'Variables here
    IRpulse_length var word(13) 'holds pulse length 
    IRpin var GPIO.2 'IR module ..TSOP1736..check my schematic in earlier posts'
    LED var GPIO.1 'LED is connected here
    'end of variables
    
    main:
    debug "working = ",13,10  'send to hyperterminal replace this with serin or hserin if you like
    
    LOW led   'LED off 
    
    Getstartbits: the incoming header test 
        irpin =0 'set ir pin low
        irpulse_length = 0 'set irpulse_length low
    
        PuLSIN IRpin,0,IRpulse_length(0) 'start PULSIN on irpin state 0 store in irpulse_length
    
        debug "pulse length " ,dec irpulse_length ,10,13 ' send irpulse_length to hyperterminal
    
    irpulse_length = 0
     goto getstartbits: 'do it again 
    
    end
    So as per the manual :
    PULSIN Pin,State,Var
    If State is zero, the width of a low pulse is measured.
    If State is one, the width of a high pulse is measured.
    So a question here is :
    Can the state be altered as execution takes place.
    For example if I have set STATE as 0 to measure the width of a low pulse, can I change the state of PULSIN to detect a high pulse just after , so that STATE is 1 and PULSIN measures a HIGH PULSE ?



    The measured width is placed in Var.
    This statement is true I have noticed the irpulse_length value displayed in hyperterminal

    BUT.... is this only the value for the header pulse that is being displayed ?
    The reason I ask is because as per the code stub I only get one reading on each button press..is this because things are happening so fast that PULSIN has already picked-up (buffered ) all incoming pulse

    Given the following pulse :


    _____|--------|______|------|______
    low----high------low----high----low

    If both high and low pulses are the same size then the duty cyclye is 50% not so ?

    and as per the manual
    If the pulse edge never happens or the width of the pulse is too great to measure, Var is set to zero
    Is this where PULSIN_MAX comes into play ?
    so we could specify the max pulse size PULSIN should care to measure?

    It looks to me like the way to measure the RC5 signal is to use a combination of interrupts ,bit check for each pulse and a counter.

    Any help or clarity on this would be really appreciated.

    Kind regards

    Dennis
    Last edited by Dennis; - 3rd March 2010 at 22:11.

  7. #7


    Did you find this post helpful? Yes | No

    Default Wouls SHIFTIN work for this ?

    Hi all
    Still no light !

    Now I am wondering if SHIFTIN would work for catching the incoming pulses.

    Has anyone tried capturing a pulse train using SHIFTIN ?

    Any info would be appreciated.

    Kind regards

    Dennis

  8. #8
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Byte_Butcher View Post
    Last year I bought a device that plugs into a USB port and "reads" IR remotes.
    It shows quite a bit of info...

    steve
    Steve, here's something similiar one can roll on one's own; works only on 'real' serial ports though (NOT USB-to-serial), found it quite useful in a few situations.

    http://www.laser.com/dante/

    Regards,

    Anand

Similar Threads

  1. PBP code to read R/C signal from receiver
    By malc-c in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 28th October 2009, 22:51
  2. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  3. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 22:31
  4. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 9th December 2008, 00:40
  5. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26

Members who have read this thread : 0

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