PDA

View Full Version : IR pulse input/output trouble



dimatt
06-03-2005, 06:49 AM
Hello! I am having trouble sending and receiving ir signals between two basic stamps. Im planning on using one stamp to send pulses to the other. The second stamp will then recognize and have outputs for different legthed pulses that are sent. I have a basic code set up at the moment for each stamp to make sure that the second stamp is recieveing and then making an action accordingly.

this is the bs2 code:

recieving stamp:

value·· VAR···· Word

Main:
· COUNT 0, 1000, value
· DEBUG ? value
· GOTO Main
· END

·transmiting stamp:

· Loop:
· FREQOUT 6, 20000, 5
· GOTO Loop

I was basically just using this code and the debug menu to check whether the correct pulse was being sent across to the other but it doesn't seem to be working for me. Insteading recieving the correct count in the debug menu it is sending mixed signals. It used to show numbers in the 100 range but then when i restart the program or cover the circuit with something it sometimes shoots up to 1000. Could this possibly be due to interference or what else could be doing this?

Jon Williams
06-03-2005, 07:43 AM
Are you using a standard IR receiver on the slave side?·If yes, you need to adjust your Master modulation output.· The other problem you have is using LOOP (a keyword) as a label.· Try this on your Master Side:

Main:
· DO
··· FREQOUT ModPin, 5, 38500
··· PAUSE·5
· LOOP
· END

Note that I added a bit of a delay between pulses.· It also occurs to me that the IR receivers we use have a bit of hysteris, so they don't shut off as soon as the IR modulation source goes a way.· The PAUSE should help that.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Andy Lindsay (Parallax)
06-03-2005, 07:52 AM
Here's a link to an article at www.parallax.com (http://www.parallax.com) that may be helpful.·

http://www.parallax.com/dl/docs/prod/audiovis/InfraredEmittingDiode.pdf (http://www.parallax.com/dl/docs/prod/audiovis/InfraredEmittingDiode.pdf)

Pages 15 to 17 demonstrate communication between two BASIC Stamps with IR LEDs and detectors.

dimatt
06-03-2005, 09:36 PM
so far i have tried both the modded program·that Jon Williams presented and even the program in here http://www.parallax.com/dl/docs/prod/audiovis/InfraredEmittingDiode.pdf·but still, nothing seems to be working for me. even the from the program from the link doesnt work for me :(

Jon Williams
06-03-2005, 09:43 PM
Perhaps you should upload your schematic (if you don't have it drawn, you can download a free schematic editor from www.expresspcb.com) and complete listing. Andy and I have a lot experience with IR (especially Andy -- he wrote a whole book on it! -- check it out) and can help you if you give us more information.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Andy Lindsay (Parallax)
06-04-2005, 12:20 AM
Yes, and Jon has published articles about infrared in Nuts & Volts Magazine that also appear in his series of books - The Nuts & Volts of BASIC Stamps (http://www.parallax.com/html_pages/downloads/nvcolumns/Nuts_Volts_Downloads.asp).·

Along with the schematic, please let us know which parts you are using.· The parts that Jon and I have been referring to are these:

IR Transmitter w/ heat shrink tubing (http://www.parallax.com/detail.asp?product_id=350-00014)

Infrared Receiver

If you are using an Infrared Transistor (http://www.parallax.com/detail.asp?product_id=350-00018) or an infrared diode instead of the infrared receiver, it's a different ballgame.·

dimatt
06-05-2005, 05:31 AM
Yes, i have been using an·infrared transistor and a Infrared-senstive photoresistor·for this project actually.·My set up is same as the jpeg below

Jon Williams
06-05-2005, 06:00 AM
That explains a couple things: You could be getting interference from other IR sources.· The IR sensor Andy referenced demodulates a 38 kHz signal which is why we use FREQOUT to drive the LED.· In your circuit, you simply need to turn the LED on, but....

There is a problem with your circuit, too.· You should have the 220-ohm resistor between the BASIC Stamp pin and the LED.· Right now you have a direct drive and it you leave the pin as an output high you're likey to damage the BASIC Stamp.· Also keep in mind that you cannot toggle the LED control pin while watching the output of the phototransistor.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Andy Lindsay (Parallax)
06-07-2005, 12:52 AM
Dimatt,

Here are modified versions of your test programs that should work with Jon's circuit provided the I/O pins are still working.· Make sure to shield the components from ambient light while you are testing.· ·



' IrLedPhototransistorTransmit.bs2
' Send high/low signals from an IR LED to an IR transistor at 10 Hz.

' {$STAMP BS2}
' {$PBASIC 2.5}

Out PIN 6

DO

HIGH Out
PAUSE 50
LOW Out
PAUSE 50

LOOP





' IrLedPhototransistorReceive.bs2
' Count cycles sent by IrLedPhototransistorTransmit.bs2.

' {$STAMP BS2}
' {$PBASIC 2.5}

In PIN 0
value VAR Word

DO

COUNT In, 1000, value
DEBUG ? value

LOOP



Regards, Andy