help require on generating 38khz
samal
Posts: 8
hello gurus,
i hooked up a IR LED to my basic stamp 2 with a 220 ohm series resistor to pin 14 and a 38khz receiver to pin 15. i am pretty new to basic stamps. now i need to generate a 38khz signal on pin 14 and listen to pin 15.
pls help me with the code.
thanks,
Sam
i hooked up a IR LED to my basic stamp 2 with a 220 ohm series resistor to pin 14 and a 38khz receiver to pin 15. i am pretty new to basic stamps. now i need to generate a 38khz signal on pin 14 and listen to pin 15.
pls help me with the code.
thanks,
Sam
Comments
I have used this with great results.
http://www.rentron.com/remote_control/TX-IR.htm
http://www.rentron.com/Files/TX-IR.pdf
I used it for this customer application.
http://www.parallax.com/tabid/321/Default.aspx
I will post the code when I find it.
SJW
' {$PBASIC 2.5}
INPUT 15
PinState VAR Byte
MAIN:
· FREQOUT 14, 1, 38000 ' Send 38,000 hz out the IR-Pin for 1 millisecond.
· PinState = IN15 ' The IR decoder holds its active low signal long enough to be read here.
· IF (PinState = 0)· THEN
··· SEROUT 16, 16468, [noparse][[/noparse]"I see it!", CR]
· ELSE
··· SEROUT 16, 16468, [noparse][[/noparse]"No IR Echo.", CR]
· ENDIF
· PAUSE 500 ' You need this pause, or data flys by too fast.
· GOTO MAIN
So, load the above code into your BS2. Open the terminal window on the IDE -- it will get the SEROUT messages above.
Then move your hand so it reflects the IR light into the IR-Decoder. When you get close enough, "I see it!" messages should
come out on the terminal window.
Geez, tough group, all he wanted was some code.
Post Edited (allanlane5) : 10/1/2008 1:28:59 PM GMT
There is some good info here:
www.robotroom.com/Infrared555.html
For more, just Google 38kHz
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Rick
thanks a bunch! for your quick replies
after i posted this question i tried looking into the help of stamp and found a command FREQOUT and i used it like this:
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
FREQOUT 14, 1, 38000
DEBUG ? IN15
LOOP UNTIL IN15 = 0
END
but this never came out of the loop even if the debug window was showing IN15 = 0 after i put a book in front of the ir thingy.
i need to try out Allans code. The idea of delay seems to be logical.
cheers,
Sam
You can fix this with a simple:
MyVal VAR BIT
DO
FREQOUT 14,1,38000
MyVal = IN15
DEBUG ? MyVal
Loop until MyVal = 0
END
Here is what I achieved by modifying Allan's code.
Mod to previous circuit : I mounted the IR tx-rx pair onto a standard servo and the code below makes
Servo - P0
IR tx - P15
IR rx - P14
Mod to code: I added a lil bit of debouncing for false triggering on IR recevier pin (pls correct me if i screwed up!)
Operation:
- the servo point 12 o'clock first
- if i put my hand in front of the IR, it turns 10 o'clock and scans for objects
- if i put my hand in front of the IR, it turns right 2 o'clock and scans for objects
- if i put my hand in front of the IR, it turns back to 12 o'clock and scans for objects
The present code is attached along with pictures of my $8 robot and BS homework board.
This is pretty cool for me as a first timer!. Thanks to all you guys out there.
I need a lil more help with the servo though.... this is what i want:
Mod to circuit: add one more IR tx-rx pair. Allign both tx-rx pair with 45-50 degrees angle between them.
i want to scan the IR while moving the servo. to me it seems that i would screw up with the timings so i needa lil help. i already read through teh servo control posting but still not able to figure out
-Thanks,
Sam