IR Proximity Detection Code Conversion from Basic Stamp Code

4jaba6

New Member
In past I used a Parallax BS2 for "Infrared Object Detection".
I would like to convert and use PICAXE for this detection.

Below is a clip of code:

loop:
pause 50
freqout 14, 1, 38500
irdet = in7
ir irdet = 0 then quit
goto loop

quit
( do something if obstacle detected )


The hardware consisted of an Infrared transmitter connected to pin 14 and
Infrared Receiver Sensor ( Panasonic 4602 ) connected to pin 7.

I have been searching good part of day thru "Forum" without much success.
The best I can find is:
However, this seems much more complicated hardware and software in comparison
to the BS2 solution.

Will appreciate any advice, rec.'s, links ect. for proximity detection with Infrared.

TIA
 

eclectic

Moderator
Just to help with your future searches around the site.

Here are a few paths to follow.

1. Look above to Buy Now then search INFRA

2. Look above to PICAXE, then find MANUALS

Section 2

Then search IRIN IROUT INFRAIN

e
 

inglewoodpete

Senior Member
The code posted above and data for the (now obsolete) PNA4602 suggest that you want to use a simple 38.5kbits/sec IR On/Off transmitter and receiver. The PWM wizard can be used to create a command that will generate the 38.5k to drive an IR LED (use 50% duty). The receiver would be wired as shown in the IRIN command description in Manual 2. Your code would then poll the IR receiver's output for an on/off condition.

There are a lot more elegant solutions to using IR for proximity detection available. Tell us some more about what you're try to do.

Edit: Refer to erco's post #7 point about using some IR receiver modules with continuous carrier - not something I've tried to do.
 
Last edited:

4jaba6

New Member
The code posted above and data for the (now obsolete) PNA4602 suggest that you want to use a simple 38.5kbits/sec IR On/Off transmitter and receiver. The PWM wizard can be used to create a command that will generate the 38.5k to drive an IR LED (use 50% duty). The receiver would be wired as shown in the IRIN command description in Manual 2. Your code would then poll the IR receiver's output for an on/off condition.

There are a lot more elegant solutions to using IR for proximity detection available. Tell us some more about what you're try to do.

inglewood,

Thanks for response.

I see the 4602 is still available.
Do you know what it was replaced with?

I am not familiar with the PWM Wizard. How do I access this?

I am attempting to transmit 38KHZ signal
that can bounce off an object and make the irr sensor go logic high.

TIA,

John
 

erco

Senior Member
Easy enough to use PWM to generate a 38khz signal if your program isn't using interfering functions & timers (IIRC SERVO & COUNT are right out). Otherwise, build a simple 555 oscillator or equivalent to generate the signal, or get a sensor which generates its own IR output, such as these 4-pin units: https://www.ebay.com/itm/Infrared-KY032-for-Smart-Car-Robot-KY-032-Obstacle-Avoidance-Sensor-Module-DIY/143557602745 and https://www.ebay.com/itm/KEYESTUDIO-IR-Infrared-Obstacle-Avoidance-Sensor-Module-for-Arduino-DIY-Robot/254270970496

Don't use these cheaper 3-pin modules, as they do not used modulated IR and give false: https://www.ebay.com/itm/5PCS-IR-Infrared-Obstacle-Avoidance-Sensor-Module-For-Arduino-Smart-Car-Robot-Z/353169141982
 
Last edited:

inglewoodpete

Senior Member
inglewood,

Thanks for response.

I see the 4602 is still available.
Do you know what it was replaced with?

I am not familiar with the PWM Wizard. How do I access this?

I am attempting to transmit 38KHZ signal
that can bounce off an object and make the irr sensor go logic high.

TIA,

John
There are a host of low-cost IR demodulators available. All of the ones I've tried simply work. They appear to have a broad tolerance of clock rates (32 to 40+ Kbits/sec. I have used this one in the past. For me, Altronics is a local electronics parts supplier for hobbyist and small scale manufacturing. I'm sure you must have equivalent retail suppliers in your part of the world.

You can open the PICAXE PWM Wizard from within the PICAXE Programming Editor: "PICAXE" tab/ribbon, "Wizards" drop-down.
 

