IR Counter


Closed Thread
Results 1 to 13 of 13

Thread: IR Counter

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default

    Hello Partime,

    I made a self-learning IR remote (with lots of help from people in this forum).

    Maybe you can help some helpfull stuff in the code (especially LEARN and SEND routines).

    Have a look here http://home.citycable.ch/flotulopex/...I_Frames_e.htm
    Roger

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    Hello Partime,

    I made a self-learning IR remote (with lots of help from people in this forum).

    Maybe you can help some helpfull stuff in the code (especially LEARN and SEND routines).

    Have a look here http://home.citycable.ch/flotulopex/...I_Frames_e.htm
    Roger, Nice ! I like your website ! Interested in that self learning remote too.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    May 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    Thank you picster and Roger for the information you presented.

    I finally captured the signal from my remote as dhouston suggested. I couldn't get Loop Recorder to capture the signal, but I did get it with a different program (http://www.passmark.com/products/soundcheck.htm). I attached a copy of the signal I captured. It is from a Hitachi CLU-5722TSI remote's channel up button. The bottom one is the full signal. The top ones are of the signal divided into two segments.

    The signal seems to follow this protocol that I found for Hitachi.
    Code:
    Code length:            32 bits
    Carrier:                39.2kHz
    
    The code is only transmitted once, and after that a stop code is transmitted.
    
    
    
    	     +--------------------------------+                   
    Header:      |                                |                  
    	     +                                +----------------+..
    			    16T                       8T
    			   8.8ms                     4.4ms
    
    	     +--+      
    1 is coded:  |  |      
    	   ..+  +------+..
    	      T   3T
    
    	     +--+  
    0 is coded:  |  |  
    	   ..+  +--+..
    	      T  T 
    			 +--+
    			 |  |
    After the last bit a ( ..+  +  ) is transmitted to terminate the last bit.
    			  T
    
    	      +--------------------------------+        +--+
    Stop code:    |                                |        |  |
    	      +                                +--------+  +
    			      16T                  4T     T
    			     8.8ms                2.2ms
    
    T = 550us
    What should the next step be? Should I try to write some code using PULSIN to read the incoming IR signal?
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    That's the NEC protocol. It's one of the oldest and is used by more manufacturers than any other. It's very reliable as it has error detection built in (although some implementations do not use that). I have shown how to send/receive it (as RF) in this thread http://www.picbasic.co.uk/forum/showthread.php?t=6261. You just have to account for the fact that the IR receiver is active low while the RF receiver is active high. There is a link within that post to a NEC datasheet that explains it completely. I've decoded the third image and attached it. Hitachi is using error detection - the first two bytes sum to FF as do the third and fourth bytes.
    Attached Images Attached Images  
    Last edited by dhouston; - 1st June 2009 at 11:58. Reason: Added PNG of decoded NEC code

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


    Did you find this post helpful? Yes | No

    Default

    I just looked at your diagram. That's not a Stop Code - it's a Repeat Code. That reduces battery drain compared to repeating the full code.

  6. #6
    Join Date
    May 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    Thanks again for your help Dave. I pretty much used your RF receiver code and modified it for use with the IR signal. Here is the code I used on an 16F84A with a 4 MHz crystal. I used it to test if the channel up button was pressed on the remote.

    Code:
    define PULSIN_MAX 968
    
    IRPIN           var     PORTB.0
    LED             var     PORTB.1
    LED2            var     PORTB.2
    RF              var     byte[4]
    Header          var     word
    PULSE_LENGTH    var     byte
    i               var     byte
    
    INIT:   RF[0]=0
            RF[1]=0
            RF[2]=0
            RF[3]=0
            i=0
            Pulsin IRPIN, 0, Header
            if (Header < 792) then INIT
            while irpin = 0:wend
            repeat
                pulsin IRPIN, 1, PULSE_LENGTH
                if (PULSE_LENGTH < 40) or (PULSE_LENGTH > 175) then INIT
                if (PULSE_LENGTH > 90) then 
                    RF.0(i) = 1
                else
                    rf.0(i) = 0
                endif
                i=i+1
            until (i>31)
            if (RF[3]=230) then 
            high LED
            pause 500
            low LED
            else
            high LED2
            pause 500
            low LED2
            endif
            goto INIT
    end
    I get LED to go high when I press the channel up button.

    It took me awhile to figure out how the data was arranged in the array. I started out using RF[0]=10 to light LED, but kept getting LED2 to light up. So, I thought there was something screwed up with the values pulsin was generating. Finally, I read through the FAQ on arrays and figured out my problem. I used RF[0]=80 and got LED to light up. However, LED would light up with any button I pushed since all the buttons used the same starting code. So, I ended up using RF[3] to test if channel up was pressed.

    Is testing RF[3] going to be the best way to determine which button is pushed? I plan to use channel up/channel down for one team and volume up/volume down for the other team.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by partime View Post
    Is testing RF[3] going to be the best way to determine which button is pushed? I plan to use channel up/channel down for one team and volume up/volume down for the other team.
    The way most use this protocol, RF[0] indicates a device (e.g. TV, CD player) and RF[2] indicates a button (e.g. number, Vol+). RF[1] is the bitwise complement of RF[0] and RF[3] is the bitwise complement of RF[2]. So, you are probably safe using either RF[2] or RF[3].

    I would suggest a change...
    Code:
            while irpin = 1:wend
    That merely waits until the initial space part of the header passes. With RF I found that was necessary.

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Replies: 17
    Last Post: - 12th April 2014, 02:17
  3. 20 Digit Virtual LED Counter
    By T.Jackson in forum Code Examples
    Replies: 9
    Last Post: - 19th November 2007, 05:02
  4. PIC10F200 Automated IR Light Switch
    By Bruce in forum Code Examples
    Replies: 7
    Last Post: - 3rd May 2007, 11:40
  5. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27

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