trouble with 38kHz receiver module...
Whelzorn
Posts: 256
Ok, I have finally got all of my BS2 OEM modules up and running fine, and I have some of these 38kHz recievers. These things are amazingly dificult to use (for me at least). I have one of the BS2's modulate the frequency to 38kHz, and the other recieve it. heres the EXTREMELY SIMPLE code:
transmitter:
receiver:
now it seems foolproof, but the LED attached to P14 flashes at a pretty random frequency. If debug "received" is put where the HIGH 14 is, and debug "nothing" is put where the LOW 14 is, then it returns about a 30% - 70% duty cycle for the receiver. I have no idea what to do to fix this, so I come to you all knowing people for the answer
thanks people
-Justin
transmitter:
'{$STAMP BS2} '{$PBASIC 2.5} DO FREQOUT 3, 1, 38000 LOOP
receiver:
'{$STAMP BS2} '{$PBASIC 2.5} IR_detect VAR Bit DO IR_detect = IN6 IF IR_detect = 0 THEN HIGH 14 ELSE LOW 14 ENDIF LOOP
now it seems foolproof, but the LED attached to P14 flashes at a pretty random frequency. If debug "received" is put where the HIGH 14 is, and debug "nothing" is put where the LOW 14 is, then it returns about a 30% - 70% duty cycle for the receiver. I have no idea what to do to fix this, so I come to you all knowing people for the answer
thanks people
-Justin
Comments
The BS2 can't produce the 38kHz carrier AND modulate the output. Simply sending a steady 38kHz signal will not trigger most IR reciever modules. Try waving your hand in front of the transmitter. If you have a reasonably close to 38Khz signal coming from the transmitter, you should see the blinks. You can attach the LED directly to the output of the IR receiver so you don't have to bother having the Stamp send a pin high or low. In fact, for just testing the link, you don't need the Stamp at all.
I have never tried to produce 38kHz from a BS2, so I don't know how well it works or how close the 38kHz it really is. Most IR receivers are sensitive to a Khz or two. Maybe someone who has made 38kHz from a BS2 could speak to this. Assuming that the 38kHz signal is OK, are you passing the signal through a Schmitt trigger? This really cleans up the signal and is necessary for data transfer in my experience.
To transfer data, you need a source of 38kHz running constantly. Then you modulate the signal to send the data. This is best done by sending the carrier signal into one·gate of a Schmitt trigger NAND like the 74HC132. The BS2 then sends serial data to the other gate of the '132. The output of the '132 is fed to a transistor which runs the IR transmitter diode. Since the '132 has a built in Schmitt trigger, you get a nice clean signal.
Another thing is that you need to drive the transmitter diode really hard. If you look in a TV remote, you will see that they use a transistor and a really low value current limiting resistor, like 2 ohms. You can get away with driving the LED this hard because of the low duty cycle. You can use a digital camera to compare the brightness of your transmitter with that of a TV remote. Yours should be just as bright or close.
Another thing is that the receivers expect a pause of 100mS or so between data bursts. If you just send a continous flow of data, you lose the connection. Periodic pauses are required to make the TX/RX hook up. This confounded me until I looked·at the output of a TV remote on a scope.
Anyway, HTH.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
http://www.rentron.com/Infrared_Communication.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
This will allow a bit of down-time between pulses.· If all goes well, you should see the receiver LED blink about once per second.· And here's a snappier receiver demo:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Post Edited (Jon Williams) : 10/20/2004 6:36:00 PM GMT
Thank you for responding!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
and using this as a transmitter:
only once every 100 or so "0's" from the debug window will it display a "1"
this is odd, because it appears that it flashes the Infrared LED once, and then stops it for the 900 ms pause, then flashes again.
Shouldnt it output 38khz from the LED continuously for 900ms?
This will send a signal Num_mSec long of Freq.
FREQOUT 3, 100, 38000 ' This sends a 38,000 hz signal for 100 mSec.
PAUSE 900 ' Pause for 900 mSec
During those 100 mSec, the IR Demodulator will output a LOW signal.
During the Pause, it will output a HIGH signal.
You *probably* want to use PULSIN to read the pulse.
Duration VAR WORD
PULSIN IR_Decoder, 0, Duration
When the 'idle' state is high, using this PULSIN will cause:
1. Wait up to 130 mSec for the 1 to 0 edge of the signal. Return 0 if the signal never goes low.
Start counting immediately if the signal is already low when the command is issued.
2. Start counting, in 2 uSec 'ticks', how long the signal is low.
3. When the signal goes high, return the number of 'ticks' it was low. 1 mSec == 500 ticks.
With this, you can "FREQOUT 3, 1, 38000", and "FREQOUT 3, 2, 38000", and the
PULSIN command should return around 500 for the first, and 1000 for the second.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
I have diagrams of 2 configurations for this. In the first the transmitter is placed on the table next to the reciever, and lower to it:
this causes the LED to flash very fast, but it means its recieving a good signal which is strange because it does not seem that the infrared light is reaching the detectors eye at all...
Also in the second example:
notice that the IR LED is placed DIRECTLY OVER the detectors eye? well, it detects almost nothing, and is very unreliable if it detects anything. This one has me completely stumped. The detector seems to be the culprit here. The part I'm using can be found here: www.radioshack.com/product.asp?catalog_name=CTLG&product_id=276-640
great thanks for trying to help, everyone...
Are you driving the IR LED from a Stamp pin? If so, you won't get much output and the Stamp pin might get damaged. Have you verified the brightness of the IR LED? As I mentioned above, you can use a digital camera to see the output.
The odd results you are getting might be because you need a pause in the stram of 38kHz IR to make the receiver module trigger. Do you get one blink when you use the second setup, then nothing? If so, that would tend to confirm this idea.
Another issue might be the accuarcy of the 38kHz signal form the Stamp. You might try a 555 circuit as Jon suggested. I have never used the receiver module you are using, but I doubt it is the problem. You can pull one out of an old VCR to mkae sure.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
EDIT: ok, the bottom configuration only works if I write the code like this:
Post Edited (Whelzorn) : 10/21/2004 10:24:08 PM GMT
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot