Shop OBEX P1 Docs P2 Docs Learn Events
IR Info, Distance Measurements and Turning Specifications. — Parallax Forums

IR Info, Distance Measurements and Turning Specifications.

AdamEAdamE Posts: 11
edited 2006-05-19 01:51 in Learn with BlocklyProp
My Boe-Bot is pretty much rigged for my task as of now (navigating through a maze) but as predicted I'm running into a few more problems, extremely sorry for posting so quickly after my last post but these forums are proving to be a valuable resource. I've tried searching for these answers on the forums and ofcourse to no avail as Im posting now.

Question 1.

My Boe-Bot is using IR (Infra-Red) Sensors to detect the distance to obstacles infront and to the sides of it. This distance is higher when an obstacle is close to the IR Sensor, and lower when farther away (kind of strange but Im sure theres a logical reason behind it). I've looked through the provided manuals and readme's that came with my Boe-Bot set and havent found anything concerning the actual units of the IR Distance Return, though I watched a video fro last years competition and they mentioned micrometers (µm).

After looking around Ive found that 100µm = 0.01 cm.

My current goal for myself however is figuring out/calculating the charge needed to move the Boe-Bot a specific distance. I've tried several methods of doing this but I've soon come to the conclusion that with robotics nothing is exact as it is in the virtual programming world (that Im most used to). So the distance travelled depends on friction, the current going to the pin (which is never exact), and the battery power, all of which cant be controlled. So I've come to the conclusion that Ill need to do some real-time calculations in order to calculate the amount of distance required to travel.

This is where the micrometers come in, my IR sensor on the front of the bot is constantly getting the distance to the wall infront of the robot. Using this information Im trying to come up with a system that moves the bot forward until the distance to the front wall has decreased by a certain amount (thus moving a certain distance), though this is proving to be a bit of a hard one.

The basic code I'm using;


' ($STAMP BS2)
' ($PBASIC 2.5)

' Define Left/Right wheel variables

Left_Wheel CON 14
Right_Wheel CON 15

' Define IR Sensor Variables

Data_ln CON 4
CLK CON 7
Distance VAR Byte

`Define Dummy Var for Loops

x VAR Byte

' Main Program


   GOSUB Detect
   GOSUB Move

Move:

   ' Move Boe-Bot Forward

   PULSOUT Left_Wheel, 900
   PULSOUT Right_Wheel, 450
   PAUSE 40

   RETURN

Detect:

   HIGH CLK
   PAUSE 3
   LOW CLK

   FOR x = 1 TO 70
      PAUSE 3
      IF IN5 = 1 THEN GOTO Jump
   NEXT

   RETURN


Jump:

   SHIFTIN Data_ln,CLK,2,[noparse][[/noparse]Distance \ 8]
   DEBUG "Distance: ",DEC Distance, CR
   PAUSE 30

   RETURN




which basically moves the boe-bot forward, and then prints the distance to the wall infront, repeatedly.

There's several extremely confusing issues I have with the results of this.

First off, why does the number increase as it gets closer to the wall?

Second, the number being returned doesnt seem coorect. As I stated before, there are .01 microns in 100 centimeters. Well when I get a distance of 200 returned, the distance in centimeters should then be .02 cm, when in reality its almost 2 inches shakehead.gif



I know thats quite a lot to chew on so I wont ask my other questions, and Its pretty big so I dont expect many answers but any help is extremely appretiated in figuring out this IR Distance system (I've looked in the book and I cant find anything, unless Ive somehow skipped a vital page but I've gone through it about 3 times)

Thanks for your time,
- Adam

Comments

  • edited 2006-05-07 04:09
    Adam,

    Working from recollections of a video you watched last year probably won't be anywhere near as productive as downloading and reading the datasheet/instruction manual for your IR sensor. You said you read everything that came with your kit, did that include a datasheet/manual for the particular IR sensor you're using?

    In your other post, Bruce Bates recommended posting a schematic along with your program. In addition to the schematic and program, it's important to also post the part name and number, and preferably a datasheet link. So, that's three items: (1) Part name/number and/or datasheet link, (2) Schematic, and (3) PBASIC code. True, it's possible that somebody on this forum might have worked with your particular platform and sensors last year, but then again, maybe not. On the other hand, there are a number of people who watch this forum that can offer some pretty good advice given those three pieces of information.

    Andy
  • LSBLSB Posts: 175
    edited 2006-05-19 01:51
    I'll start by telling you I'm no expert, but for what it's worth...

    Andy's advice is good, the more specific the info given, the more specific the help can be; post all you can to get the best answer.
    That said, I'll offer what I can... It seems obvious to me that your sensor is not measuring distance-- IR intensity would increase as distance shortens, but not distance.
    I would place my robot a short, known distance from a reflective surface and record the value and the distance. Move the sensor back an inch and repeat--again and again until readings fail. With this info, if the change is linear (same change in value for each distance), you can simply divide value by [noparse][[/noparse]change] to convert to inches. If the value changes, say logarithmically, a formula may be devised; worst case a lookup table may provide distance figures.
    Keep in mind that the numbers won't be the same for different surfaces, angles, colors...
Sign In or Register to comment.