NEC IR Protocol remote decoder, help me before I kill myself!


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    1


    Did you find this post helpful? Yes | No

    Default Re: NEC IR Protocol remote decoder, help me before I kill myself!

    Quote Originally Posted by Bonxy View Post
    Bruce, thank you :-)

    Your code worked perfectly at 4 mhz first go :-)

    So, I've hacked away at it all day and through trial & error and determination I have got it to work at 20mhz, It was a total pain I could not work out the math for the life of me, so I searched the forum and net, but everyone seems to have a different idea on how to work it out, in the end I resorted to trial & error but I got it to work at 20mhz.

    The repeatsub does not work correctly all the time, again I assum a timing error

    I show the results below for all to see, I've also tried to add the repeat (button held down) function with limited success, if you or anyone would care to comment on or improve the end result that would be awesom..

    '#CONFIG
    '__config _XT_OSC & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
    '#ENDCONFIG
    'Defines for EasyPic3
    DEFINE LCD_DREG PORTB ' Define LCD registers and bits
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 3
    INCLUDE "AllDigital.pbp" 'Set ALL ports to Digital i/o
    include "LCDDEFS.bas" 'easy lcd

    DEFINE OSC 20 'set osc to 20mhz

    Leader VAR WORD ' will be up to 900 for a 9mS leader pulse
    BtnVal VAR word[32] ' holds 32 pulse results 'NEEDS TO BE WORD VAR FOR 20Mhz
    DByte1 VAR BYTE ' address byte
    DByte2 VAR BYTE ' inverse of address byte
    DByte3 VAR BYTE ' command byte
    DByte4 VAR BYTE ' inverse of command byte
    i VAR BYTE ' loop count

    Main:

    PULSIN PORTC.0,0,Leader ' leader pulse is ~9mS low-going

    IF Leader < 4400 THEN goto Main 'use 850 for 4mhz, use 4400 for 20mhz

    FOR i = 0 TO 31 ' grab 32 incoming pulses
    PULSIN PORTC.0,1,BtnVal(i) ' now measuring high-going pulse widths

    if btnval(i) > 950 then goto repeatsub 'capture repeat pulse ?

    NEXT i



    ' now we'll decode 4 bytes from 32 pulses (address)
    FOR i = 0 TO 7
    IF BtnVal[i] > 350 THEN ' > use 150 for 4mhz, use 350 for 20mhz
    DByte1.0[i]=1
    ELSE
    DByte1.0[i]=0
    ENDIF
    NEXT i


    'now we'll decode 4 bytes from 32 pulses (command)
    FOR i = 16 TO 23
    IF BtnVal[i] > 350 THEN ' > use 150 for 4mhz, use 350 for 20mhz
    DByte3.0[i-16]=1
    ELSE
    DByte3.0[i-16]=0
    ENDIF
    NEXT i

    'show results on LCD, address on top line & command on bottom line
    Lcdout cmd,clss,cmd,movtoA2, "Address " , hex DByte1 'debug to LCD display
    lcdout cmd,movtoB2, "Command " , hex DByte3 'debug to LCD display

    'HSEROUT [BIN8 DByte1,13,10,BIN8 DByte2," Address",13,10,13,10]
    'HSEROUT [BIN8 DByte3,13,10,BIN8 DByte4," Command",13,10,13,10]
    PAUSE 200 'dont know why this is needed for it to work ?
    GOTO Main




    'we get to heare if button on remote is held down
    repeatsub:
    toggle porta.0 ' led to tell us that a button is held down (repeat)

    PAUSE 400 'only god knows why this is needed for it to work ?
    goto main
    return


    Thanks..
    Bruce
    Ioannas
    dhouston
    bogdan
    cncmachineguy
    jumper
    Hello friend my name es Paul, one question: what happen if I want to turn on the light with a specific key to the remote control? example, I want to turn on the light with the source button, from my samsug led tv, the codec is: E0E0807F hex, please help me.

  2. #2
    Join Date
    Nov 2006
    Location
    Murrieta, CA
    Posts
    62


    Did you find this post helpful? Yes | No

    Default Re: NEC IR Protocol remote decoder, help me before I kill myself!

    Quote Originally Posted by pull88 View Post
    Hello friend my name es Paul, one question: what happen if I want to turn on the light with a specific key to the remote control? example, I want to turn on the light with the source button, from my samsug led tv, the codec is: E0E0807F hex, please help me.
    I know this reply is 5 years too late.. lol. but just in case anyone else would like to control their lights. http://www.picbasic.co.uk/forum/showthread.php?t=15712
    There are 10 kinds of people. Those that know binary and those that do not.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,821


    Did you find this post helpful? Yes | No

    Default Re: NEC IR Protocol remote decoder, help me before I kill myself!

    By the way, your signature link is not valid anymore. Are you aware of that?

    Ioannis

Members who have read this thread : 7

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

Tags for this Thread

Posting Permissions

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