Chrono and IR sensors
Hello all,
Let me give you a little background. I am trying to make a chrono for detecting high speed projectiles. I composed the code to do so using the RCTime to gain the highest resolution of 2uS that is possible on my BS2. All that went well as I was only using 2 push buttons to do all the testing as my IR LED and detectors had not arrived from parallax yet. When the kits arrived, made the circuit as suggested on in the manual and BOE BOT book in chapter 8. The IR sensor is hooked up correctly with the output in series with a 220 ohm resistor to pin 0. The LED is series with a 2kohm resistor to pin 7 (also tried 470ohm and 1k ohm). Here is the code I am using to test a simple break between the LED and detector.
I am having real problems with getting results with this setup. It is very buggy constantly switching between broken and unbroken states (view code). If I do get it barely working, I have to cover the detector for quite some time before the "Beam is broken; object detected" message appears. In total darkness, it doesn't want to work at all. So that would lead me to believe the LED is not working. I have 6 brand new LED's, the circuit and polarity of the LED's are correct. tested the detector by writing some simple code and using my TV remote and it did pick up.
Is there anything I can do different or is just how these things react?
Any assistance would be grateful.
I noticed in this code that was provided that the FREQOUT command would stop "emmiting" as soon as it proceeded to the next line of code. Wouldn't this give you an error? This is the example code given by parallax so I am a bit confused.
Thanks in advance.
Regards,
Let me give you a little background. I am trying to make a chrono for detecting high speed projectiles. I composed the code to do so using the RCTime to gain the highest resolution of 2uS that is possible on my BS2. All that went well as I was only using 2 push buttons to do all the testing as my IR LED and detectors had not arrived from parallax yet. When the kits arrived, made the circuit as suggested on in the manual and BOE BOT book in chapter 8. The IR sensor is hooked up correctly with the output in series with a 220 ohm resistor to pin 0. The LED is series with a 2kohm resistor to pin 7 (also tried 470ohm and 1k ohm). Here is the code I am using to test a simple break between the LED and detector.
' {$STAMP BS2} ' {$PBASIC 2.5} IR_detect VAR Bit LOW 7 LOOP: PAUSE 50 FREQOUT 7, 1, 38500 IR_detect = IN0 IF IR_detect = 0 THEN unbroken ' Make sure to add six spaces to the debug statement ' below. That way both debug statements will have the ' same number of spaces for a better display. DEBUG HOME, "Beam is broken; object detected. " GOTO LOOP unbroken: DEBUG HOME, "Beam is unbroken; object not detected." GOTO LOOP
I am having real problems with getting results with this setup. It is very buggy constantly switching between broken and unbroken states (view code). If I do get it barely working, I have to cover the detector for quite some time before the "Beam is broken; object detected" message appears. In total darkness, it doesn't want to work at all. So that would lead me to believe the LED is not working. I have 6 brand new LED's, the circuit and polarity of the LED's are correct. tested the detector by writing some simple code and using my TV remote and it did pick up.
Is there anything I can do different or is just how these things react?
Any assistance would be grateful.
I noticed in this code that was provided that the FREQOUT command would stop "emmiting" as soon as it proceeded to the next line of code. Wouldn't this give you an error? This is the example code given by parallax so I am a bit confused.
Thanks in advance.
Regards,
Comments
Interested a little more information on the BS2 freqout generating the 38.5kHz harmonic
also look up a post on speed trap in stamp area about 2 weeks ago
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Erco,
I am using 2 sensors set about 4 inches apart currently. The stamps seem to be quite reliable in this setup. Once the first sensor is triggered, the rctime starts and counts the time until trigger two goes high. I will post the code for that if you like. I am currently using an IR LED and photo transistor, sorry for the confusion.
I am using 350-00014 product from parallax. I thought that was a photo transistor at least. I does send a high signal to the stamp upon not receiving an IR source at around 38 khz.
The problem I am having is constant 38500 hz signal and being able to detect a triggered switch. I could try polling I guess but am unsure. I also though about using my PWMpal but it only produces a 20 khz max.
How would you generate the freqout frequency for the led and also use the pulsin command to monitor. Sorry for any noob questions.
Regards
38 kHz modules are usually rectangular with a small dome lens on one side (sometimes covered by an X) and come in either black or metal covered. More importantly, the 38 kHz modules have lots of internal circuitry that filters out most non-38 kHz signals. That circuitry has a response delay associated with it, which is the only reason why the Parallax object detection method works.·Your code above (freqout 7,1,38500) sends a pulse train out, stops sending it, and after a brief execution delay, starts looking if the sensor sees the pulse. In reality, the pulse train is long gone at the speed of light, but due to the sensor's circuitry delay characteristics, it still shows active low for a brief detectable period. There is also a delay when it first goes low. Those delays will vary from sensor to sensor, so you may not get accurate timing results·using ·2 different sensors.
Whatcha got?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Post Edited (erco) : 3/6/2009 8:07:56 PM GMT
In terms of providing a constant 38.5kHz signal, look up the 555 timer chip. Very simple to use, and all parts needed can be had from Radio Shack. The Stamp simply can't do two things at once. However, it isn't as easy to do the freq. sweep trick for distance detection. You could probably use a digital pot to do that along with the 555 timer.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
What I really need is just a n optocoupler type steup. I can recess the photo transistor to protect it from ambient light. You mentioned I would need external circuitry. Would something like this setup work? ( jpeg attached)
Were can you photo transistors with the three connections and what is the difference between them and the ones that look like led's. I imagine they have internal circuitry like a switching transistor or something.
How about the photo emitter and transistor set?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."