RC5 code for infrared receiver


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default I think I got it now !!

    @ Dave Houston and @ Bruce

    Hi Guys

    I think I finally got it !!

    I decided to measure the incoming pulses with PULSIN and debug :-), next step is a scope :-)

    So for the PULSIN command
    @ 4 Mhz PULSIN returns a value with a 10uS resolution/increments.
    So for the SONY protocol header the returned PULSIN value should be around 240 not so ?

    So if testing a SONY remote I should be testing for an incoming PULSIN value of between say 190 and 290 not so ?
    Those figures are based on the debug tests I have done with ..get this..a Phillips remote.

    One question here:
    What tolerance value should I be using ? Is 20% ok or should I use 30% just to be safe ?

    So i figure the header test would be something like

    Code:
    IRpulse_length var word(13)
    IRpin var GPIO.0
    
    getheader:
    
    PULSIN IRpin,0,IRpulse_length(0)
    
    if IRpulse_length <190 then getheader
    
    if IRpulse_length >290 then getheader
    
    goto getheader
    If the IR pulse passes the test , the next step is to collect the bits and then to possibly use an AND to mask the received data to split into device and commands .. not so ?

    Another question :
    How do I test the second pulse as in the case for the RC5 protocol ?
    Should I just grab all 13 bits following the initial header and then check the second bit once I have captured them all ?
    This would probably be the best idea since the second bit determines whether or not the code is RC5-X which only uses one start pulse.


    I would really appreciate your comments here. it's not a problem if you don't/can't reply since I'm sure you have been asked this a million times on these forums. I will still continue to experiment until I have it working though and will post back results along the way as always.

    Kind regards
    Dennis
    Last edited by Dennis; - 1st March 2010 at 22:16.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dennis View Post


    @ 4 Mhz PULSIN returns a value with a 10uS resolution/increments.
    So for the SONY protocol header the returned PULSIN value should be around 240 not so ?
    Yes. About 240.

    So if testing a SONY remote I should be testing for an incoming PULSIN value of between say 190 and 290 not so ?
    I have some lighting devices here that "speak Sony" and use a 16F684 running @ 8MHz, and I have my "limits" set at 450 and 520.
    That seems to work reliably with all 3 remotes I use... RCA, Universal, and Phillips.

    One question here:
    What tolerance value should I be using ? Is 20% ok or should I use 30% just to be safe ?
    Mine are more like 10% and that works fine with all 3 remotes I use.

    So i figure the header test would be something like

    Code:
    IRpulse_length var word(13)
    IRpin var GPIO.0
    
    getheader:
    
    PULSIN IRpin,0,IRpulse_length(0)
    
    if IRpulse_length <190 then getheader
    
    if IRpulse_length >290 then getheader
    
    goto getheader
    If the IR pulse passes the test , the next step is to collect the bits and then to possibly use an AND to mask the received data to split into device and commands .. not so ?
    Yeah. I use this:
    Code:
    IRIN:     
        IR_Dev=255:IR_But=255 ' Preset the Return variables
        Pulsin IRinput,0,Header ' Measure the header length.
        If Header < 450 then Return' If the result is less than 450 toss it out
        If Header > 520 then Return' If the result is greater than 520 toss it out  
    ' Receive the 12 data bits and convert them into a packet
        For Bitcnt=0 to 11 ' Create a loop of 12
        Pulsin IRinput,0,P_Val ' Receive the IR pulses
        If P_Val >= 190 then ' If >= 190 then we've received a 1
            Packet.0[Bitcnt]=1 ' So set the appropriate bit
            Else
            Packet.0[Bitcnt]=0 '...or clear the appropriate bit
            Endif
        Next     
        IR_But=Packet & %01111111 'Extract the 7 BUTTON bits
        IR_Dev=(Packet >>7) & %00011111 'Right shift and extract the 5 DEVICE bits     
        return
    Another question :
    How do I test the second pulse as in the case for the RC5 protocol
    I haven't fooled with RC5 yet, only Sony.
    I'm hoping you'll become an expert soon.

    steve

  3. #3


    Did you find this post helpful? Yes | No

    Default Awesome :-)

    @Steve ...Seems like I am finally making some headway ..YAY

    Hey I recognize that code ... it's from 'Controlling the world from your armchair' aka article.pdf by Les Johnson :-)

    I tried it and it didn't work at the time .. I'm sure it's 'cos I had the wrong pulsin resolution and timing.

    Now if you look carefully at the previous posts you'll see mention of the RC5 protocol and here for a more detailed tech dive [HTML]http://www.sbprojects.com/knowledge/ir/rc5.htm[/HTML]

    Expert ...pffft..there are so many remote controllers out there :-) and so many different codes :-)

    Thanks for the extra info regarding PULSIN header checks by the way :-)

    Kind regards

    Dennis

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dennis View Post

    Hey I recognize that code ... it's from 'Controlling the world from your armchair' aka article.pdf by Les Johnson :-)
    Yep. Works great too.

    Now if you look carefully at the previous posts you'll see mention of the RC5 protocol and here for a more detailed tech dive [HTML]http://www.sbprojects.com/knowledge/ir/rc5.htm[/HTML]
    Thanks. I've read a bit about RC5... I just haven't used it for anything yet.

    Say, the other thing I'll mention is that if you use DT_interrupts (or probably any interrupts for that matter) you may want to turn them off just before the PULSIN command and turn 'em back on afterward. It took me an embarrassingly long amount of time to troubleshoot THAT problem...


    steve

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


    Did you find this post helpful? Yes | No

    Default

    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.
    Regards,

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

  6. #6


    Did you find this post helpful? Yes | No

    Default cool

    @Bruce - thanks for the cool tips nad the code there, I'm dying to try that as soon as I can source some 18F2431's..order placed but still waiting for them.
    Did you ever manage to get any reliable way prior to the CCP modules and the 18F2431 ?

    @Steve - thanks for the tip about interrupts I am not using any yet but weill heed the warning as soon as I do start with them :-)

    Kind regards

    Dennis

  7. #7
    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.

  8. #8
    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

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