Demodulating an IR LED?

Discussion in 'General Electronics Chat' started by blueroomelectronics, Aug 11, 2013.

  1. blueroomelectronics

    Thread Starter AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    I'd like to remove the 38kHz carrier from an IR blaster source, but I'd like to use a hardwired connection from the 1/8" phone plug blaster output to drive an high speed opto-coupler.

    This means I have to build a low-pass filter to remove the carrier signal. As a bonus since I'm using an 8bit PIC to process the data I'd really like to be able to use the built in comparators vs an external OpAmp (assuming I need an OpAmp).

    Thoughts, suggestions?
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
  3. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    +1

    These things simplify otherwise complicated designs and work quite well..
     
  4. blueroomelectronics

    Thread Starter AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    There's the rub, I'm not using IR. I'm running a 1/8" cable from an IR blaster port to an opto coupler's LED. But basically what I want is the demod circuit from a TSOP-31238
     
  5. tubeguy

    Well-Known Member

    Nov 3, 2012
    1,157
    197
    Is there possibly a software solution to this ?
     
  6. blueroomelectronics

    Thread Starter AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    Possibly, but chucking stuff away 38,000 times a second will take a fair amount of CPU overhead.
     
  7. tubeguy

    Well-Known Member

    Nov 3, 2012
    1,157
    197
    Yes, good point.

    Just curious, how many instructions per second can it run?
     
  8. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    This does it. Don't know if the package is workable for you, though.
    An alternate way would be to just shine a discrete IR LED onto the above-mentioned receiver - a roll your own opto isolator.

    If nothing else, take a look at the datasheet's block diagram as a guide.

    EDIT: If this doesn't float your boat, you could maybe get by with an RC that charged fast (within 1 cycle at 38khz - maybe through a diode) and discharged slow (through a resistor across the diode). Set the discharge RC to be a few cycles at 38KHz and detect it with a Schmidt input gate or comparator with hysteresis. When IR hits the detector the cap will charge immediately and flip the detector. When the IR light is off for 1/2 cycle, the cap will begin to discharge but slower due to the resistor. As long as the RC is longer than 1/2 cycle the next pulse of 38khz IR will charge the cap again before it discharges enough to flip the detector back. The IR bursts are pulsed so when the IR turns off completely, the cap will discharge and flip the detector back. Crude but probably will work.
    Have fun!
     
    Last edited: Aug 11, 2013
  9. LDC3

    Active Member

    Apr 27, 2013
    920
    160
    Actually, you would need to sample at more than twice that rate (>77kHz), or else you would get aliasing.
     
  10. blueroomelectronics

    Thread Starter AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    Nice part, too bad DIP packaging is vanishing fast. I need the output pulses to be decode-able so I only want to remove the 38kHz with as little effect on the data-stream as possible.
     
  11. bance

    Member

    Aug 11, 2012
    315
    34
    Not sure if this is the sort of thing you're looking for, but I've been thinking about a project in the same vein using a microcontroller.....

    Link

    HTH Steve.
     
  12. tubeguy

    Well-Known Member

    Nov 3, 2012
    1,157
    197
    How about using the simple RC filter as suggested by JohnInTx, driven by a push-pull
    opto-isolator. A ballpark calc comes out as 1k and ~ 0.47uf.
    The push-pull drive would make for a more equal charge-discharge cycle.
     
    Last edited: Aug 11, 2013
  13. WBahn

    Moderator

    Mar 31, 2012
    17,751
    4,797
    I didn't see it mentioned elsewhere, so I'll point it out here. You do NOT want to low-pass filter it because the whole point of the 38kHz is to make it distinquishable from the low frequency background IR. You want to band-pass filter it and then demodulate it. You can do this in hardware or, as long as you use an antialiasing filter and sample fast enough, you can do this in software, or you can do some combination of the two. Dedicating an 8-pin PIC to a task like this is a very viable and reasonable approach. One question you are going to have to deal with, though, is what constitutes a 0 and a 1, i.e., where do you set your threshold? If you are looking at a signal coming out of a port and not an actual IR signal, then this might be pretty easy.
     
  14. tubeguy

    Well-Known Member

    Nov 3, 2012
    1,157
    197
    I'm thinking that if he is taking the signal from an IR blaster, the signal that has been received is already a valid IR command. :confused:
     
  15. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,059
    3,820
    A Sallen Key low pass filter works well. As said above, the ir blaster already has a valid reflection.
     
    Last edited: Aug 12, 2013
  16. blueroomelectronics

    Thread Starter AAC Fanatic!

    Jul 22, 2007
    1,758
    98
  17. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    If you have reasons not to do it in software (which would be the easiest and best way!) you can do it with a digital monostable.

    For each HI input pulse you generate a HI output period of 1/38kHz (or a bit less, depending on original pulse width).

    The output would be digital, and practically identical to the code modulation (ie have no 38kHz modulation present).

    ----------
    Now if you want to do it in software it is incredibly easy. At the place where your code checks if the input is HI, instead of checking for HI in one instant, check for "HI" over a period of 1/38kHz. If the signal is HI at any time during that short test period then the I.R. LED is "on".
     
  18. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,059
    3,820
    Or, another software strategy would be to look for 5 zero-crossings in a 1/7600 second period (132 uSec) to insure it is "on". That way, low frequency interference (noise) is filtered out.
     
  19. Shagas

    Active Member

    May 13, 2013
    802
    74
    This might be a stupid suggestion ,
    but since you are trying to take the carrier away from your output , why don't you wire your output to an IR LED and stick a TSOP-31238 right near the LED and you've got a demodulated output on the TSOP-31238 . No micros , no fuss
    You can bundle and glue them together and close it off so no exterior light comes in so you will have a small 'demodulation box'. Kind of like an optocoupler .


    EDIT:
    You can get these flat IR LEDS
    http://www.gme.cz/l-nm-13c1-p520-065
    which will make the demodulation box even smaller and they emmit at 940nm which is almost optimal for the TSOP-31238
     
  20. LDC3

    Active Member

    Apr 27, 2013
    920
    160
    JohnInTX suggested a similar chip (without the photodiode) in post #8.
     
Loading...