To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 8066
8065  |  8067
Subject: 
Got some code for you: Sonar on handy in feet & inches!
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Thu, 14 Sep 2000 01:49:13 GMT
Viewed: 
1022 times
  
Hi,

I  wanted to see how to convert the sonar hits into feet in
inches.  Well as the textbook rule goes it looke like it takes
333.333 ticks = 1 inch round trip.   Since the timer is running
2,000,000 counts per second.  But in real life I had to fudge it!
Here's the code:

Ignore the Infrared remote stuff. My test application is controlled
by a remote control, to execute different portions of the code.
I am working on one that calibrates the robots turns. Also I put my
robot in expore mode by hitting a button, for off sonar, test the wheel
encoders, and so on..
well here's the code:
void display_sonar ()

{
int result;
int feet;
int inches;
int sonar_time;
float infeet;
     sonar_init();
while (irccmd != 63){
  result = sonar_closeup();
  if (result != -1 ) {
sonar_time = result/285;
  feet = sonar_time/12;
  inches =sonar_time-(feet*12);
printf("dist: %d' %d\"\n",feet,inches);
}
  else {printf ("Out of Range!\n");}
  msleep (50L);
}
beep ();
beep ();
beep ();
alloff ();
}

I have no clue why I have to enter 285, is it because my "baffle" for
the sonar is too tight? The clock is the same
for Sonar Closeup.. just the BINH pulse is shorter right?  Does everyone
else fudge it to get an accurate reading?
I tested the code up against a tape measurer against a straight wall!
Consistant readings up to 10 feet then
poof out of range.  I was also playing with VR1 to see if I can cut the
gain down can I get down to 1"
NOPE.. 3" is the best I can do.


OK.. anyone have some SLAVE SPI code for a compass on the Handiboard
sharing sonar????????????????



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR