Shop OBEX P1 Docs P2 Docs Learn Events
IR pulse input/output trouble — Parallax Forums

IR pulse input/output trouble

dimattdimatt Posts: 5
edited 2005-06-06 16:52 in BASIC Stamp
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?

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-02 23:43
    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
  • edited 2005-06-02 23:52
    Here's a link to an article at www.parallax.com that may be helpful.·

    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.
  • dimattdimatt Posts: 5
    edited 2005-06-03 13:36
    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 [noparse]:([/noparse]
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-03 13:43
    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
  • edited 2005-06-03 16:20
    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.·

    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

    Infrared Receiver

    If you are using an Infrared Transistor or an infrared diode instead of the infrared receiver, it's a different ballgame.·
  • dimattdimatt Posts: 5
    edited 2005-06-04 21:31
    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
    221 x 168 - 20K
    ir.jpg 20.1K
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-04 22:00
    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
    428 x 317 - 1K
  • edited 2005-06-06 16:52
    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.· ·

    [color=#008000]' IrLedPhototransistorTransmit.bs2[/color]
    [color=#008000]' Send high/low signals from an IR LED to an IR transistor at 10 Hz.[/color]
     
    [color=#008000]' {$STAMP BS2}[/color]
    [color=#008000]' {$PBASIC 2.5}[/color]
     
    [color=#000000]Out PIN 6[/color]
     
    [color=#0000ff]DO[/color]
     
      [color=#0000ff]HIGH[/color][color=#000000] Out[/color]
      [color=#0000ff]PAUSE[/color][color=#000000] 50[/color]
      [color=#0000ff]LOW[/color][color=#000000] Out[/color]
      [color=#0000ff]PAUSE[/color][color=#000000] 50[/color]
     
    [color=#0000ff]LOOP[/color]
    
    


    [color=#008000]' IrLedPhototransistorReceive.bs2[/color]
    [color=#008000]' Count cycles sent by IrLedPhototransistorTransmit.bs2.[/color]
     
    [color=#008000]' {$STAMP BS2}[/color]
    [color=#008000]' {$PBASIC 2.5}[/color]
     
    [color=#000000][color=#000000]In PIN 0[/color]
    value VAR Word[/color]
     
    [color=#0000ff]DO[/color]
     
      [color=#0000ff]COUNT[/color][color=#000000] In, 1000, value[/color]
      [color=#0000ff]DEBUG[/color][color=#000000] ? value[/color]
     
    [color=#0000ff]LOOP[/color]
    
    


    Regards, Andy
Sign In or Register to comment.