Decoding an incoming infrared signal: need advice


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Maybe you can find some tips with the following
    http://rentron.com/PicBasic/IR_Chips.htm
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    From the bit timing you indicate, I would guess this is a Sony IR transmitter? PULSIN should
    be all you need to decode this type. It's one of the easiest around to encode & decode.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile Decoding routine for IR encoded signal

    No guys,

    I can't change my hardware.

    BRUCE:
    "From the bit timing you indicate, I would guess this is a Sony IR transmitter? PULSIN should
    be all you need to decode this type. It's one of the easiest around to encode & decode."

    It is a VISHAY TSOP4840 receiver (see mouser for the datasheet) and the emiter is a VISHAY TSAL6100 led. I'm using pic's PWM output to encode and I need to decode on the other side but do it quickly and acurately. I'm not using pulsin, I'm polling the input pin, what's wrong with that?

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Nothing's wrong with polling, if it works for you. I just prefer PULSIN since it's more
    than accurate enough, and a lot easier.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by Bruce View Post
    Nothing's wrong with polling, if it works for you. I just prefer PULSIN since it's more
    than accurate enough, and a lot easier.
    I agree.

    Thank you very much.

  6. #6
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile

    I have a strange behavior.

    The signal I am supposed to get is:

    Assuming the normal state is low, I drive the input pin low with an IR receiver-demodulator.

    2400us low (=header), then for each of 16 bits I have a bit prefix which is a 600us pause then if the bit is = 1 there will be a 1200us low or if bit = 0, there will be 600us low.

    The incoming IR signal triggers an int on RA4 and then I start pulsin-ing to get the data.

    The sequence I get is something like:
    127,261,136,251,140,137,137,136,136,247,261,136,24 7,0,0,0
    0,1,0,1,0,0,0,0,0,1,1,0,1,?,?,?

    There seems to be an offset somewhere. I don't seem to get the first bit.
    Maybe it takes too much time to get to the routine that checks the pulse durations???

    The data structure I am supposed to get is:
    0,0,1,0,1,0,0,0,0,0,1,1,0,1,?,?


    Here is my code, in the case someone has an idea:

    Code:
    '-------------------------------------------------------------------------------
    '----- HEADER PULSE ------------------------------------------------------------
    '-------------------------------------------------------------------------------
    
    'based on pulsin routines from: http://rentron.com/PicBasic/IR_Chips.htm
    
    PULSIN PORTA.4,0,pulse_in        '// Read-in start pulse - in a word var!!
    IF (pulse_in < 480) OR (pulse_in = 0) THEN '// Less than header, then keep looking
       'GOTO bypass
    ENDIF
    
    
    '-------------------------------------------------------------------------------
    '----- get 2 databytes ---------------------------------------------------------
    '-------------------------------------------------------------------------------
    
    'Maybe it is too late to get the header because pulsin may reacto to a high to low transition
    'while we are ALREADY in the low state, so the header will be bypassed ????
    
    FOR i = 0 to 15                     'get a sequence of incoming 16 bits (WITHOUT their prefixes)
        PULSIN PORTA.4,0,ir_pulse[i]    '// Read 16 low-going pulses on RA.4
    NEXT i                              '// Loop 16 times
    
    '    LCDOUT $fe,1,"hdr:",#pulse_in
    ' PAUSE 2000
    
    'databyte = $FF                    '// Start with all 1's and find each 0
    
    'we scan the second byte we stored from MSB to LSB
    'FOR i = 8 TO 15                     '// Get 8 "data" bits
    FOR i = 0 TO 15                     '// Get 8 "data" bits
        LCDOUT $fe,1,#i,":",#ir_pulse[i]
        PAUSE 2000
        IF (ir_pulse[i] < 240) THEN       '240*5us resolution at 8MHz = 1200 us
            databyte.0(15-i) = 0               'clear the bit
        ELSE 
            databyte.0(15-i) = 1
        ENDIF
    NEXT i

  7. #7
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile Solved

    I solved the problem.
    The header triggers the int and cannot be detected by pulsin that detects an edge.
    When int is triggered, I just check with a loop and 15us increments the duration of the triggering signal (the 2400us signal) then I use pulsin to get the bits and their length (thus their state).

    Cool.

Similar Threads

  1. Recording incoming logic signal duration, both edges - how to?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 6th January 2010, 08:56
  2. signal decoding
    By Steve S. in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 14th September 2008, 21:58
  3. PIC16F684 + LCD to use the 256bytes of EEPROM - HELP
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th March 2008, 15:19
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 21:36
  5. "momentary" IR decoding
    By sporker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th June 2005, 02:53

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