Can not decode properly IR remote code.


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: Can not decode properly IR remote code.

    I don't understand why are you using serin????!?!?
    IR protocol doesn't work with serin, you must create code to read it. By looking at the picture it seems to me that the protocol its NEC, so use code to decode NEC protocol. If you do a search in the forum you will find some code.
    Thanks and Regards;
    Gadelhas

  2. #2
    Join Date
    Feb 2013
    Posts
    1,156


    Did you find this post helpful? Yes | No

    Default Re: Can not decode properly IR remote code.

    Yes, I found that it is nec, and tried to take code from here:

    http://www.picbasic.co.uk/forum/showthread.php?t=15368

    and modified it to my needs:

    Code:
    Include "modedefs.bas"  ' Include serial modes
    'DEFINES FOR LCD PORTS
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 1
    DEFINE LCD_BITS 4 
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 1500
    DEFINE LCD_DATAUS 44 
    
    define osc 4
    
    ADCON1=%00000110 'CONFIGURE PORT A AS DIGITAL
    'TRISA=1 'CONFIGURE PORT A AS INPUT
    low TRISB
    LOW TRISC
    LOW TRISA
    
    
    Leader VAR WORD     ' will be up to 900 for a 9mS leader pulse
    BtnVal VAR BYTE[32] ' holds 32 pulse results
    DByte1 VAR BYTE     ' address byte
    DByte2 VAR BYTE     ' inverse of address byte
    DByte3 VAR BYTE     ' command byte
    DByte4 VAR BYTE     ' inverse of command byte
    X      VAR BYTE     ' loop count
    
    LCDOUT $FE, 1,  "test " 
     
    Main: 
      PULSIN PORTC.4,0,Leader  ' leader pulse is ~9mS low-going
      IF Leader < 850 THEN Main
     
      FOR X = 0 TO 31          ' grab 32 incoming pulses
          PULSIN PORTC.4,1,BtnVal(X) ' now measuring high-going pulse widths
      NEXT X
     
      ' now we'll decode 4 bytes from 32 pulses
      FOR X = 0 TO 7               ' sort 1st 8 pulses
          IF BtnVal[X] > 150 THEN  ' > 150 x 10uS = > 1.5mS pulse period
             DByte1.0[X]=1
          ELSE
             DByte1.0[X]=0
          ENDIF
      NEXT X
     
      FOR X = 8 TO 15              ' sort 2nd 8 pulses, etc....
          IF BtnVal[X] > 150 THEN
             DByte2.0[X-8]=1
          ELSE
             DByte2.0[X-8]=0
          ENDIF
      NEXT X
     
      FOR X = 16 TO 23
          IF BtnVal[X] > 150 THEN
             DByte3.0[X-16]=1
          ELSE
             DByte3.0[X-16]=0
          ENDIF
      NEXT X
     
      FOR X = 24 TO 31
          IF BtnVal[X] > 150 THEN
             DByte4.0[X-24]=1
          ELSE
             DByte4.0[X-24]=0
          ENDIF
      NEXT X
     
    LCDOUT $FE, 1, #dbyte1, " ", #dbyte2, "    "  
    LCDOUT $FE, $C0,#dbyte3, " ", #dbyte4, "    "  
     
      PAUSE 1000
      GOTO Main
    The problem is, it still does not works. It displays "0" when I press a key on remote. Sometimes, it will display something, like 4 or 170, but it never matches the key pressed and never repeats.

  3. #3
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: Can not decode properly IR remote code.

    I didn't look at the code, because i'm at work, but you should post your schematic too!
    Thanks and Regards;
    Gadelhas

  4. #4
    Join Date
    Feb 2013
    Posts
    1,156


    Did you find this post helpful? Yes | No

    Default Re: Can not decode properly IR remote code.

    There's nothing much to post in schematic, the receiver is hooked as it should, GND goes to GND, VDD goes to VDD, and OUT is connected to PORTC.4

  5. #5
    Join Date
    Aug 2011
    Location
    Guadalajara, México
    Posts
    28


    Did you find this post helpful? Yes | No

    Default Re: Can not decode properly IR remote code.

    I never tried NEC protocol before, but Sony SIRC has been worked flawlessly to me and it's very easy to decode with minimal resources, you should give a try:
    http://www.picbasic.co.uk/forum/cont...next-project!!

    Regards.
    My English doesn't sucks, it's just fugly...

Similar Threads

  1. remote code learning
    By Bruce in forum Code Examples
    Replies: 20
    Last Post: - 21st February 2021, 16:38
  2. Using Walter's Servo PWM encode / decode code
    By NickMu in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 2nd November 2012, 00:17
  3. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 20:14
  4. Hitachi remote code
    By aa222k in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th October 2008, 00:20
  5. IR decode problem "hitachi TV remote"
    By chai98a in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th March 2006, 16:29

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