Making a 38KHz infrared sensor

Hello everybody !

First, excuse-me for my bad english but it isn’t my mother tongue. :laughing:

I’ve made a simple IRPD for my quadrapod using this scheme :

http://www.ikalogic.com/art_pics/40khz_ir_prox/shm1.jpg

So, when there is nothing in front of the bot, a +5V logic voltage is applied on VOUT and when something is detected by the photodiode, the voltage step down to 0V.
My problem is that I don’t know which command I’m to use with my Basic ATOM 28 so the voltage drop will be detected.

Previously, I was using a simpler detector that supplied a +5V voltage when triggered and using this code :

delay var byte
rate var byte
count1 var byte

delay=40
rate=80

testloop
high P15
button P14,0,delay,rate,count1,1,turnleft
low P15
goto testloop

But, when I try to change the normal state of the pin, it doesn’t work. (Either it go backward and turn left permanently detecting something or it goes always forward never detecting anything).

So, is there any other simpler command to use (like detecting a dropping voltage) ?

Thank you for your reply,

Corentin

If it is simply detecting +5v and 0V then this is a simple TTL input, so assuming you are connect to pin P0, you could do something like:

input p0

loop:
   if in0 then
      ; do the +5v stuff
   else
      ; do the 0v stuff
   endif
 ...
goto loop

If the output is variable between 0-5v you can use the AtoD converter:

word w
w wVolts
...
w = adin p0
; w is in the range 0-1023 so to convert w to 1/10s of volt you could do something like
wVolts = (w * 5 * 10)/1024    ; multiply by 5v and 10 to get 10s of degree (could do 100 but not in word...)
; do comparisons for different voltages...

I hope that helps
Kurt

Thank you for this solution !
I’ve got a hard time to configure it but it works fine now ! :smiley:

(The voltage was dropping to 2.6 V not 0 V like announcied in the diagram) :laughing:

Tell us about your quad! And in a day or so (house rules) please post a pix!

And welcome!

Alan KM6VV

Did you end up using the AD example code?

Do you want to mean a picture ? I will do it tomorrow.

Yes, I plugged the Vout in the AX0 pin of my mini-ABB and used the adin command. :stuck_out_tongue:

My quad is the ancient model (no longer in production) of Lynxmotion, the yellow lexan one. :mrgreen:
I named him John Henry as a wink to the Sarah Connor’s Chronicle series.

Here is a video with his new IRPD and new walking gait :

alpha-arts.net/robot.php

I did an experiment with IR detection and it worked ok but it had some limitations on the type of surfaces and objects it was able to see. Flat walls were ideal but the legs of chairs, the thin edge of a book shelf, or anything below the eye level gave shaky results.

Here’s a video:

Hi Mike,
Nice video. One thing I found when I was playing with the IR sensor on my Rover I had much better luck finding smaller things when it was vertical and not horizontal. Robot Dude confirmed that they found that as well when they were doing the seek and destroy as he mentioned in the thread: viewtopic.php?f=9&t=4875&start=75

Of course his eyes may look a bit strange if they were vertical. :slight_smile:

Kurt

I remember that post. I’m not using the Sharp GP2D12 IR Sensor in this case though, instead I am using the Panisonic IR module and IR emitter. Perhaps you were talking about moving these components in a verticle fashion, in which case it would look funny. I can increase the detectablility by using a lower value resistor so that the IR is brighter but it can only go so bright before it burns out. :laughing:

[size=150]The Eyes[/size]
http://www.parallax.com/Portals/0/Images/Prod/3/350/350-00014-M.jpghttp://www.parallax.com/Portals/0/Images/Prod/3/350/350-00003-M.jpg

I ment to say in the previous post that the ADin feature of the BAP is one of my favorite features. I wanted to make that point but forgot. :laughing: The ADin allows my IR wiring harness to plug right in and function.