IR transmitter - can't get it to work

Discussion in 'The Projects Forum' started by wannaBinventor, Jul 8, 2010.

  1. wannaBinventor

    Thread Starter Active Member

    Apr 8, 2010
    I'm working on an IR transmitter that I just cannot get going.

    I'm using a TSOP 4838 as the receiver connected to a 74 series inverting gate so the "receiving IR indicating LED" comes on when the TSOP receives a signal (active low output, so I had to invert it).

    The receiving side works fine. I can go all the way across the room with a TV remote and make my indicator LED flash all day long.

    My transmitter is another story.

    I'm using an astable 555 generate a 38khz square wave (My schematic attached shows a fixed resistor, but its actually a pot adjusted around 8K). Since the TSOP doesn't like continuous pulses, I've set another 555 up with its output connected to the "38khz wave" 555 (connected output from the "pulse control 555" to pin 2 [trigger] of the 38khz 555).

    See schematic in attachments.

    I've calculated the following info about my pulse generator 555:

    Frequency in Hertz: 496.5517
    Duty Cycle: 60.00%
    Mark Time (O/P High) 1.20582ms
    Space Time (O/P Low) 0.80388ms
    R1: 1,000,000
    R2: 2,000,000
    C1: 0.000000000580 (580pF)

    This should generate -- in terms of 38khz cycles:
    About 46 cycles of 38Khz IR LED off
    About 31 cycles of 38Khz IR LED on
    This seems to be well within the requirements of the TSOP4838.

    I don't have anything to measure frequency, so I have a feeling that the way I've cascaded the 555s I'm not actually getting a 38Khz signal pulsed on for 31 cycles. The reception indicator LED seems to agree here.

    That little Circuit Sim applet I took a shot of to attach does confirm my "pulser 555" frequency, but will not display a reading of the second 555. I'm wondering if it is actually generating a pulsed 38Khz output.

    Any help is appreciated. Thanks!
    Last edited: Jul 8, 2010
  2. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    You might want to try something like this:


    Note, I used a 556 instead of two 555's, but the principle should be the same. Connected output of the modulating section to the reset of the CW section. You do need the pull-up resistor.

  3. wannaBinventor

    Thread Starter Active Member

    Apr 8, 2010
    Thanks for the help on that. I may verywell have to give that a go. Please confirm my suspision that the left 555 on your schemaitc is generating about a 32Khz signal and that I woukd need to adjust some values for my 38Khz.

    I'd still like to figure out why my setup wasn't working.

    Looking at yours, I am having the feeling that I was doing a couple of things wrong:

    1) I'm tying the "38Khz 555's" reset to 5v, but I need to connect it, with a pullup resistor, to the "Pulse Control 555's output pin.

    2) I need to connect the threshold and trigger pins together on the "38Khz 555."

    Does this look like all that I had wrong?

    Thanks again for the help.

  4. SgtWookie


    Jul 17, 2007
    The IR receiver is going to be really picky about the frequency of the received signal.

    You're going to need a method to "tweak" the transmit frequency to get the receiver to recognize it. Although the formulas in the datasheets will get you "in the ballpark", you need the "ball" over the "home plate", otherwise the receiver will ignore you.

    Resistors and capacitors have tolerances; the latter can have tolerances up to +/-80%. You need to have a variable resistor aka pot in order to compensate for the tolerances.

    You do not have a cap on the CTRL pin. For typical circuits, you can get along without it. For extra precision, you need it.

    Using very high values of resistance makes the circuit very susceptible to noise. If you're over 100k, consider increasing capacitance to compensate. If you're under 10k total, consider decreasing capacitance. In any case, when using the datasheet schematic for an astable multivibrator, the resistor between pin 7 and Vcc should not allow more than 5mA current. That means 200 Ohms per volt of Vcc.
  5. wannaBinventor

    Thread Starter Active Member

    Apr 8, 2010
    Thanks for the reply.

    I do actually have a 10K pot in place of the 8K fixed resistor shown on my schematic. I've even tried adding a 3k3 resistor in series with the pot in case I just wasn't getting enough resistance to compensate for variances elsewhere, but to no effect.
  6. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    That project was done in about 2005, and unfortunately, I do not remember too many of the details, as I switched from using the 555's/556 to using an MCU (12F508) for the final design. The original trial version used a LM567 tone detector for the modulated IR. However, I may be able to address some of your questions from memory.

    That is correct. The left side of the schematic is the 32KHz to 38KHZ generator (I don't remember what its actual frequency was). Let's call that the carrier wave (CW). You can easily calculate from the formula in the datasheet your target frequency. Notice that I use a diode in the timing circuit to change the duty cycle. That invalidates the "simple" formula in the datasheet; although, you can still calculate the on and off times and get the overall frequency from that. Bill Marsden's blog on this Forum is a great place to see how the diode works. It basically allows one to control the on and off times independently.

    Remember you need two oscillators, one for the CW and one for the modulator that turns the CW off and on. Your simulation seems to show blips during the period the CW should be off. I chose to use the reset pin, because then you know for sure the CW is held off by the modulator.

    Don't know. You might consider using the standard design (i.e., the one without diodes), calculate your values to get the right frequencies, and see if that works. Your simulator may allow you to use diodes and get the right target frequencies too. I had a scope and a DMM with a frequency counter. If you have one on your DMM, you can play with the values to get the right frequencies.

    Again, my apologies for having such a dim memory. It is really so much easier with an MCU. In fact, this is the project that got me over the hurdle to learning a little about how to program in assembly.

  7. wannaBinventor

    Thread Starter Active Member

    Apr 8, 2010
    I'll give connecting the O/P of the modulator 555 to the reset pin of the CW 555 a shot and if that doesn't work I may go with trying to use a PIC. The book which has taught me assembly didn't really cover PWM, but I guess I could put google to work on that one.

    I was eventually planning on modulating it with a PIC anyway based on different inputs, so maybe this wouldn't be so bad.
  8. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    I used the 12F508/509, which doesn't have PWM built in. I just toggled the pin driving the IRED on and off with appropriate delay loops. I wanted short range, so I powered the IRED directly from the PIC using a 1K current limiting resistor.

  9. SgtWookie


    Jul 17, 2007
  10. Markd77

    Senior Member

    Sep 7, 2009
    If you go down the PIC route this might be a starting point. It is a remote control for my Pentax camera (with timelapse capability) but should be easy enough to cut up.
    Code ( (Unknown Language)):
    1.     list    p=10F202
    2.     radix    hex
    3.     title "pentaxIR"
    4.         #include <>
    6.     __CONFIG   _MCLRE_OFF & _CP_OFF & _WDT_OFF
    8. ;The remote control generates a series of IR pulses as shown below. The 'on'-
    9. ;pulses are modulated at 38kHz.
    10. ;              
    11. ;              |||||||||||||         |||   |||   |||   |||   |||   |||   |||
    12. ;   38kHz ---> |||||||||||||         |||   |||   |||   |||   |||   |||   |||
    13. ; modulation  _|||||||||||||_________|||___|||___|||___|||___|||___|||___|||_
    14. ;              
    15. ;duration [ms] |    13     |    3    |1| 1 |1| 1 |1| 1 |1| 1 |1| 1 |1| 1 |1|
    17. ;38khz 27% duty ~ 7 cycles on, 19 cycles off. 1ms ~ 38 pulses, 3ms ~ 115 pulses, 13ms ~ 500 pulses
    18. ;actually 38.4kHz but should be close enough    
    20. ;switch on GP3
    22.     cblock 0x08
    23.     interval
    24.     count
    25.     count2
    26.     count3
    27.     count4
    28.     countdown
    31.     endc
    33. ;    
    34. ;----------------------------------------------------------------------
    36. ;**********************************************************************
    37.     ORG     0x1FF             ; processor reset vector
    39. ; Internal RC calibration value is placed at location 0x1FF by Microchip
    40. ; as a movlw k, where the k is a literal value.
    42.     ORG     0x000             ; coding begins here
    43.     movwf   OSCCAL            ; update register with factory cal value
    45. init    ;initialise stuff here
    46.     CLRF GPIO                 ; Initialize GPIO by
    47.                             ; clearing output
    48.                             ; data latches
    49.     MOVLW B'00001000'         ; Value used to
    50.                             ; initialize data
    51.                             ; direction
    52.     TRIS GPIO             ; Set mostly outputs
    53.     movlw B'10000000'        ;weak pullups on, wake on change off
    54.     OPTION
    55.     btfss STATUS, 7
    56.     goto sleeploop            ;power on, not pin change
    58.     call fire
    60.     movlw D'100'
    61.     movwf countdown
    62. settingtest                    ;see if switch held for 2 seconds
    63.     call delay20ms
    64.     btfsc GPIO, 3
    65.     goto sleeploop            ;normal press
    66.     decfsz countdown, F
    67.     goto settingtest
    68. settingtest2                ;has been pressed for 2 seconds
    69.     btfss GPIO, 3
    70.     goto settingtest2        ;wait for release
    71.     clrf interval
    73. settingnotpressed
    74.     movlw D'100'
    75.     movwf countdown
    76. settingnotpressed2    
    77.     call delay20ms            ;debounce
    78.     btfss GPIO, 3
    79.     goto settingpressed
    80.     decfsz countdown, F
    81.     goto settingnotpressed2
    82.     goto intervalfire        ;if released for 2 seconds
    84. settingpressed                ;if pressed 8 times interval = 0 so time=256 sec
    85.     bcf STATUS, C
    86.     movf interval, F        ;if interval 0 make carry 1, ready for rotate
    87.     btfsc STATUS, Z
    88.     bsf STATUS, C
    89.     rlf interval, F            ;interval=interval X 2
    90. settingpressed2        
    91.     call delay20ms            ;debounce
    92.     btfsc GPIO, 3
    93.     goto settingnotpressed
    94.     goto settingpressed2
    96. intervalfire
    97.     movf interval, W
    98.     movwf countdown
    99. intervalfire2
    100.     movlw D'50'
    101.     movwf count4
    102. intervalfire3                ;1 second delay
    103.     call delay20ms
    104.     btfss GPIO, 3
    105.     goto init                ;back to normal mode if button pressed
    106.     decfsz count4, F
    107.     goto intervalfire3
    109.     decfsz countdown, F
    110.     goto intervalfire2
    111.     call fire
    112.     goto intervalfire
    118. sleeploop
    119.     movlw B'00000000'        ;weak pullups on, wake on change on
    120.     OPTION
    121.     movf GPIO, W
    122.     sleep
    124. fire
    125.     movlw D'13'
    126.     call pulseWms
    127.     call delay1ms
    128.     call delay1ms
    129.     call delay1ms
    130.     movlw D'7'
    132.     movwf count2
    133. pulse7
    134.     movlw 1
    135.     call pulseWms
    136.     call delay1ms
    137.     decfsz count2, F
    138.     goto pulse7
    139.     retlw 0
    142. pulseWms
    143.     movwf count
    144. pulseouter
    145.     movlw d'38'
    146.     movwf count3
    147. pulseinner
    148.     movlw b'00000100'
    149.     movwf GPIO
    150.     goto $+1
    151.     goto $+1
    152.     goto $+1
    154.     clrf GPIO
    155.     goto $+1
    157.     goto $+1
    158.     goto $+1
    159.     goto $+1
    160.     goto $+1
    161.     goto $+1
    162.     goto $+1
    163.     decfsz count3, F
    164.     goto pulseinner
    165.     decfsz count, F
    166.     goto pulseouter
    167.     retlw 0
    170. delay20ms                        ;19693 cycles
    171.             ;19688 cycles
    172.     movlw    0x61
    173.     movwf    count
    174.     movlw    0x10
    175.     movwf    count2
    176. delay20ms_0
    177.     decfsz    count, f
    178.     goto    $+2
    179.     decfsz    count2, f
    180.     goto    delay20ms_0
    182.             ;1 cycle
    183.     nop
    185.             ;4 cycles (including call)
    186.     retlw 0
    189. delay1ms:    ;
    190.     movlw 0xFF
    191.     movwf count
    192. loop1ms    
    193.     nop
    194.     decfsz count,F
    195.     goto loop1ms
    196.     retlw 0 ;delay1ms
    200.     end
  11. wannaBinventor

    Thread Starter Active Member

    Apr 8, 2010
    I appreciate the code and the references guys. I like that calculator Sgt. Wook!

    The circuit works now.

    Thanks for the help. I just had to make some modifications to my schematic based on what jpanhalt posted. Basically, I had to connect the pulse 555's output to the carrier wave 555's reset instead of the trigger pin.

    The range is quite short, only about 5 feet. I'm certain that I'm loosing some range over my carrier wave not quite being at 38Khz. I was playing around with a pot to adjust that, but I only wanted to make my wife play "remote tester lady" for so long. LOL.
    I think the main problem with range is the fact that I'm using a 47 ohm resistor with about a 3.7 output and then about a 1.4 forward voltage gives me 2.3 volts. I calculate this to be about 49 mA, when the LED says it will take 100mA. Even still, I just need to upgrade to a better IR LED because I'm seeing that a lot of them take around 1 A pulsed.
  12. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    1) Agree on increasing the IRED current to near its max.
    2) Putting the detector in a tube (black) to shield it from extraneous light may help too.

  13. Markd77

    Senior Member

    Sep 7, 2009
    Careful with the duty cycle if you are going for max current. For a lot of them the on pulse has to be 1/10th or less of the cycle time for max current. It should say in the datasheet.