erco

Senior Member
@Y4jaba6: You likely have an ugly "gotcha" coming. Most cheap 38khz IR receivers (typ TL1838, TSOP1838) will NOT detect a steady (continuous) unmodulated 38 khz IR signal. They are optimized to receive coded/modulated bursts like IR control signals. When exposed to a steady IR signal, they will go active low briefly, then go high again until the unmodulated IR is removed. GOTCHA.

For the simple application you describe, you want one of the rare "CONTINUOUS SIGNAL COMPATIBLE" types, such as the TSSP4038 or TSOP4038 (obsolete). See my post elsewhere at https://forums.parallax.com/discussion/142217/ir-receivers-hoarding-time/p1 More info at https://www.robotroom.com/PNA4602M-Replacement-1.html TSSP4038 has replaced TSOP4038 and both work fine at 3V.

Both of the 4-pin sensors I mentioned 2 posts back use continuous signal compatible IR sensors, but they are very short range compared to a 4038. A 4038 is much more sensitive (long range) and can do double duty as an IR remote receiver (for use with IRIN) and an obstacle detector.
 
Last edited:

erco

Senior Member
I have used this one in the past. For me, Altronics is a local electronics parts supplier for hobbyist and small scale manufacturing.
YIKES! I'm a spoiled cheapskate compared to inglewoodpete. That sensor is $7.50. IWP must be rich, which makes him my new best friend!

I'm a natural-born hoarder, so I order cheap parts from Ebay China. Here are 10 for $1.70, free ship: https://www.ebay.com/itm/313170618491 Again, these are not continuous signal compatible but fine for receiving IR remote signals using IRIN.
 

inglewoodpete

Senior Member
YIKES! I'm a spoiled cheapskate compared to inglewoodpete. That sensor is $7.50. IWP must be rich, which makes him my new best friend!
Not rich (but I'm not complaining). Just impatient. I'm not prepared to wait a month for delivery from China of products that may not live up to expectation. I've been burned a few times. (and A$7.50 is <US$5.00 but that's still not 0.17!)
 
Last edited:

4jaba6

New Member
Easy enough to use PWM to generate a 38khz signal if your program isn't using interfering functions & timers (IIRC SERVO & COUNT are right out). Otherwise, build a simple 555 oscillator or equivalent to generate the signal, or get a sensor which generates its own IR output, such as these 4-pin units: https://www.ebay.com/itm/Infrared-KY032-for-Smart-Car-Robot-KY-032-Obstacle-Avoidance-Sensor-Module-DIY/143557602745 and https://www.ebay.com/itm/KEYESTUDIO-IR-Infrared-Obstacle-Avoidance-Sensor-Module-for-Arduino-DIY-Robot/254270970496

Don't use these cheaper 3-pin modules, as they do not used modulated IR and give false: https://www.ebay.com/itm/5PCS-IR-Infrared-Obstacle-Avoidance-Sensor-Module-For-Arduino-Smart-Car-Robot-Z/353169141982

Erco and inglewood,

Enjoying the debate, esp. about China suppliers.

Do you guys or anyone have Picaxe Code for "Obstacle Detection" using the KY032?

TIA
 

erco

Senior Member
The code obviously depends on your particular application & deployment. The sensor normally reads high, but goes low when reflected IR is detected from an obstacle. Sensitivity & range vary based on the color, texture & geometry of the obstacle.

See also ultrasonic sensors (starting at $1): https://www.ebay.com/itm/202988008986

and do this resistor hack to use one I/O pin with the ULTRA command:
 
Last edited:

4jaba6

New Member
OK, I have found Picaxe Code that works for "I R Obstacle Detection".
It comes from Trainelectronics.com... http://www.trainelectronics.com/articles.htm
article "Pulsed Infrared Sensors"..... http://www.trainelectronics.com/artcles/sensor_article/PulsedIR/index.htm
courtesy of Dave Bodnar.
The code shows IR pulsed out using PWM by an IR Transmitter.
If reflected back by an Obstacle, it makes input logic low on an IRR Sensor.
This turns Picaxe pin low and is interpreted by the code and acts accordingly.
 
Top