Sample code for incoming IR data processing?

Discussion in 'Programmer's Corner' started by nutcrack, Jul 26, 2006.

  1. nutcrack

    Thread Starter New Member

    Dec 25, 2005
    8
    0
    I think I can send some simple text like "partX OK" via an IR LED
    with a pic (16f84a), serial 7 bit, pulsing through the LED with Start, one and zero flags, tested, seems working.

    However, I don't have a good grasp on how to parse the (signal converted digital) data stream on receiving end (character by character), for now, I want to display the incoming data on an lcd, I have code to take care of lcd display part. Googling has not produced meaningful results, could anyone share some sample assembly code for ir data parsing?

    Many thanks.
     
  2. Papabravo

    Expert

    Feb 24, 2006
    9,905
    1,723
    You will have great difficulty constructing and adjusting an IR Receiver that will decode NRZ data that comes out of a standard UART. Most IR coomunication schemes use modulation schemes that are more immune to noise, ambient light, and device variations.

    Check out the protocols used in remotes, and IR remote turotials.
     
  3. nutcrack

    Thread Starter New Member

    Dec 25, 2005
    8
    0
    Sorry, I was not specific enough, I did not use UART. And I did check with some relevant and great tutorial, and fairly easily got the receiver to display data (control digits) from a Sony remote control, using (TV) Remote no problem, working.
    Then, I moved on to the next part, that is, constructed an IR transmitter (easy to do), and edited code from a tutorial, to send some simple text (RS232 out, pulsing at 36Khz). Once powered up, the IR LED blinks periodically (I see it as a sign of pulsing data out).
    On the receiver end, the PWM demodulator is TSOP1736.
    I'm grateful to my 'mentor' to help me to reach this stage. OK, I need more help.

    Thanks.
     
  4. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Hi,

    If you are using a UART, life is simple. You set up the data frame, and every time a whole character has come in, it generates an interrupt to let to processor know there's a fresh chatacter to bring in. Things like that are always easier in hardware.

    You're doing 7 bit ASCII. That means your receiver wants to shift in 7 bits/character. To make life easier, think about a unique start sequence to identify each line, and another to indicate end of line. That way, you know the stuff in between is the message. As a confidence measure, consider going to 8 bits, with the extra being a parity bit.
     
Loading...