Basic Atom and IRPD

I got my little Octabot rover all wired up, and everything seems to be working fine except the IRPD (the only sensor I have at present). I am not sure the right (looking at the front of the sensor) IR LED is working properly even though I see the status LED pulse on and off.

One problem I had is the code I based my program on seems to have an error in it from what I see in the IRPD manual. The original code was using pulseout but the IRPD code in the manual sets the line high, checks the sensor, pause 1, then sets the line low again.

Anyway, no matter how I adjust the pots on the IRPD, I can’t seem to get a trigger off the right IR LED. The left one triggers fine as far as I can tell.

Any ideas I may not have tried?

Here is my current code:

[code]’ Motors
leftm con p0
leftd var word
lefta var word

rightm con p1
rightd var word
righta var word

revdir var word

’ IRPD
rights con p12 'Change pin number to pin you are using for your right led Voilet wire
lefts con p13 'Change pin number to pin you are using for your left led Blue wire
sensor var in14 'Change pin number to pin you are using for your sensor Yellow wire

templ var bit
tempr var bit
left var sword
right var sword

speed var word
test var word
object var word
'========================================================================
'========================================================================
leftd = -1
lefta = -5

rightd = 1
righta = 35

revdir = -1

speed = 75
test = 1

while test <> 0
servo leftm, (speed + lefta) * leftd, 2
servo rightm, (speed + righta) * rightd, 2

gosub Check_IRPD

branch object, [Hit_Left, Hit_Right, Hit_Center]

goto Do_Again	

Hit_Left:
while object <> 0
gosub Rotate_Right
gosub Check_IRPD
wend

goto Do_Again

Hit_Right:
while object <> 0
gosub Rotate_Left
gosub Check_IRPD
wend

goto Do_Again

Hit_Center:
’ Backup some
gosub Backup

branch object, [Turn_Right, Turn_Left, Turn_Left]

Turn_Right:
while object <> 0
gosub Rotate_Right
gosub Check_IRPD
wend
goto Do_Again

Turn_Left:
while object <> 0
gosub Rotate_Left
gosub Check_IRPD
wend

Do_Again:
gosub Check_IRPD
wend

goto Exit_Now

Rotate_Right:
gosub Backup
servo leftm, (speed + 350 + lefta) * leftd, 5
servo rightm, (speed + 350 + righta) * rightd * revdir, 5
return

Rotate_Left:
gosub Backup
servo leftm, (speed + 350 + lefta) * leftd * revdir, 5
servo rightm, (speed + 350 + righta) * rightd, 5
return

Backup:
servo leftm, (speed + 350 + lefta) * leftd * revdir, 5
servo rightm, (speed + 350 + righta) * rightd * revdir, 5
return

Check_IRPD
servo leftm, 0, 1
servo rightm, 0, 1

’ pulsout rights ,125 'Flash the right led.
high rights
pause 1

tempr = sensor 'Store the right value for templ.
low rights

’ pulsout lefts,75 'Flash the left led.
high lefts
pause 1

templ = sensor	 'Store the left value for tempr.
low lefts

’ serout s_out, i9600, “templ =”, dec templ, 13]
’ serout s_out, i9600, " tempr = ++", dec tempr, 13]

object = 0

if templ then
	object = object + 1
endif

if tempr then
	object = object + 2
endif
return

Exit_Now:[/code]

I watched my robot run around my apartment for several hours last night, and the code that handles the left side of the IRPD works wonderfully. The robot just get stuck in corners at all now. The more I watched it, the more I think that half of the IRPD is not working, or is not working right.

I think if the IRPD was working 100%, this code of mine would be working as well as any code could with just an IRPD as a sensor. I can actually observe it doing all the moves programmed to handle each input (and some surprising moves I did not specifically program). I still need to smooth out the Backup routine a bit.

8-Dale

The most common problem with people using the IRPD is they don’t properly isolate the LED’s from the IR receiver. This usually causes false detections, not what you’re reporting. The other is to try and enable both IR LEDs at the same time. This will not work. Tip, you can use a video camera to see the IR being emmitted from the IR LEDs. They will show up as light blue, and not terribly bright on the IRPD because they are on for only a short time. But it will tell you if there is a hardware problem.

I know what you mean about emergent behaviours. It’s errie cool! :smiley:

I did properly isolate the IR receiver as described in the manual. That’s why one half of the code with the IRPD works so well - I don’t get false detections.

I patterned my Check_IRPD strictly after the code shown in the manual, which is why I spotted and fixed the bug in the orignal program I based mine on. I only enable one LED at at time.

I can see the status LEDS light up faintly for very short times in a darkened room. I believe all the correct things are happening in the proper sequence. One half of the IRPD is just not completely working as it should as I can not get any detections on that side at all, even by putting my hand in front of it.

Oh yeah! I watched my Octabot get stuck on things and then suddenly just backup, start detecting again, and move on. This is wicked cool, for sure! :smiley:

I only programmed it to backup after it detects an obstacle, then rotate one direction or the other until it gets a clear path (no detections) and move on. It favors forward movement.

8-Dale

Hole on thar :smiley: You must use a CCD based camera to “see” if the IR is really emitting IR light. It’s the only way to know for sure if it is.

If you look at the schematic for the IRPD you will see the IR LED drive circuity is identical for the two sides. As is the rest actually, so we need to verify if the IR LEDs are working for ya.

It’s been a long time since I messed with this, but this might work better for you.

Check_IRPD
for x = 1 to 4
  high rights
  pause 1
  low rights
  pause 1 
next x
  high rights
  pause 1
    tempr = sensor
  low rights
  pause 1
for x = 1 to 4
  high lefts
  pause 1
  low lefts
  pause 1 
next x
  high lefts
  pause 1
    templ = sensor
  low lefts
  pause 1
return

Hear me out on this… The IR receiver has an AGC (automatic gain control) This is why you can’t just turn the LED on full time, as it saturates the receiver and the gain is reduced too much to try and compensate. Having too short a blip is troublesome as well. So the above code makes the sensor receive a short string of bits rather than a one time blip of data. You’re only looking at the last one, but it’s giving the sensor more similar data as it was designed for. I hope this helps.

I meant I can see the status LEDS, not the IR. My mistake there. I don’t have access to any kind of camera to use to try and see the IR. It’s a moot point now, since one of the IR emitters broke off the board today, so I can’t even send it back for a replacement now. :frowning:

I understand, but unfortunately I have no way to do this to verify whether the IR is actually working or not, sorry. :frowning:

8-Dale

I’ll replace it for ya, email me your address and we’ll get you a new one. :smiley:

I pay close attention to all of your posts, Jim, and I am learning much from them as well as the posts from others here. :smiley:

Ah, OK, I understand. I will incorporate this new code into my software and check it out as soon as I can afford to get myself another IRPD. The IRPD is one awesome sensor!

You should have seen my cat (1 year old female) when I had my robot running around my apartment for 3 hours or so last night. She actually follows it and occassionally touches it. It snuck up on her a few times and that was so funny!

8-Dale

Thankyou so much, Jim! Info is on the way. :slight_smile:

8-Dale