IR decode problem "hitachi TV remote"


Closed Thread
Results 1 to 4 of 4

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    I'm not sure what you are asking but here's a code snippet that captures the 4 bytes represented by the Hitachi (same as NEC) code.
    Code:
    IR	VAR	byte[4]
    pulses  VAR     byte[33]
    BitMask VAR     byte
    i       VAR     byte            'loop index
    b       VAR     byte            'byte index
    LeadIn  VAR     word            'start pulse
    
    
    loop:   PulsIn GPIO.1, 0, LeadIn
            If LeadIn < 855 Then loop
       	If LeadIn > 1045 Then loop
       	For i = 0 TO 32
         	  PulsIn GPIO.1, 1, pulses[i]
       	Next
            For i = 1 To 32
              If (pulses[i] < 40) Or (pulses[i] > 200) Then 
                Goto loop
              EndIf
              b = i >> 3                      	'0,1,2,3
              If pulses[i] > 99 Then  
                IR[b] = IR[b] | BitMask       	'set bit 
              EndIf 
              BitMask = BitMask << 1        	'$01,$02,$04,$08,$10,$20,$40,$80
              If BitMask = 0 Then BitMask = $01 
            Next
    At this point IR[0:3] contain the data.

  2. #2
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Hi dhouston thank for your advise.
    After we try on your code that show improvement of pulse capture ability but still not canisistance.

    Question. Refer code above.
    Why my code show low speed than your code?
    For my code show 4-5 value of pulse capture but your code can capture all bit.

    Do you have tips for make basic source code or not...

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


    Did you find this post helpful? Yes | No

    Default

    I wrote that from memory and made one mistake. The first capture in the loop is the space following the start pulse. The bits of the code are in pulses[1:32].

    The second loop should be changed to:
    Code:
            For i = 0 To 31
              If (pulses[i+1] < 40) Or (pulses[i+1] > 200) Then 
                Goto loop
              EndIf
              b = i >> 3                      	'0,1,2,3
              If pulses[i+1] > 99 Then  
                IR[b] = IR[b] | BitMask       	'set bit 
              EndIf 
              BitMask = BitMask << 1        	'$01,$02,$04,$08,$10,$20,$40,$80
              If BitMask = 0 Then BitMask = $01 
            Next
    I've used that basic algorithm for several years to capture X-10 RF codes which also use the NEC protocol. You can find a description of the protocol at http://www.cpcares.com/pdf/UPD6121G-001.PDF.

    If you're having a problem with consistency, it is most likely hardware related.

    With IR, you should also define a maximum value for PulsIn. That's not always needed with RF where there are constant noise pulses in the absence of a signal.

Similar Threads

  1. Ir problem sending data
    By Mus.me in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th December 2009, 06:27
  2. Plz help in completing RC-5 IR remote lamp dimmer project
    By vu2iia in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd April 2008, 09:44
  3. PIC10F200 Automated IR Light Switch
    By Bruce in forum Code Examples
    Replies: 7
    Last Post: - 3rd May 2007, 12:40
  4. How to decode IR Hitachi remate (TV) pls help
    By chai98a in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th March 2006, 12:55
  5. Problem with comparing IR signal to Binary
    By zazery in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd April 2004, 04:38

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