IR Module signal detect

My robot is using a radio shack 38khz IR module and IR leds driven by a 555 timer circuit. It's probably not actually 40khz, but it's close enough that I can see the signal from the module when pointed at a nearby object.

The problem I'm having is that the pulses comming from the the detector are getting missed as I poll port E. Is there some way I can use an interrupt to detect a change on the pin instead of polling?

Should I try to correct the transmit frequency instead? Right now, I see a signal from the detector when my robot comes within 2 feet of a wall, but the signal is pulsed, and the pulses are falling in between my polls of the port value.


Reply to
Loading thread data ...

Hi Tom

I have played around with similar IR receivers and found that Using an unmodulated

40kHz tone didn't work. These modules are designed for a 32-40kHz signal that is modulated on/off. I had to add another 555 timer to turn the 40kHz signal on and off. I don't know what the upper limit of this on/off frequency is but it is probably well into the kHz. This may work with the polling arrangement you have in place. As far as using a pin as an interrupt input this is microcontroller specific. I don't know what microcontroller you are using.

I am familiar with the PIC controllers and the ones I work with have a change of state interrupt on pin RB0.

The output of these receivers is typically open collector and a pull up resistor of 10k may be required.

I've found that these sensors were too sensitive, and were triggered by objects the robot could go under. Too compensate for this, I would stick clear tape over the receiving window and mask off sections with black tape and a permanent marker.

These units can also be modified to receive ultrasonic signals. This involves removing the IR diode from behind the receieving window and connecting a 40kHz piezo transducer in its place. one leg of the transducer can be soldered to the metal case of the IR receiver.

Happy roboteering


Reply to

The IR modules integrate the 40 khz pulses, so it sounds like you're getting a constant output from the module, rather than a pulsetrain. Either turn the LEDs on+off at some rate, or just look for a constant high level [or low, depending on the module].

Reply to
dan michaels

... oops, not a very lucid post :-(

The IR modules integrate the incoming IR pulses, so you're probably getting a constant output from the module. It sounds like you think you're getting a pulsetrain out. The solution is to either turn the "pulsetrain" to the LEDs on+off at some rate [ie, to modulate it], or to just look for a constant high level [or low, depending on the module] with your polled I/O routine.

[hmmm, I hope this makes more sense - maybe time to quit for the day :)].
Reply to
dan michaels

Not sure what you mean by your description, but here goes...

The way these work is to "gate" the modulation, not send a continuous stream of modulated signal. The problem when doing the latter is that these receivers have an automatic gain circuit in them, and the gain is set during the "quiet" moments between each modulated burst. If you send continuous modulation, the gain goes way down, and you may not receive a stable signal, even if the receiver is close to the light source.

If using hardware only, provide the modulation as usual, then gate it with an AND gate. A separate 555 timer can turn this on and off maybe

10-20 times a second. The output of the receiver, when the modulated light is detected, will be a nice square wave of 10-20 Hz. At that slow speed, your controller is sure to see it. If you have a spare output pin and some extra clock cycles in your controller, you can gate the modulation under software.

Another idea: rather than use an external interrupt, use a timer that triggers an internal interrupt. At each interrupt, activate the modulation for a brief period of not more than 600 us. Look for the output of the receiver to go high. If it does not, no obstacle.

-- Gordon Robots for Less at Budget Robotics:

formatting link
Robot Builder's Sourcebook & Robot Builder's Bonanza

mykrowyre wrote:

Reply to
Gordon McComb

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.