IR transmitter - can't get it to work

Thread Starter

wannaBinventor

Joined Apr 8, 2010
180
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!
 

Attachments

Last edited:

jpanhalt

Joined Jan 18, 2008
11,087
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.

John
 

Thread Starter

wannaBinventor

Joined Apr 8, 2010
180
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.

-WannaB
 

SgtWookie

Joined Jul 17, 2007
22,230
WannaB,
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.
 

Thread Starter

wannaBinventor

Joined Apr 8, 2010
180
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.
 

jpanhalt

Joined Jan 18, 2008
11,087
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.

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.
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.

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."
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.

Does this look like all that I had wrong?
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.

John
 

Thread Starter

wannaBinventor

Joined Apr 8, 2010
180
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.
 

jpanhalt

Joined Jan 18, 2008
11,087
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 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.

John
 

SgtWookie

Joined Jul 17, 2007
22,230

Markd77

Joined Sep 7, 2009
2,806
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.
Rich (BB code):
    list    p=10F202
    radix    hex
    title "pentaxIR"
        #include <p10F202.inc>

    __CONFIG   _MCLRE_OFF & _CP_OFF & _WDT_OFF

;The remote control generates a series of IR pulses as shown below. The 'on'-
;pulses are modulated at 38kHz.
;               
;              |||||||||||||         |||   |||   |||   |||   |||   |||   |||
;   38kHz ---> |||||||||||||         |||   |||   |||   |||   |||   |||   |||
; modulation  _|||||||||||||_________|||___|||___|||___|||___|||___|||___|||_
;               
;duration [ms] |    13     |    3    |1| 1 |1| 1 |1| 1 |1| 1 |1| 1 |1| 1 |1|
    
;38khz 27% duty ~ 7 cycles on, 19 cycles off. 1ms ~ 38 pulses, 3ms ~ 115 pulses, 13ms ~ 500 pulses
;actually 38.4kHz but should be close enough    

;switch on GP3

    cblock 0x08
    interval
    count
    count2
    count3
    count4
    countdown
    

    endc

;    
;----------------------------------------------------------------------

;**********************************************************************
    ORG     0x1FF             ; processor reset vector

; Internal RC calibration value is placed at location 0x1FF by Microchip
; as a movlw k, where the k is a literal value.

    ORG     0x000             ; coding begins here
    movwf   OSCCAL            ; update register with factory cal value 
    
init    ;initialise stuff here
    CLRF GPIO                 ; Initialize GPIO by
                            ; clearing output
                            ; data latches
    MOVLW B'00001000'         ; Value used to
                            ; initialize data
                            ; direction
    TRIS GPIO             ; Set mostly outputs
    movlw B'10000000'        ;weak pullups on, wake on change off
    OPTION
    btfss STATUS, 7
    goto sleeploop            ;power on, not pin change

    call fire

    movlw D'100'
    movwf countdown
settingtest                    ;see if switch held for 2 seconds
    call delay20ms
    btfsc GPIO, 3
    goto sleeploop            ;normal press
    decfsz countdown, F
    goto settingtest
settingtest2                ;has been pressed for 2 seconds
    btfss GPIO, 3
    goto settingtest2        ;wait for release
    clrf interval

settingnotpressed
    movlw D'100'
    movwf countdown
settingnotpressed2    
    call delay20ms            ;debounce
    btfss GPIO, 3
    goto settingpressed
    decfsz countdown, F
    goto settingnotpressed2
    goto intervalfire        ;if released for 2 seconds

settingpressed                ;if pressed 8 times interval = 0 so time=256 sec
    bcf STATUS, C
    movf interval, F        ;if interval 0 make carry 1, ready for rotate
    btfsc STATUS, Z
    bsf STATUS, C
    rlf interval, F            ;interval=interval X 2
settingpressed2        
    call delay20ms            ;debounce
    btfsc GPIO, 3
    goto settingnotpressed
    goto settingpressed2

intervalfire
    movf interval, W
    movwf countdown
intervalfire2
    movlw D'50'
    movwf count4
intervalfire3                ;1 second delay
    call delay20ms
    btfss GPIO, 3
    goto init                ;back to normal mode if button pressed
    decfsz count4, F
    goto intervalfire3

    decfsz countdown, F
    goto intervalfire2
    call fire
    goto intervalfire
    




sleeploop
    movlw B'00000000'        ;weak pullups on, wake on change on
    OPTION
    movf GPIO, W
    sleep

fire
    movlw D'13'
    call pulseWms
    call delay1ms
    call delay1ms
    call delay1ms
    movlw D'7'

    movwf count2
pulse7
    movlw 1
    call pulseWms
    call delay1ms
    decfsz count2, F
    goto pulse7
    retlw 0


pulseWms
    movwf count
pulseouter
    movlw d'38'
    movwf count3
pulseinner
    movlw b'00000100'
    movwf GPIO
    goto $+1
    goto $+1
    goto $+1

    clrf GPIO
    goto $+1

    goto $+1
    goto $+1
    goto $+1
    goto $+1
    goto $+1
    goto $+1
    decfsz count3, F
    goto pulseinner
    decfsz count, F
    goto pulseouter
    retlw 0


delay20ms                        ;19693 cycles
            ;19688 cycles
    movlw    0x61
    movwf    count
    movlw    0x10
    movwf    count2
delay20ms_0
    decfsz    count, f
    goto    $+2
    decfsz    count2, f
    goto    delay20ms_0

            ;1 cycle
    nop

            ;4 cycles (including call)
    retlw 0


delay1ms:    ;
    movlw 0xFF
    movwf count
loop1ms    
    nop
    decfsz count,F
    goto loop1ms
    retlw 0 ;delay1ms



    end
 

Thread Starter

wannaBinventor

Joined Apr 8, 2010
180
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.
 

jpanhalt

Joined Jan 18, 2008
11,087
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.

John
 

Markd77

Joined Sep 7, 2009
2,806
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.
 
Top