IRIN IROUT on same picaxe08M2

Dicky Mint

Senior Member
Hi All

I’d like to know if both the IROUT and the IRIN can be used on the same 08M2+ chip at the same time?

I’d like to use an SMD IR phototransistor (or photodiode) instead of the leaded IR sensor IRM-3638, and an IR LED to detect, by reflection, the presence of a hand or similar object at a distance of greater than about 6 inches.

I have attempted to detect a hand, with some limited success, by using, a always on, IR LED and a IR phototransistor feeding an ADC input on an 08M2+ .

This is all very well but is prone to interference by ambient light!

I'm hoping a modulated carrier wave of 38kHz will increase sensitivity and selectivity a little?

Rick
 

stan74

Senior Member
You could use pwm for 38KHz and the photo transistor (collector and emitter) between +V and a pin via a resistor. Check if pin goes high from reflection.
 

hippy

Ex-Staff (retired)
I’d like to know if both the IROUT and the IRIN can be used on the same 08M2+ chip at the same time?
No. The IROUT will block until it completes, then the IRIN will start, having missed what IROUT has sent.

Or IRIN starts, blocks, never completes, so a following IROUT is never executed.
 

erco

Senior Member
IRIN & IROUT receive & send Sony codes which take a while to execute, and what with the speed of light and all that, it's tough. Much like batting a ball hard then trying to run & catch it yourself. :)

A workaround IS possible though. There's just enough lag in most IR receiver's output to catch it when it goes low briefly. Send a short burst of 38kHz modulated IR through and LED and immediately look at the sensor. The reflected IR is long gone, but the sensor output stays low just long enough to catch it. Pretty cool, huh? See https://www.analysir.com/blog/2014/03/27/infrared-receivers-signal-lag/

Photo shows IR signal in yellow. When it ends, the blue output signal stays low for a it. Don't miss it!

 

erco

Senior Member
BTW, I learned that trick from the Parallax Boebot course, which also shows a neat frequency sweep to swag distance. Download their PDF here, and jump to PDF page 283/360 (p 269 printed on page top) for ranging info


Receiver lag info from PDF page 254/360 (p 240 printed on page top)

The key to making each IR LED/detector pair work is to send 1 ms of 38.5 kHz FREQOUT
harmonic, and then, immediately store the IR detector’s output in a variable. Here is an
example that sends the 38.5 kHz signal to the IR LED connected to P8, then stores the IR
detector’s output, which is connected to P9, in a bit variable named irDetectLeft.
FREQOUT 8, 1, 38500
irDetectLeft = IN9
The IR detector’s output state when it sees no IR signal is high. When the IR detector
sees the 38500 Hz harmonic reflected by an object, its output is low. The IR detector’s
output only stays low for a fraction of a millisecond after the FREQOUT command is done
sending the harmonic, so it’s essential to store the IR detector’s output in a variable
immediately after sending the FREQOUT command. The value stored by the variable can
then be displayed in the Debug Terminal or used for navigation decisions by the Boe-Bot.
 
Top