Shop OBEX P1 Docs P2 Docs Learn Events
Using Boe-Bot IR to detect wheel revolutions — Parallax Forums

Using Boe-Bot IR to detect wheel revolutions

FragsterTXFragsterTX Posts: 4
edited 2006-08-04 21:30 in Robotics
Has anyone tried using the·IR lamp and detector supplied with the Boe-Bot to measure the·revolutions of the wheels? (for accurate distance measurement).· I've done this and it works great at slower speeds but when you kick it up to full speed, there apparently isn't enough time to register each individual hole in the wheels (there are eight).· I've tried adjusting the number holes to look for but can't find anything that is reliable like the slower speed method.

I was impressed with how accurate it seems at slower speeds but obviously disappointed at higher speeds.

Here is my code (disregard the sloppiness, please).

' Robotics with the Boe-Bot - IrDistanceMeasurementTest.bs2
' Test using IR transmitter and detector to measure wheel revolutions.
' {$STAMP BS2}
' {$PBASIC 2.5}
'DEBUG "Program Running!"
'
[noparse][[/noparse] Constants ]
LeftServoMax········· CON·· 841
LeftServoMin········· CON·· 660
RightServoMax········ CON·· 850
RightServoMin········ CON·· 650
LeftServoAdj········· CON·· 850 - LeftServoMax
RightServoAdj········ CON·· 850 - RightServoMax
WheelHoles··········· CON·· 8···················· ' How many openings in Boe-Bot wheel?
'
[noparse][[/noparse] Variables ]
irDetectLeft········· VAR·· Bit
irDetectRight········ VAR·· Bit
irCount·············· VAR·· Byte
irInterrupt·········· VAR·· Bit
revolutions·········· VAR·· Word
detectsPerHole······· VAR·· Byte
previousDetects······ VAR·· Byte
'
[noparse][[/noparse] Initialization ]
DEBUG "Testing piezospeaker..."
FREQOUT 4, 2000, 3000···························· ' Signal program start/reset.
DEBUG CLS,
····· "RIGHT IR DETECTOR", CR,
····· "Detects· Revolutions", CR,
····· "
·
"
irCount = 0······································ ' Initialize detect counter variable
irInterrupt = 0·································· ' Initialize detect interrupt variable
revolutions = 0·································· ' Initialize number of revolutions variable
'
[noparse][[/noparse] Main Routine ]
DO
· 'FREQOUT 8, 1, 38500
· 'irDetectLeft = IN9
· FREQOUT 2, 1, 35500
· irDetectRight = IN0
· 'IF (irDetectLeft = 0) THEN
· '· HIGH 10
· 'ELSE
· '· LOW 10
· 'ENDIF
· IF (irDetectRight = 0) THEN
··· HIGH 1
··· IF irInterrupt = 0 THEN
····· irInterrupt = 1···························· ' Set interrupt flag to monitor next break
··· ENDIF
· ELSE
··· LOW 1
··· IF irInterrupt = 1 THEN
····· irCount = irCount + 1
····· irInterrupt = 0······························ ' Reset interrupt flag to start new detect cycle
··· ENDIF
· ENDIF
· IF irCount = 8 THEN
··· revolutions = revolutions + 1············· ' Count another full revolution
··· irCount = 0
··· END······································· ' Stop processing and verify if one full turn occurred
··· 'PAUSE 100
· ENDIF
· DEBUG CRSRXY, 2, 3, DEC5 irCount ,
······· CRSRXY, 15, 3, DEC5 revolutions
· PULSOUT 12, LeftServoMin '+ 55
· PAUSE 20

LOOP
END

Comments

  • FragsterTXFragsterTX Posts: 4
    edited 2006-08-03 02:46
    Well, I'm disappointed I've gotten no replies, even if it's just to say "can't be done."

    I suppose I could block off all but one of the wheel openings thereby eliminating any counting but I figure that I'd run into the same problem--the apparent slowness·of the IR detector check may miss the opening at full speed.

    I think I'll proceed with my little experiment and just keep the speed down an a level whereby my process works.· I'm just fooling around with programming the Boe-Bot to accurately travel xy distance.· I know there is a real IR wheel·detector kit for the boe-bot but I wanted to use the parts that came with it.

    Anyway, thanks to anyone who read this and didn't say to themselves, "why in the heck would you want to do that?"
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-03 16:05
    There was already a thread on this recently and I suggested checking out the following web page information and code.· I hope this helps.· Take care.

    http://www.parallax.com/detail.asp?product_id=28107

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • XNORXNOR Posts: 74
    edited 2006-08-04 00:07
    Great idea! smile.gif

    How did you physically set up the IR detectors so that they could "see" the wheels?
    Maybe you could post some pictures? smile.gif
  • FragsterTXFragsterTX Posts: 4
    edited 2006-08-04 04:31
    Well okay, but only if you don't laugh at my southern ingenuity.· I used stuff I had around the house that was easily modified (I'm lazy)--popcicle sticks and binder clips.·

    I've included a couple of shots so you can see the IR decector tie-wrapped to the Boe-Bot frame just behind the wheels and the IR lamp attached to my wonderful wooden rig around the boe-bot.

    Fun stuff!

    I think now I'll work on the code to monitor both wheels and·insure the bot tracks straight (one servo is faster than the other).
    400 x 300 - 40K
    400 x 300 - 36K
    400 x 300 - 39K
    400 x 300 - 43K
  • FragsterTXFragsterTX Posts: 4
    edited 2006-08-04 04:33
    Oh, I forgot to mention the long cable assemblies I used to connect the IR stuff to the breadboard are just 3-pin fan extension cables, typically used in PC's. They were $1.29 at Fry's. I couldn't find any servo extensions at the time so I just cut off the tab on the male end and they work great.
  • XNORXNOR Posts: 74
    edited 2006-08-04 21:30
    FragsterTX said...
    Well okay, but only if you don't laugh at my southern ingenuity. I used stuff I had around the house that was easily modified (I'm lazy)--popcicle sticks and binder clips.

    I've included a couple of shots so you can see the IR decector tie-wrapped to the Boe-Bot frame just behind the wheels and the IR lamp attached to my wonderful wooden rig around the boe-bot.

    Thank you for the pictures FragsterTX!
    I like it when people recycle their (techno-) scrap. wink.gif
Sign In or Register to comment.