Go to Post Large areas of ice in south Georgia is some what of an oxymoron. The best place for ice in south Georgia is in tea. - FrankJ [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 23-01-2008, 18:04
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Ultrasonic rangefinder code

Hi, I'm looking for code that might already be written to obtain a distance from an ultrasonic rangefinder. The one in specific that I have is at the following link.

http://www.acroname.com/robotics/parts/R271-SRF05.html

I could write the code myself, but I would rather see what is already out there so that I don't need to make the same mistakes that others have gone through.

Thanks much!
  #2   Spotlight this post!  
Unread 23-01-2008, 18:20
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: Ultrasonic rangefinder code

WPI Lib has very good sensor code, including code for ultrasonic sensors. For details, look at the WPI Lib documentation.

WPI Lib is basically an extended version of the library used in EasyC.
__________________

Last edited by slavik262 : 23-01-2008 at 18:24.
  #3   Spotlight this post!  
Unread 23-01-2008, 18:29
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Ultrasonic rangefinder code

What if I don't use EasyC? Will the code still work?

Thanks!
  #4   Spotlight this post!  
Unread 23-01-2008, 20:14
JonathanLKS JonathanLKS is offline
Code::Blocks
FRC #0610 (The Coyotes)
Team Role: Leadership
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Toronto
Posts: 36
JonathanLKS will become famous soon enough
Send a message via MSN to JonathanLKS
Re: Ultrasonic rangefinder code

WPILib will work without EasyC, though I don't think it'll work with any of Kevin's code if your using that as well.
__________________

Team 610 [ Co-Leader | Head Programmer | Webmaster ]
We're attending: Greater Toronto Regional, San Diego Regional, Championship
  #5   Spotlight this post!  
Unread 23-01-2008, 20:23
lukevanoort lukevanoort is offline
in between teams
AKA: Luke Van Oort
no team
 
Join Date: Oct 2005
Rookie Year: 2005
Location: Waterloo, ON, Canada
Posts: 1,873
lukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond repute
Send a message via AIM to lukevanoort
Re: Ultrasonic rangefinder code

If you are willing to try a different ultrasonic, the MaxBotix one requires practically no coding at all; it can output distance as an analog signal, which requires no interrupts, and all you need to do is read from an analog input. The two ultrasonics cost about the same too ($0.45 difference).
__________________
Team 1219: 2009 - Mentor
Team 587: 2005 - Animator, 2006-2008 - Team Captain
  #6   Spotlight this post!  
Unread 23-01-2008, 21:22
Phalanx's Avatar
Phalanx Phalanx is offline
Formerly Team 1089 (Mercury)
AKA: Michael Reffler
FRC #5431 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jun 2005
Rookie Year: 1999
Location: Lewisville, TX (previously NJ)
Posts: 384
Phalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond repute
Re: Ultrasonic rangefinder code

We aren't using EasyC or WPILIB, but we have used the Maxbotic sensor using analog with good results. The current models use a 9.8mV to an inch scaling.

The code was simple as well.
Here's a sample for it that I just typed from memory using analog port 1:

Code:
unsigned int sonic;
unsigned int mV;
unsigned int inches;
sonic = Get_Analog_Value(rc_ana_01);
mV =( (sonic * 5000) / 1024 );
inches = mV * 10 / 98;
__________________
Don't just ask the experts, become one!
Leadership is not about ability. It's about responsibility!
Diagonally Parked in a Parallel Universe. It's okay we do Quantum Physics



Last edited by Phalanx : 23-01-2008 at 21:24.
  #7   Spotlight this post!  
Unread 24-01-2008, 18:19
Andy Goetz Andy Goetz is offline
Team Captain
FRC #2898 (The Flying Hedgehogs)
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Beaverton, Oregon
Posts: 5
Andy Goetz is on a distinguished road
Re: Ultrasonic rangefinder code

If you do the algebra, with the Maxsonar, you can just divide the incoming value by two to get the distance in inches.
  #8   Spotlight this post!  
Unread 24-01-2008, 18:53
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,521
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Ultrasonic rangefinder code

Andy, that depends on a lot of things and isn't necessarily true.

On ours, using Kevin's ADC code, we have to devide by 3.933, or multiple by 100/393 to get inches.
  #9   Spotlight this post!  
Unread 24-01-2008, 21:07
Phalanx's Avatar
Phalanx Phalanx is offline
Formerly Team 1089 (Mercury)
AKA: Michael Reffler
FRC #5431 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jun 2005
Rookie Year: 1999
Location: Lewisville, TX (previously NJ)
Posts: 384
Phalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond repute
Re: Ultrasonic rangefinder code

Quote:
Originally Posted by Andy Goetz View Post
If you do the algebra, with the Maxsonar, you can just divide the incoming value by two to get the distance in inches.
Well you can do that, if you don't mind the small error that is introduced from it, and that the version of the sensor uses 10mV per inch scaling. All the newer models use 9.8mV per inch scaling so your range readings will be off even more.

For example a reading of 512 would be 2.5mV which is very close the 2.55mV maximum range that this device uses. So dividing by 2 would give you 256, which is close to 250 inches the device is reporting, but 6 inches off at that range(using 10mV inch). As you get closer it becomes less of an issue.

It all depends on the level of precision you need or want.
__________________
Don't just ask the experts, become one!
Leadership is not about ability. It's about responsibility!
Diagonally Parked in a Parallel Universe. It's okay we do Quantum Physics


  #10   Spotlight this post!  
Unread 25-01-2008, 00:37
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Ultrasonic rangefinder code

There's no particular reason for the software to deal with distance in inches, or centimeters, or any "engineering" unit. We've usually done all the navigation using the equivalent of raw encoder or analog input counts.

For something like autonomous scripting we typically convert in the other direction, to turn familiar units like inches into the values the program likes.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SRF04 Ultrasonic Rangefinder Unresponsive the401tauntaun Programming 10 20-01-2008 12:39
Ultrasonic will not work with another Ultrasonic plz help Jackel148 Programming 10 10-05-2006 15:31
Ultrasonic Distances irishninja FIRST Tech Challenge 1 30-04-2006 20:25
Programming Parallax Ultrasonic Rangefinder edman Programming 2 17-02-2006 08:35
Ultrasonic Rangefinder Operating On I2C Bus CapnBFG Electrical 10 04-06-2005 01:31


All times are GMT -5. The time now is 21:50.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi