PIC Beginner - Infrared Receiver and IR Protocol


Results 1 to 18 of 18

Threaded View

  1. #4
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    From your schematic it appears you are using an IR receiver. Which one?

    IR receivers usually are active low while the code I supplied for the NEC protocol was for RF where the receiver is active high. Also, my code was meant to work with the RF transmitter code that accompanied it which used slightly different timing than the NEC IR protocol.

    The EDN article is wrong about details of the NEC IR protocol. It is explained in this NEC datasheet.You will need to modify my RF code in order to receive/decode IR codes.
    Code:
    '12F629
    
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    
    DEFINE PULSIN_MAX 1140				'>1140 RETURNS 0
    DEFINE DEBUG_REG GPIO
    DEFINE DEBUG_BIT 2				'GPIO.2
    DEFINE DEBUG_MODE 1 				'Inverted
    DEFINE DEBUG_BAUD 9600
    DEFINE OSCCAL_1K 1
    
    IR      VAR     byte[4]
    pulse   VAR     byte
    i       VAR     byte	         	
    stx     VAR     word            	'start of transmission
    
            CMCON = 7                   'comparators off
            Debug "IR NEC PROTOCOL"
    init:   IR[0]=0:IR[1]=0:IR[2]=0:IR[3]=0:i=0
            PulsIn GPIO.1, 0, stx	
            If (stx<760) Then init  		
            'debug #stx                 
            While GPIO.1=1:Wend			'wait space
            Repeat
              PulsIn GPIO.1, 1, pulse
              If (pulse>100) Then
                IR.0(i)=1				'set bit
              EndIf
              i=i+1 
            Until (i>31)
            For i = 0 To 3
              Debug IHEX2(IR[i] REV 8)
            Next
            GoTo init
    
            End
    I have not tested the above code (I don't have time to build a circuit with an IR receiver.) and you will need to convert it for your PIC and the pins you are using.

    Note also that my code does not deal with the NEC shortcut repeat code.
    Last edited by dhouston; - 30th August 2009 at 11:55.

Similar Threads

  1. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  2. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  3. Infrared Receiver
    By emavil in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th December 2006, 01:03
  4. how to get pic to pic communication
    By kinsiro in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th August 2005, 17:12
  5. Can this IR Xmitter/Rcvr be improved?
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th August 2005, 11:27

Members who have read this thread : 1

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