View Full Version : how to count a part of 38khz
10-02-2008, 04:21 AM
I'm looking for a way to count 38mhz that my Ir diode is putting out I no the stamp not that fast. but I was thinking i could use a IR module with resistor capacitor added to the output to divide it to some thing in khz range. I have a pickit2 that can read up to 500khz. I was going to use it to count the out put.
Post Edited (be80be) : 10/2/2008 12:37:57 PM GMT
Phil Pilgrim (PhiPi)
10-02-2008, 04:32 AM
Your IR diode is putting out 38KHz, not 38MHz.
10-02-2008, 04:55 AM
You would need to use a phototransistor to produce individual pulses at 38KHz. The IR detector that Parallax and others use already demodulates the 38KHz signal to produce an on/off logic signal. The detector usually needs several cycles of the 38KHz signal to detect its presence or absence, typically a minimum of 10-15.
10-02-2008, 06:04 AM
Well you may be right I made a IR setup using a ir diode and a 555 timer it said 38mhz thay may of miss said the 38mhz and meant 38khz
10-02-2008, 06:11 AM
It was a miss print
10-02-2008, 07:53 PM
I still would like to know if the stamp can count the 38khz see i made 2 ir transmitters 1 puts out 38 khz it will turn my ir module
the next 1 i know it's on but its way to fast it doesn't turn on my ir module
10-02-2008, 08:33 PM
As was said, the IR-Module is 'looking' for a IR light 'blinking' at 38,000 times a second. After it 'sees' a few cycles of this, it 'locks up' on it and outputs a LOW, as long as it continues to 'see' the IR light still blinking at 38,000 times a second.
Once the IR light stops blinking, the IR-Module continues to hold the pin low for some period, long enough that the BS2 can read the pin after the FREQOUT statement.
Oh, and typical TV IR-Remotes output 'pulse patterns' of this light. I believe the Sony protocol uses 600 uSec and 1200 uSec for bit-times. A "pulse pattern" being defined as "blinking the light at a 38 Khz rate for 600 uSec, then NOT blinking the light for 600 uSec, equals a "One" ". Mind you, there's hundreds of different manufacturer pulse-patterns.
Given that's what's happening, the answer is no, the BS2 cannot count the 38 Khz. But usually you don't want to. It CAN read the size of the IR-Module output pulses, however.
Oh, and the reason they all use this magic 38,000 times a second blink rate is that this filters out sunlight.
Now, if you REALLY want to put the blink-rate on an oscilloscope or logic-analyzer or something, you can use a true IR recieving transistor.
If you're just trying to insure the IR-LED is working, look at it with a digital camera -- they recieve IR light.
10-02-2008, 08:35 PM
Oh, and note also it's very very easy to 'jam' the IR signal with another IR-LED signalling at a 38 Khz rate. This is why this scheme makes it so difficult to try to control TWO robots with TWO different remotes -- the remotes jam each other.
Phil Pilgrim (PhiPi)
10-02-2008, 11:10 PM
The BS2 is perfectly capable of counting at 38KHz, using the COUNT instruction. (It can actually count up to 120KHz.)
be80be, if you want to use the BS2 to verify that your 38KHz circuit is really clocking at that rate, you can use a phototransistor, as Mike suggested, or connect the circuit's output directly to a BS2 pin and it's ground to Vss. (That's assuming the output operates at normal logic levels. If not, use the phototransistor.) Then, using a WORD variable for the result, COUNT the number of pulses in a 100ms time interval and multiply by 10 to get the frequency.
10-02-2008, 11:14 PM
I know how the module works but thats not what wrong 1 of my transmitters work the second 1 i know is on and blinking but it way to fast to turn on the Ir module I used my cam to see that it was on what i was hope for was to set 1 for 38khz and 1 for 36khz and use a 36 and 38 ir modue to pick it up so i made 2 a 38khz that works like it should. But the 36khz I cant slow it down to 36khz. I think after looking at the 38khz transmitter that works. It can be slowed down to 36khz . I going to pulse the 38khz on 20us off 20us and the 36 the same. is what i want to do with this.
10-02-2008, 11:19 PM
Thank you Phil thats what i was looking for how to count Is there any howto's on how to use count with basic stamp2
Phil Pilgrim (PhiPi)
10-02-2008, 11:28 PM
The PBASIC manual is pretty thorough in this regard. There's really not much to it: just specify the pin number, length of time to count and a variable for the result, and the Stamp does the rest.
10-03-2008, 07:31 PM
The FREQOUT signal has components of 36 Khz AND 38 Khz -- it's not a perfect square wave at that frequency. I'm not sure the IR-Decoder's have that close a frequency discrimination either. But if it works it's a brilliant way to have two non-interfering signals.