Shop OBEX P1 Docs P2 Docs Learn Events
Infrared, once again... — Parallax Forums

Infrared, once again...

CumQuaTCumQuaT Posts: 156
edited 2009-08-17 08:38 in Propeller 1
Hello again! I've been playing around alot lately with infrared, and I've been trying to capture and play back the pulses used in various toy laser tag guns. (basically I'm trying to breadboard out a laser tag gun that can shoot the same IR frequency)

I've been toying around with the IR kit on the obex page as I know that the toy I'm trying to record uses a 38khz receiver, but with no success at all. It picks up the signal from the gun as far as I can tell, but I can't seem to get any code working to play it back... Basically I'm trying to get the data that I get from the receiver and turn it into code that I can use anywhere (to build, for example, a Laser Tag gun turret)

I'm sure there are people on here that have used the IR kit before. Has anyone been able to record something and turn it into code that will play it back on command... I'm still kinda new to the Propellor, so high-tech responses may be a bit over my head, sorry. You'll have to speak in layman's terms for me!!!

I'm used to working with PICs and such, so I'm familiar with coding... Just not with the prop...

Thanks in advance, people!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who are you, and why are you reading my signature?

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-08-16 10:21
    did you take a look at the code that jazzed postet in this thread ?

    maybe it is easier to build it new from scratch.

    To do this I would code a small testprogram that sends an easy bitpattern like 10011 0s and 1s coded the same way as in remote controls
    make another testprg running independently in a second cog that does receive this bitpattern
    i.e. measuring the high and low timings
    store these values in an array
    then play back the bitpattern by using the timing from the array

    as a first step do it THIS way as in this way you have EVERYTHING under control
    especially the sended bitpattern so you can easily check if
    - your receiving code works right
    - the receiver-hardware works right
    - the calculation of the timing works right
    - playback timining is right

    this might look as a longer way to go
    but on other ways as soon as a problem occurs with some "do it all at once with unkown bitstream-code"
    it will take much more time to narrow down where the problem is

    you can try a quick shot using the IR-Kit-code but as soon as the problem occurs switch over to understand everything from scratch

    best regards

    Stefan
  • CumQuaTCumQuaT Posts: 156
    edited 2009-08-16 10:48
    Sounds like a good plan, Stefan! I'll give that a go. One question though, do you have some demo code I could use to record the frequencies into an array? As I said before I'm not overly fantastic when it comes to using Spin...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Who are you, and why are you reading my signature?
  • CumQuaTCumQuaT Posts: 156
    edited 2009-08-17 04:31
    So did you have an example of the code I could use for that?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Who are you, and why are you reading my signature?
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-08-17 05:22
    the attached zip-archive shows how to use arrays and how to use FullDuplexSerial
    to get detailed debug-information

    best regards

    Stefan
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2009-08-17 08:38
    Maybe as a simple starting point hook an IR phototransistor to an input pin.

    Hook an IR LED to an output pin.

    Create a fast loop that simply tests the state of the input pin and pulses the out pin in exactly the same way.

    Pointing the laser toy at the phototransistor should echo the same pattern to the IR LED on the out pin.
    The IR LED should be able to activate the laser tag receiver now just as though it were the original device.
    Even without mimicking the 38khz carrier perfectly this should work if you put the IR LED right on top
    of the receiver (the filtering can't be so good that this much IR light won't overpower it)

    Now you can just write a program to record the pattern and then send it out to a pin as 38khz modulated pulses.


    I remember reading somewhere that an AVR was used to control VCR functions by sending IR pulse trains
    to LEDs taped directly over the sensors. They did not modulate the carrier but it still worked, but only as far as
    an inch or so from the sensors...no further.

    Post Edited (HollyMinkowski) : 8/17/2009 8:47:26 AM GMT
Sign In or Register to comment.