This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Decoding IR signal

I am developing an universal remote which can be controlled via Bluetooth. For that I need to decode an IR signal.

I am using TSOP decoder.

The steps I think, I should do is,

  1. Use a PPI channel to listen for an HiToLo transition in the TSOP output GPIO pin and whenever that event occur, make it start a timer with 50us time period.

  2. At every 50us, sample the TSOP input and store it in an array. (Please tell the best method to store the CC values in an array).

  3. I don't know how to detect that the IR transmission has been ended, I am thinking to stop decoding once I get a zero(HIGH TSOP output) for 10ms.

  4. Once the decoding has been completed, calculate the time of MARKS and SPACES from the previous array and store it for later transmission.

Another method I could think of, is to start a timer whenever HiToLo transition occur at 'TSOP output pin' and store the edge transition point's time to an array. But the problem here is, how to know that IR reception has been ended? use another timer as timeout timer?

What is the best approach? please help.

  • Hello Insaf

    I am no expert in handling IR decoders but this is what I've found.

    Timings would depend on the protocol used, but overall your plan seems reasonable.

    When storing in an array you could use a global array of set size, and a static counter variable in the timer handler. This variable would be used to select the location in the array where you store your data. At the end of every timer handler execution, you could increase the counter variable by 1.

    One thing to watch out for is counter variable overflow, causing it to revert to 0, as this would start overwriting data in the array. You would have to store the data in a more suitable location before that happens, if you need to.

    Detecting stop would again depend on the protocol used, if the protocol has a specific stop indication that can be used, otherwise I think using a timer to detect timeout would be a good place to start.

    EDIT:

    I recommend reading through the answer to this post

    devzone.nordicsemi.com/.../

    There are several handy tips there.

    Best regards

    Jørn Frøysa

Related