Receivng IR signals
leshea2
Posts: 83
If Pulsout is the best command reference to use to have an IR led emit a signal, is Pulsin the best reference to use to have the IR detector receive·the signal and send it to the stamp, so the stamp can then send the data·to my desktop computer ?
Thanks !
Thanks !
Comments
' {$STAMP BS2sx}
' {$PBASIC 2.5}
GJH VAR Byte
Main:
SERIN 16, 16624, [noparse][[/noparse]WAIT("Ready")]
PAUSE 20
FREQOUT 3, 2000, 2500
PAUSE 200
PULSIN 6, 1, GJH
PAUSE 200
SEROUT 16, 16624, [noparse][[/noparse]GJH]
END
(The serin and serout command are for interacting with my desktop computer.)
Thanks !
Now, if you want the BS2 to send to itself, you shouldn't have that "PAUSE 200" in there.
And it's not clear what the "PULSIN 6, 1, GJH" is supposed to do...
Thanks !
The PULSIN is very forgiving. But if you don't output 38500, the IR_Decoder will never pull the signal low.
' {$STAMP BS2sx}
' {$PBASIC 2.5}
GJH VAR Byte
Main:
SERIN 16, 16624, [noparse][[/noparse]WAIT("Ready")]
PAUSE 20
FREQOUT 3, 2000, 38500
PULSIN 6, 1, GJH
PAUSE 200
SEROUT 16, 16624, [noparse][[/noparse]GJH]
GOTO Main
END
instead of the previous code, it should work ?
Thanks !
You don't need to generate the 38500 Hz frequency for that long. On the BS2, I use FREQOUT IRPin, 1, 38500 to modulate for 1ms.
Is your PC looking for a binary byte or a string representation? If the latter, you'll want to use SEROUT 16, 16624, [noparse][[/noparse]dec GJH].
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
I am not sure that this is what you intend for the result to be. Better help with better info.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
' {$STAMP BS2sx}
' {$PBASIC 2.5}
GJH VAR Byte
Main2:
PAUSE 500
FREQOUT 3, 100, 38500
PULSIN 6, 0, GJH
DEBUG DEC GJH
GOTO Main2:
END
and now a whole·bunch of numbers show up. My question is, does anyone know what is suppose to be on the debug screen? Is there a specific patten of numbers that have to be printed on the debug screen, that tells you that both the IR LED and the IR detector are working properly ?
Thanks for all of your help !
"I'm trying to send to myself as a test, and you said PULSIN is used to read and measure the response from the IR led, so when I use "PULSIN 6, 1, GJH" in the code, I’m trying to receive what I just sent"
is analogous to standing in a dark room with your eyes closed, flicking the light switch on and then off, then opening your eyes to see the 'leftover' light.·
Unless there is a large latency in the IR detector (ie reports is seeing modulated IR long after the IR has stopped being received) this will never work.
The speed of light·is ~3x10^8m/s.· If the op instruction execution speed of a stamp is ~250us and there is no latency in the IR detector, your IR emitter and detector will need to be at least 75,000m apart for this to even have a chance of working.· Hope you're using a superbright IR emitter!
Nate
PS:·For IR emitter/detector test, use two Stamps, or a TV remote & a Stamp.
Post Edited (Nate) : 4/27/2006 10:26:33 AM GMT
My sentiments exactly when I first read of someone doing this, some time back. However, I've been around here for a while, and suspected that Parallax might have a tricky circuit floating around which might permit such a seemingly impossible methodology. Indeed they did!
What happens if you add a decent sized capacitor to the I/R emitter·control lead? Oops
By using just such a "charge source" for the I/R emitter, the latency which you correctly mention, is created, and it's just long enough to get to an immediately succeeding Pulsin command and have it execute properly. Indeed the power was off, and the lights stayed on!
My apologies if I described it slightly incorrectly, as I'm a programmer type, and not a circuitry type, but I'm sure you get the idea. Sustained power is the key to it.
Simple but powerful circuit, and entirely appropriate for the type and caliber of robots usually seen around these forums. Now you can utter the same chuckle that I did, when I realized what was afoot!
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Post Edited (Bruce Bates) : 4/27/2006 10:54:44 AM GMT
If I am reading you correctly, then wouldn't the cap on the IR emitter just provide "DC-like" (or at best, pulses with a DC bias) power to the emitter for a short while after the FREQOUT completes? If the detector is indeed looking for ONLY 38.5 kHz modulated light, then it probably would not ever see what it is looking for, because the capacitor would "mush" (integrate) the signal going to the emitter. If the detector is just a generic IR detector, then ANY IR (sun, remote control, etc...) would trigger it and the FREQOUT becomes irrelevant.
I recall, however, that the "tuned" can-type detectors DO hold their output in the "detected state" for a slightly longer time than the appropriately modulated IR is detected, which would allow this type of code to DEBUG one of two outputs...detected or not.
...or I could be on the wrong track....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
Perhaps this (attached) sensor can't be used in this application, but this documentation is where I learned about the basic technique, for better or worse. BTW - You take your LIFE in your hands when you ask a software guy like me ANYTHING significant about circuitry or HARDWARE! :-)
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
My understanding was that the poster wanted to send and recieve a multi-bit signal with one BS.· I do not·believe this could be done without additional memory devices or a long distance between the sender and receiver (or a multi-dimensional phase converter).
Nate
How about it? What is it you really want to do? Maybe more info on the desired result will help us to help you...
and Beau,
· I am also a "programmer with a screwdriver" (the most dangerous thing you may ever run into<g>).· So back at ya'
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
' {$STAMP BS2sx}
' {$PBASIC 2.5}
GJH VAR Byte
Main2:
PAUSE 500
FREQOUT 3, 100, 38500
PULSIN 6, 0, GJH
DEBUG DEC GJH
GOTO Main2:
END
The debug screen shows a lot of numbers, (1000, 00001, 30087, and so on), even if the emitter is not connected. So is there a way to make sure that the detector is actually receiving the emitted signal, like a specific repeating pattern of numbers ?
Thanks !
If it was really seeing the signal, then the pulse-width would only vary by a few counts.
Download the StampWorks manual and check out experiment #20. If you're using the same type of IR Detector that comes with the StampWorks kit, I don't think you really want to use PULSIN to read the status. You simply want to check the status of the pin the detector is connected to. If it's low, IR was detected. If it's high, IR wasn't detected. So your code would be more like this:
detected VAR BIT
Main2:
PAUSE 500
FREQOUT 3, 100, 38500
detected = ~IN3 ' Detector is active-low. (Change IN3 to your IR Detector's pin.)
IF detected then
DEBUG "IR Detected", CR
ELSE
DEBUG "No IR detected", CR
ENDIF
GOTO Main2:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
Now, I don't know what the numbers you're seeing SHOULD be. That depends on the placement of the IR_LED and the IR_Decoder. However, they shouldn't vary that much. Meaning, IF you got 600 one time, the next time shouldn't be more than 610, or less than 580. If it was all working properly, that is.
The code works, but why does the debug screen say IR Detected, even when I disconnect the IR Emitting LED ? If there is no 38.5 signal being emitted, what is the IR Detector, detecting ?
Which IR detector are you using? The one I've used (the one that comes with various Parallax kits) doesn't require any resistors when connecting it to a Stamp. You said that your detector drives low when it detects and floats otherwise. Do you have it wired the way Allan suggested? If so, then a 0 on pin 6 means that it is driving the pin low which is supposed to mean that it has detected IR.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
Thanks !
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
It says it's also a bipolar integrated circuit with a photo detection function.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
Thanks !
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
http://lib.store.yahoo.net/lib/e-clec-tech/38khz.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows