Programming built in comparator need advice.

Discussion in 'Embedded Systems and Microcontrollers' started by oookey, May 17, 2013.

  1. oookey

    Thread Starter Well-Known Member

    May 24, 2010
    Hi everybody, :)
    I’m trying to use the signal from the TV remote control to trigger the 12F615 in order to produce PWM for output, via photo diode as receiving the signal.

    Having though of using op amps to receive and amplify the signal to 5V, then feed to the MCU, to produce the O/P, this involves quite number of components, perhaps I could use the built-in comparator of the 12F615.

    I used to play with “FLOW CODE” to program my PIC projects, however it seems a difficult task for this software to program the built-in comparator mode. Hoping the experts here could guide me in C programming, to have my MCU working.

    The circuits of my project and datasheet of the MCU attached.

  2. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    You don't need the comparator.

    To receive/decode the TV remote you need a 3pin IR sensor, commonly available from all the hobby suppliers. That sensor outputs 0-5v digital directly, so you can read it with any digital input pin.

    To decode the control code you need to program the PIC to recognise that particular pattern. There are lots of websites showing the standard Sony and Philips IR codes. A google search will give you a lot of info. :)
  3. oookey

    Thread Starter Well-Known Member

    May 24, 2010
    Thanks! :)

    i need only the carrier frequency to trigger the MCU, i do not need the decode info. ;)
  4. John P

    AAC Fanatic!

    Oct 14, 2008
    Even so--detecting the carrier is quite a challenge in the presence of interfering light. If you buy the integrated receiver, all the work is done for you. They're incredibly cheap, so this isn't a place to be tempted to build your own. Just be careful to get a receiver that matches the frequency you'll be transmitting.
  5. MMcLaren

    Distinguished Member

    Feb 14, 2010
    I would also recommend using an IR receiver IC.

    I built something awhile ago using a 12F683 (assembly language) with a Sony SIRC remote (see diagram below). The program simply samples the IR receiver output periodically to decode the SIRC remote keys and it generates bit-banged gamma corrected PWM outputs.

    Regards, Mike

  6. oookey

    Thread Starter Well-Known Member

    May 24, 2010
    Thanks for the advice.
    I agreed there is very wide range of carrier frequencies, though if I use a phototransistor(datasheet attached), the circuit as attach shows, may be able to overcome the problem of choosing the correct type of IR receiver, because of the carrier frequency.

    My working assumptions:

    1. The carrier frequency ranges from 25kHz to 455kHz, then the Xc of 1uF capacitor would be 6Ω to 0.3Ω,
    2. The 100kΩ is to pull MCU port to 0V when no signal received,
    3. After a signal pulse received, a debounce of 28Usec is introduced, prior next instruction. assuming 60% duty cycle for the carrier frequency.

    The distance of the remote source is 2M max away from the receiver, will the circuit work?
  7. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    No it will not.

    About the only thing it is good for is to connect it to an oscilloscope, point the specific TV you wish to use at it and measure the carrier frequency. Then go and buy a 3 pin IR receiver that is close to that frequency.
  8. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    No (as ErnieM said).

    IR LEDs transmission power decreases at the square of the distance.

    The 3pin sensor everyone is telling you to use has an inbuilt special high gain amplifier, that allows it to detect weak IR signals if they are approx 39kHz.

    I have done experiments with direct IR LED to IR photodiode, and the best distance you can get is a few inches, and requires correctly setting up the biasing of the sensor.

    If you don't want to buy a 3-pin sensor, there is one inside every TV, VCR, settop box, (anything that has an IR remote) so you can salvage a sensor if you like.

    And of course you can get IR transmitting LEDs from inside any old remotes.